From nobody Sun May 19 04:55:55 2024 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 F0456140367; Tue, 23 Apr 2024 19:22:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713900145; cv=none; b=T5rdMI6Q3CkiPSLvOmZpDW+MMtb/S1/dkLsQeg8TFaWCqu3313ool174kd3aGlMUCk/WGLo8JSKtZ5KZQpk6iH+qQWa9Os7v0zJY9J/ZeltgSsJYSA9sfHPiqb3mdrZlIXLinGUYRmT2kglLQrdvJA4Nqr8Bf9xnvBoYGyCnFHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713900145; c=relaxed/simple; bh=TXpKuuBZAw7XLuMVlMCZHKeGjYVk37z7qTLtUWCrQ6w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R6KH91MqHduNf+NfUVCGDLciUSe39O5zvD0INdHrPPaq6pVFHAvQ6MSwOQ95C4QYTgZUe7KG9Jd2P3pJ33ap/t0j5NOP8Z7PY9LRjOSjezE6nAASjN0K7L14aWtL+bWLr1UuwVx5EcPhX9jtaDeuniIrEdWhmnS/ShDGFShTncs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=vxiLZCma; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="vxiLZCma" 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Luis Chamberlain Content-Type: text/plain; charset="utf-8" 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 =20 #define __acquires(x) #define __releases(x) --=20 2.43.0 From nobody Sun May 19 04:55:55 2024 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 F2958140368; Tue, 23 Apr 2024 19:22:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713900146; cv=none; b=PgJASjqC4NSbpFZ2fGI+s6iSGXn/2kQpKSGzl6Y1ogJVJIjq2nF/w1AI4OI64QcV3dyjGVYfA5jQhp2jUbERIS2IPtOkd74BrSOOn0bOc5zKcSipOG9xDEQMMZQr1SpKV9f8ThlNApSdjJ6bZv/UPaWquA6x58uuPqhAU0BgIn8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713900146; c=relaxed/simple; bh=AifPCum3Y5cpyN0GlKVylAcfCgrw/OwmF5XdgLkmvEg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pm8siU2Qh/kpTDePXZKTEZlM0Uhf3UdHzN0/hXr16jiTruIb4O6/7t+b8MxOdO/gsKdJGO9UEF+WAGc8KfpoECLu6CgD9Q8PynXxq7YUzdGnKS+HsgLFVUJrtVLs4b4JrbhL29to8DKGCVuZMB6252pGJmZCmwSsHQcG8JlkcZU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=p+WQ0DGV; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="p+WQ0DGV" 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Luis Chamberlain Content-Type: text/plain; charset="utf-8" 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: Asser= tion `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) !=3D 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(str= uct xarray *xa, =20 do { xas_lock_irq(&xas); - xas_store(&xas, p); - XA_BUG_ON(xa, xas_error(&xas)); - XA_BUG_ON(xa, xa_load(xa, index) !=3D 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) !=3D -ENOMEM); } while (xas_nomem(&xas, GFP_KERNEL)); =20 XA_BUG_ON(xa, xas_error(&xas)); + XA_BUG_ON(xa, xa_load(xa, index) !=3D p); } =20 /* mimics page_cache_delete() */ --=20 2.43.0