From patchwork Mon Oct 5 13:26:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 7327541 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A51E5BEEA4 for ; Mon, 5 Oct 2015 13:28:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C3E6E20693 for ; Mon, 5 Oct 2015 13:28:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DA3FD20690 for ; Mon, 5 Oct 2015 13:28:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752543AbbJEN20 (ORCPT ); Mon, 5 Oct 2015 09:28:26 -0400 Received: from m50-134.163.com ([123.125.50.134]:52336 "EHLO m50-134.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751936AbbJEN2Z (ORCPT ); Mon, 5 Oct 2015 09:28:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=hNAyfTyR2v+KdeOh6N 7pzaC4HHccS1S72iShyS8h/wU=; b=J0TQivHDFy/Rv6jpXjCSjeafw8TGyr8Ds5 Wz0fS5Y8QblF0bilub49/MASeolOGxqLCAB4bGlBC0NIDKrfm+1QgDhukRaNkCxJ QKBonTILAtDlOu42LrKf2S+ZrMpxR+W2y86TTCCh8PJ8td5i6XMRA6zgXNS+l5OE 6DfuWolgM= Received: from localhost (unknown [116.77.145.2]) by smtp4 (Coremail) with SMTP id DtGowED5CUl0ehJWHnNJAQ--.24402S3; Mon, 05 Oct 2015 21:26:14 +0800 (CST) From: Geliang Tang To: "James E.J. Bottomley" Cc: Geliang Tang , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3] scsi: drop unlikely behind BUG_ON() Date: Mon, 5 Oct 2015 21:26:04 +0800 Message-Id: <482d18783d6df356809b67431de95addfa20aa79.1444051018.git.geliangtang@163.com> X-Mailer: git-send-email 2.5.0 X-CM-TRANSID: DtGowED5CUl0ehJWHnNJAQ--.24402S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxJry5Kry3JrW7XF1ftw4xJFb_yoW8GryrpF 4Iga4UGrs7G3yFka4qgw18u345Ka93Gry3tF9xW393ZFWDCaySq3W5tasxZF18K3yrGFs8 XFnFgryUZF15AwUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UonQUUUUUU= X-Originating-IP: [116.77.145.2] X-CM-SenderInfo: 5jhoxtpqjwt0rj6rljoofrz/1tbiJRiKmVUL7T2vQQAAsO Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP (1) For !CONFIG_BUG cases, the bug call is a no-op, so we couldn't care less and the change is ok. (2) ppc and mips, which HAVE_ARCH_BUG_ON, do not rely on branch predictions as it seems to be pointless[1] and thus callers should not be trying to push an optimization in the first place. (3) For CONFIG_BUG and !HAVE_ARCH_BUG_ON cases, BUG_ON() contains an unlikely compiler flag already. Hence, we can drop unlikely behind BUG_ON(). [1] http://lkml.iu.edu/hypermail/linux/kernel/1101.3/02289.html Signed-off-by: Geliang Tang Reviewed-by: Bart Van Assche --- Changes in v2: - Just rewrite the commit log. --- drivers/scsi/scsi_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index f570b48..3b5faab 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1164,8 +1164,8 @@ int scsi_init_io(struct scsi_cmnd *cmd) count = blk_rq_map_integrity_sg(rq->q, rq->bio, prot_sdb->table.sgl); - BUG_ON(unlikely(count > ivecs)); - BUG_ON(unlikely(count > queue_max_integrity_segments(rq->q))); + BUG_ON(count > ivecs); + BUG_ON(count > queue_max_integrity_segments(rq->q)); cmd->prot_sdb = prot_sdb; cmd->prot_sdb->table.nents = count;