提交 0092df08 编写于 作者: X Xie XiuQi

sysctl: add procfs interface to disable/enable usermodhelper_affinity

hulk inclusion
category: feature
feature: performance/latency
upstream: never
bugzilla: 2680,10641
CVE: NA

The pervious patch "kmod: run usermodehelpers only on cpus allowed for
kthreadd V2" allow to set usermodehelper thread's affinity.

add a interface to disable/enable usermodhelper_affinity.
Disabled by default.

[XQ: backport patch from euleros 2.x:
  - kmod.c => umh.c
]
Signed-off-by: NXie XiuQi <xiexiuqi@huawei.com>
Reviewed-by: NLi Bin <huawei.libin@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 672627d1
...@@ -83,4 +83,5 @@ extern int sysctl_schedstats(struct ctl_table *table, int write, ...@@ -83,4 +83,5 @@ extern int sysctl_schedstats(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, void __user *buffer, size_t *lenp,
loff_t *ppos); loff_t *ppos);
extern int sysctl_umh_affinity;
#endif /* _LINUX_SCHED_SYSCTL_H */ #endif /* _LINUX_SCHED_SYSCTL_H */
...@@ -1240,6 +1240,15 @@ static struct ctl_table kern_table[] = { ...@@ -1240,6 +1240,15 @@ static struct ctl_table kern_table[] = {
.extra2 = &one, .extra2 = &one,
}, },
#endif #endif
{
.procname = "usermodhelper_affinity",
.data = &sysctl_umh_affinity,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = &zero,
.extra2 = &one,
},
{ } { }
}; };
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/shmem_fs.h> #include <linux/shmem_fs.h>
#include <linux/pipe_fs_i.h> #include <linux/pipe_fs_i.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/sched/sysctl.h>
#include <trace/events/module.h> #include <trace/events/module.h>
...@@ -39,6 +40,8 @@ static kernel_cap_t usermodehelper_inheritable = CAP_FULL_SET; ...@@ -39,6 +40,8 @@ static kernel_cap_t usermodehelper_inheritable = CAP_FULL_SET;
static DEFINE_SPINLOCK(umh_sysctl_lock); static DEFINE_SPINLOCK(umh_sysctl_lock);
static DECLARE_RWSEM(umhelper_sem); static DECLARE_RWSEM(umhelper_sem);
int __read_mostly sysctl_umh_affinity;
static void call_usermodehelper_freeinfo(struct subprocess_info *info) static void call_usermodehelper_freeinfo(struct subprocess_info *info)
{ {
if (info->cleanup) if (info->cleanup)
...@@ -80,7 +83,10 @@ static int call_usermodehelper_exec_async(void *data) ...@@ -80,7 +83,10 @@ static int call_usermodehelper_exec_async(void *data)
* start the usermode helper threads only on the processors allowed for * start the usermode helper threads only on the processors allowed for
* kthreadd. * kthreadd.
*/ */
if (sysctl_umh_affinity)
set_kthreadd_affinity(); set_kthreadd_affinity();
else
set_cpus_allowed_ptr(current, cpu_all_mask);
/* /*
* Our parent (unbound workqueue) runs with elevated scheduling * Our parent (unbound workqueue) runs with elevated scheduling
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册