Lines Matching refs:oc

143 static inline bool is_sysrq_oom(struct oom_control *oc)  in is_sysrq_oom()  argument
145 return oc->order == -1; in is_sysrq_oom()
148 static inline bool is_memcg_oom(struct oom_control *oc) in is_memcg_oom() argument
150 return oc->memcg != NULL; in is_memcg_oom()
258 static enum oom_constraint constrained_alloc(struct oom_control *oc) in constrained_alloc() argument
262 enum zone_type high_zoneidx = gfp_zone(oc->gfp_mask); in constrained_alloc()
266 if (is_memcg_oom(oc)) { in constrained_alloc()
267 oc->totalpages = mem_cgroup_get_max(oc->memcg) ?: 1; in constrained_alloc()
272 oc->totalpages = totalram_pages + total_swap_pages; in constrained_alloc()
277 if (!oc->zonelist) in constrained_alloc()
284 if (oc->gfp_mask & __GFP_THISNODE) in constrained_alloc()
292 if (oc->nodemask && in constrained_alloc()
293 !nodes_subset(node_states[N_MEMORY], *oc->nodemask)) { in constrained_alloc()
294 oc->totalpages = total_swap_pages; in constrained_alloc()
295 for_each_node_mask(nid, *oc->nodemask) in constrained_alloc()
296 oc->totalpages += node_spanned_pages(nid); in constrained_alloc()
301 for_each_zone_zonelist_nodemask(zone, z, oc->zonelist, in constrained_alloc()
302 high_zoneidx, oc->nodemask) in constrained_alloc()
303 if (!cpuset_zone_allowed(zone, oc->gfp_mask)) in constrained_alloc()
307 oc->totalpages = total_swap_pages; in constrained_alloc()
309 oc->totalpages += node_spanned_pages(nid); in constrained_alloc()
317 struct oom_control *oc = arg; in oom_evaluate_task() local
320 if (oom_unkillable_task(task, NULL, oc->nodemask)) in oom_evaluate_task()
329 if (!is_sysrq_oom(oc) && tsk_is_oom_victim(task)) { in oom_evaluate_task()
344 points = oom_badness(task, NULL, oc->nodemask, oc->totalpages); in oom_evaluate_task()
345 if (!points || points < oc->chosen_points) in oom_evaluate_task()
349 if (points == oc->chosen_points && thread_group_leader(oc->chosen)) in oom_evaluate_task()
352 if (oc->chosen) in oom_evaluate_task()
353 put_task_struct(oc->chosen); in oom_evaluate_task()
355 oc->chosen = task; in oom_evaluate_task()
356 oc->chosen_points = points; in oom_evaluate_task()
360 if (oc->chosen) in oom_evaluate_task()
361 put_task_struct(oc->chosen); in oom_evaluate_task()
362 oc->chosen = (void *)-1UL; in oom_evaluate_task()
370 static void select_bad_process(struct oom_control *oc) in select_bad_process() argument
372 if (is_memcg_oom(oc)) in select_bad_process()
373 mem_cgroup_scan_tasks(oc->memcg, oom_evaluate_task, oc); in select_bad_process()
379 if (oom_evaluate_task(p, oc)) in select_bad_process()
384 oc->chosen_points = oc->chosen_points * 1000 / oc->totalpages; in select_bad_process()
431 static void dump_header(struct oom_control *oc, struct task_struct *p) in dump_header() argument
434 current->comm, oc->gfp_mask, &oc->gfp_mask, in dump_header()
435 nodemask_pr_args(oc->nodemask), oc->order, in dump_header()
437 if (!IS_ENABLED(CONFIG_COMPACTION) && oc->order) in dump_header()
442 if (is_memcg_oom(oc)) in dump_header()
443 mem_cgroup_print_oom_info(oc->memcg, p); in dump_header()
445 show_mem(SHOW_MEM_FILTER_NODES, oc->nodemask); in dump_header()
450 dump_tasks(oc->memcg, oc->nodemask); in dump_header()
925 static void oom_kill_process(struct oom_control *oc, const char *message) in oom_kill_process() argument
927 struct task_struct *p = oc->chosen; in oom_kill_process()
928 unsigned int points = oc->chosen_points; in oom_kill_process()
953 dump_header(oc, p); in oom_kill_process()
975 oc->memcg, oc->nodemask, oc->totalpages); in oom_kill_process()
991 oom_group = mem_cgroup_get_oom_group(victim, oc->memcg); in oom_kill_process()
1008 static void check_panic_on_oom(struct oom_control *oc, in check_panic_on_oom() argument
1023 if (is_sysrq_oom(oc)) in check_panic_on_oom()
1025 dump_header(oc, NULL); in check_panic_on_oom()
1053 bool out_of_memory(struct oom_control *oc) in out_of_memory() argument
1061 if (!is_memcg_oom(oc)) { in out_of_memory()
1085 if (oc->gfp_mask && !(oc->gfp_mask & __GFP_FS)) in out_of_memory()
1092 constraint = constrained_alloc(oc); in out_of_memory()
1094 oc->nodemask = NULL; in out_of_memory()
1095 check_panic_on_oom(oc, constraint); in out_of_memory()
1097 if (!is_memcg_oom(oc) && sysctl_oom_kill_allocating_task && in out_of_memory()
1098 current->mm && !oom_unkillable_task(current, NULL, oc->nodemask) && in out_of_memory()
1101 oc->chosen = current; in out_of_memory()
1102 oom_kill_process(oc, "Out of memory (oom_kill_allocating_task)"); in out_of_memory()
1106 select_bad_process(oc); in out_of_memory()
1108 if (!oc->chosen) { in out_of_memory()
1109 dump_header(oc, NULL); in out_of_memory()
1116 if (!is_sysrq_oom(oc) && !is_memcg_oom(oc)) in out_of_memory()
1119 if (oc->chosen && oc->chosen != (void *)-1UL) in out_of_memory()
1120 oom_kill_process(oc, !is_memcg_oom(oc) ? "Out of memory" : in out_of_memory()
1122 return !!oc->chosen; in out_of_memory()
1132 struct oom_control oc = { in pagefault_out_of_memory() local
1145 out_of_memory(&oc); in pagefault_out_of_memory()