All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Yangtao Li <tiny.windzz@gmail.com>,
	cl@linux.com, penberg@kernel.org, rientjes@google.com,
	iamjoonsoo.kim@lge.com, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Dmitry Vyukov <dvyukov@google.com>
Subject: Re: [PATCH] mm, slab: remove unnecessary unlikely()
Date: Mon, 5 Nov 2018 11:18:05 +0100	[thread overview]
Message-ID: <2c42ba08-f78a-36f6-5a5d-21dd00861872@suse.cz> (raw)
In-Reply-To: <20181104125028.3572-1-tiny.windzz@gmail.com>

+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.

> ---
>  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-05 10:18 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 [this message]
2018-11-06  5:38   ` Dmitry Vyukov
2018-11-06  8:54     ` Vlastimil Babka
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=2c42ba08-f78a-36f6-5a5d-21dd00861872@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.