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: add cpuset1_online_css helper for v1-specific operations

This commit introduces the cpuset1_online_css helper to centralize
v1-specific handling during cpuset online. It performs operations such as
updating the CS_SPREAD_PAGE, CS_SPREAD_SLAB, and CGRP_CPUSET_CLONE_CHILDREN
flags, which are unique to the cpuset v1 control group interface.

The helper is now placed in cpuset-v1.c to maintain clear separation
between v1 and v2 logic.

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
56805c1b 14c11e1b

+51 -38
+2
kernel/cgroup/cpuset-internal.h
··· 293 293 struct cpumask *new_cpus, nodemask_t *new_mems, 294 294 bool cpus_updated, bool mems_updated); 295 295 int cpuset1_validate_change(struct cpuset *cur, struct cpuset *trial); 296 + void cpuset1_online_css(struct cgroup_subsys_state *css); 296 297 #else 297 298 static inline void fmeter_init(struct fmeter *fmp) {} 298 299 static inline void cpuset1_update_task_spread_flags(struct cpuset *cs, ··· 304 303 bool cpus_updated, bool mems_updated) {} 305 304 static inline int cpuset1_validate_change(struct cpuset *cur, 306 305 struct cpuset *trial) { return 0; } 306 + static inline void cpuset1_online_css(struct cgroup_subsys_state *css) {} 307 307 #endif /* CONFIG_CPUSETS_V1 */ 308 308 309 309 #endif /* __CPUSET_INTERNAL_H */
+48
kernel/cgroup/cpuset-v1.c
··· 499 499 return retval; 500 500 } 501 501 502 + void cpuset1_online_css(struct cgroup_subsys_state *css) 503 + { 504 + struct cpuset *tmp_cs; 505 + struct cgroup_subsys_state *pos_css; 506 + struct cpuset *cs = css_cs(css); 507 + struct cpuset *parent = parent_cs(cs); 508 + 509 + lockdep_assert_cpus_held(); 510 + lockdep_assert_cpuset_lock_held(); 511 + 512 + if (is_spread_page(parent)) 513 + set_bit(CS_SPREAD_PAGE, &cs->flags); 514 + if (is_spread_slab(parent)) 515 + set_bit(CS_SPREAD_SLAB, &cs->flags); 516 + 517 + if (!test_bit(CGRP_CPUSET_CLONE_CHILDREN, &css->cgroup->flags)) 518 + return; 519 + 520 + /* 521 + * Clone @parent's configuration if CGRP_CPUSET_CLONE_CHILDREN is 522 + * set. This flag handling is implemented in cgroup core for 523 + * historical reasons - the flag may be specified during mount. 524 + * 525 + * Currently, if any sibling cpusets have exclusive cpus or mem, we 526 + * refuse to clone the configuration - thereby refusing the task to 527 + * be entered, and as a result refusing the sys_unshare() or 528 + * clone() which initiated it. If this becomes a problem for some 529 + * users who wish to allow that scenario, then this could be 530 + * changed to grant parent->cpus_allowed-sibling_cpus_exclusive 531 + * (and likewise for mems) to the new cgroup. 532 + */ 533 + rcu_read_lock(); 534 + cpuset_for_each_child(tmp_cs, pos_css, parent) { 535 + if (is_mem_exclusive(tmp_cs) || is_cpu_exclusive(tmp_cs)) { 536 + rcu_read_unlock(); 537 + return; 538 + } 539 + } 540 + rcu_read_unlock(); 541 + 542 + cpuset_callback_lock_irq(); 543 + cs->mems_allowed = parent->mems_allowed; 544 + cs->effective_mems = parent->mems_allowed; 545 + cpumask_copy(cs->cpus_allowed, parent->cpus_allowed); 546 + cpumask_copy(cs->effective_cpus, parent->cpus_allowed); 547 + cpuset_callback_unlock_irq(); 548 + } 549 + 502 550 /* 503 551 * for the common functions, 'private' gives the type of file 504 552 */
+1 -38
kernel/cgroup/cpuset.c
··· 3616 3616 { 3617 3617 struct cpuset *cs = css_cs(css); 3618 3618 struct cpuset *parent = parent_cs(cs); 3619 - struct cpuset *tmp_cs; 3620 - struct cgroup_subsys_state *pos_css; 3621 3619 3622 3620 if (!parent) 3623 3621 return 0; 3624 3622 3625 3623 cpuset_full_lock(); 3626 - if (is_spread_page(parent)) 3627 - set_bit(CS_SPREAD_PAGE, &cs->flags); 3628 - if (is_spread_slab(parent)) 3629 - set_bit(CS_SPREAD_SLAB, &cs->flags); 3630 3624 /* 3631 3625 * For v2, clear CS_SCHED_LOAD_BALANCE if parent is isolated 3632 3626 */ ··· 3635 3641 cs->effective_mems = parent->effective_mems; 3636 3642 } 3637 3643 spin_unlock_irq(&callback_lock); 3644 + cpuset1_online_css(css); 3638 3645 3639 - if (!test_bit(CGRP_CPUSET_CLONE_CHILDREN, &css->cgroup->flags)) 3640 - goto out_unlock; 3641 - 3642 - /* 3643 - * Clone @parent's configuration if CGRP_CPUSET_CLONE_CHILDREN is 3644 - * set. This flag handling is implemented in cgroup core for 3645 - * historical reasons - the flag may be specified during mount. 3646 - * 3647 - * Currently, if any sibling cpusets have exclusive cpus or mem, we 3648 - * refuse to clone the configuration - thereby refusing the task to 3649 - * be entered, and as a result refusing the sys_unshare() or 3650 - * clone() which initiated it. If this becomes a problem for some 3651 - * users who wish to allow that scenario, then this could be 3652 - * changed to grant parent->cpus_allowed-sibling_cpus_exclusive 3653 - * (and likewise for mems) to the new cgroup. 3654 - */ 3655 - rcu_read_lock(); 3656 - cpuset_for_each_child(tmp_cs, pos_css, parent) { 3657 - if (is_mem_exclusive(tmp_cs) || is_cpu_exclusive(tmp_cs)) { 3658 - rcu_read_unlock(); 3659 - goto out_unlock; 3660 - } 3661 - } 3662 - rcu_read_unlock(); 3663 - 3664 - spin_lock_irq(&callback_lock); 3665 - cs->mems_allowed = parent->mems_allowed; 3666 - cs->effective_mems = parent->mems_allowed; 3667 - cpumask_copy(cs->cpus_allowed, parent->cpus_allowed); 3668 - cpumask_copy(cs->effective_cpus, parent->cpus_allowed); 3669 - spin_unlock_irq(&callback_lock); 3670 - out_unlock: 3671 3646 cpuset_full_unlock(); 3672 3647 return 0; 3673 3648 }