Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp518789rwn; Thu, 15 Sep 2022 02:16:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR5MP68F3x24Cc+a+juhpKm2/+FLOrr9SiL7FGzuD1Z0TfXf2rR4eUb5OKNOyion2DNzziNY X-Received: by 2002:a05:6a00:170a:b0:537:4212:5f5d with SMTP id h10-20020a056a00170a00b0053742125f5dmr41269853pfc.40.1663233418688; Thu, 15 Sep 2022 02:16:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663233418; cv=none; d=google.com; s=arc-20160816; b=fipB+J1lJOi21FsGfKnD+7gDFYq2oKRY0F1K6zrfbxAlnYECHp7D/NTHGVWkUejT9j /BGUDTXqBy9jVAm2iqo/YxWD0UXW+0UUdjSgvSHh80nKJCY1FwMuVvLhBELpk2USDKdC HHz6DjBJ6SGBMgLJJEovwAZEy0SGWz5BYlO8ogq/5ZandXOnFEMzk6IAMxfWTq+LpcLP AZRUABJJGmFfs1ofsCF08FoWGL+lmkCrflmm9Q7GqubwNQxQBE06hXIsEni7b4/UYIRI OXH8qmFOj9edRvpunsTTkdQNmKL435C7GHvOcO8sjxd2B7Fpon6TIOUEcFNE3nTcA9qf TJBw== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=4VB80UV5+6nyzar30klGdnaOCL1uc6aWxiAwEroWZ0g=; b=pRig0+Oh1/AlRfLM7tP/KZiOvWzBghh/TWD93TnR5RQ+i69QrwyCOMdTkw9lLZA+Xx a5RPcOT7kYkUQjo1SAvE/uKliiHxHbyvrPqho1vrmIrXtUVBwLkVlzoqR3eh1hPzDioN 31sZMTl1xHcEnnx2oc+4gsKdKmoFO/QIOPBS2bJboH1fXzScHrCwX3lwMezD1CKOG+3n +fe58KGW9fM6phD/713fNBjJC4qRKq1Qv381kgdqshMKoQF+4w/nmPy/hmj7qYUBK2OD HfHTcedwnq0nfR4em5yFaYXNpHcfEQw4mVrEhOByeRmTsZRgqECk99XJNVSx4rw/3WpS Sahg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j3-20020a17090a588300b00203336ddd4asi1309603pji.56.2022.09.15.02.16.47; Thu, 15 Sep 2022 02:16:58 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229609AbiIOJNo (ORCPT + 99 others); Thu, 15 Sep 2022 05:13:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229990AbiIOJND (ORCPT ); Thu, 15 Sep 2022 05:13:03 -0400 Received: from mx1.molgen.mpg.de (mx3.molgen.mpg.de [141.14.17.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AC7698D2B; Thu, 15 Sep 2022 02:12:35 -0700 (PDT) Received: from [172.30.1.130] (unknown [193.158.90.91]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pmenzel) by mx.molgen.mpg.de (Postfix) with ESMTPSA id 6FF8761EA1931; Thu, 15 Sep 2022 11:12:32 +0200 (CEST) Message-ID: <6a1060e1-990c-b068-b515-b43c62595a8b@molgen.mpg.de> Date: Thu, 15 Sep 2022 11:12:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v2 1/4] md/raid10: cleanup wait_barrier() Content-Language: en-US To: Yu Kuai Cc: Logan Gunthorpe , song@kernel.org, guoqing.jiang@linux.dev, linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, "yukuai (C)" References: <20220914014914.398712-1-yukuai1@huaweicloud.com> <20220914014914.398712-2-yukuai1@huaweicloud.com> <1932cd56-87fc-51ac-4cb0-ec35d912525c@huaweicloud.com> From: Paul Menzel In-Reply-To: <1932cd56-87fc-51ac-4cb0-ec35d912525c@huaweicloud.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS 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 Dear Yu, Am 15.09.22 um 09:21 schrieb Yu Kuai: > 在 2022/09/15 0:16, Logan Gunthorpe 写道: >> On 2022-09-13 19:49, Yu Kuai wrote: >>> From: Yu Kuai >>> >>> Currently the nasty condition is wait_barrier() is hard to read. This >>> patch factor out the condition into a function. >>> >>> There are no functional changes. >>> >>> Signed-off-by: Yu Kuai >>> --- >>>   drivers/md/raid10.c | 56 ++++++++++++++++++++++++++------------------- >>>   1 file changed, 32 insertions(+), 24 deletions(-) >>> >>> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c >>> index 64d6e4cd8a3a..56458a53043d 100644 >>> --- a/drivers/md/raid10.c >>> +++ b/drivers/md/raid10.c >>> @@ -957,44 +957,52 @@ static void lower_barrier(struct r10conf *conf) >>>       wake_up(&conf->wait_barrier); >>>   } >>> +static bool stop_waiting_barrier(struct r10conf *conf) >>> +{ >>> +    /* barrier is dropped */ >>> +    if (!conf->barrier) >>> +        return true; >>> + >>> +    /* >>> +     * If there are already pending requests (preventing the barrier >>> from >>> +     * rising completely), and the pre-process bio queue isn't >>> empty, then >>> +     * don't wait, as we need to empty that queue to get the nr_pending >>> +     * count down. >>> +     */ >>> +    if (atomic_read(&conf->nr_pending)) { >>> +        struct bio_list *bio_list = current->bio_list; >> >> I'd probably just put the bio_list declaration at the top of this >> function, then the nested if statements are not necessary. The compiler >> should be able to optimize the access just fine. >> >>>       if (conf->barrier) { >>> -        struct bio_list *bio_list = current->bio_list; >>> -        conf->nr_waiting++; >>> -        /* Wait for the barrier to drop. >>> -         * However if there are already pending >>> -         * requests (preventing the barrier from >>> -         * rising completely), and the >>> -         * pre-process bio queue isn't empty, >>> -         * then don't wait, as we need to empty >>> -         * that queue to get the nr_pending >>> -         * count down. >>> -         */ >>>           /* Return false when nowait flag is set */ >>>           if (nowait) { >>>               ret = false; >>>           } else { >>> +            conf->nr_waiting++; >> >> Technically speaking, I think moving nr_waiting counts as a functional >> change. As best as I can see it is correct, but it should probably be at >> least mentioned in the commit message, or maybe done as a separate >> commit with it's own justification. That way if it causes problems down >> the road, a bisect will make the issue clearer. > > Thanks for your advice, I just think increase and decrease nr_waiting in > the case 'nowait' is pointless, and I move it incidentally. > > I'll post a separate clean up patch to do that. > > Paul, can I still add your Acked-by for this patch? Yes, sure. Kind regards, Paul