From patchwork Tue Apr 23 19:22:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13640579 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 71859C18E72 for ; Tue, 23 Apr 2024 19:22:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1DD426B0173; Tue, 23 Apr 2024 15:22:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 18DB66B0174; Tue, 23 Apr 2024 15:22:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ED28C6B0176; Tue, 23 Apr 2024 15:22:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C07BA6B0173 for ; Tue, 23 Apr 2024 15:22:27 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 4D71FA09EE for ; Tue, 23 Apr 2024 19:22:27 +0000 (UTC) X-FDA: 82041767934.19.B2917F8 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf03.hostedemail.com (Postfix) with ESMTP id D630C20006 for ; Tue, 23 Apr 2024 19:22:25 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=vxiLZCma; spf=none (imf03.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=1713900145; 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=4AXHJdmSYJnEI0IP6FH8bmSpXiYxRSvQ1Evd/zp1EnA=; b=DF9Pkn4vLKoPwdDNfwWCovwuiORNNkJhX+d88e1FGipdKXkKKsDJDSrBPL+91FLh69i5xi MVjHcxEMi882L8wiKEPLbI3psGpwn79nhnbjR9zhxkBwyPw6500KLNyD4M0OcPtzefIquf e+lXgHYK9l0NPUh17OlBgRNvuVTsTt0= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=vxiLZCma; spf=none (imf03.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=1713900145; a=rsa-sha256; cv=none; b=shuquq/HxidE/BWilCACWw1mAre7ppGTGkeihas+KZYXu2qgnxbTRC1wZUm8X1xm77NiNg NcMeBx2myymas9bFOmFOTUQU6GxphmkmCNZV+3Z3SBgeUhackQo2rMHDMUr7HLuJC8g8Bn g0lK9v334kyjZNQyg700Ym8HG4+vgbU= 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=4AXHJdmSYJnEI0IP6FH8bmSpXiYxRSvQ1Evd/zp1EnA=; b=vxiLZCmaDDlR7+8fenhQsKOVeS /+y9kr2bwsOY/lXfCe+0MXzsZAhtLqxIEenPWKkOg6+83wzWyeBbfvBb4c7oENEXy9VX0T5a4MjrI EwP6RrJNgnnQPZsJgYNxBo8bJlOA7htBxgfCpF6/FihJOcJBoMlk+54kFeSt0SnZM0T3SvAfiv6de WvoluQF7Chl67Ui4zCnKqE32+t1peZjhnPSbKhXnE+CkLUGj9+VjnAO276PWYEI9EJRopvA8Ao6Ks MjQHqKJzl2/8qwABHC2uysuNYc9lGuFisBE5sJgcFUvqQYhWSSB6Nt0drk0pD+/Kb67G9rkqzFC4m 2nU6eK7g==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzLig-00000001GKm-2wcw; Tue, 23 Apr 2024 19:22:22 +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 v2 1/2] tools: fix userspace compilation with new test_xarray changes Date: Tue, 23 Apr 2024 12:22:20 -0700 Message-ID: <20240423192221.301095-2-mcgrof@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423192221.301095-1-mcgrof@kernel.org> References: <20240423192221.301095-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: D630C20006 X-Stat-Signature: 9hxfqbrw1q6793be9hoeymz3yhuu1m9g X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1713900145-534104 X-HE-Meta: U2FsdGVkX19ycsmorVZO91RYvcFlw4zWIr+RzC5/KJg+TE67rlunby3SPYFQwHz5fbMVUii1/B4ApGtj8EAGsqPgab8GPNCPX7jJyWLavDbYHYuE1bQlOSQajUb0rIp8Sq+LpeGeezL3YdK6sUlR0gb9MvuadjNRnJwXoi5vfhi8qXCMB+87NmVP5I/4mirviftq4UVd3UHCzHTVpdg5B89I5UPlwNarzbxY5KxCOje5yfkz0jMfpDIVO5uYHeo7SmSuAsGjARtce7mxhwkg2KhMyzQMjXowVsr1gEJY3TwFg68YKcrHG/Ffr2Aaf5zlbPeGuaUezchhpXmumvAVZuaZgH6Isv8zM2/OiYpVqLQiU2QMA7xrNYsXJ1d+xPaHzErsHRRUR6ezmmVXJZdK5WhqtWZ9KZm5twcnPI1l1r0BI4dZ/aKPb1GEpU164NL/GY43hhx68A9/8zFt5oot8nt6eVw9RYigoJLvpixcRFZgCEjXRLq1DdpY21P/zpUrzo7XaALBqSoEmu5L6jYZ0LdKWcenj5A+1FVppLRTzvlGPlv67bMbWC0s5dgX7x+zuBJ9893NtQB87lbdjNGlxe5+v4UmYfVWKJAGMXnz3g9JoPINfENhKDQCVPChS93Knj/CNxWgoXcwanTNss50wDS+f2FfRMUr6RaCYkWcD3sz1awdzSJK/Cr8k6KSunR0g4XmqtCo54iBikoTjZt5C1cLRGF4A5rDzT+kFwqACQZUjcnojgKAx3zuw4+lv7G2hVw6wemuRjqsZefukGscwuFRwHVwsP53jg9SlqZb6lRQhuHV+e8NOqvhIdgSFgABZLuk9uqpjeTMIaf7XKQAYu2G3EiM39PprGSAFXfoB7YJpk84IMJq6Zg56x0qlO2zvmYptbT6iSBgoi+r5jTy5MAmDS7YIZ0OJfKZmTjnNG3GW5hl+04p8ney7coX7FWiL53yOwjblyYXZLnKZ4D kYSgXOwG GzlIG6MgV464ZZUqyZNpQnfvynN8qlQ5k6gtmAT9vVur8swhhK0SJK+9ClEsT5/pm0EttyrJ4hIPs1kPSQj1CFdAnzBDKAO9byXtFmeGAgWj81qfzuHSsFMB9jYOQDG2x0nmgAg8lL51JQ73to3j8mP5OePsDB44ILwFN 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" Fixes: a60cc288a1a2 ("test_xarray: add tests for advanced multi-index use") Signed-off-by: Luis Chamberlain --- 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 19:22:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13640578 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 628F1C4345F for ; Tue, 23 Apr 2024 19:22:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C8B0E6B0171; Tue, 23 Apr 2024 15:22:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C45EB6B0175; Tue, 23 Apr 2024 15:22:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ADB476B0174; Tue, 23 Apr 2024 15:22:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 91DAB6B0171 for ; Tue, 23 Apr 2024 15:22:27 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 56D1A1C0BAA for ; Tue, 23 Apr 2024 19:22:27 +0000 (UTC) X-FDA: 82041767934.15.77AA219 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf11.hostedemail.com (Postfix) with ESMTP id 59E8440015 for ; Tue, 23 Apr 2024 19:22:25 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=p+WQ0DGV; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=none (imf11.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=1713900145; 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=QH8+VVHeKCvyXF+XfpPQcB3hgAUVEIgYamedVnOHyoQ=; b=h+13VdsvtJmv0wNjangM44xfxIrDHiQB7UIDdAGU+CIwUv6C9Jos5HrrOQiSCyfKRgClHH id/wvT6JgTpXrVLS8yCGzY8z3kNLlTx1UaBqjfDbSt9jIgl/eEIN63NSWYbhqjtsjhXcV9 iBVc5dG4Zkt7k3JZf4JN2ZkzAf2pB+g= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=p+WQ0DGV; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=none (imf11.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=1713900145; a=rsa-sha256; cv=none; b=fX4OoAa5n+y8fdJNamAG3iHxdVWUm+sk8hxYHZdi9mqgOxNI1YpYHNfV9/sZIrwt9/MU/a 663h3vru0pknNU6+WrS5HwJZY+7hUpTpW+e2Yv9R37rzfhNaRDT4zJpybCZiFyWGuKNOS7 zm5mP1rvShbmop6SNFCTgK/n0jH8Y08= 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=QH8+VVHeKCvyXF+XfpPQcB3hgAUVEIgYamedVnOHyoQ=; b=p+WQ0DGVtlrOAjESqjZUK58O8k nisgxZqza7lnpwKkHu/cm5nXgHvuDPDUh+ETV2yigLg30aS1kNAP/2njfMQUTDyClS/xUJ4u0PfnI AtDL6m9exbragWOT0L9tZ5cJd/CSP9tu9X9S85K9dDMYFwkAlfkZry2fx3pvV/xnqMjBgMSRECaGo arQv8U4+baya92uW5jw1z9dDgR47wh3gSS3UWBpOgWsX3gtqQpqbvQfqKiC3V3NWlPdDvcDvYVqmi V1C1vE6m5kmnyO5PKjON0tvVNztPaXjYUo6ZyOq3lBuo1iM9DQGHi3/spFwK2piLYT76AzMlnqzkI 8BjjovSw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzLig-00000001GKt-3E51; Tue, 23 Apr 2024 19:22:22 +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 v2 2/2] lib/test_xarray.c: fix error assumptions on check_xa_multi_store_adv_add() Date: Tue, 23 Apr 2024 12:22:21 -0700 Message-ID: <20240423192221.301095-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423192221.301095-1-mcgrof@kernel.org> References: <20240423192221.301095-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 59E8440015 X-Stat-Signature: o6bhqwojui8jdq31h3rn6g1s1cz48oga X-HE-Tag: 1713900145-342953 X-HE-Meta: U2FsdGVkX1+umOJq8Vw3nmbpFFLU3u1Fi03xb1lSO84fp7KvH4I4wYToEQ9oSbkQFaJiiVsUulzzogd2vnyeuaAUG3/6UFIVjrtJcD5Vu7+9vvUnAPqwKumIPuKC3c6ma4UpaFlFvQcGkk+SuhnIvJDfBdGNIC3UpPrNkVIOMT0igIcz0pXi85jcrWWBbR+jM5ZVElDflgQu1F0lLWLszFhWAHz0W/KbVzI0zJAMHg1AeIy/pffHsu4+Jh74OMmtC6uN83UREPL3kA2SVckdgVlhJ/aJEB8CB3fzvwf4XfglbNLRxnfPQDeoI9qaNTGxh/rAiEw9/DKmr4/fmwYzLM61wFNJAvE8A+RGvLoaatGbxj10MtJi4VmdVsEB+qApQRAsoJ+G+X9fP/VEQ7ULjXzsUtnWsMji2DUgkdMEb4G+N8GO+v6tXGMLP4EA0QnOHhYF1MGks3ZaYbZqO4iwQ4FtRoMvmYQgwbnvNTajDWUce6FVjklSFZmTNZdCa+yNmOeAF8snMp+hoa74zlFnUprJVfAanWUyvT7GKLYvkoRzmT4Ekoz4uJuQI4c+ckMMJLgvnIP0c5aQ9ixvHRT7JD9WOBEtfv85aa/ESmoRdudzgRNj1p8DqVvkJklVWcVMGHtNPhOv/e9hsx2thKBRRz5zOJMkhyltbYU5bh3QJ/7vJ28gUWVYJcPW1niFG4LkSeLbaEaJQzJjYNJgasTfLg8bcygLkhrRVqveS9JDjGSK9JxPtBXv73iB6CEmUMMJeOhF+fp/RDpITz8IzrtTw4eNNvxsEFo3ldiogkhxlfc+5SL9cas8oG/KSYQh4OAx6JO0b7t0rZdvagSru8Fp/2DHCnwvV8kI8hlEvlxHP5MYmeuilKa1Fplg04L8yTAjSe5TTBkiTvHdGGtLLse0skqmT3xS424tCUAojjbCRoXSwmJtnf0OS1OU8u06O1W03awZkR04FsmI79iuv9u lXovga9V cPO/GI3TsVIE7irDDwyWY5gc1PEtNUXAy3msBJ59qKu0dQd/wrGrZu42mUunYJ5nuMwkQstSbC34d6u920Ai5eVdPhO6PrSNwVB/v4XZ2AIVWRd3sYrkomgPVhoFclBOy8NnLwRqoqN22tIvtH+m8Ri5RUkJahyYkA9Ya 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 Fixes: a60cc288a1a2 ("test_xarray: add tests for advanced multi-index use") Signed-off-by: Luis Chamberlain --- 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() */