Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1272727rwe; Thu, 25 Aug 2022 20:34:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR6/cN86Cffo0qAnPjVE1IwxasNQhCY1MOT5a14ncKWMXVfddej4Zc3Il9mhYXQt0pgvn+zB X-Received: by 2002:a05:6a00:2181:b0:51b:560b:dd30 with SMTP id h1-20020a056a00218100b0051b560bdd30mr1988676pfi.44.1661484882814; Thu, 25 Aug 2022 20:34:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661484882; cv=none; d=google.com; s=arc-20160816; b=xlTvPwLp9oQZWO9/6/HTdtPKq7hJE0UL2+cDx7Zr4iVl3e7EFcjW523VLDJEn2JCE9 W2wA0poNgHMqAHlguq/MDlzwTU1JbyyPGSNtbvJ6kj71G3nKyUtnD73QQr84Akv4SkMZ hASi9H48UUa/XA/63QfXtIZ/TTU2FtiiCKXqS8rw8qvWMqxme9OcnRUdRWovsBOTFxrU mc+hU9pkTJH0vtjfi5in/EHXDwaT96ZjhrAi2cPmkX5C7cw/etv/hQLE8Rn7xTKVNLEg KLc8Y3xhISdv2GX7MdGEZbpBhTUov/kdDovpPa8aFki0ZUstPNJ5qPpL+GPoDE3TOCgv nCPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=kwUjNUJwk6RMdAPZmD6maPyqIJWkzrMN3f55Vw6ldTg=; b=Xos5e1nAk1LN7RpmApV21zOB1Hi5HGtXJGuOp1jhSIgu6uLs8CJcvoktcMvmf7suGi QkoJYP2UESaESKoKD75AhvlpYXWfLSJNOMViWsg+3OPGS1wxNEBpxwc3iFWdlm5pk+X2 SPDvNO1TBghlE/+BYJd1aagUcat3mWaUfZuIrSWYkPsjl4U3FirxCY1/nGg1I/ZqScpY A5b86q56TKoihKNw0KKOWE6pVPllYhq6z2cgKqPU2f/qH5AA0y48GpMgxAIFOPN7JSTB 5gCjMsDXAdaDIF2KP7JH0+REODCFNUSAYYYrxM6f4MXa4h7FUuY6oqLasMVRm0aaO1WO QTmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d9-20020a17090a628900b001f541fc751fsi769366pjj.190.2022.08.25.20.34.30; Thu, 25 Aug 2022 20:34:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244843AbiHZDOv (ORCPT + 99 others); Thu, 25 Aug 2022 23:14:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244922AbiHZDOi (ORCPT ); Thu, 25 Aug 2022 23:14:38 -0400 Received: from out30-42.freemail.mail.aliyun.com (out30-42.freemail.mail.aliyun.com [115.124.30.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24F63CE339; Thu, 25 Aug 2022 20:14:34 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=liusong@linux.alibaba.com;NM=1;PH=DS;RN=3;SR=0;TI=SMTPD_---0VNH5TJ6_1661483653; Received: from localhost(mailfrom:liusong@linux.alibaba.com fp:SMTPD_---0VNH5TJ6_1661483653) by smtp.aliyun-inc.com; Fri, 26 Aug 2022 11:14:32 +0800 From: Liu Song To: axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH] sbitmap: remove unnecessary code in __sbitmap_queue_get_batch Date: Fri, 26 Aug 2022 11:14:13 +0800 Message-Id: <1661483653-27326-1-git-send-email-liusong@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Liu Song If "nr + nr_tags <= map_depth", then the value of nr_tags will not be greater than map_depth, so no additional comparison is required. Signed-off-by: Liu Song --- lib/sbitmap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/sbitmap.c b/lib/sbitmap.c index 29eb048..34c904b 100644 --- a/lib/sbitmap.c +++ b/lib/sbitmap.c @@ -533,10 +533,9 @@ unsigned long __sbitmap_queue_get_batch(struct sbitmap_queue *sbq, int nr_tags, nr = find_first_zero_bit(&map->word, map_depth); if (nr + nr_tags <= map_depth) { atomic_long_t *ptr = (atomic_long_t *) &map->word; - int map_tags = min_t(int, nr_tags, map_depth); unsigned long val, ret; - get_mask = ((1UL << map_tags) - 1) << nr; + get_mask = ((1UL << nr_tags) - 1) << nr; do { val = READ_ONCE(map->word); if ((val & ~get_mask) != val) @@ -547,7 +546,7 @@ unsigned long __sbitmap_queue_get_batch(struct sbitmap_queue *sbq, int nr_tags, if (get_mask) { *offset = nr + (index << sb->shift); update_alloc_hint_after_get(sb, depth, hint, - *offset + map_tags - 1); + *offset + nr_tags - 1); return get_mask; } } -- 1.8.3.1