Re: [PATCH v5] Refactor part of the oom report in dump_header
From: David Rientjes
Date: Fri May 25 2018 - 15:49:02 EST
On Fri, 25 May 2018, ufo19890607 wrote:
> From: yuzhoujian <yuzhoujian@xxxxxxxxxxxxxxx>
>
> The dump_header does not print the memcg's name when the system
> oom happened, so users cannot locate the certain container which
> contains the task that has been killed by the oom killer.
>
> I follow the advices of David Rientjes and Michal Hocko, and refactor
> part of the oom report in a backwards compatible way. After this patch,
> users can get the memcg's path from the oom report and check the certain
> container more quickly.
>
I like the direction you are taking. A couple notes:
- you may find it easier to declare an array of const char * for each
constraint:
static const char * const oom_constraint_text[] = {
[CONSTRAINT_NONE] = "CONSTRAINT_NONE",
[CONSTRAINT_CPUSET] = "CONSTRAINT_CPUSET",
[CONSTRAINT_MEMORY_POLICY] = "CONSTRAINT_MEMORY_POLICY",
[CONSTRAINT_MEMCG] = "CONSTRAINT_MEMCG",
};
- we need to eliminate all the usage of pr_cont() because otherwise we
can still get interleaving in the kernel log (the single line output
should always be a complete single line that can be parsed by
userspace).
- to generate a single line output, I think you need a call to a
function in mm/memcontrol.c when is_memcg_oom(oc) is true and
otherwise a function in mm/oom_kill.c when false.