Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4466365pxj; Wed, 12 May 2021 06:20:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzp238bsEhcxTAYhBinSkkQBTVIM9zZs9B7p8OMVaH+OTVGaEUoewOTDKl5hG84+cMjypLt X-Received: by 2002:a17:906:dbdc:: with SMTP id yc28mr17383199ejb.130.1620825644666; Wed, 12 May 2021 06:20:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620825644; cv=none; d=google.com; s=arc-20160816; b=h+rnlRTujkVQ3prTSaoI3dLh+ngFkgj5grtchTEZFMCcqt1eCImH8/sG7uF42Rn/az kbnf7iyFdqIBYoVvKL+K1h+z5gv4K3TFOIFSEPUw9M5QztexaV1hAI2dQQNFMGTvcmo/ 4HPeAnnGggmRslj+EA9ei1BmNimQXj8WxnE45nhNmiFVyiJOSGqqk2OkWpo51EFWo/+e /KhozaO4Lo5jDYVSa6JaKvJ9DKHTYJEyUepLmp7CWBveox6Jf27eeYa15VQVFQi0wEX+ 40BC8jARVG2st0yRMMT0BpDJrJsfRWuZh5VnpYVyBXh7klL5s2PMe3Xp2eISWJ1YHz3e FUaw== 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:dkim-signature; bh=EEMjiMEC2w2Vz+O0N6rorDES3ckF2mfiLbifAYHGYhU=; b=QCJV7IlJasjpbqxI8nKbGivs9JSqDfPZ2iLchUtYalaH4IvAAGXa7qqmIvL+TPwB2J wKMwScu3QeCBkLGk6oWpeAcb2BoxYWTLRfeBabIc+gAI9v+8a/+s9nBIB4uDeb3ul0qm VuXDmJJnA6QmVF9sWzhw0ADFyCWsO89/TZSdPSrqc8I7nkT7CR84ws3MzCL0L6IDgeje e9Xib3d9CfQvVYvhrMOeXX8b87wyCb3SxjOM8jPxPo6zJ9zTezLV9xYQHkgL9txfnfDe R6bpl1g7IAXNA0qe7eIgEL+os16l9rzFO4/xJzM0pWtak4ShILPcwqWy4zfZUpFw2/zT gskg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iSWdCs42; 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 j7si23910379ejm.492.2021.05.12.06.20.19; Wed, 12 May 2021 06:20:44 -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=iSWdCs42; 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 S233328AbhELM4s (ORCPT + 99 others); Wed, 12 May 2021 08:56:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:56340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233560AbhELMzQ (ORCPT ); Wed, 12 May 2021 08:55:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BE660613F8; Wed, 12 May 2021 12:54:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620824048; bh=s63/YJ4rfJgTZzM8uR7M0raGMpzNRGRCgreL8WEBXdY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iSWdCs42qLZHX2ToG41t7al8jA2FDsE9y5DGWzMyqPTV7ldBCszU/dCVM5pmB23ln Nxeqm5eS8LBZzGvfHr5P4oBu80yPT0cI1rXim5a+J2MokjMFjdjbdWYRDvcetofq39 AdRj332k+PLgLfIjDjh84V+hVAaQU6oTFJjoQSsY7nAZFzMq5RpTPaaRWnTQeFq1Bh yu3ooTHmAUWnmclclXHqV7qFBTR25Q5pE1bO9im87xM0lGqjCKrKmXWyflv8t3xU/S kc6hk/oHF6j/cX4ifwcYDeo4SwqbNp6UNpEDxfEzkkmT0IyA/WMy2Eyyw9bZemiurq 6gno/8flQsjtA== Date: Wed, 12 May 2021 14:54:04 +0200 From: Jessica Yu To: zhouchuangao Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] kernel/module: Use BUG_ON instead of if condition followed by BUG Message-ID: References: <1620610682-25567-1-git-send-email-zhouchuangao@vivo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <1620610682-25567-1-git-send-email-zhouchuangao@vivo.com> X-OS: Linux p200300cbcf361a0029e37a38368d6727.dip0.t-ipconnect.de 5.12.0-2-default x86_64 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +++ zhouchuangao [09/05/21 18:38 -0700]: >This patch comes from cocinelle warning. Please include the output of the cocinelle warning here as well. See commit 56149c8cd820 ("media: pci: saa7164-core.c: replace if (cond) BUG() with BUG_ON()") for an example. Thanks. >BUG_ON uses unlikely in if(). Through disassembly, we can see that >brk #0x800 is compiled to the end of the function. >As you can see below: > ...... > ffffff8008660bec: d65f03c0 ret > ffffff8008660bf0: d4210000 brk #0x800 > >Usually, the condition in if () is not satisfied. For the >multi-stage pipeline, we do not need to perform fetch decode >and excute operation on brk instruction. > >In my opinion, this can improve the efficiency of the >multi-stage pipeline. > >Signed-off-by: zhouchuangao >--- > kernel/module.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > >diff --git a/kernel/module.c b/kernel/module.c >index b5dd92e..faf9114 100644 >--- a/kernel/module.c >+++ b/kernel/module.c >@@ -1014,8 +1014,7 @@ void __symbol_put(const char *symbol) > }; > > preempt_disable(); >- if (!find_symbol(&fsa)) >- BUG(); >+ BUG_ON(!find_symbol(&fsa)); > module_put(fsa.owner); > preempt_enable(); > } >-- >2.7.4 >