Lines Matching refs:oc

72 static inline bool is_memcg_oom(struct oom_control *oc)  in is_memcg_oom()  argument
74 return oc->memcg != NULL; in is_memcg_oom()
91 struct oom_control *oc) in oom_cpuset_eligible() argument
95 const nodemask_t *mask = oc->nodemask; in oom_cpuset_eligible()
122 static bool oom_cpuset_eligible(struct task_struct *tsk, struct oom_control *oc) in oom_cpuset_eligible() argument
157 static inline bool is_sysrq_oom(struct oom_control *oc) in is_sysrq_oom() argument
159 return oc->order == -1; in is_sysrq_oom()
252 static enum oom_constraint constrained_alloc(struct oom_control *oc) in constrained_alloc() argument
256 enum zone_type highest_zoneidx = gfp_zone(oc->gfp_mask); in constrained_alloc()
260 if (is_memcg_oom(oc)) { in constrained_alloc()
261 oc->totalpages = mem_cgroup_get_max(oc->memcg) ?: 1; in constrained_alloc()
266 oc->totalpages = totalram_pages() + total_swap_pages; in constrained_alloc()
271 if (!oc->zonelist) in constrained_alloc()
278 if (oc->gfp_mask & __GFP_THISNODE) in constrained_alloc()
286 if (oc->nodemask && in constrained_alloc()
287 !nodes_subset(node_states[N_MEMORY], *oc->nodemask)) { in constrained_alloc()
288 oc->totalpages = total_swap_pages; in constrained_alloc()
289 for_each_node_mask(nid, *oc->nodemask) in constrained_alloc()
290 oc->totalpages += node_present_pages(nid); in constrained_alloc()
295 for_each_zone_zonelist_nodemask(zone, z, oc->zonelist, in constrained_alloc()
296 highest_zoneidx, oc->nodemask) in constrained_alloc()
297 if (!cpuset_zone_allowed(zone, oc->gfp_mask)) in constrained_alloc()
301 oc->totalpages = total_swap_pages; in constrained_alloc()
303 oc->totalpages += node_present_pages(nid); in constrained_alloc()
311 struct oom_control *oc = arg; in oom_evaluate_task() local
318 if (!is_memcg_oom(oc) && !oom_cpuset_eligible(task, oc)) in oom_evaluate_task()
327 if (!is_sysrq_oom(oc) && tsk_is_oom_victim(task)) { in oom_evaluate_task()
342 points = oom_badness(task, oc->totalpages); in oom_evaluate_task()
343 if (points == LONG_MIN || points < oc->chosen_points) in oom_evaluate_task()
347 if (oc->chosen) in oom_evaluate_task()
348 put_task_struct(oc->chosen); in oom_evaluate_task()
350 oc->chosen = task; in oom_evaluate_task()
351 oc->chosen_points = points; in oom_evaluate_task()
355 if (oc->chosen) in oom_evaluate_task()
356 put_task_struct(oc->chosen); in oom_evaluate_task()
357 oc->chosen = (void *)-1UL; in oom_evaluate_task()
365 static void select_bad_process(struct oom_control *oc) in select_bad_process() argument
367 oc->chosen_points = LONG_MIN; in select_bad_process()
369 if (is_memcg_oom(oc)) in select_bad_process()
370 mem_cgroup_scan_tasks(oc->memcg, oom_evaluate_task, oc); in select_bad_process()
376 if (oom_evaluate_task(p, oc)) in select_bad_process()
384 struct oom_control *oc = arg; in dump_task() local
391 if (!is_memcg_oom(oc) && !oom_cpuset_eligible(p, oc)) in dump_task()
425 static void dump_tasks(struct oom_control *oc) in dump_tasks() argument
430 if (is_memcg_oom(oc)) in dump_tasks()
431 mem_cgroup_scan_tasks(oc->memcg, dump_task, oc); in dump_tasks()
437 dump_task(p, oc); in dump_tasks()
442 static void dump_oom_victim(struct oom_control *oc, struct task_struct *victim) in dump_oom_victim() argument
446 oom_constraint_text[oc->constraint], in dump_oom_victim()
447 nodemask_pr_args(oc->nodemask)); in dump_oom_victim()
449 mem_cgroup_print_oom_context(oc->memcg, victim); in dump_oom_victim()
454 static void dump_header(struct oom_control *oc) in dump_header() argument
457 current->comm, oc->gfp_mask, &oc->gfp_mask, oc->order, in dump_header()
459 if (!IS_ENABLED(CONFIG_COMPACTION) && oc->order) in dump_header()
463 if (is_memcg_oom(oc)) in dump_header()
464 mem_cgroup_print_oom_meminfo(oc->memcg); in dump_header()
466 __show_mem(SHOW_MEM_FILTER_NODES, oc->nodemask, gfp_zone(oc->gfp_mask)); in dump_header()
471 dump_tasks(oc); in dump_header()
1012 static void oom_kill_process(struct oom_control *oc, const char *message) in oom_kill_process() argument
1014 struct task_struct *victim = oc->chosen; in oom_kill_process()
1035 dump_header(oc); in oom_kill_process()
1036 dump_oom_victim(oc, victim); in oom_kill_process()
1044 oom_group = mem_cgroup_get_oom_group(victim, oc->memcg); in oom_kill_process()
1063 static void check_panic_on_oom(struct oom_control *oc) in check_panic_on_oom() argument
1073 if (oc->constraint != CONSTRAINT_NONE) in check_panic_on_oom()
1077 if (is_sysrq_oom(oc)) in check_panic_on_oom()
1079 dump_header(oc); in check_panic_on_oom()
1107 bool out_of_memory(struct oom_control *oc) in out_of_memory() argument
1114 if (!is_memcg_oom(oc)) { in out_of_memory()
1116 if (freed > 0 && !is_sysrq_oom(oc)) in out_of_memory()
1137 if (!(oc->gfp_mask & __GFP_FS) && !is_memcg_oom(oc)) in out_of_memory()
1144 oc->constraint = constrained_alloc(oc); in out_of_memory()
1145 if (oc->constraint != CONSTRAINT_MEMORY_POLICY) in out_of_memory()
1146 oc->nodemask = NULL; in out_of_memory()
1147 check_panic_on_oom(oc); in out_of_memory()
1149 if (!is_memcg_oom(oc) && sysctl_oom_kill_allocating_task && in out_of_memory()
1151 oom_cpuset_eligible(current, oc) && in out_of_memory()
1154 oc->chosen = current; in out_of_memory()
1155 oom_kill_process(oc, "Out of memory (oom_kill_allocating_task)"); in out_of_memory()
1159 select_bad_process(oc); in out_of_memory()
1161 if (!oc->chosen) { in out_of_memory()
1162 dump_header(oc); in out_of_memory()
1169 if (!is_sysrq_oom(oc) && !is_memcg_oom(oc)) in out_of_memory()
1172 if (oc->chosen && oc->chosen != (void *)-1UL) in out_of_memory()
1173 oom_kill_process(oc, !is_memcg_oom(oc) ? "Out of memory" : in out_of_memory()
1175 return !!oc->chosen; in out_of_memory()