Skip to contentSkip to conversation

mm: remove __GFP_NOFAIL is deprecated comment

PATCH In review Michal Hocko 3 participants 4 messages Feb 25, 2016 – Mar 7, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: remove __GFP_NOFAIL is deprecated comment

From: Michal Hocko <[email protected]>

647757197cd3 ("mm: clarify __GFP_NOFAIL deprecation status") was incomplete and didn't remove the comment about __GFP_NOFAIL being deprecated in buffered_rmqueue. Let's get rid of this leftover but keep the WARN_ON_ONCE for order > 1 because we should really discourage from using __GFP_NOFAIL with higher order allocations because those are just too subtle.

---
Hi,
this popped out when discussing another patch http://lkml.kernel.org/r/[email protected]
so I think it is worth removing the comment.

 mm/page_alloc.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)
mm/page_alloc.c +5 -13
index 1993894b4219..109d975a7172 100644
@@ -2347,19 +2347,11 @@ struct page *buffered_rmqueue(struct zone *preferred_zone,
 		list_del(&page->lru);
 		pcp->count--;
 	} else {
-		if (unlikely(gfp_flags & __GFP_NOFAIL)) {
-			/*
-			 * __GFP_NOFAIL is not to be used in new code.
-			 *
-			 * All __GFP_NOFAIL callers should be fixed so that they
-			 * properly detect and handle allocation failures.
-			 *
-			 * We most definitely don't want callers attempting to
-			 * allocate greater than order-1 page units with
-			 * __GFP_NOFAIL.
-			 */
-			WARN_ON_ONCE(order > 1);
-		}
+		/*
+		 * We most definitely don't want callers attempting to
+		 * allocate greater than order-1 page units with __GFP_NOFAIL.
+		 */
+		WARN_ON_ONCE(unlikely(gfp_flags & __GFP_NOFAIL) && (order > 1));
 		spin_lock_irqsave(&zone->lock, flags);
 
 		page = NULL;
Signature · 7 lines
2.7.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Reviewed-by on v1 1/1
#1 lore raw
Quoted 34 lines · Michal Hocko

From: Michal Hocko <[email protected]>

647757197cd3 ("mm: clarify __GFP_NOFAIL deprecation status") was incomplete and didn't remove the comment about __GFP_NOFAIL being deprecated in buffered_rmqueue. Let's get rid of this leftover but keep the WARN_ON_ONCE for order > 1 because we should really discourage from using __GFP_NOFAIL with higher order allocations because those are just too subtle.

---
Hi,
this popped out when discussing another patch http://lkml.kernel.org/r/[email protected]
so I think it is worth removing the comment.

 mm/page_alloc.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)
mm/page_alloc.c +0 -8
index 1993894b4219..109d975a7172 100644
@@ -2347,19 +2347,11 @@ struct page *buffered_rmqueue(struct zone *preferred_zone,
 		list_del(&page->lru);
 		pcp->count--;
 	} else {
-		if (unlikely(gfp_flags & __GFP_NOFAIL)) {
-			/*
-			 * __GFP_NOFAIL is not to be used in new code.
-			 *
-			 * All __GFP_NOFAIL callers should be fixed so that they
-			 * properly detect and handle allocation failures.
-			 *
-			 * We most definitely don't want callers attempting to

mm/page_alloc.c struct page *buffered_rmqueue(struct zone *preferred_zone, · line 2354

Quoted 10 lines
mm/page_alloc.c +5 -5
-			 * allocate greater than order-1 page units with
-			 * __GFP_NOFAIL.
-			 */
-			WARN_ON_ONCE(order > 1);
-		}
+		/*
+		 * We most definitely don't want callers attempting to
+		 * allocate greater than order-1 page units with __GFP_NOFAIL.
+		 */
+		WARN_ON_ONCE(unlikely(gfp_flags & __GFP_NOFAIL) && (order > 1));

WARN_ON_ONCE already includes an unlikely in its definition:
http://lxr.free-electrons.com/source/include/asm-generic/bug.h#L109

mm/page_alloc.c struct page *buffered_rmqueue(struct zone *preferred_zone, · line 2357

Quoted 4 lines
mm/page_alloc.c +0 -0
 		spin_lock_irqsave(&zone->lock, flags);
 
 		page = NULL;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author Reviewed-by Nikolay Borisov
#2 lore raw

On Thu 25-02-16 13:36:11, Nikolay Borisov wrote:
[...]

Quoted 8 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+		/*
+		 * We most definitely don't want callers attempting to
+		 * allocate greater than order-1 page units with __GFP_NOFAIL.
+		 */
+		WARN_ON_ONCE(unlikely(gfp_flags & __GFP_NOFAIL) && (order > 1));

WARN_ON_ONCE already includes an unlikely in its definition:
http://lxr.free-electrons.com/source/include/asm-generic/bug.h#L109

OK, I just wanted to keep the condition untouched but you are right the unlikely can be removed.

Quoted 1 line

Thanks!
---

#3 lore raw
Quoted 13 lines · Michal Hocko

On Thu 25-02-16 13:36:11, Nikolay Borisov wrote:

(quoted diff) +0 -11
-		if (unlikely(gfp_flags & __GFP_NOFAIL)) {
-			/*
-			 * __GFP_NOFAIL is not to be used in new code.
-			 *
-			 * All __GFP_NOFAIL callers should be fixed so that they
-			 * properly detect and handle allocation failures.
-			 *
-			 * We most definitely don't want callers attempting to
-			 * allocate greater than order-1 page units with
-			 * __GFP_NOFAIL.
-			 */

Review

Quoted 10 lines
(quoted diff) +5 -2
-			WARN_ON_ONCE(order > 1);
-		}
+		/*
+		 * We most definitely don't want callers attempting to
+		 * allocate greater than order-1 page units with __GFP_NOFAIL.
+		 */
+		WARN_ON_ONCE((gfp_flags & __GFP_NOFAIL) && (order > 1));
  		spin_lock_irqsave(&zone->lock, flags);
 
  		page = NULL;

Hmm, even the reduced text (and the WARN_ON in the first place) sounds IMHO discouraging enough to make people think that opencoding a loop around such allocations is a good workaround. Yeah, we have a better/more thorough explanation around the __GFP_NOFAIL definition, but the WARN_ON will point people here.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>