Thread (99 messages) 99 messages, 9 authors, 2024-08-30

Re: [PATCH v3 4/4] mm: prohibit NULL deference exposed for unsupported non-blockable __GFP_NOFAIL

From: David Hildenbrand <hidden>
Date: 2024-08-19 12:48:13
Also in: linux-mm

On 19.08.24 12:19, Michal Hocko wrote:
On Mon 19-08-24 11:44:39, David Hildenbrand wrote:
[...]
quoted
quoted
   	if (gfp_mask & __GFP_NOFAIL) {
   		/*
-		 * All existing users of the __GFP_NOFAIL are blockable, so warn
-		 * of any new users that actually require GFP_NOWAIT
+		 * All existing users of the __GFP_NOFAIL are blockable
+		 * otherwise we introduce a busy loop with inside the page
+		 * allocator from non-sleepable contexts
   		 */
-		if (WARN_ON_ONCE_GFP(!can_direct_reclaim, gfp_mask))
-			goto fail;
+		BUG_ON(!can_direct_reclaim);
No new BUG_ON(), WARN_ON_ONCE() is good enough for something that should be
found during ordinary testing.
Do you mean
	if (WARN_ON_ONCE_GFP(...))
		goto retry?
Not really ...

but now I read the description more carefully and I am not sure why we 
are so into throwing around BUG_ONs here, for something that is simply 
not allowed and doesn't make sense.

If __GFP_NOFAIL is documented to

"
+ * It _must_ be blockable and used together with __GFP_DIRECT_RECLAIM.
+ * It should _never_ be used in non-sleepable contexts.
"

Why not document

"__GFP_NOFAIL always implies __GFP_DIRECT_RECLAIM" and do exactly that?

-- 
Cheers,

David / dhildenb
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help