Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1143707pxv; Thu, 1 Jul 2021 18:45:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwPwgCF2q6rs0HdEfPu2c/vF0GuQEXU5GC+VyhSWYgkL1DeJTT2FdDjD+lVDdmEhEXTlOe X-Received: by 2002:a17:907:8693:: with SMTP id qa19mr2805574ejc.189.1625190305320; Thu, 01 Jul 2021 18:45:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625190305; cv=none; d=google.com; s=arc-20160816; b=WDQ+9qX/9XNlU0y+NS1CtMv+Jg9t29PuBapenKRe55+dOEK4UuE7/eYTSxL7tpkMbd 7W6og20dFfdGgiT07GU4pKXoFVpWQS6uW3yRA6m226JXuh4iiSNeXD0Pg8wSl3Lm68pl +9FvK9TTeSLFZ+E8OpKKpLWChK2lRsoBA73vkRMNHDrwFLv283dTuhJPykzp909t9fUJ ghM2CwS2KaUocNc6RfB4nxNXoIqQsrHtwXJDwxZBMNKZoJ/38zii6KkjlQ+BtjrrnGTQ zlD/HJRR3HafjKnEc/zTu9Crl0CjHUYAfbpwyEYznp610vogjlSnF3JG5PjdpyP6/rIM 2SUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=NVvDpX6B0bQZL9rAZJV0luYE+NgON9amMkUJkPoZg88=; b=vViPPmzjwwK5kZFKvuITHQiOLUhw+Fot6Raueok4JaByEP26s/BGsfiXjIv8yJBOvr UQzhYk2k3xIWFqnInQUXC66h+H2hDKkjHzzLcThDQW83iAx+NoGP1mnFmmHWqoTbaocd V2w7F27dQLOUherTpidV29wNlc5bwT2ki2Bb99zRZACHWoICGTQultD41rV7Q2TJ8uIX sQlKZrBIcrzVhConNC5JIrsJB5g2YllCV4w+KHx21qfqvTWeJpmRHSvPvWyDtrHKJCxt FWyKzBLm1M4Zw5GqV4Vv1x1yCzQ3brUYZyZCAilr1+fZ8ADzq2KSMH9Ghiy3fJJZWBqm aLKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ozlabs.org header.s=201707 header.b="gB9eIdn/"; 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=ozlabs.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gv14si1616516ejc.459.2021.07.01.18.44.40; Thu, 01 Jul 2021 18:45:05 -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=@ozlabs.org header.s=201707 header.b="gB9eIdn/"; 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=ozlabs.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234627AbhGBBWJ (ORCPT + 99 others); Thu, 1 Jul 2021 21:22:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234501AbhGBBWI (ORCPT ); Thu, 1 Jul 2021 21:22:08 -0400 Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F0A1C061762 for ; Thu, 1 Jul 2021 18:19:37 -0700 (PDT) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4GGHLB622kz9sRf; Fri, 2 Jul 2021 11:19:30 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1625188773; bh=VFIGdRKCJvgeACmd5nk9f13+KDVmVzSnIzMWi3Jxn5Y=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=gB9eIdn/6nE0I+uBVLoKj33dhmVaovyTRAKENPRatU69jAGVxTVCJuswWca/qEVON oRUYMouHATU06xauQ2tULNKU3pVoMF6yiSpCgX8WcKo7rD73YQnUCbAEhOjcniSuhX YKYOwkf0KJ8i6gIxSSma2krd3Qw8FAi11oxNv8ZXdt5Q1ESro3vkTQ6XUbLboIXobi bGo6GEs3xHlB5jZAwOUHDBdbDIM67q5kxdxGXojPRxj9WnfNXCaiSgzbwUrETk/Icl vWxJaQr/Y5goDVresyV30FSPE8dddkPGQa24ZmN++tLkx2OHwg/uWdPMFbawJNZ1wj GmHfvvo/+oiqg== Message-ID: <60a148d7c63510cbf31f3517dcb097c77d4ecd7c.camel@ozlabs.org> Subject: Re: [PATCH v2] sched: Use BUG_ON From: Jeremy Kerr To: Jason Wang Cc: arnd@arndb.de, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Date: Fri, 02 Jul 2021 09:19:27 +0800 In-Reply-To: <20210701141130.940-1-wangborong@cdjrlc.com> References: <20210701141130.940-1-wangborong@cdjrlc.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jason, > The BUG_ON macro simplifies the if condition followed by BUG, so that > we can use BUG_ON instead of if condition followed by BUG. [...] > -       if (spu_acquire(ctx)) > -               BUG();  /* a kernel thread never has signals pending */ > +       /* a kernel thread never has signals pending */ > +       BUG_ON(spu_acquire(ctx)); I'm not convinced that this is an improvement; you've combined the acquire and the BUG into a single statement, and now it's no longer clear what the comment applies to. If you really wanted to use BUG_ON, something like this would be more clear: rc = spu_acquire(ctx); /* a kernel thread never has signals pending */ BUG_ON(rc); but we don't have a suitable rc variable handy, so we'd need one of those declared too. You could avoid that with: if (spu_acquire(ctx)) BUG_ON(1); /* a kernel thread never has signals pending */ but wait: no need for the constant there, so this would be better: if (spu_acquire(ctx)) BUG(); /* a kernel thread never has signals pending */ wait, what are we doing again? To me, this is a bit of shuffling code around, for no real benefit. Regards, Jeremy