From patchwork Tue Apr 23 18:05:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13640524 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 A1A07C04FFE for ; Tue, 23 Apr 2024 18:05:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 357246B015E; Tue, 23 Apr 2024 14:05:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B8DF6B015F; Tue, 23 Apr 2024 14:05:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17F7F6B0160; Tue, 23 Apr 2024 14:05:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id EF2A76B015E for ; Tue, 23 Apr 2024 14:05:22 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A54B180C51 for ; Tue, 23 Apr 2024 18:05:22 +0000 (UTC) X-FDA: 82041573684.10.5202959 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf07.hostedemail.com (Postfix) with ESMTP id 86E4F4002A for ; Tue, 23 Apr 2024 18:05:19 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=m4+wTHPB; spf=none (imf07.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=1713895520; 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:in-reply-to:references:references:dkim-signature; bh=GImDTwHR7dxIEVcWRknSk262EH01U7E8MroXbU85sZU=; b=MwjgExDdlFAa7veXmHrNo1VasjLydl+uLFdh/XJ9GPCtlw8xIPTJWeJto1ZnrbgdKFOn/K xArSRVa/2oaJNUbbf+6qIRIExWWsXv88zhElgpfMd38EpFuAbe4ZQem1+kuPGYgYoVqsoB rej9MhcSqigvwRyKG9+rhlnE4xSDmac= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713895520; a=rsa-sha256; cv=none; b=BrCYMLRplvpKnVrjHGOzmfLrPz0B3UTjDwoiIjMdKZdPku3xqlILNmFJ+lW0PzkeBRwNsC ETm6JHj7e4cAEzNTzfEyUKpnqVpqDOrHxwxOy4ObKtygk26O3ZQkKFazo6dphXp4crWgqI 1aUtC83tc8xJTuVSF2+R2i5Qtkif9ik= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=m4+wTHPB; spf=none (imf07.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) 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:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=GImDTwHR7dxIEVcWRknSk262EH01U7E8MroXbU85sZU=; b=m4+wTHPBl7ke3GLR8Q2b1LHcAX JVT7yZ1fWERESM53VFS7Y09mCvRfxhECgGDOhMXy0F9AN7DlmZxr4B4fJBp+5rSMtpnylKk6BbvvH sSeESgQtqFvtlxvaZcuIwiEA3bf56LUGnuxpRlF3f4SovqpomZI9qLcbhmLQBS8Me8YJgBFFXP0nH Kfjwc7uH4DCOv5rQ/cVe5sgIJ7si8n9VBj6UzIOlYz7mQX9HJ3wreugOvBnlKjDQ4j15P7d9ZMVcf QjnPJ6jVmMWZkwTh1yF695V5XfejVFnbeztFMkFoKYp4yP0hWoADmjnlUjLBqcHn2hhMKhfl0d+VY RZYQtzlA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzKW5-000000014oa-2H9e; Tue, 23 Apr 2024 18:05:17 +0000 From: Luis Chamberlain To: akpm@linux-foundation.org, willy@infradead.org, Liam.Howlett@oracle.com Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, djwong@kernel.org, david@fromorbit.com, gost.dev@samsung.com, p.raghav@samsung.com, da.gomez@samsung.com, mcgrof@kernel.org Subject: [PATCH 1/2] tools: fix userspace compilation with new test_xarray changes Date: Tue, 23 Apr 2024 11:05:15 -0700 Message-ID: <20240423180517.256812-2-mcgrof@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423180517.256812-1-mcgrof@kernel.org> References: <20240423180517.256812-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 86E4F4002A X-Rspam-User: X-Stat-Signature: ft4cr7z8a8ye3bmyguk69dxmw9fhd1wa X-HE-Tag: 1713895519-201818 X-HE-Meta: U2FsdGVkX1+Aq8zlsu34nTlTyBemajrA61kk4j7FiELfa8g7oePObFolIG8ABPJyULdBl32meajaZN48YXpNI4PE7m8EqapkrdvlL8+viVtHbQYc+Rz8Kso8J5qJHJE2YNgJ0SL/6mPQJl32UJia2eZpWjQDYJDUEQWzOn2s+QDNb5NNUMUtTVm3+b0Y85IVENs4Iraz48UaOqkgZjonEMSv3Ovb134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mSAQNAWfPZeoe5amLyUvE7ceh+LMENT2aCGKt3xLM5E7uw9YzGM/F8bLCrGQN2FiRrMTmjHAj9BkWO3UYYazPJnVtR08L0h381vPfeP7I+m84jM70n4M7It5e3qDluQulZr1Y+g9qBD/uVHfnF7bjT7Ygw== 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: Liam reported that compiling the test_xarray on userspace was broken. I was not even aware that was possible but you can via and you can run these tests in userspace with: make -C tools/testing/radix-tree ./tools/testing/radix-tree/xarray Add the two helpers we need to fix compilation. We don't need a userspace schedule() so just make it do nothing. Reported-by: "Liam R. Howlett" Signed-off-by: Luis Chamberlain Tested-by: Liam R. Howlett --- tools/testing/radix-tree/linux/kernel.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/radix-tree/linux/kernel.h b/tools/testing/radix-tree/linux/kernel.h index c5c9d05f29da..c0a2bb785b92 100644 --- a/tools/testing/radix-tree/linux/kernel.h +++ b/tools/testing/radix-tree/linux/kernel.h @@ -18,6 +18,8 @@ #define pr_info printk #define pr_debug printk #define pr_cont printk +#define schedule() +#define PAGE_SHIFT 12 #define __acquires(x) #define __releases(x) From patchwork Tue Apr 23 18:05:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13640525 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 37B4EC4345F for ; Tue, 23 Apr 2024 18:05:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 85F466B015F; Tue, 23 Apr 2024 14:05:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8101B6B0160; Tue, 23 Apr 2024 14:05:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D6BD6B0161; Tue, 23 Apr 2024 14:05:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 434B06B0160 for ; Tue, 23 Apr 2024 14:05:23 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id F189D4088A for ; Tue, 23 Apr 2024 18:05:22 +0000 (UTC) X-FDA: 82041573684.17.BABA859 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf12.hostedemail.com (Postfix) with ESMTP id 7AB7C4000F for ; Tue, 23 Apr 2024 18:05:21 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=qOzyjcNR; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=none (imf12.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713895521; 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:in-reply-to:references:references:dkim-signature; bh=ucWCcqpK+RgxRkCoiBrn6yK6YGAtyibZy8sxqOnryEM=; b=EHRG6fhzhwufSekHzPwanb0G5C//RYa72cgHeOIKhpiyNf0yet6OqXgO/RP0dSeh+oigar ZhxRl4pgG+cWFOf1HaHEW7FEZOx/VXQDgsAnCYrjRwF2W2X32fqFoSTk690QWJg+1rRt61 bA6DxPbuveEP8trLg2fF9WOHTdAjsCk= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=qOzyjcNR; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=none (imf12.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713895521; a=rsa-sha256; cv=none; b=2J+chlTzwxBsJ3G6GWj9Wt0RzF9gjsnNQt8osLegknvzkmzn3fDcXnrib0o11IfZupSImY eIgNkbks0oOpVio6zAeVbPdx/N/rU1ucQbhcFUeLvOOIJvmiehmYaRj7wQK9Pmbu+a8xyB /wbVu+VTUBQ+bW9liD4isk1vYFGtcQY= 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:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=ucWCcqpK+RgxRkCoiBrn6yK6YGAtyibZy8sxqOnryEM=; b=qOzyjcNRdSbxBDuZsbyVrfEg6C hz4XiG/TqH/YQrqkTW+XVNZOm3RAdD2IHy+TkB73mS4ryfWsUEc3AMbKuap4Mhvk8pemd8Z2pdCYC fPQjbCsUO2woGCj5zNZzEqelEXcBV644WZ5FVRslbTCHknlhPln2EB0s9+itnNSo8LAzWUv842VYn mBy3Yx6OQWjiAasKbIH3rseys+VjISPqNkZs4M6wkMdWDX09ifLMI9DmgSYvdksNEjLw1749B8PhT 2bOrSpivC4PVkNUgYQWEtub8W+5itQGQdvT30QWfQU4AQ6TTluNSnhr1n4BbAbLvkaUQ2bnU4KNWB 7/8pkewg==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzKW5-000000014oc-2SlA; Tue, 23 Apr 2024 18:05:17 +0000 From: Luis Chamberlain To: akpm@linux-foundation.org, willy@infradead.org, Liam.Howlett@oracle.com Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, djwong@kernel.org, david@fromorbit.com, gost.dev@samsung.com, p.raghav@samsung.com, da.gomez@samsung.com, mcgrof@kernel.org Subject: [PATCH 2/2] lib/test_xarray.c: fix error assumptions on check_xa_multi_store_adv_add() Date: Tue, 23 Apr 2024 11:05:16 -0700 Message-ID: <20240423180517.256812-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423180517.256812-1-mcgrof@kernel.org> References: <20240423180517.256812-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 7AB7C4000F X-Rspam-User: X-Stat-Signature: ymjug5h6qgeyg6z1as8b1z316o18w4cs X-HE-Tag: 1713895521-266484 X-HE-Meta: U2FsdGVkX19TSMSLHASMGgiDODRv1cchG0P/dvWxv7UnJ6tPN364gt9Scicqq9dLEE1Shna2NGdswOzGKu1GM6tERdkU2K4YNA/wHKSckyXRo79ZCLLRVJD7Nk8yPkMkdMG+pLZueridXUY8NzPHqAFb7Ne6iJusIFHXazi6DkT9D1Tj6nGCY7+gO0Wlm0tOCEji0aGHfPqU3sTxzcFKVLAsigjcet8FWrgI9hbgPPCqNCWb+ZlgRw5t9RUNphBuwGHtQ+vQJtK3q5DhB276gw/h2zQYRWaVE/uvbbda9iehI6wRgqe5voWbiK0RyfUvFQXIk+QABZL3Fclh3DjVzMGLtVDmAWcBuWVS35tf/bgJwwyu0FLC6KzlQ92l7K1E1P8siv+WdP3gzyPuoioIzK21rY2bRd5QyvFFcIjR9408OydNxwVy2BhajaV+TBONLnguaUtVZQgn70OX1HFTAeLP5kwy8rM8syfHew+mtsLZQZDVUXbaB1OEYV5I6C/ZmG3EKhRwvf081Ei7IN97YIKT5dtTumlCL0zQToyXu3KIUaXhQQSMdVVWhM1Iudn83pq7k8bHcuZZC2fWe3c5PhVz0jKvKypAbQKiqGqcBeCtkAz055leGBX43uK2HgmnRMj2oQskLpXR3kSP4bGN3+LBMkjtb8ACjWdNYlZnGynjS7LjdLNWqBQbGsXCqa6cNCbSxx3c8JJZI2tOmNFyKzs7/V/R+tnvipvc/QyHeBLaGvEWQqh0KnLEY1UZ7rt4ZzVB85iEP2jRnwPn+coDVc4eXbyoqUzlRjQr4NdlrzQfW44gjn2TtCGlveDw6BNMJVVODPudIABLNgl6g/DrFgomlWGvgYFvuz1/cjbca73j66IWVY3W621u4HB/q0FU9roQSFfBoYvSNoLpl1sZbQKxrocmbmqcKQHNW/khjPLnbDenxo1HMc1Ze0MSwioxabFv07OTcjuaEQkztZe 9oVr3cO9 qNIE8ptmOsnVXiGLCSLiSGzB74+WW9pCaigIL1/rq2wcgF16jMyExtYDPaanXFMSR3I1+ujACwOZJhNhgLp2XaVPC6Wi72cK+1ywJ+6g3mRWn0dYV8IeqF5ggrFJwK5S2GPYXcOvykFDZgP9qi3Jok9CtmsPvs+CK9HL3 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: While testing lib/test_xarray in userspace I've noticed we can fail with: make -C tools/testing/radix-tree ./tools/testing/radix-tree/xarray BUG at check_xa_multi_store_adv_add:749 xarray: 0x55905fb21a00x head 0x55905fa1d8e0x flags 0 marks 0 0 0 0: 0x55905fa1d8e0x xarray: ../../../lib/test_xarray.c:749: check_xa_multi_store_adv_add: Assertion `0' failed. Aborted We get a failure with a BUG_ON(), and that is because we actually can fail due to -ENOMEM, the check in xas_nomem() will fix this for us so it makes no sense to expect no failure inside the loop. So modify the check and since this is also useful for instructional purposes clarify the situation. The check for XA_BUG_ON(xa, xa_load(xa, index) != p) is already done at the end of the loop so just remove the bogus on inside the loop. With this we now pass the test in both kernel and userspace: In userspace: ./tools/testing/radix-tree/xarray XArray: 149092856 of 149092856 tests passed In kernel space: XArray: 148257077 of 148257077 tests passed Signed-off-by: Luis Chamberlain Reviewed-by: Liam R. Howlett --- lib/test_xarray.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/test_xarray.c b/lib/test_xarray.c index ebe2af2e072d..5ab35190aae3 100644 --- a/lib/test_xarray.c +++ b/lib/test_xarray.c @@ -744,15 +744,20 @@ static noinline void check_xa_multi_store_adv_add(struct xarray *xa, do { xas_lock_irq(&xas); - xas_store(&xas, p); - XA_BUG_ON(xa, xas_error(&xas)); - XA_BUG_ON(xa, xa_load(xa, index) != p); - xas_unlock_irq(&xas); + /* + * In our selftest case the only failure we can expect is for + * there not to be enough memory as we're not mimicking the + * entire page cache, so verify that's the only error we can run + * into here. The xas_nomem() which follows will ensure to fix + * that condition for us so to chug on on the loop. + */ + XA_BUG_ON(xa, xas_error(&xas) && xas_error(&xas) != -ENOMEM); } while (xas_nomem(&xas, GFP_KERNEL)); XA_BUG_ON(xa, xas_error(&xas)); + XA_BUG_ON(xa, xa_load(xa, index) != p); } /* mimics page_cache_delete() */