Re: [PATCH 2/5] kernel.h: Add non_block_start/end()
From: Jason Gunthorpe
Date: Thu Aug 15 2019 - 14:24:53 EST
On Thu, Aug 15, 2019 at 07:42:07PM +0200, Michal Hocko wrote:
> On Thu 15-08-19 13:56:31, Jason Gunthorpe wrote:
> > On Thu, Aug 15, 2019 at 06:00:41PM +0200, Michal Hocko wrote:
> >
> > > > AFAIK 'GFP_NOWAIT' is characterized by the lack of __GFP_FS and
> > > > __GFP_DIRECT_RECLAIM..
> > > >
> > > > This matches the existing test in __need_fs_reclaim() - so if you are
> > > > OK with GFP_NOFS, aka __GFP_IO which triggers try_to_compact_pages(),
> > > > allocations during OOM, then I think fs_reclaim already matches what
> > > > you described?
> > >
> > > No GFP_NOFS is equally bad. Please read my other email explaining what
> > > the oom_reaper actually requires. In short no blocking on direct or
> > > indirect dependecy on memory allocation that might sleep.
> >
> > It is much easier to follow with some hints on code, so the true
> > requirement is that the OOM repear not block on GFP_FS and GFP_IO
> > allocations, great, that constraint is now clear.
>
> I still do not get why do you put FS/IO into the picture. This is really
> about __GFP_DIRECT_RECLAIM.
Like I said this is complicated, translating "no blocking on direct or
indirect dependecy on memory allocation that might sleep" into GFP
flags is hard for us outside the mm community.
So the contraint here is no __GFP_DIRECT_RECLAIM?
I bring up FS/IO because that is what Tejun mentioned when I asked him
about reclaim restrictions, and is what fs_reclaim_acquire() is
already sensitive too. It is pretty confusing if we have places using
the word 'reclaim' with different restrictions. :(
> > CPU0 CPU1
> > mutex_lock()
> > kmalloc(GFP_KERNEL)
>
> no I mean __GFP_DIRECT_RECLAIM here.
>
> > mutex_unlock()
> > fs_reclaim_acquire()
> > mutex_lock() <- illegal: lock dep assertion
>
> I cannot really comment on how that is achieveable by lockdep.
??? I am trying to explain this is already done and working today. The
above example will already fault with lockdep enabled.
This is existing debugging we can use and improve upon rather that
invent new debugging.
Jason