Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6341846rwd; Mon, 19 Jun 2023 06:05:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5VRpPlXD44CM+xju/42r7whofDRj4ITQPLizEabyVcpGK9EH/mnsxKJSt16HPyQNu7zOyk X-Received: by 2002:a54:4199:0:b0:39a:7830:f237 with SMTP id 25-20020a544199000000b0039a7830f237mr9460021oiy.7.1687179950707; Mon, 19 Jun 2023 06:05:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687179950; cv=none; d=google.com; s=arc-20160816; b=efVasme6XRGT/TrqnTp/Tf6iS4LIdwr+SuAt7XXOATACH68/mQvhzciHOivAEsr54G 0/7I3wfpzNdSbVZ04GnCHNQ8vm/ot8QZpCn5HJOQp2cFu4jgmmrBoRQWj4ya1tj2F94t ijE9386wgf6KKijqRvVd/8IqldfEEATCTr7LlW9z4qBdSrj6DS8Tkamm9H9xvkX1wSeU kChEwfEggSCSsBeDYWIeKg1FC2n1n+G2zDCHq/2IkEFYPOP+w9bgJgrXg+iZlUtQllVu /8I0gCCJR3l6jr2O3OY5e9CxJetELI0vaU3DyfqyRpQ0IFjOPTvtS3uUYRjCjKAU89cr Au5w== 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 :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=7N6KJyoC64BEyPvgvrdhSVrGpK1QhqwnBdQz7rclKU4=; b=kvJNyFJ3RcElTDhyxJuTW1pBsujPa0rN5i60OG1hGM0HMUxuT3Ull61UoVsy4KeDsH awDcsreQR7aadSK/pG4RvOVNIEasKpkpjAm0jdeR96PCdK3YEnv4DHc5AKkEfJBPuE0Y CKAlw9fcVC6Sw32zZNDNhZULDt8HTb9as6CRGm/LdqrcZztbhCzLTMUzufcKjLGxmV6I mYKZ+og1GWIq8pvcsbQMiIUXJ8BI5AxTH+rANISGSDCyZn42brhzdG+iFnD3daqbX8DD kHnBDBhHVsJdvjBEotMp5ofpxluzpClKv5eyHgLNAhZ8+hijrbSToVE7/YZrfubYeQSE 7shg== 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 t12-20020a17090a024c00b00253160141c7si7574265pje.83.2023.06.19.06.05.26; Mon, 19 Jun 2023 06:05:50 -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 S231391AbjFSNA2 (ORCPT + 99 others); Mon, 19 Jun 2023 09:00:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231642AbjFSNAM (ORCPT ); Mon, 19 Jun 2023 09:00:12 -0400 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C34DD119; Mon, 19 Jun 2023 06:00:10 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Ql8xd3QFYz4f3rKQ; Mon, 19 Jun 2023 21:00:05 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP4 (Coremail) with SMTP id gCh0CgBH_rFQUZBkmWM9MA--.52075S3; Mon, 19 Jun 2023 21:00:02 +0800 (CST) Subject: Re: [PATCH] raid10: avoid spin_lock from fastpath from raid10_unplug() To: Paul Menzel , Yu Kuai Cc: aligrudi@gmail.com, song@kernel.org, linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, "yukuai (C)" References: <20230618142520.14662-1-yukuai1@huaweicloud.com> From: Yu Kuai Message-ID: <4c729ee3-ad63-1928-0113-19b576b09b24@huaweicloud.com> Date: Mon, 19 Jun 2023 21:00:00 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgBH_rFQUZBkmWM9MA--.52075S3 X-Coremail-Antispam: 1UD129KBjvJXoWxXF4UJFyrKrWkWr4kZF17GFg_yoW5Ww45pa yktFWYyrWDuryvqw4DJ3WUZa4Ygw4kt3Zrtr95A3WDXr1jgFyaqr4jqr4q9r4DZrs7GFyU Aa15JrykZF1jyaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUv014x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvEwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lc7I2V7IY0VAS07AlzVAY IcxG8wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14 v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkG c2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAFwI 0_Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWrJr0_WFyUJwCI42IY6I8E87Iv67AKxVW8 JVWxJwCI42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI43ZEXa7VUb XdbUUUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, MAY_BE_FORGED,NICE_REPLY_A,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Hi, 在 2023/06/19 18:26, Paul Menzel 写道: > Dear Yu, > > > Thank you for your patch. Some minor nits from my side, you can also > ignore. > > Am 18.06.23 um 16:25 schrieb Yu Kuai: >> From: Yu Kuai >> >> Commit 0c0be98bbe67 ("md/raid10: prevent unnecessary calls to wake_up() >> in fast path") missed one place, for example, while testing with: > > … one place. For example, with > >> >> fio -direct=1 -rw=write/randwrite -iodepth=1 ... >> >> Then plug and unplug will be called for each io, then wake_up() from > > Maybe: > >     fio -direct=1 -rw=write/randwrite -iodepth=1 ... > > plug und unplug are called for each io, then … > >> raid10_unplug() will cause lock contention as well. > > Maybe paste the perf command and output? Related test and test result and perf result can be found in the below Link. By the way, I'll wait for more review to send a v2 to optmize commit message. Thanks, Kuai > >> Avoid this contention by using wake_up_barrier() instead of wake_up(), >> where spin_lock is not held while waitqueue is empty. > > It’d be great if you added also the test results to the commit message. > >> By the way, in this scenario, each blk_plug_cb() will be allocated and >> freed for each io, this seems need to be optimized as well. >> >> Reported-and-tested-by: Ali Gholami Rudi >> Link: https://lore.kernel.org/all/20231606122233@laper.mirepesht/ >> Signed-off-by: Yu Kuai >> --- >>   drivers/md/raid10.c | 4 ++-- >>   1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c >> index d0de8c9fb3cf..fbaaa5e05edc 100644 >> --- a/drivers/md/raid10.c >> +++ b/drivers/md/raid10.c >> @@ -1118,7 +1118,7 @@ static void raid10_unplug(struct blk_plug_cb >> *cb, bool from_schedule) >>           spin_lock_irq(&conf->device_lock); >>           bio_list_merge(&conf->pending_bio_list, &plug->pending); >>           spin_unlock_irq(&conf->device_lock); >> -        wake_up(&conf->wait_barrier); >> +        wake_up_barrier(conf); >>           md_wakeup_thread(mddev->thread); >>           kfree(plug); >>           return; >> @@ -1127,7 +1127,7 @@ static void raid10_unplug(struct blk_plug_cb >> *cb, bool from_schedule) >>       /* we aren't scheduling, so we can do the write-out directly. */ >>       bio = bio_list_get(&plug->pending); >>       raid1_prepare_flush_writes(mddev->bitmap); >> -    wake_up(&conf->wait_barrier); >> +    wake_up_barrier(conf); >>       while (bio) { /* submit pending writes */ >>           struct bio *next = bio->bi_next; > > Reviewed-by: Paul Menzel > > > Kind regards, > > Paul > > . >