From patchwork Fri Feb 16 19:43:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13560508 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFD39C48260 for ; Fri, 16 Feb 2024 19:43:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3AED36B00AD; Fri, 16 Feb 2024 14:43:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 336476B00AE; Fri, 16 Feb 2024 14:43:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FDE66B00AF; Fri, 16 Feb 2024 14:43:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 101B06B00AD for ; Fri, 16 Feb 2024 14:43:37 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9C6EAA024D for ; Fri, 16 Feb 2024 19:43:36 +0000 (UTC) X-FDA: 81798691632.21.800A0DD Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf15.hostedemail.com (Postfix) with ESMTP id D01E2A000F for ; Fri, 16 Feb 2024 19:43:32 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=owRcMhkv; spf=none (imf15.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708112614; a=rsa-sha256; cv=none; b=Uzo+g9Y49tIasbe16iYwbSEH23JkByv6OP6mPJtEPCReDpG+2B052cn3bfzxbkjW1X/3Cq Ft/BDMwFOXxGnHhmypVdcZu7SiaWfDQDSYrRs9O0J9Tll1ZgzmvlRTWPAo83+Tx+O1yStd 5IfwdFtUS2q6LgX6Hp6GjMk04HmuQac= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=owRcMhkv; spf=none (imf15.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708112614; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=JIBYKrHmraGn0Qv35tDBtlGinkhRJwFyg9FJtFLUQ5w=; b=Uj152cxL3n8vwhhvKNuqlyDMDJIm6tfGHdZxFHoXwbG+mR+mndcpx+0+3pyH5ySJBSwTpD 3f1VXU3XRv7kYvisK91muThlXeKm39RwbOQxEKJlkYQUbpzl9X7Fc+7Wx1FpxCusFTjTFc cVxIYsf5xj81NVJjr9l2ShKm3KwOAas= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=JIBYKrHmraGn0Qv35tDBtlGinkhRJwFyg9FJtFLUQ5w=; b=owRcMhkvsO9GVbii6oW8q+GWe1 dwoWp3Fgl1UHLXCCxepniozgLA+wTKFO0nEyuy16XKn5SNR5vbimxmlk6GTIn8ow92LNuxTcN6rTm ZNto7Uzzu+qKz4kQ5crgnuG8SPOVFSeOnv7bs3eu5l/yObnDR+SAMdGRdAZPZDHkQrQpxLfl0fA8k vlaO+FaU3OnZl1XW7Gz+85hrCErHErBoE9w741qyc5H19aaJlJgYQv3rL0TfSe5Eugrx3PnR5ZVuN 8D0nEvSQ9RnaKuWS74WIjzem8ayqdFwbbGoDtOnI6nQHyHE6jxzP6bWCBKjWfsa4hxv/hvXasCuHp 4B24ayMw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rb47O-00000003WfT-2ZJh; Fri, 16 Feb 2024 19:43:30 +0000 From: Luis Chamberlain To: akpm@linux-foundation.org, willy@infradead.org Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, gost.dev@samsung.com, p.raghav@samsung.com, da.gomez@samsung.com, mcgrof@kernel.org, kernel test robot Subject: [PATCH] test_xarray: fix soft lockup for advanced-api tests Date: Fri, 16 Feb 2024 11:43:29 -0800 Message-ID: <20240216194329.840555-1-mcgrof@kernel.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: D01E2A000F X-Stat-Signature: misbjh4x4yymkxb93myzd11cpx4ooywg X-Rspam-User: X-HE-Tag: 1708112612-287888 X-HE-Meta: U2FsdGVkX1+zouTJgzBpAs+zPmGtYNA8bWb1kQ4XpKpSCFIj0w8sZ+5dYVR5/7W67E2c77TRFfCj7ytO7oOxn65zrh7EhmHGHszO1f2K5YSOjmIsLJJRiPeLIMM58O/fOmS8QqdesayvFxmJZIQQ74rROX5Cjz6oboAVg/oTu3QvOfYe2bNOTNASjeifIboaatA8m+ktR2xCSnE8PMm90FoYfPC9S+MqOeyNeWizKYAhjKTwmgKYDL7/2crSQL4pbv1RlEh1zfZooRfRznJdbXNzGeUGbf7gwRE4P2LAPvHO7Qdut49VUfMzZN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mWuig2qRXK5cEXXYZIlv+QaXfXOOFgUfDduVm2q0N1pr8DxvWyMQRlqfvgJ4YQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The new adanced API tests want to vet the xarray API is doing what it promises by manually iterating over a set of possible indexes on its own, and using a query operation which holds the RCU lock and then releases it. So it is not using the helper loop options which xarray provides on purpose. Any loop which iterates over 1 million entries (which is possible with order 20, so emulating say a 4 GiB block size) to just to rcu lock and unlock will eventually end up triggering a soft lockup on systems which don't preempt, and have lock provin and RCU prooving enabled. xarray users already use XA_CHECK_SCHED for loops which may take a long time, in our case we don't want to RCU unlock and lock as the caller does that already, but rather just force a schedule every XA_CHECK_SCHED iterations since the test is trying to not trust and rather test that xarray is doing the right thing. [0] https://lkml.kernel.org/r/202402071613.70f28243-lkp@intel.com Reported-by: kernel test robot Signed-off-by: Luis Chamberlain Reported-by: kernel test robot --- lib/test_xarray.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/test_xarray.c b/lib/test_xarray.c index d4e55b4867dc..ac162025cc59 100644 --- a/lib/test_xarray.c +++ b/lib/test_xarray.c @@ -781,6 +781,7 @@ static noinline void *test_get_entry(struct xarray *xa, unsigned long index) { XA_STATE(xas, xa, index); void *p; + static unsigned int i = 0; rcu_read_lock(); repeat: @@ -790,6 +791,17 @@ static noinline void *test_get_entry(struct xarray *xa, unsigned long index) goto repeat; rcu_read_unlock(); + /* + * This is not part of the page cache, this selftest is pretty + * aggressive and does not want to trust the xarray API but rather + * test it, and for order 20 (4 GiB block size) we can loop over + * over a million entries which can cause a soft lockup. Page cache + * APIs won't be stupid, proper page cache APIs loop over the proper + * order so when using a larger order we skip shared entries. + */ + if (++i % XA_CHECK_SCHED == 0) + schedule(); + return p; }