Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

cpuset: decouple tmpmasks and cpumasks freeing in cgroup

Currently, free_cpumasks() can free both tmpmasks and cpumasks of a cpuset
(cs). However, these two operations are not logically coupled. To improve
code clarity:
1. Move cpumask freeing to free_cpuset()
2. Rename free_cpumasks() to free_tmpmasks()

This change enforces the single responsibility principle.

Signed-off-by: Chen Ridong <chenridong@huawei.com>
Reviewed-by: Waiman Long <longman@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Chen Ridong and committed by
Tejun Heo
5806b3d0 8d2a7558

+13 -19
+13 -19
kernel/cgroup/cpuset.c
··· 459 459 } 460 460 461 461 /** 462 - * free_cpumasks - free cpumasks in a tmpmasks structure 463 - * @cs: the cpuset that have cpumasks to be free. 462 + * free_tmpmasks - free cpumasks in a tmpmasks structure 464 463 * @tmp: the tmpmasks structure pointer 465 464 */ 466 - static inline void free_cpumasks(struct cpuset *cs, struct tmpmasks *tmp) 465 + static inline void free_tmpmasks(struct tmpmasks *tmp) 467 466 { 468 - if (cs) { 469 - free_cpumask_var(cs->cpus_allowed); 470 - free_cpumask_var(cs->effective_cpus); 471 - free_cpumask_var(cs->effective_xcpus); 472 - free_cpumask_var(cs->exclusive_cpus); 473 - } 474 - if (tmp) { 475 - free_cpumask_var(tmp->new_cpus); 476 - free_cpumask_var(tmp->addmask); 477 - free_cpumask_var(tmp->delmask); 478 - } 467 + free_cpumask_var(tmp->new_cpus); 468 + free_cpumask_var(tmp->addmask); 469 + free_cpumask_var(tmp->delmask); 479 470 } 480 471 481 472 /** ··· 499 508 */ 500 509 static inline void free_cpuset(struct cpuset *cs) 501 510 { 502 - free_cpumasks(cs, NULL); 511 + free_cpumask_var(cs->cpus_allowed); 512 + free_cpumask_var(cs->effective_cpus); 513 + free_cpumask_var(cs->effective_xcpus); 514 + free_cpumask_var(cs->exclusive_cpus); 503 515 kfree(cs); 504 516 } 505 517 ··· 2421 2427 if (cs->partition_root_state) 2422 2428 update_partition_sd_lb(cs, old_prs); 2423 2429 out_free: 2424 - free_cpumasks(NULL, &tmp); 2430 + free_tmpmasks(&tmp); 2425 2431 return retval; 2426 2432 } 2427 2433 ··· 2524 2530 if (cs->partition_root_state) 2525 2531 update_partition_sd_lb(cs, old_prs); 2526 2532 2527 - free_cpumasks(NULL, &tmp); 2533 + free_tmpmasks(&tmp); 2528 2534 return 0; 2529 2535 } 2530 2536 ··· 2977 2983 notify_partition_change(cs, old_prs); 2978 2984 if (force_sd_rebuild) 2979 2985 rebuild_sched_domains_locked(); 2980 - free_cpumasks(NULL, &tmpmask); 2986 + free_tmpmasks(&tmpmask); 2981 2987 return 0; 2982 2988 } 2983 2989 ··· 4000 4006 if (force_sd_rebuild) 4001 4007 rebuild_sched_domains_cpuslocked(); 4002 4008 4003 - free_cpumasks(NULL, ptmp); 4009 + free_tmpmasks(ptmp); 4004 4010 } 4005 4011 4006 4012 void cpuset_update_active_cpus(void)