Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp42144pxf; Wed, 17 Mar 2021 14:51:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzANcmU/+HEY6SeRY1Z47GEJd2hpvNZV9zKTosYcI/elcppD2OB5ZscRIO9Nvq+0YQpySEJ X-Received: by 2002:a17:906:bd2:: with SMTP id y18mr37912338ejg.482.1616017874363; Wed, 17 Mar 2021 14:51:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616017874; cv=none; d=google.com; s=arc-20160816; b=wQeZU/LAjstSQ6rzruuyjtrk0TKI9nzdYn6d98rfw62R/0egXRab6jvPV/Gh4VRE9R tZzDbZZ6fm8LFBiWe0s1ZLz5kK2zUeOA3yU/Xu/eb6hnuYo77it4pkXeL29rVPB+mxCV wgJbG/nYEBYQBs89LG2gpsTeQCvjekbQy7KtNvJA+Knxz2PnWf0G8ZHGngigzoPWSLUm 8Q8RrcvGat6LmUTBX11YSy4hdP0oYxH+6rqNOGzI9P+CaIi7W0hySUdGanzyDV9VQ9/E +tcsq7nDikMrQZgR3wUVAeeA8k1ZjgH8RfUsR/ZYY10OEGZ4jT8dLU4Yad72at6ACavg pD5g== 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=7mh5w9h/ks1YA0qvR1xgGLz7ViU6w51VLw2K9dNSqUg=; b=M1V4le5qgEoBOBxCRC1nDKa3dTNSHDJVhRoYa6cFh8/FAdE9MMc8HA9NXynm3ug0pE YWC+R1sCxa0ucRnn9sBsvlSRarqqPci016KdsW8Zyuo5QDkG32AOkp7IYgnranuCK4l6 eYn0mTXg4WEmTSka+olyj6QebXdTzFF224mJbiYXHaAwUGLXWCd+IaQGEhI/WOuGBydO SG2PnaalkdqsUc8CP7nZGHk4v5RSvjLjewD91a23tl7Vgi6o8CIn4A5XDhl/aRU8m4PJ ziw5Pv9IpU0zC6H2OfvlPYqvqvkNxX4khD0VPeDnuTpz4tu4DXy0xAvnwDFjs/1OzhYM /3zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LE0sFBzm; 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 z2si19713edb.287.2021.03.17.14.50.52; Wed, 17 Mar 2021 14:51:14 -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=LE0sFBzm; 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 S230036AbhCQVjQ (ORCPT + 99 others); Wed, 17 Mar 2021 17:39:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:38156 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229545AbhCQVjN (ORCPT ); Wed, 17 Mar 2021 17:39:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1175E64F17 for ; Wed, 17 Mar 2021 21:39:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616017153; bh=VIMNcF6dOmgW2zs3po0Jqy5OCE8TvozkFRpvez7f7cg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=LE0sFBzm2pFGpEeYIHfkNKt6447R41ZcaGkrtkTm6zspzHk0CZhNcI0F7rzhndFhZ cnjYbh9tU8nXfC3h41LJjVZGoISEX232YYOHaZMIAFJZ0+DRnHugDDhURqE2NRxWMT Y/EI0Kg6G3/iscelMhsEAMLJSLJhfh5n4yrBRKYh+BYHFlwkT3g8GBGxtYoyJp4EMb npZ5Fn7OhB0XFHL4HeLMdeVeThkq9HY8RtJUiRQW5MK89X4X65hCJXtv+IGSj84JP6 GZ8zVeE8IT9PnACzGub7HUk09ozheJW0SGceLChIHBRywh4Wjq9o8a8aCmVE5oG9T3 6+z6cdOn4ol/w== Received: by mail-ot1-f47.google.com with SMTP id k14-20020a9d7dce0000b02901b866632f29so3245772otn.1 for ; Wed, 17 Mar 2021 14:39:13 -0700 (PDT) X-Gm-Message-State: AOAM533IRI73Y8yKM2EGBEe8enowcOZyPqUNSKhdWeN1t09h7SaOrNPf uRQVnlFDOgFEVFPUeFs0mTC42uOrqbz0EutAfKk= X-Received: by 2002:a05:6830:14c1:: with SMTP id t1mr5015779otq.305.1616017152243; Wed, 17 Mar 2021 14:39:12 -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> <20210317200529.GB3830960@gmail.com> In-Reply-To: <20210317200529.GB3830960@gmail.com> From: Arnd Bergmann Date: Wed, 17 Mar 2021 22:38:55 +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:05 PM Ingo Molnar wrote: > * Arnd Bergmann wrote: > > On Wed, Mar 17, 2021 at 9:45 AM Ingo Molnar wrote: > > > > > > 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(). Fair enough. Readability really is the key here, and I agree the current version is easier to understand. The only architectures that even define an optimized BUG_ON() are mips and powerpc, and saving a few cycles is barely worth it in a fast path, which this is clearly not. Arnd