Received: by 2002:a05:6a10:144:0:0:0:0 with SMTP id 4csp28692pxw; Thu, 7 Apr 2022 23:31:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSfbLzLHM9R9i2jhsI/4PfeSpqCG+ynetNVLYGoPO2ZtrC1d9/XSvdyM9fplxbbkwf5Nvz X-Received: by 2002:aa7:88ce:0:b0:505:6a0b:c965 with SMTP id k14-20020aa788ce000000b005056a0bc965mr5931476pff.67.1649399491758; Thu, 07 Apr 2022 23:31:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649399491; cv=none; d=google.com; s=arc-20160816; b=YerZINGa2EldxqL+0zApzkRLtKt3nDsn7NehhLX8DxANRXOlX8dwQNKPZ1iiMlDy1E aGRbSuk6yr4LNE829xPXm/Q2GWkA6jSFOxIAeSrX+0bGSReGEXULFdmY19628hVyt59a k9J0mygVBE+0prMYm0LOnXjY4p7THgTF/kh2cO0llpq151A0Vdo0dpOXIzkOMMLd5DhR cMvtPAxbKI+rQ8DrmKN6I58dt+r57WfHQaIl89m7SmcEuKOTuxiAvdW/FA/GuBRV28NH EJr75VGNFqHMs26x0yIwl636hJSIO9Tvosby2XANWGq5EXuANhy+popvmLbY469pIa9W 4UJQ== 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=LwACgBHjx4pJUIm6fVU5Jm7rMF6w4rkrcMcx4fw4FCI=; b=XBYx6nsArwBIUgOLtWVZVW8MXjfmNq3ci018MubV/1kQYwYYF3oATDheHNd7f/HGt6 wAxsvZqKJZXFiV2zDrOtAEeGH/ZKXITM4K3DiZbrHISyHMhK001RpVvTCChdfeaeWHgx LBxTJEK7GgbRHB56kNNZ4F0dvbZXz/FrraLCcHI8eAJLqgXP5IqUGOocYAH9n8rhHfJU 63L+M6x08zwWEj2yW43leWTd+OSrf/+s1eVUDBstPwXQc6fcL6S9MFmN7z/SJLCOqxOh Vh3rOva7LIZrVVmya65z4RpNrFJujepR5lMuHkuPWvM7mtUaI/V8OFxkmAnc5v2oCKZS Gy3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=375lV7YC; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id na4-20020a17090b4c0400b001bf2eed25aesi484572pjb.32.2022.04.07.23.31.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 23:31:31 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=375lV7YC; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6D6C962A0E; Thu, 7 Apr 2022 23:02:03 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235038AbiDHGD6 (ORCPT + 99 others); Fri, 8 Apr 2022 02:03:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbiDHGD4 (ORCPT ); Fri, 8 Apr 2022 02:03:56 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F297A7246E; Thu, 7 Apr 2022 23:01:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=LwACgBHjx4pJUIm6fVU5Jm7rMF6w4rkrcMcx4fw4FCI=; b=375lV7YC8QITt0RjH/PrWrQSKU +OF4LBtPCTwnV3ST18w56iW8/gCOQIxCsXu4Jo9EyVXrx7K33nAbuJIxIc2VOOYCq7mYfZy/NUftn m/bbl1LQ36t79bf6ml8bGRR3gzVcLKK3ZTEfTzjpkI/FXvPLe1uCOB01UyzJcx4iT41nY5fm6QsmX tqQ4n0fApCd4PXVOtvPsxYCOUwGUrm4SV0JPwQdT/BxCv6jCuAliPmkFn/0u6Zn5ENZjNaaElGc/M YUXFyPChzzwczeI6hCxNBrr6EMxUdkUCBD+79za8afY+zpH8HDSp/ZJB9ZpWX9qYNF0lvbxbl+s5E abO0PaSg==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nchgv-00FDvY-B7; Fri, 08 Apr 2022 06:01:53 +0000 Date: Thu, 7 Apr 2022 23:01:53 -0700 From: Christoph Hellwig To: Logan Gunthorpe Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, Song Liu , Shaohua Li , Guoqing Jiang , Stephen Bates , Martin Oliveira , David Sloan Subject: Re: [PATCH v1 3/8] md/raid5: Move common stripe count increment code into __find_stripe() Message-ID: References: <20220407164511.8472-1-logang@deltatee.com> <20220407164511.8472-4-logang@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220407164511.8472-4-logang@deltatee.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no 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 On Thu, Apr 07, 2022 at 10:45:06AM -0600, Logan Gunthorpe wrote: > static struct stripe_head *__find_stripe(struct r5conf *conf, sector_t sector, > - short generation) > + short generation, int hash) > { > + int inc_empty_inactive_list_flag; > struct stripe_head *sh; > > pr_debug("__find_stripe, sector %llu\n", (unsigned long long)sector); > hlist_for_each_entry(sh, stripe_hash(conf, sector), hash) > if (sh->sector == sector && sh->generation == generation) > - return sh; > + goto found; > pr_debug("__stripe %llu not in cache\n", (unsigned long long)sector); > return NULL; > + > +found: > + if (!atomic_inc_not_zero(&sh->count)) { There is a way on list iterators outside the loop body waging right now. So maybe just leave __find_stripe as-is and add a new find_get_stripe that wraps it. And then just return early when the atomic_inc_not_zero dos not succeed and save on one level of indentation.