rue/mm: add sysctl_vm_use_priority_oom to enable priority oom for all cgroups

Add sysctl_vm_use_priority_oom as a global setting to enable the
priority_oom setting for all cgroups without the need to manually
set it for each cgroup. This global setting has no effect when it
is turned off.

Signed-off-by: Haojie Ning <paulning@tencent.com>
Signed-off-by: Honglin Li <honglinli@tencent.com>
This commit is contained in:
Haojie Ning 2024-07-30 16:10:10 +08:00 committed by Haisu Wang
parent 7c45f9b01f
commit a1574c433d
3 changed files with 15 additions and 1 deletions

View File

@ -31,6 +31,7 @@ struct mm_struct;
struct kmem_cache;
struct oom_control;
extern int sysctl_vm_use_priority_oom;
extern int kclean_dying_memcg_run(void);
extern unsigned int sysctl_clean_dying_memcg_threshold;
extern void kclean_dying_memcg_stop(void);
@ -1018,7 +1019,7 @@ static inline bool root_memcg_use_priority_oom(void)
if (mem_cgroup_disabled())
return false;
if (root_mem_cgroup->use_priority_oom)
if (root_mem_cgroup->use_priority_oom || sysctl_vm_use_priority_oom)
return true;
return false;

View File

@ -98,6 +98,7 @@ extern int sysctl_qos_mbuf_enable;
#ifdef CONFIG_MEMCG
extern int sysctl_vm_memory_qos;
extern int sysctl_vm_use_priority_oom;
extern int sysctl_vm_qos_highest_reclaim_prio;
extern unsigned int sysctl_vm_qos_prio_reclaim_ratio;
extern unsigned int sysctl_clean_dying_memcg_async;
@ -3000,6 +3001,15 @@ static struct ctl_table vm_table[] = {
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
{
.procname = "use_priority_oom",
.data = &sysctl_vm_use_priority_oom,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_ONE,
},
{
.procname = "qos_highest_reclaim_prio",
.data = &sysctl_vm_qos_highest_reclaim_prio,

View File

@ -118,6 +118,7 @@ static DECLARE_WAIT_QUEUE_HEAD(memcg_cgwb_frn_waitq);
#define PAGECACHE_MAX_RATIO_MAX 100
int sysctl_vm_memory_qos;
int sysctl_vm_use_priority_oom;
/* default has none reclaim priority */
int sysctl_vm_qos_highest_reclaim_prio = CGROUP_PRIORITY_MAX;
@ -1552,6 +1553,8 @@ void mem_cgroup_oom_select_bad_process(struct oom_control *oc)
if (!sysctl_vm_memory_qos)
oc->priority_select = false;
else if (sysctl_vm_use_priority_oom)
oc->priority_select = true;
else
oc->priority_select = memcg->use_priority_oom;