On 10/23/20 2:21 PM, Daniel Vetter wrote:
Extracted from slab.h, which seems to have the most complete version including the correct might_sleep() check. Roll it out to slob.c.
Motivated by a discussion with Paul about possibly changing call_rcu behaviour to allocate memory, but only roughly every 500th call.
There are a lot fewer places in the kernel that care about whether allocating memory is allowed or not (due to deadlocks with reclaim code) than places that care whether sleeping is allowed. But debugging these also tends to be a lot harder, so nice descriptive checks could come in handy. I might have some use eventually for annotations in drivers/gpu.
Note that unlike fs_reclaim_acquire/release gfpflags_allow_blocking does not consult the PF_MEMALLOC flags. But there is no flag equivalent for GFP_NOWAIT, hence this check can't go wrong due to memalloc_no*_save/restore contexts.
Cc: Paul E. McKenney paulmck@kernel.org Cc: Christoph Lameter cl@linux.com Cc: Pekka Enberg penberg@kernel.org Cc: David Rientjes rientjes@google.com Cc: Joonsoo Kim iamjoonsoo.kim@lge.com Cc: Andrew Morton akpm@linux-foundation.org Cc: Peter Zijlstra peterz@infradead.org Cc: Ingo Molnar mingo@kernel.org Cc: Vlastimil Babka vbabka@suse.cz Cc: Mathieu Desnoyers mathieu.desnoyers@efficios.com Cc: Sebastian Andrzej Siewior bigeasy@linutronix.de Cc: Michel Lespinasse walken@google.com Cc: Daniel Vetter daniel.vetter@ffwll.ch Cc: Waiman Long longman@redhat.com Cc: Thomas Gleixner tglx@linutronix.de Cc: Randy Dunlap rdunlap@infradead.org Cc: linux-mm@kvack.org Cc: linux-fsdevel@vger.kernel.org Cc: Dave Chinner david@fromorbit.com Cc: Qian Cai cai@lca.pw Cc: linux-xfs@vger.kernel.org Signed-off-by: Daniel Vetter daniel.vetter@intel.com
Looks useful. Acked-by: Vlastimil Babka vbabka@suse.cz