Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp39423pxf; Wed, 17 Mar 2021 14:45:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5rYkFgb6PdK5vjQ4fFMrYQg8j+C5BdARI5is+CvtS2VmMhV+sPTq7qqbI65Ctv4yyzrYO X-Received: by 2002:a17:906:3488:: with SMTP id g8mr36666626ejb.282.1616017503218; Wed, 17 Mar 2021 14:45:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616017503; cv=none; d=google.com; s=arc-20160816; b=cHtnqg3YY4Ja19YCIsNSekvx6Lvt2yH7ZFAXJidfJz5zt28iZKiKQ4AlBQtOXCf9Vp BTvDlCaK6kqDV6OgXQrMhxuEJDcybI92zNp2ho8TFtGhtsk6X7icCzLuIPuLI7WN78Pp qbCETJU//7S+PIR1DcyHZpXj8ubXYvUss8EdGrzNTdcHlJOKuo8smsp4hL9VCJ8BCU4m icK530Y74AUPFwdFCQYvHq8vDuG2ZA65ysX0Lun3Crod3TInkGTpx73xtuftuwUGL4fS qje7hebMNw7gniOnDJ2ytUpqWExJaNpcEqMaPJ/apob3Z04qlE2VfyH2LcZDeTztqZXv ow0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=+Vwc4bO99bghaL7G6q7uXcTp67keKl3EuKi8TYc6T54=; b=VVJEpTvXfwQp5O+1kxW+3MtBGrr/Aiw4jeRdAy9T0jviUYrqOb+uEMM21YTdFbkZJs T9Ln8o0rLcs7/Nh9XzuqQCiuN8LIFW0LaZ9KdOkRHxECwTI/DvDFkCqm98fhD2kGz1RI RtZlOLuXYc0xko/HoBMgoXjKWvOvCoEsbAyL7j7raqH2wDnUq+up38HqxKo3u2eGJxSW EK7buxQZTmQpoMSbvGQsOqZ6CReoKofNVtrEfYzmJML8bbudkaltts0IrAOs0o2i7dif RXFsTSvrooey0D+OpVSG4brK04qtz7dQ9CqHFg0n3JXZJjyVTJWPsKQHjoPA+jnUCW5o Ilcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Nh4IiV+C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gb25si21708ejc.472.2021.03.17.14.44.40; Wed, 17 Mar 2021 14:45:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Nh4IiV+C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233439AbhCQUFm (ORCPT + 99 others); Wed, 17 Mar 2021 16:05:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233434AbhCQUFd (ORCPT ); Wed, 17 Mar 2021 16:05:33 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E397C06174A for ; Wed, 17 Mar 2021 13:05:33 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id f22-20020a7bc8d60000b029010c024a1407so4114955wml.2 for ; Wed, 17 Mar 2021 13:05:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=+Vwc4bO99bghaL7G6q7uXcTp67keKl3EuKi8TYc6T54=; b=Nh4IiV+CY/hil5aTSUXqAdzud5UnOUwWcJXs3tAmQbpCoS0BDd4G3ZBrLvEgalinjg dW3W7ErDtmCGkZ7f84aV/aJAGG8bpIoXkG+Clgb5wmzz/LnFLdYyTMGQi3ezM/p3Xt6+ i5+ipOzD/QZ14Gugee1di73kOvGqV/y12muzhvmUeqEasxeY1X99M3S4xaYA8JNBC5A3 LpTBJPRA2qsTGzEtBBLzbP0mdbMqyBFosn/H8BOUtVAR05c1+C3cmMUb7d/+2lMxkAFT NTtYSGNKvWsiWWDopzoyTkKQzYNI5hQ4e5NFmN1AlotqaXL8ukhICeEXFnwJxzI9Pcr8 JGhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=+Vwc4bO99bghaL7G6q7uXcTp67keKl3EuKi8TYc6T54=; b=qAPpMX6Ed7wuWRw7b9hAMch14WFt1Hpv8dKWp4Y82zBQIl5mMgfug4x+yMx+Cla2Kh 6JW/RHJf7PJ3FBwLrWTc/W+2D9cHobWTkvC5FVMkV1NLmNlZ6tkTeu1g0RTW7d06hnyV KFr0jYKbIQC9GsTXm0VSX9nWOOjhecbFNwCc3desia59yPs/CztnkMtYR0Ko4DO82YmO RhL4Gunewgm8OoG5rVYbCeYWI7lUGpS2HQzwSsfn2HvDd1CGkEKmKO94eD4+iWXnAH75 qqrriRR6dS0yc8+TUwclOfUvver9Fy7Xs5dZ7Lz9uuhq5+rG7TlJHCriDr0/7xUMdAi9 12mA== X-Gm-Message-State: AOAM530iYzvEecqGVRB0i/ZzQYzrydpKopJQJwzfCCo+4HBsWDiU78dj 5TiG35nh/QKIzJ1oGqlqs6N8iu7dIKE= X-Received: by 2002:a1c:2049:: with SMTP id g70mr443832wmg.7.1616011532075; Wed, 17 Mar 2021 13:05:32 -0700 (PDT) Received: from gmail.com (54033286.catv.pool.telekom.hu. [84.3.50.134]) by smtp.gmail.com with ESMTPSA id c9sm3382698wml.42.2021.03.17.13.05.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Mar 2021 13:05:31 -0700 (PDT) Sender: Ingo Molnar Date: Wed, 17 Mar 2021 21:05:29 +0100 From: Ingo Molnar To: Arnd Bergmann Cc: Jiapeng Chong , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] sched: replace if (cond) BUG() with BUG_ON() Message-ID: <20210317200529.GB3830960@gmail.com> References: <1615949121-70877-1-git-send-email-jiapeng.chong@linux.alibaba.com> <20210317083947.GD3881262@gmail.com> <20210317084132.GA378908@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Arnd Bergmann wrote: > On Wed, Mar 17, 2021 at 9:45 AM Ingo Molnar wrote: > > * Ingo Molnar wrote: > > > * Jiapeng Chong wrote: > > > > > > > Fix the following coccicheck warnings: > > > > > > > > ./kernel/sched/core.c:8039:2-5: WARNING: Use BUG_ON instead of if > > > > condition followed by BUG. > > > > > > > > Reported-by: Abaci Robot > > > > Signed-off-by: Jiapeng Chong > > > > --- > > > > kernel/sched/core.c | 3 +-- > > > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > > > > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > > > > index 9819121..7392bc0 100644 > > > > --- a/kernel/sched/core.c > > > > +++ b/kernel/sched/core.c > > > > @@ -8035,8 +8035,7 @@ void __init sched_init_smp(void) > > > > mutex_unlock(&sched_domains_mutex); > > > > > > > > /* Move init over to a non-isolated CPU */ > > > > - if (set_cpus_allowed_ptr(current, housekeeping_cpumask(HK_FLAG_DOMAIN)) < 0) > > > > - BUG(); > > > > + BUG(set_cpus_allowed_ptr(current, housekeeping_cpumask(HK_FLAG_DOMAIN)) < 0); > > > > > > The patch doesn't quite do what the title & changelog claims... > > > > More importantly, we use this pattern when we don't want !CONFIG_BUG > > to remove the 'condition'. > > > > I.e. the "side effect" here is important scheduler logic. It must > > never be optimized out. > > This behavior for !CONFIG_BUG has changed a while ago, it is now safe > to rely on the side-effect of the BUG_ON() condition regardless of > CONFIG_BUG. When that option is disabled, running into the condition > just ends up in a "do {} while (1)" loop. Dunno, I still think it's not a particularly clean pattern to 'hide' significant side effects within a BUG_ON(). Thanks, Ingo