Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1447311imu; Mon, 5 Nov 2018 21:39:07 -0800 (PST) X-Google-Smtp-Source: AJdET5cyd6XTkBQcxLQOz+PLtEO7RHV3MqkzCJw9R1sxy7Fj9300vnxAurEK05qffc+oS1Vhl95A X-Received: by 2002:a63:8043:: with SMTP id j64mr22935302pgd.405.1541482747884; Mon, 05 Nov 2018 21:39:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541482747; cv=none; d=google.com; s=arc-20160816; b=jLkC1gtv75LkejLG/J8nddbY0ACfFriNn7NdylE0HYT+NY++2AMoXpEdi/Hy7pZLLt mfuKVuvrd1Ch69QlaO/2Bk2CL96zeVL7fI1qxuCg0P3xuFXqatMucldu2SrUDCHIGDd8 leu8ejtPXWCkC9ebX66IGW3OKKxR62eTS+Be7kZtvQ+n7v+YCCTZAOM1BWddduCLAEwn 1uBWBdrbwYoq10ZV1jM0NZft7qMYjNTJB5sYZb29hmQpF+9K1/9bLswik0nVeWoORB6w +yDKKNydfsz3ToSoWFUeeKJGVgkjMJkZXOmiiLbZICFRZL9CyB4ZvJPeGPr9EFF2uPc0 JCgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=ecz96OisFOefJV91RAs0gl1wjGoiHBxXhRFmTTSXIGE=; b=E3DV3zzMy7mYt7GpIMH5Yg2yMSH+S2Id1zn5SuB5ZWuqXuQX61xblqDFou/MWePIG6 D4IN0+W2mjU/7F1GlphE96whxFFg4exfHN2amZbvwFG2ihDlkQjLLf93lcF9fcl5C4iw sC1E2jdelsV+UruoDJZYXSmgrpICXyPLWkpQ9GCWxfcmQP+9gyPQj6XjHltyJ086C+oA BsOKyCR4+qJ+APtQwPecWVDF+16hf3pmiPlXiKTAjHGaoo+Ak4QKtNp7Mx83iQa56N6K +UINGZVFZRYnPj3YdSCWlYTjLtFiX9UmtYITwf4aLYIYvKSENi/JYgOdDNzHxPXtJGDr vDPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=i3GCrOXU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k6si19691813pgr.500.2018.11.05.21.38.51; Mon, 05 Nov 2018 21:39:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=i3GCrOXU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729508AbeKFPB6 (ORCPT + 99 others); Tue, 6 Nov 2018 10:01:58 -0500 Received: from mail-it1-f195.google.com ([209.85.166.195]:35100 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729016AbeKFPB6 (ORCPT ); Tue, 6 Nov 2018 10:01:58 -0500 Received: by mail-it1-f195.google.com with SMTP id v11so9959706itj.0 for ; Mon, 05 Nov 2018 21:38:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=ecz96OisFOefJV91RAs0gl1wjGoiHBxXhRFmTTSXIGE=; b=i3GCrOXUpAfqAu7EfI7MVIpLdEnJxCWV3EB7qbh2uhd85rTza/bqCtS1SBK7JNEa+V UZRqpF78K8nLYLNjR081LuZyFYUq1qzIvFG7Bx31vZCWJoiQ2A5vizwW3aVamtOPfSKe zVzky7chI1qVtWqx8SsvvFPd7uL+fYG30KrASyk8X/mxoW+1X1XliboIAPcWKK24GIO2 WNH4KF6QmZ1w7hejoBdR0DFdIW+Crg/vQL9VsD7RXFR514OApzPN7BlxLlTLqjmyfq2W dd963j3+ENXCZW5wleDJn8EJN0y4FOwuHLCvdUt+ozs4L4dAbD6GJuAshf9HGAiR4ei8 tQpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=ecz96OisFOefJV91RAs0gl1wjGoiHBxXhRFmTTSXIGE=; b=WHc7CSxsEey0qF20lkVDBfwKpD8r81LcIPzIk2iQRg/1QNs9CLSTWg9boZn/6EasLx v6mm1hzoVKa7fa6641datEw28c131jy/UzYNzr6gJNbfgWsiddkbVbaYUe+QA1sVFfsy ie9LyapvvRh6UjJHrfQT1HGzFqTUnLxNEiybIO30udd3V1DcAOAAG8ux4m4uSbeQkELv Ha6uYSzuCLLoZrcZimyNNexYTTyT/gB2AmDk7ehnQXqN+D8oIaY6iUMkVhKQWaDoqply /1CZ3m1QHfcJiEhqVJwtJ6uO5yMsinLEsW+xc5b6+/4VhHhTpcnboVNpvdx+rvXXRWRK NTOQ== X-Gm-Message-State: AGRZ1gI2I8aKGgootE1q4tRrGwEnzOMyTO4OM6OgLgmrXS/FzkzsBmw7 xe0tx3lhFOn9o5ZmVVhffXgI2g8rpTy7bKOIaAMYiw== X-Received: by 2002:a24:940f:: with SMTP id j15-v6mr894704ite.12.1541482709163; Mon, 05 Nov 2018 21:38:29 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a02:b01b:0:0:0:0:0 with HTTP; Mon, 5 Nov 2018 21:38:08 -0800 (PST) In-Reply-To: <2c42ba08-f78a-36f6-5a5d-21dd00861872@suse.cz> References: <20181104125028.3572-1-tiny.windzz@gmail.com> <2c42ba08-f78a-36f6-5a5d-21dd00861872@suse.cz> From: Dmitry Vyukov Date: Tue, 6 Nov 2018 06:38:08 +0100 Message-ID: Subject: Re: [PATCH] mm, slab: remove unnecessary unlikely() To: Vlastimil Babka Cc: Yangtao Li , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Linux-MM , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 5, 2018 at 11:18 AM, Vlastimil Babka 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 > > Acked-by: Vlastimil Babka > > 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. >> --- >> 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); >> } >> >> >