Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1949269rdh; Sat, 28 Oct 2023 14:17:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGD74qygMRuk/t3wPFE0T52I2SLV7b4fg0oro2+otFv8l7IQ1sLRnUP/uszieSaNPwZDmSI X-Received: by 2002:a17:902:d28b:b0:1ca:e491:f525 with SMTP id t11-20020a170902d28b00b001cae491f525mr5950002plc.31.1698527845247; Sat, 28 Oct 2023 14:17:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698527845; cv=none; d=google.com; s=arc-20160816; b=ddYUQfRNG2lOFbuuAf98WfzvX6/u2FhEvXJcsbQex0OBA0g2TPCQIBxRmtpyJoVtpu wuB5bPZZtEbTy6NwVhmHlkZHwsiX7yA9Y7vU6REkYYYWbAMw5jy7Y0EK6DgZCAqxT5Bc 6qeLUlRuBUAIpucziM8rTX/hT8ATvSzBTDmREzQA3VVoPC0mVUn3ChAjYsbB9CQhJnSw jVnNbxe3/7ZpRYJPjToorO2wuaplL8uRBny1XWCgzREuHCdYuxqpMf72PeHNzwKOT0o2 IkUUkHqncNAqCHWJ7dJKC5L96mhHsrXfpkYweGoE3cSd232DtwcPPwQJrM1lt8cslhZA 1C5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:mime-version :content-transfer-encoding:content-language:accept-language :in-reply-to:message-id:date:thread-index:thread-topic:subject:cc:to :from:dkim-signature:dkim-filter; bh=JNoJR/Xq7klfzP9hsOQ2xMnfdiLvLMoR5LEBEoVDOGw=; fh=uxBAUgUSkBYxjd1CTtcj7MO+vdwExfJsOb4I3IkdCcM=; b=AduIJb9Ri1y58xSxFUFv8N0QqhwzVkfTL+Ay0eq/qpqeyRYQuL2FVPVICxgyTi/TfR ZqW9/80kUoF2uMfXPcpVk1B204weLN5Ba8MA20B5NYtTTWwQ8CPrRu74NMGgven5kRJD YPGARTs3S6KfRlrjl9giXd7kPlE1OWQjuXKE5dzDiNz4ZFlqQabrRwqJs09zyIr0ZoSH GLUP/rNrZObs4P8WAiMeILZv/qYcz8RJL6rqTk/cB8wIkdkXwIWok42BrepUlD4vKjuE wStpJSHbO4sFc8ej/tj+52PF1LIJ8F5x9+UoW981KjLxVY6B1rbvcwdnW69Uv1PdlF9g 55og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="Mm7/kBdi"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id r11-20020a170903410b00b001c9fe071f2bsi2876277pld.8.2023.10.28.14.17.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 14:17:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="Mm7/kBdi"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 80457806CC33; Sat, 28 Oct 2023 14:16:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229957AbjJ1VPu (ORCPT + 99 others); Sat, 28 Oct 2023 17:15:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229907AbjJ1VPq (ORCPT ); Sat, 28 Oct 2023 17:15:46 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBBD5ED for ; Sat, 28 Oct 2023 14:15:41 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20231028211540euoutp01ffc7935afe2763072faedbf8699f8479~SYfsIp-6U2292822928euoutp01R for ; Sat, 28 Oct 2023 21:15:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20231028211540euoutp01ffc7935afe2763072faedbf8699f8479~SYfsIp-6U2292822928euoutp01R DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1698527740; bh=JNoJR/Xq7klfzP9hsOQ2xMnfdiLvLMoR5LEBEoVDOGw=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=Mm7/kBdisYvKed+Ygjkzhy9JoYAi4fful3cwN1vo9Q93LupZh5jo6Qx+rmZQKHVPd DyzqzIDTQ4ta+ecdzC7gF4ZhT3ywHxbN9VgChrJTvJA8ynYNXCPcGdwAnG6/90wRR5 OB4t5WBqrOK4IkC+G7LWapdYxKCBFI2bfx6akZgc= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20231028211539eucas1p244eaee8bc62c90f79ee02e581ed59c80~SYfrfIuDH1224812248eucas1p22; Sat, 28 Oct 2023 21:15:39 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id C0.20.11320.BF97D356; Sat, 28 Oct 2023 22:15:39 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20231028211538eucas1p1456b4c759a9fed51a6a77fbf2c946011~SYfqobMTB1181011810eucas1p1C; Sat, 28 Oct 2023 21:15:38 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231028211538eusmtrp241d650d122083e72da8aaaa16e6632fb~SYfqnuS2Q1141411414eusmtrp2Z; Sat, 28 Oct 2023 21:15:38 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-82-653d79fb8a21 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 0C.F0.25043.AF97D356; Sat, 28 Oct 2023 22:15:38 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20231028211538eusmtip1460431297fe820fa6ae8f8fd8d552ed5~SYfqdcDZX0467404674eusmtip1I; Sat, 28 Oct 2023 21:15:38 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 28 Oct 2023 22:15:38 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Sat, 28 Oct 2023 22:15:37 +0100 From: Daniel Gomez To: "minchan@kernel.org" , "senozhatsky@chromium.org" , "axboe@kernel.dk" , "djwong@kernel.org" , "willy@infradead.org" , "hughd@google.com" , "akpm@linux-foundation.org" , "mcgrof@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" , "linux-xfs@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" CC: "gost.dev@samsung.com" , Pankaj Raghav , Daniel Gomez Subject: [RFC PATCH 02/11] test_xarray: add tests for advanced multi-index use Thread-Topic: [RFC PATCH 02/11] test_xarray: add tests for advanced multi-index use Thread-Index: AQHaCePl1pHcrPV2xkWSZMmpwVjy+w== Date: Sat, 28 Oct 2023 21:15:37 +0000 Message-ID: <20231028211518.3424020-3-da.gomez@samsung.com> In-Reply-To: <20231028211518.3424020-1-da.gomez@samsung.com> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [106.110.32.103] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA02SbUxSYRTHe+By75Wi3cTyKTUbWS0sspZ1IzPbWvGl5Zq9zLUZixs5ERlI 7y9mNdMPVlamQKFmmkU5yJQUXMNZovbinNNMJZLMwZqZZC+aFlxrfvudc57z///P9uDMQDtr AZ4sT6eUcrGMh7KR6uc/X60cO76JiqrvDyd1lQaUfNB7GSXbXbPJj19zEdLaHUlarHaEbK/V oWSfYZJF1o6bMbLrykdAln0bwsg6YwlKjv3QoXEckTajDREVmdSix/f4ovaXapHpfjYqMn3N w0RNBWOIaMS0MB5PZMdIKFnyEUq5KvYA+7DW0sBQfF52bDxfmAH0i3JAAA6JtbCpeBDkADYe SNwDsHnEgdKFF8Brv51MuhgBsKJ0AMsBuH/ljWcv3S8HsM5pAf8f9Q89m9poBfDN0OiUVgWA DfZR4HNEieWw3m7CfIMgQsuCDXcu+QdM4gw0DGgQH3OJeNiiuYv6OIjYDRtvtTJoFsCOARfm Y4RYAr3N3f5MHGIjPNdzxtcOIGKgY7TGvwqIMPih4hdGywfDbpeeQV89B5ZoLUya58GJWidK 8wr4stMFaI6CT+7WIzTz4Pil4qmYAth14zpKcyQsK/b4dTh/Ne2FLsR3FyQy2dBaVTplthW2 jbpZNHOh+0UVRnMonHyqZ1wBkZpp+TTTP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/acZ4awRSVePv4H9ZmOxNnrTxghbAOJ rUv3QX2vJPGnYyHUxXoSN6ZOYYOwtSWWLXwNNodXQFDi5MwnLBMYpWchWTcLScssJC2zkLQs YGRZxSiSWlqcm55bbKRXnJhbXJqXrpecn7uJEZiath37uWUH48pXH/UOMTJxMB5ilOBgVhLh ZXa0SRXiTUmsrEotyo8vKs1JLT7EaAoMoYnMUqLJ+cDkmFcSb2hmYGpoYmZpYGppZqwkzutZ 0JEoJJCeWJKanZpakFoE08fEwSnVwOR56tOqI322ddo/H6305LugNa/mya2Hyxc0Oi3gEFdW UZ7jt1j8W86BIpYct9pKs70zLRRfv1ZmvbvC2O5pkmjS07f/Hjw3vyMR4yz34L5E/rfHL0OV V63h/r9YtbzMbaXg0gkvN3g8e/xo04I7nQHsnJ+UH/Hd8uZMeN5pEevvt2/hm2o1o1nqc+sU pzidqp2xRsrWPVXnxBxD3ztRS4+euZXkEnrUPurpY07DJyIdfT6Sr76yX5q3IuP2g/Vci8sP Oq1JO6l0IMn21pXIqJZInytlrme27NPXfuiz9tDZ99MW/zsYY17ZM+NHotDxuOUxeZvPPWA5 +77ONrfFXWXjqZ/He39Oq3t8SXDefKNJSizFGYmGWsxFxYkAFE7R3dYDAAA= X-CMS-MailID: 20231028211538eucas1p1456b4c759a9fed51a6a77fbf2c946011 X-Msg-Generator: CA X-RootMTR: 20231028211538eucas1p1456b4c759a9fed51a6a77fbf2c946011 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231028211538eucas1p1456b4c759a9fed51a6a77fbf2c946011 References: <20230919135536.2165715-1-da.gomez@samsung.com> <20231028211518.3424020-1-da.gomez@samsung.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sat, 28 Oct 2023 14:16:02 -0700 (PDT) From: Luis Chamberlain The multi index selftests are great but they don't replicate how we deal with the page cache exactly, which makes it a bit hard to follow as the page cache uses the advanced API. Add tests which use the advanced API, mimicking what we do in the page cache, while at it, extend the example to do what is needed for min order support. Signed-off-by: Luis Chamberlain Tested-by: Daniel Gomez --- lib/test_xarray.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) diff --git a/lib/test_xarray.c b/lib/test_xarray.c index 6c22588963bc..22a687e33dc5 100644 --- a/lib/test_xarray.c +++ b/lib/test_xarray.c @@ -694,6 +694,139 @@ static noinline void check_multi_store(struct xarray = *xa) #endif } =20 +#ifdef CONFIG_XARRAY_MULTI +static noinline void check_xa_multi_store_adv_add(struct xarray *xa, + unsigned long index, + unsigned int order, + void *p) +{ + XA_STATE(xas, xa, index); + + xas_set_order(&xas, index, order); + + 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); + } while (xas_nomem(&xas, GFP_KERNEL)); + + XA_BUG_ON(xa, xas_error(&xas)); +} + +static noinline void check_xa_multi_store_adv_delete(struct xarray *xa, + unsigned long index, + unsigned int order) +{ + unsigned int nrpages =3D 1UL << order; + unsigned long base =3D round_down(index, nrpages); + XA_STATE(xas, xa, base); + + xas_set_order(&xas, base, order); + xas_store(&xas, NULL); + xas_init_marks(&xas); +} + +static unsigned long some_val =3D 0xdeadbeef; +static unsigned long some_val_2 =3D 0xdeaddead; + +/* mimics the page cache */ +static noinline void check_xa_multi_store_adv(struct xarray *xa, + unsigned long pos, + unsigned int order) +{ + unsigned int nrpages =3D 1UL << order; + unsigned long index, base, next_index, next_next_index; + unsigned int i; + + index =3D pos >> PAGE_SHIFT; + base =3D round_down(index, nrpages); + next_index =3D round_down(base + nrpages, nrpages); + next_next_index =3D round_down(next_index + nrpages, nrpages); + + check_xa_multi_store_adv_add(xa, base, order, &some_val); + + for (i =3D 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, base + i) !=3D &some_val); + + XA_BUG_ON(xa, xa_load(xa, next_index) !=3D NULL); + + /* Use order 0 for the next item */ + check_xa_multi_store_adv_add(xa, next_index, 0, &some_val_2); + XA_BUG_ON(xa, xa_load(xa, next_index) !=3D &some_val_2); + + /* Remove the next item */ + check_xa_multi_store_adv_delete(xa, next_index, 0); + + /* Now use order for a new pointer */ + check_xa_multi_store_adv_add(xa, next_index, order, &some_val_2); + + for (i =3D 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, next_index + i) !=3D &some_val_2); + + check_xa_multi_store_adv_delete(xa, next_index, order); + check_xa_multi_store_adv_delete(xa, base, order); + XA_BUG_ON(xa, !xa_empty(xa)); + + /* starting fresh again */ + + /* let's test some holes now */ + + /* hole at base and next_next */ + check_xa_multi_store_adv_add(xa, next_index, order, &some_val_2); + + for (i =3D 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, base + i) !=3D NULL); + + for (i =3D 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, next_index + i) !=3D &some_val_2); + + for (i =3D 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, next_next_index + i) !=3D NULL); + + check_xa_multi_store_adv_delete(xa, next_index, order); + XA_BUG_ON(xa, !xa_empty(xa)); + + /* hole at base and next */ + + check_xa_multi_store_adv_add(xa, next_next_index, order, &some_val_2); + + for (i =3D 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, base + i) !=3D NULL); + + for (i =3D 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, next_index + i) !=3D NULL); + + for (i =3D 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, next_next_index + i) !=3D &some_val_2); + + check_xa_multi_store_adv_delete(xa, next_next_index, order); + XA_BUG_ON(xa, !xa_empty(xa)); +} +#endif + +static noinline void check_multi_store_advanced(struct xarray *xa) +{ +#ifdef CONFIG_XARRAY_MULTI + unsigned int max_order =3D IS_ENABLED(CONFIG_XARRAY_MULTI) ? 20 : 1; + unsigned long end =3D ULONG_MAX/2; + unsigned long pos, i; + + /* + * About 117 million tests below. + */ + for (pos =3D 7; pos < end; pos =3D (pos * pos) + 564) { + for (i =3D 0; i < max_order; i++) { + check_xa_multi_store_adv(xa, pos, i); + check_xa_multi_store_adv(xa, pos + 157, i); + } + } +#endif +} + static noinline void check_xa_alloc_1(struct xarray *xa, unsigned int base= ) { int i; @@ -1825,6 +1958,7 @@ static int xarray_checks(void) check_reserve(&array); check_reserve(&xa0); check_multi_store(&array); + check_multi_store_advanced(&array); check_get_order(&array); check_xa_alloc(); check_find(&array); --=20 2.39.2