hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I9GZAQ CVE: NA
--------------------------------
Add cfs_preferred_nid_init hook for scheduler, allow user to init same numa_preferred_nid for multi threads of the process.
Signed-off-by: Hui Tang tanghui20@huawei.com --- include/linux/sched_hook_defs.h | 1 + kernel/fork.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+)
diff --git a/include/linux/sched_hook_defs.h b/include/linux/sched_hook_defs.h index 0a871f728c85..de6451930d8a 100644 --- a/include/linux/sched_hook_defs.h +++ b/include/linux/sched_hook_defs.h @@ -14,3 +14,4 @@ BPF_SCHED_HOOK(int, -1, cfs_can_migrate_task, struct task_struct *p, struct sched_migrate_node *migrate_node) BPF_SCHED_HOOK(void, (void) 0, cfs_change_preferred_node, struct sched_preferred_node_ctx *ctx) +BPF_SCHED_HOOK(int, -1, cfs_preferred_nid_init, struct task_struct *tsk) diff --git a/kernel/fork.c b/kernel/fork.c index 12db99751381..dcf1f9c655d8 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -97,6 +97,7 @@ #include <linux/scs.h> #include <linux/io_uring.h> #include <linux/sched/mm.h> +#include <linux/bpf_sched.h> #ifdef CONFIG_QOS_SCHED_SMART_GRID #include <linux/sched/grid_qos.h> #endif @@ -2320,6 +2321,20 @@ static __latent_entropy struct task_struct *copy_process( p->tgid = p->pid; }
+#if defined (CONFIG_SCHED_TASK_RELATIONSHIP) && defined(CONFIG_BPF_SCHED) + if (bpf_sched_enabled() && task_relationship_supported(p)) { + retval = bpf_sched_cfs_preferred_nid_init(p); + if (clone_flags & CLONE_THREAD) { + if (retval > 0) + p->numa_preferred_nid = + p->group_leader->numa_preferred_nid; + } else { + if (retval > 0 && retval <= nr_node_ids) + p->numa_preferred_nid = retval - 1; + } + } +#endif + p->nr_dirtied = 0; p->nr_dirtied_pause = 128 >> (PAGE_SHIFT - 10); p->dirty_paused_when = 0;
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/10316 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/X...
FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/10316 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/X...