linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Qi Zheng <zhengqi.arch@bytedance.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: akinobu.mita@gmail.com, vbabka@suse.cz,
	gregkh@linuxfoundation.org, jirislaby@kernel.org,
	rostedt@goodmis.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org
Subject: Re: [PATCH 1/2] mm: fix missing handler for __GFP_NOWARN
Date: Wed, 11 May 2022 10:36:18 +0800	[thread overview]
Message-ID: <ebb3c657-c914-7d71-c4c9-6e8fe2d2e0c0@bytedance.com> (raw)
In-Reply-To: <20220510193215.14ed7e3fb70857738e10c0a2@linux-foundation.org>



On 2022/5/11 10:32 AM, Andrew Morton wrote:
> On Wed, 11 May 2022 10:19:48 +0800 Qi Zheng <zhengqi.arch@bytedance.com> wrote:
> 
>>
>> ,,,
>>>> --- a/mm/internal.h
>>>> +++ b/mm/internal.h
>>>> @@ -35,6 +35,17 @@ struct folio_batch;
>>>>    /* Do not use these with a slab allocator */
>>>>    #define GFP_SLAB_BUG_MASK (__GFP_DMA32|__GFP_HIGHMEM|~__GFP_BITS_MASK)
>>>>    
>>>> +#define WARN_ON_ONCE_GFP(cond, gfp)	({				\
>>>> +	static bool __section(".data.once") __warned;			\
>>>> +	int __ret_warn_once = !!(cond);					\
>>>> +									\
>>>> +	if (unlikely(!(gfp & __GFP_NOWARN) && __ret_warn_once && !__warned)) { \
>>>> +		__warned = true;					\
>>>> +		WARN_ON(1);						\
>>>> +	}								\
>>>> +	unlikely(__ret_warn_once);					\
>>>> +})
>>>
>>> I don't think WARN_ON_ONCE_GFP is a good name for this.  But
>>> WARN_ON_ONCE_IF_NOT_GFP_NOWARN is too long :(
>>>
>>> WARN_ON_ONCE_NOWARN might be better.  No strong opinion here, really.
>>
>> I've thought about WARN_ON_ONCE_NOWARN, but I feel a little weird
>> putting 'WARN' and 'NOWARN' together, how about WARN_ON_ONCE_IF_ALLOWED?
> 
> I dunno.  WARN_ON_ONCE_GFP isn't too bad I suppose.  Add a comment over
> the definition explaining it?

OK, I will add a comment to it.

> 
>>>
>>>> @@ -4902,8 +4906,8 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
>>>>    	 * We also sanity check to catch abuse of atomic reserves being used by
>>>>    	 * callers that are not in atomic context.
>>>>    	 */
>>>> -	if (WARN_ON_ONCE((gfp_mask & (__GFP_ATOMIC|__GFP_DIRECT_RECLAIM)) ==
>>>> -				(__GFP_ATOMIC|__GFP_DIRECT_RECLAIM)))
>>>> +	if (WARN_ON_ONCE_GFP((gfp_mask & (__GFP_ATOMIC|__GFP_DIRECT_RECLAIM)) ==
>>>> +				(__GFP_ATOMIC|__GFP_DIRECT_RECLAIM), gfp_mask))
>>>>    		gfp_mask &= ~__GFP_ATOMIC;
>>>>    
>>>>    retry_cpuset:
>>>
>>> I dropped this hunk - Neil's "mm: discard __GFP_ATOMIC"
>>> (https://lkml.kernel.org/r/163712397076.13692.4727608274002939094@noble.neil.brown.name)
>>> deleted this code.
>>>
>>
>> This series is based on v5.18-rc5, I will rebase it to the latest next
>> branch and check if there are any missing WARN_ON_ONCEs that are not
>> being handled.
> 
> Against git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm branch
> mm-unstable, please.  That ends up in linux-next, with a delay.

OK, will do.

-- 
Thanks,
Qi


  reply	other threads:[~2022-05-11  2:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-10 11:38 Qi Zheng
2022-05-10 11:38 ` [PATCH 2/2] tty: fix deadlock caused by calling printk() under tty_port->lock Qi Zheng
2022-05-11  5:57   ` Jiri Slaby
2022-05-11  6:11     ` Qi Zheng
2022-05-10 18:59 ` [PATCH 1/2] mm: fix missing handler for __GFP_NOWARN Andrew Morton
2022-05-11  2:19   ` Qi Zheng
2022-05-11  2:32     ` Andrew Morton
2022-05-11  2:36       ` Qi Zheng [this message]
2022-05-11  5:12 ` Qi Zheng
2022-05-11  5:28   ` Qi Zheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ebb3c657-c914-7d71-c4c9-6e8fe2d2e0c0@bytedance.com \
    --to=zhengqi.arch@bytedance.com \
    --cc=akinobu.mita@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rostedt@goodmis.org \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox