On Wed 20-02-19 09:37:56, Bujnak, Stepan wrote: > On Wed, Feb 20, 2019 at 7:49 AM Michal Hocko <mhocko@xxxxxxxxxx> wrote: [...] > > You are trying to allocate from the OOM context. That is a big no no. > > Not to mention that this is deadlock prone because get_cmdline needs > > mmap_sem and the allocating context migh hold the lock already. So the > > patch is simply wrong. > > > > Thanks for the notes. I understand how allocating from OOM context > is a problem. However I still believe that this would be helpful > for debugging OOM kills since task->comm is often not descriptive > enough. Would it help if instead of calling kstrdup_quotable_cmdline() > which allocates the buffer on heap I called get_cmdline() directly > passing it stack-allocated buffer of certain size e.g. 256? No it wouldn't because get_cmdline take mmap_sem lock as already pointed out. Please also note that the cmd line might be considered security/privacy sensitive information and dumping it to the log sounds like a bad idea in general. -- Michal Hocko SUSE Labs