* [PATCH] mm: remove __GFP_NOFAIL is deprecated comment
@ 2016-02-25 10:43 Michal Hocko
2016-02-25 11:36 ` Nikolay Borisov
0 siblings, 1 reply; 4+ messages in thread
From: Michal Hocko @ 2016-02-25 10:43 UTC (permalink / raw)
To: Andrew Morton
Cc: David Rientjes, Nikolay Borisov, linux-mm, LKML, Michal Hocko
From: Michal Hocko <mhocko@suse.com>
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.
Signed-off-by: Michal Hocko <mhocko@suse.com>
---
Hi,
this popped out when discussing another patch http://lkml.kernel.org/r/56CEC568.6080809@kyup.com
so I think it is worth removing the comment.
mm/page_alloc.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 1993894b4219..109d975a7172 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -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;
--
2.7.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm: remove __GFP_NOFAIL is deprecated comment
2016-02-25 10:43 [PATCH] mm: remove __GFP_NOFAIL is deprecated comment Michal Hocko
@ 2016-02-25 11:36 ` Nikolay Borisov
2016-02-25 13:48 ` Michal Hocko
0 siblings, 1 reply; 4+ messages in thread
From: Nikolay Borisov @ 2016-02-25 11:36 UTC (permalink / raw)
To: Michal Hocko, Andrew Morton; +Cc: David Rientjes, linux-mm, LKML, Michal Hocko
On 02/25/2016 12:43 PM, Michal Hocko wrote:
> From: Michal Hocko <mhocko@suse.com>
>
> 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.
>
> Signed-off-by: Michal Hocko <mhocko@suse.com>
> ---
> Hi,
> this popped out when discussing another patch http://lkml.kernel.org/r/56CEC568.6080809@kyup.com
> so I think it is worth removing the comment.
>
> mm/page_alloc.c | 18 +++++-------------
> 1 file changed, 5 insertions(+), 13 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 1993894b4219..109d975a7172 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -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));
WARN_ON_ONCE already includes an unlikely in its definition:
http://lxr.free-electrons.com/source/include/asm-generic/bug.h#L109
> spin_lock_irqsave(&zone->lock, flags);
>
> page = NULL;
>
Reviewed-by: Nikolay Borisov <kernel@kyup.com>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm: remove __GFP_NOFAIL is deprecated comment
2016-02-25 11:36 ` Nikolay Borisov
@ 2016-02-25 13:48 ` Michal Hocko
2016-03-07 14:57 ` Vlastimil Babka
0 siblings, 1 reply; 4+ messages in thread
From: Michal Hocko @ 2016-02-25 13:48 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: Andrew Morton, David Rientjes, linux-mm, LKML
On Thu 25-02-16 13:36:11, Nikolay Borisov wrote:
[...]
> > + /*
> > + * 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.
> Reviewed-by: Nikolay Borisov <kernel@kyup.com>
Thanks!
---
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm: remove __GFP_NOFAIL is deprecated comment
2016-02-25 13:48 ` Michal Hocko
@ 2016-03-07 14:57 ` Vlastimil Babka
0 siblings, 0 replies; 4+ messages in thread
From: Vlastimil Babka @ 2016-03-07 14:57 UTC (permalink / raw)
To: Michal Hocko, Nikolay Borisov
Cc: Andrew Morton, David Rientjes, linux-mm, LKML
On 02/25/2016 02:48 PM, Michal Hocko wrote:
> On Thu 25-02-16 13:36:11, Nikolay Borisov wrote:
> - 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((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 majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-03-07 14:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-25 10:43 [PATCH] mm: remove __GFP_NOFAIL is deprecated comment Michal Hocko
2016-02-25 11:36 ` Nikolay Borisov
2016-02-25 13:48 ` Michal Hocko
2016-03-07 14:57 ` Vlastimil Babka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox