Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2511168lqp; Mon, 25 Mar 2024 00:26:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWJ3ru9JN4T7X42aI1ek0S+8+WCF2P4RJe1TlNFUlCyNtuJRhfRjgQaYfuHDMWmmYueJnThz8mGHdWahJ3YcuciZVJZPH85g16ld8/ePg== X-Google-Smtp-Source: AGHT+IFuN/Nv54Df7GO3AZImW/pQbv/rOswwy5HDBp5aF5iK8BHqr9sm62gROFLl8BbaeZXplAqT X-Received: by 2002:a9d:74d7:0:b0:6e4:dcca:aafa with SMTP id a23-20020a9d74d7000000b006e4dccaaafamr7604775otl.12.1711351581930; Mon, 25 Mar 2024 00:26:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711351581; cv=pass; d=google.com; s=arc-20160816; b=XOXI6nHKbNpS/52O1idx38lTHpQSo/06RaRAMs6K00jaqP/N4Gp/OjgzgIG8mZazaa Allq7JdnVo5vApvYixRmXIjGKcA/P8WfwJgtV0nuqrkzgdiU1ycyxaSOLUEzZgcya3dK 27g0sgpM5y2a2RXotW0polmy04sdCzII3coEv9v5lC25Vq9SOswzcSJfQTql/g5GlplY w6u2sv90p2j+9nMepqGrxsHFfiCMJsYt9eoqRRxggWNvG/TdQQuuTNQvACvrgGKxwvvO SBGof/pqqsY/MIUvAXlfnNPmM+TVDxGVKkJl6EKwcq22/mCoIfa/kD079F/kIgs+YFG6 YNfw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=li7rHqgNVUhjfGFknxQ8NArkDjOFDGuJlzvMX5CGYsk=; fh=DY+Ih6PilZxOxuDoX27sFFPpZY9PKpB3HbB7CPkTi+g=; b=kkyKnFYzGI/D69dpBxNv1sCoyKnJTxRiQ1pa9S3Cv6uFCK9lVnvH28lgJPe1JtSaWd Om75Valr7ptHMQrUuhLPSUBGEUPOCPCTBG3lclq3s6+iKG+z8f52WIM2NQbk6U4RHS4C x2R9EP0qNVSmX/ClAl3lOLLn8nHCw6QwuAT1lN04wZ2fHhOa2LegRuWmK/rzuRi/OVRP ZvEQxC779ekFMhHa4YqppmMvXlI1QKn2aUYhZYrBcPcM5D1I8SuDx80XUhrrneub9C02 QFHGtjjT4YW4dnZ6sVirR4APKPoyEI6nSfMwCXqtJXocP7rj7Rl5GDA/C8VznYiWKLTV 8h7Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qCyMtPYs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114487-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114487-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id t18-20020a634612000000b005dbde0102b0si7121709pga.288.2024.03.25.00.26.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 00:26:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-114487-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qCyMtPYs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114487-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114487-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A0640B29410 for ; Mon, 25 Mar 2024 06:11:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AE02417EB8E; Sun, 24 Mar 2024 23:46:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qCyMtPYs" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A971224A3A; Sun, 24 Mar 2024 23:12:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711321933; cv=none; b=dMj2vd8ulXvXjoEnXSOV/qN+R7iYP+pXE3/kMbsojaJ+i0L4FYhYoAZkLhZKf2nyyGteXI026FtEPS7XyB7HCpUvuUl3HO7mn5oCkpBghLcGduJcWTIKd+USWLSZ67MK9x2JnDeefQBt+1R+C/VrLkZPCCPGAkOy+YbK2hY1mTY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711321933; c=relaxed/simple; bh=YDc8E3KzalxDjkSCtlxxcLyzt/KQurU33A4ccpgqgYA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t7Thv+aOyWnCRtklrNtndkZI8f54F4GT0s56KuU6DuuBcXuiVlQeE5GGMoRLbEXO2vn0vHb/X7V14E6IgC2sxPIXSwD4DiCULuh8+dHzNbb4Mu1hLu6Evx+fEIcLOZDZ1pD91E4XK65Vxue34LqrtvwhCQqP2LjN4TVY6QYAPWM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qCyMtPYs; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56A7FC433C7; Sun, 24 Mar 2024 23:12:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711321932; bh=YDc8E3KzalxDjkSCtlxxcLyzt/KQurU33A4ccpgqgYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qCyMtPYs962fV+cmIrPnLbxbXqbR2tIXrcqax9mlIA5KOAnuX0VMdfDRPqEZ+RDTo OtC3qIv7tZ0tX2dy8in2ozYc/jX5lGTtfc2RxM4bodAik4+qkOjduJHm6THLm7x6AJ 9EYatV2utxkicbHQnzUz1g1CiB+HzbYxDveOHlekB9Uaa6BttRA3iOHpzVDpYp2O/c N96txkEnplxV59LQMqZLlIqlcVtQ5MluibDZVkojvZRgmhyg2voG85YoAz7NoC3JuI AMbbsZyWnT5Y2gX+ffGBPBzbiCnNBW5SEkNOPS5OIF7N/f5L592mRxxsbfmoILN1ml MqhrSYizZKkrA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Yu Kuai , Song Liu , Sasha Levin Subject: [PATCH 6.1 002/451] md/raid10: prevent soft lockup while flush writes Date: Sun, 24 Mar 2024 19:04:38 -0400 Message-ID: <20240324231207.1351418-3-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Yu Kuai [ Upstream commit 010444623e7f4da6b4a4dd603a7da7469981e293 ] 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 Fix the problem by adding cond_resched() to raid10 like what raid1 did. Note that unlimited plugged bio still need to be optimized, for example, in the case of lots of dirty pages writeback, this will take lots of memory and io will spend a long time in plug, hence io latency is bad. Signed-off-by: Yu Kuai Signed-off-by: Song Liu Link: https://lore.kernel.org/r/20230529131106.2123367-2-yukuai1@huaweicloud.com Signed-off-by: Sasha Levin --- drivers/md/raid10.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 7b318e7e8d459..009f7ffe4e10c 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -920,6 +920,7 @@ static void flush_pending_writes(struct r10conf *conf) raid1_submit_write(bio); bio = next; + cond_resched(); } blk_finish_plug(&plug); } else @@ -1130,6 +1131,7 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule) raid1_submit_write(bio); bio = next; + cond_resched(); } kfree(plug); } -- 2.43.0