Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp784057rdg; Wed, 11 Oct 2023 05:38:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvlThqbTLjph26j5hSJz73psA++heEcKda7PotAMQha2Mart3si4VhrFD5abFrTaA+VnjD X-Received: by 2002:a05:6870:c347:b0:1b7:4521:14b6 with SMTP id e7-20020a056870c34700b001b7452114b6mr25202316oak.5.1697027885064; Wed, 11 Oct 2023 05:38:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697027885; cv=none; d=google.com; s=arc-20160816; b=CQz9IE1mFzVPA2AF9lCpg2Fq2xewwL0VEIqt5lxngj699fJdvPqh72VlLXYOMHaydW pQLVkp5MmsHIE11AiepTK/SkxCScrbjTKbQRMoh/VbPevrBeouxny+hRt5MFaXop7S1k hosK0nDHZ7CmqevkncUiZmJZO8BFr18JKiZHHF/CMZPhwHkipYmKhlu4AW11EkjY+r5W hxhVByT7xmB6SPe+12FRzStRnAlTaCbUwGn3PvZbRXgmwBeqiQ9AiGV4vxNQam2WvVxy ttkA4fi8zfpl4k2S5YbvkQTK1era2aPNetyd4F0cJ12pUQ9Vz4Kt7GltcdnunKZ8MIhe Qaog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id; bh=FV65RZ4Fw0mm88541VMjQg1843gTBzL0WzBy7oz5stM=; fh=2gKFCUzySrHeIBJMSHAx1HXclSr/Lo4PFuCedPzqT9A=; b=hqBtrQxjAczUzQmu015ktfCeeoA3nEcH9ORLIbOgUZv8dGsdPr0wnF/dIeY1j4tXOo N+MFzx7WtsxlAlA4raYvM8ArGz6jQ0FOUE94qMvwGQ9oN9dUYz8tDm1Kehn0k9gKSEIj XKE0ZKMS+VJaAWNokf5DagBs+qlZPPAQrFqdaKeZyGeoxHsH5zdUmMUb/0OFf+6Ng0RT u1tPcSZKe/Ok/0HS+jcvwqtBg7cDyCjq4XtmPGT5zdpfbBX/293ikAMvWxGXwE9KpA6z JCvzo/nB5E3C0LTQdEga+8rIwvAuKfrX07e2LFdYrPAPZzq4yFlaD/o83d8s68v6nwU0 I3KA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id c23-20020a631c17000000b0057776b67494si13998339pgc.887.2023.10.11.05.38.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 05:38:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 39699808751C; Wed, 11 Oct 2023 05:37:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232306AbjJKMhN (ORCPT + 99 others); Wed, 11 Oct 2023 08:37:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234852AbjJKMhJ (ORCPT ); Wed, 11 Oct 2023 08:37:09 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E013493; Wed, 11 Oct 2023 05:37:05 -0700 (PDT) Received: from kwepemm000012.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4S5Bxv69jdzLpZw; Wed, 11 Oct 2023 20:33:07 +0800 (CST) Received: from [10.174.178.220] (10.174.178.220) by kwepemm000012.china.huawei.com (7.193.23.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 11 Oct 2023 20:37:03 +0800 Message-ID: <5ea16795-08c6-ef6b-b8cb-f1de2f5a0021@huawei.com> Date: Wed, 11 Oct 2023 20:37:02 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH 1/2] scsi: core: cleanup scsi_dev_queue_ready() Content-Language: en-US From: Wenchao Hao To: Damien Le Moal CC: "James E . J . Bottomley" , "Martin K . Petersen" , , , References: <20230922093842.2646157-1-haowenchao2@huawei.com> <20230922093842.2646157-2-haowenchao2@huawei.com> <7a11374c-4e8e-b7f9-aca4-55686a6ec501@huawei.com> In-Reply-To: <7a11374c-4e8e-b7f9-aca4-55686a6ec501@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.178.220] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm000012.china.huawei.com (7.193.23.142) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.5 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 11 Oct 2023 05:37:27 -0700 (PDT) On 2023/9/24 14:27, Wenchao Hao wrote: > On 2023/9/22 20:50, Damien Le Moal wrote: >> On 2023/09/22 2:38, Wenchao Hao wrote: >>> This is just a cleanup for scsi_dev_queue_ready() to avoid >>> redundant goto and if statement, it did not change the origin >>> logic. >>> >>> Signed-off-by: Wenchao Hao >>> --- >>>   drivers/scsi/scsi_lib.c | 35 ++++++++++++++++++----------------- >>>   1 file changed, 18 insertions(+), 17 deletions(-) >>> >>> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c >>> index ca5eb058d5c7..f3e388127dbd 100644 >>> --- a/drivers/scsi/scsi_lib.c >>> +++ b/drivers/scsi/scsi_lib.c >>> @@ -1254,28 +1254,29 @@ static inline int scsi_dev_queue_ready(struct request_queue *q, >>>       int token; >>>       token = sbitmap_get(&sdev->budget_map); >>> -    if (atomic_read(&sdev->device_blocked)) { >>> -        if (token < 0) >>> -            goto out; >>> +    if (token < 0) >>> +        return -1; >> >> This is changing how this function works... >> > > I don't think so... > The origin function flow: > > static inline int scsi_dev_queue_ready(struct request_queue *q, >                   struct scsi_device *sdev) > { >     ... >     token = sbitmap_get(&sdev->budget_map); >     if (atomic_read(&sdev->device_blocked)) { >         if (token < 0) >             goto out; >     } >     return token; > out: >     return -1 > } > > If the token is less than 0, it would always return -1. So we can found > it's not necessary to check token after atomic_read(). > >>> -        if (scsi_device_busy(sdev) > 1) >>> -            goto out_dec; >>> +    /* >>> +     * device_blocked is not set at mostly time, so check it first >>> +     * and return token when it is not set. >>> +     */ >>> +    if (!atomic_read(&sdev->device_blocked)) >>> +        return token; >> >> ...because you reversed the tests order. > > As explained in comment, the device_blocked is not set at mostly time, > so when it's not set, just return the token. > Friendly ping...