Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp305923pxf; Wed, 17 Mar 2021 05:56:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkW9auUsH/bHGDx7eGECOcTQrIIYFj+1pM836Z3pgSEqq4EBWXuM+64SD/pNICnAa1MwYq X-Received: by 2002:a17:906:5902:: with SMTP id h2mr35037147ejq.416.1615985819343; Wed, 17 Mar 2021 05:56:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615985819; cv=none; d=google.com; s=arc-20160816; b=o98Dp6MPm5OifSKBG5evmQUgy0bPKudajRZit+vAk3XOywdUvHWInC+MPeRebilLod TOC19t3h42INi5XK8VtUKitk5/WqYueLSw5FGZKEX5LrL9poTsDbNySxVcDUjZMhUjBK vhcKgnODkGmpYd40+nGPPBdB1yrwGxVEi69MvDvKlbH96nls8/XU1/pSV7JomXcFchzr Ovm21H8cMdefz2fGnEvRL0snvaO13lHRVVyEI6hWoMuRN/PHyuppuWOijbel75eeTOWw utsq0d8TexCRzpLO3L9qvg0+F3VCwXoxW5nXXVhdLVZoCr5JLClk35owzH9lrmk97mPV 6BOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=FrWJEnLtr5Auy3/EU9Y/+fZiNe2NWval3nQhhiTHJVI=; b=tAUaitWvfpU366yuOgT81E3IkfPG2++f2VQcasqZygAQCTHeSfBroBKcG6kYQRp/4z O8WuHvEjMTXbRjbtMr4NcSXoq+8deAs3BJ9DBfS/sZBAEtFNTxeens0dc7OA6X30qmOP 4RrZtaDQyzB8q0aLlkEb7ySlTQWgi5jK1mD6k+nyeGtBnkoWXpDRLwvA0fO4mNglBeTK TmZy3aofrwaNl7vO5Ni81QStppfSOdr678pwZJOhwKd5l6lmYYFObatEGLVsV8kC6W1Q a07TtoyovBwiKvPsV10hCCtnWwUDu/2pV8EwdcKibGorhbYVdGOs6AwGK7e7mz1Cs58Y rREg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="BZHG/4nY"; 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 m23si16039513ejr.429.2021.03.17.05.56.35; Wed, 17 Mar 2021 05:56:59 -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=@kernel.org header.s=k20201202 header.b="BZHG/4nY"; 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 S230145AbhCQMza (ORCPT + 99 others); Wed, 17 Mar 2021 08:55:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:34188 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230169AbhCQMzW (ORCPT ); Wed, 17 Mar 2021 08:55:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5C08B64F6C for ; Wed, 17 Mar 2021 12:55:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615985721; bh=VTpFVMscC2ZS5zTHGA+3sEixNuJvoOgW/ohm5EunFR4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=BZHG/4nYskrmM7mwF/jEsR/7iwgngenLi0ETXs9+owCVvBraukmdINkF+t5HFcEHk N78EucWLbWzVnbl32S0bPl06IvxcUTJxpy5YuXAuXgcCojjQ22eIID8skApRQDHv9e I47DJ/NSgbGr+hS2Ycgz6eVYSDXFO4/HmbUJumrYPZvylLEpksdKtPWz0KLDXlwJrg 7w9Vw8Ct/RNxDmpCFw2OUKfDJAHj1FdrYf7sCgPbdetyrSp/KXfidXCgEuXh0yhBBm 1cLXH5TohllbqO/ox9k1qqQMIiSLNnnwFp2sSmvTp9tLyLyOyFIUmfSdZcQ6O32q6p hmds/rptiYAUA== Received: by mail-ot1-f43.google.com with SMTP id o19-20020a9d22130000b02901bfa5b79e18so1678552ota.0 for ; Wed, 17 Mar 2021 05:55:21 -0700 (PDT) X-Gm-Message-State: AOAM532KCh9KmUDOr0fXJCkGnOq83A8k11F5SMZulP8D7RhFekcNmSLJ 6rMXCEAEicxXYZFhVmBDu3RZL88h0VApdVvSEUs= X-Received: by 2002:a05:6830:14c1:: with SMTP id t1mr3238358otq.305.1615985720417; Wed, 17 Mar 2021 05:55:20 -0700 (PDT) MIME-Version: 1.0 References: <1615949121-70877-1-git-send-email-jiapeng.chong@linux.alibaba.com> <20210317083947.GD3881262@gmail.com> <20210317084132.GA378908@gmail.com> In-Reply-To: <20210317084132.GA378908@gmail.com> From: Arnd Bergmann Date: Wed, 17 Mar 2021 13:55:04 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] sched: replace if (cond) BUG() with BUG_ON() To: Ingo Molnar 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" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Arnd