linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: Yangtao Li <tiny.windzz@gmail.com>,
	Christoph Lameter <cl@linux.com>,
	Pekka Enberg <penberg@kernel.org>,
	David Rientjes <rientjes@google.com>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux-MM <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm, slab: remove unnecessary unlikely()
Date: Tue, 6 Nov 2018 09:54:49 +0100	[thread overview]
Message-ID: <a16bb44b-5231-97fe-920d-20cd92b5f3b2@suse.cz> (raw)
In-Reply-To: <CACT4Y+a+7gqs+gdfePuVGZ-bDGvb8ieE8ugA-pK1AZ8HwfecQg@mail.gmail.com>

On 11/6/18 6:38 AM, Dmitry Vyukov wrote:
> On Mon, Nov 5, 2018 at 11:18 AM, Vlastimil Babka <vbabka@suse.cz> wrote:
>> +CC Dmitry
>>
>> On 11/4/18 1:50 PM, Yangtao Li wrote:
>>> WARN_ON() already contains an unlikely(), so it's not necessary to use
>>> unlikely.
>>>
>>> Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
>>
>> Acked-by: Vlastimil Babka <vbabka@suse.cz>
>>
>> Maybe also change it back to WARN_ON_ONCE? I already considered it while
>> reviewing Dmitry's patch and wasn't sure. Now I think that what can
>> happen is that either a kernel bug is introduced that _ONCE is enough to
>> catch (two separate bugs introduced to both hit this would be rare, and
>> in that case the second one will be reported after the first one is
>> fixed), or this gets called with a user-supplied value, and then we want
>> to avoid spamming dmesg with multiple warnings that the user could
>> trigger at will.
> 
> 
> If you asking me, I am fine both changes.
> I was mainly interested in removing the bogus warnings that actually fire.

OK thanks. Andrew can you update the patch to WARN_ON_ONCE?

Changelog addition:
Also change WARN_ON() back to WARN_ON_ONCE() to avoid potentially
spamming dmesg with user-triggerable large allocations.

> 
>>> ---
>>>  mm/slab_common.c | 4 +---
>>>  1 file changed, 1 insertion(+), 3 deletions(-)
>>>
>>> diff --git a/mm/slab_common.c b/mm/slab_common.c
>>> index 7eb8dc136c1c..4f54684f5435 100644
>>> --- a/mm/slab_common.c
>>> +++ b/mm/slab_common.c
>>> @@ -1029,10 +1029,8 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
>>>
>>>               index = size_index[size_index_elem(size)];
>>>       } else {
>>> -             if (unlikely(size > KMALLOC_MAX_CACHE_SIZE)) {
>>> -                     WARN_ON(1);
>>> +             if (WARN_ON(size > KMALLOC_MAX_CACHE_SIZE))
>>>                       return NULL;
>>> -             }
>>>               index = fls(size - 1);
>>>       }
>>>
>>>
>>

  reply	other threads:[~2018-11-06  8:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-04 12:50 [PATCH] mm, slab: remove unnecessary unlikely() Yangtao Li
2018-11-05 10:18 ` Vlastimil Babka
2018-11-06  5:38   ` Dmitry Vyukov
2018-11-06  8:54     ` Vlastimil Babka [this message]
2018-11-07 22:55 ` David Rientjes

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=a16bb44b-5231-97fe-920d-20cd92b5f3b2@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=dvyukov@google.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=tiny.windzz@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).