Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6554086rwr; Mon, 24 Apr 2023 23:33:17 -0700 (PDT) X-Google-Smtp-Source: AKy350Zy4NXQ/g/wC8Ca4xBU10rhaY/+M6j6V+sJqZozyhStChN+i4kU3qvxy9UBDwA199WH/5q3 X-Received: by 2002:a17:902:ce8f:b0:1a9:7262:fe55 with SMTP id f15-20020a170902ce8f00b001a97262fe55mr9242396plg.13.1682404396932; Mon, 24 Apr 2023 23:33:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682404396; cv=none; d=google.com; s=arc-20160816; b=mEAJThHCTQ1p2y9PibSe3d5uteG7W9r8QUfi/M7Ed7nMX4JlsB2gc9FHDqaXSBjPJ5 2y1FKcE3fGmJ9OqPWAcW72uxm8lSTv104vitBio7tgarwAn1R4HkjfXb7suS8KYu2cps WwTDZUbqal953kvuew52ifm/P57Xs3LebcGPmuCkTGnEe5eHctK4IV+fVwkILFzbs/8E 7M3iCpd4DEpyzxWOpUbT0C43axE6+GxAu32uqg7DVHd0egl0Sw/MjiAkotbN0cqJMVLP FbNz2XNbTlAaGSryzhU0kZROL9sjzQvyL59V+s8ofUJqWx0DHh+6zxOTVKF8AntSoiKl /dEg== 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=AcBT1BuZd+huxmrMmYlarTtATljo7EzS/i5lwQGGXKg=; b=Y6mZfo29tdeN3Dbd2u1Ksg0RU+uP+dOaFXbKY+Epc+s1r8mouxaG450TruEaSveL64 78TICMYrdTKUmJCDPn1bqN+4vRoBXIPxxK7PwDQY3j+SZHzk8Qx1v3bp3QoDQJFLEad3 btMY+Bb8fY2/jwa21SWj5GGNx0YKz/2obklu9keOAuOHGPWNnj7HBAFL1naGO9fLs4w0 9v/IBreUP9p8MjTHiVUODzYt4GbRn2qQHRMoyB3XQkzvIIgHMEleh/gOJ8zCcE/u18oi AMMyWzrmxN9CC4OoB1pXPMywY87cuh5gTFcLBf6fkFDjHCz/0qYduLggI1mqkNUkkkIG kHiw== 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 jw20-20020a170903279400b001a63bb1497dsi12774264plb.376.2023.04.24.23.33.03; Mon, 24 Apr 2023 23:33:16 -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 S233381AbjDYGQp (ORCPT + 99 others); Tue, 25 Apr 2023 02:16:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232430AbjDYGQo (ORCPT ); Tue, 25 Apr 2023 02:16:44 -0400 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D13EC9001; Mon, 24 Apr 2023 23:16:39 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Q5BbR1PBdz4f3l8b; Tue, 25 Apr 2023 14:16:35 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP4 (Coremail) with SMTP id gCh0CgBXwLNCcEdk4b9tIA--.42722S3; Tue, 25 Apr 2023 14:16:36 +0800 (CST) Subject: Re: [PATCH -next 1/8] md/raid10: prevent soft lockup while flush writes To: Song Liu , Yu Kuai Cc: neilb@suse.de, akpm@osdl.org, linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, "yukuai (C)" References: <20230420112946.2869956-1-yukuai1@huaweicloud.com> <20230420112946.2869956-2-yukuai1@huaweicloud.com> From: Yu Kuai Message-ID: Date: Tue, 25 Apr 2023 14:16:34 +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: gCh0CgBXwLNCcEdk4b9tIA--.42722S3 X-Coremail-Antispam: 1UD129KBjvJXoW7WF1DJw1kXr4kWFyruFyDWrg_yoW5JrWkp3 yqgayav3WUC3srAwsFyF18KFyrta98trW7urWkAw17XFW3WF9rKa4DJrWjgryDZryfurW7 AFyvkrZ7Ww1rtaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkC14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvEwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lc7I2V7IY0VAS07AlzVAY IcxG8wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14 v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkG c2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6rW3Jr0E3s1lIxAIcVC2z280aVAFwI0_Jr0_ Gr1lIxAIcVC2z280aVCY1x0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjfUoOJ5UU UUU X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-2.7 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/04/25 8:23, Song Liu 写道: > On Thu, Apr 20, 2023 at 4:31 AM Yu Kuai wrote: >> >> From: Yu Kuai >> >> Currently, there is no limit for raid1/raid10 plugged bio. While flushing >> writes, raid1 has cond_resched() while raid10 doesn't, and too many >> writes can cause soft lockup. >> >> Follow up soft lockup can be triggered easily with writeback test for >> raid10 with ramdisks: >> >> watchdog: BUG: soft lockup - CPU#10 stuck for 27s! [md0_raid10:1293] >> Call Trace: >> >> call_rcu+0x16/0x20 >> put_object+0x41/0x80 >> __delete_object+0x50/0x90 >> delete_object_full+0x2b/0x40 >> kmemleak_free+0x46/0xa0 >> slab_free_freelist_hook.constprop.0+0xed/0x1a0 >> kmem_cache_free+0xfd/0x300 >> mempool_free_slab+0x1f/0x30 >> mempool_free+0x3a/0x100 >> bio_free+0x59/0x80 >> bio_put+0xcf/0x2c0 >> free_r10bio+0xbf/0xf0 >> raid_end_bio_io+0x78/0xb0 >> one_write_done+0x8a/0xa0 >> raid10_end_write_request+0x1b4/0x430 >> bio_endio+0x175/0x320 >> brd_submit_bio+0x3b9/0x9b7 [brd] >> __submit_bio+0x69/0xe0 >> submit_bio_noacct_nocheck+0x1e6/0x5a0 >> submit_bio_noacct+0x38c/0x7e0 >> flush_pending_writes+0xf0/0x240 >> raid10d+0xac/0x1ed0 > > Is it possible to trigger this with a mdadm test? > The test I mentioned in patch 8 can trigger this problem reliablity, so I this add a new test can achieve this. Thanks, Kuai > Thanks, > Song > >> >> This patch fix the problem by adding cond_resched() to raid10 like what >> raid1 did. >> >> Note that unlimited plugged bio still need to be optimized because in >> the case of writeback lots of dirty pages, this will take lots of memory >> and io latecy is quite bad. >> >> Signed-off-by: Yu Kuai >> --- >> drivers/md/raid10.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c >> index 6590aa49598c..a116b7c9d9f3 100644 >> --- a/drivers/md/raid10.c >> +++ b/drivers/md/raid10.c >> @@ -921,6 +921,7 @@ static void flush_pending_writes(struct r10conf *conf) >> else >> submit_bio_noacct(bio); >> bio = next; >> + cond_resched(); >> } >> blk_finish_plug(&plug); >> } else >> @@ -1140,6 +1141,7 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule) >> else >> submit_bio_noacct(bio); >> bio = next; >> + cond_resched(); >> } >> kfree(plug); >> } >> -- >> 2.39.2 >> > . >