From patchwork Sat Nov 4 00:57:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 161507 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1397425vqu; Fri, 3 Nov 2023 17:58:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHfZPCv7xegFf51HCAnaP6fAkhb+EjnKGpfzhJrTz/3Vio9iKxlRXCAyJ8Yg1btaP4M+xR7 X-Received: by 2002:a05:6a21:35c4:b0:181:1d71:7e0f with SMTP id ba4-20020a056a2135c400b001811d717e0fmr12170589pzc.61.1699059486539; Fri, 03 Nov 2023 17:58:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699059486; cv=none; d=google.com; s=arc-20160816; b=TXaq26pr8ckJonpzYq9UjrZbS/VD3gkpD37KKVQK3jWPfwZKaHncBTwQHkqwtNiTlF lVnoTE08xta/L/Z1/Fmb4SPbniLxfQntxYzhblRPn/Jibc5jWyZ1eC3iqePvVhI5EVGs fvy4SN0aiyfgRiJFPjLxteawT2BFIWRiNPFDG671oxAtxzyooee9JeBfbhUWnn6JeN3F 3A6QmOYoViClTNsRu6/w7i9gBFInu6USut5cLQGjNz7aqY2VxySlWjE1nY2CnOBqZR+A HhH822SoMjyChIUTOe3gWZq6fdINiYNnWeB9jVUlUo+JwoFdD5j4voOCPh/Pw11IvYIU sm7g== 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=1KdTgtYEN2dnWWW2liOHDQAROLy4THOQmqwXWvqVoBg=; fh=ATjfU8IIUJMRKS1BXjl/oCZ/z4wqJuaZwT8Kl1aPZcU=; b=mmWFCb5s251qP9jU+k4wc0pSoSDJPQw2Arz0ueUR07znubgLG4zfYBajV2yjmHoLik KmlOf5Sd3kDUNIbr6Meb44R0AoCdagcGeyahYw0rAMmuKo+7LJpiR28OcnRiU3QMvPpb hPZBWh4tw2P14/kSu4EGhCIGwu/pRx5kjNf/JaJESQAhZAZ9P+jSROv12MzlDzMHZxyN vaJX4mr+wUhpDEMEK6oC1050P9rDubXYzVB9D2pcTuJO2YwQTbE3adnVGvF2Lywj9v0V aa2Wwo7Yq78bwaaqsfxyqnWoEDwT4fBDWXbbpFDlFXrv9761bm8FFcEpjL38szZFcb1U 3JGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=SUcbDIYm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id z128-20020a633386000000b005bd641c3614si379337pgz.769.2023.11.03.17.58.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 17:58:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=SUcbDIYm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 A1D5980260F7; Fri, 3 Nov 2023 17:58:05 -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 S231618AbjKDA6E (ORCPT + 34 others); Fri, 3 Nov 2023 20:58:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229864AbjKDA6B (ORCPT ); Fri, 3 Nov 2023 20:58:01 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A10BE3 for ; Fri, 3 Nov 2023 17:57:57 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20231104005754euoutp012e60a1bedd4d484c750e76b220e5ec87~URZb1op5z1873918739euoutp01M for ; Sat, 4 Nov 2023 00:57:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20231104005754euoutp012e60a1bedd4d484c750e76b220e5ec87~URZb1op5z1873918739euoutp01M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1699059474; bh=1KdTgtYEN2dnWWW2liOHDQAROLy4THOQmqwXWvqVoBg=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=SUcbDIYmLUZfmeHpoem3N3WYTH3mXMqK5IK/fsr3MMdJT3b0JEfCVpXuWEjHz21wV C4vvMk2RkInPUV8lBUPXAGXtOGs2gA4EbqF1DEakX9N7AxvQykm0xPj2OAfJFTmKki KYIGCFooSRYP2Sbz0jjVLKSLtDF++5xPjvj4wvxY= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20231104005753eucas1p1a92a433419ced42881862ba7643d303d~URZbdRkCt2722627226eucas1p1O; Sat, 4 Nov 2023 00:57:53 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 0F.9E.42423.11795456; Sat, 4 Nov 2023 00:57:53 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20231104005753eucas1p19e4ec0196f5ea297f59fb86b2a648b53~URZbHLER31996619966eucas1p1p; Sat, 4 Nov 2023 00:57:53 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231104005753eusmtrp297c5d7c9860fb6d646e7d3309512a88f~URZbGq1Ei0448904489eusmtrp2t; Sat, 4 Nov 2023 00:57:53 +0000 (GMT) X-AuditID: cbfec7f2-a51ff7000002a5b7-38-65459711785b Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 31.08.25043.11795456; Sat, 4 Nov 2023 00:57:53 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20231104005753eusmtip1cddf8a9bfb0b96b110e142adafaad76f~URZa8Fzl61908919089eusmtip1Q; Sat, 4 Nov 2023 00:57:53 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 4 Nov 2023 00:57:51 +0000 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Sat, 4 Nov 2023 00:57:51 +0000 From: Daniel Gomez To: "willy@infradead.org" CC: "gost.dev@samsung.com" , "linux-kernel@vger.kernel.org" , Pankaj Raghav , "mcgrof@kernel.org" , Daniel Gomez Subject: [PATCH 1/2] test_xarray: add tests for advanced multi-index use Thread-Topic: [PATCH 1/2] test_xarray: add tests for advanced multi-index use Thread-Index: AQHaDrnvyiy7tu6TLES21e0ZuAEgHQ== Date: Sat, 4 Nov 2023 00:57:50 +0000 Message-ID: <20231104005747.1389762-2-da.gomez@samsung.com> In-Reply-To: <20231104005747.1389762-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] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphleLIzCtJLcpLzFFi42LZduznOV3B6a6pBrdvK1pc3jWHzeLGhKeM Fr9/zGFzYPbYvELLY9OqTjaPz5vkApijuGxSUnMyy1KL9O0SuDL+729hL3irXrHoylHWBsb5 Cl2MnBwSAiYSn0/OYu1i5OIQEljBKLG1cSozhPOFUeLJxcdMEM5nRomFP28ww7Q83j2NDcQW ElgO1HJOCa5o4915UO2nGSUO3D+DMHja1Olg7WwCmhL7Tm5iB7FFBPQlVl46ywhSxCzwilHi 3dGJLCAJYQEPiS37z7NBFPlLTNz6iBXC1pP40H4XrIZFQEXiwYS1YHFeAWuJ5sUPmUBsTgEb iT2r14MtYBSQlXi08heYzSwgLnHryXwmiB8EJRbN3gP1j5jEv10P2SBsHYmz158wQtgGEluX 7mOBsJUk/nQsZISYoydxY+oUNghbW2LZwtfMEDcISpyc+YQF5BkJgcmcEruubGGFaHaRWPV5 CdRQYYlXx7ewQ9gyEv93zmeawKg9C8l9s5DsmIVkxywkOxYwsqxiFE8tLc5NTy02zEst1ytO zC0uzUvXS87P3cQITCin/x3/tINx7quPeocYmTgYDzFKcDArifA6erukCvGmJFZWpRblxxeV 5qQWH2KU5mBREudVTZFPFRJITyxJzU5NLUgtgskycXBKNTCFXeWstH7uut7l6xyLr1UTmXfV 2Fx97bvT5P6NWY4eMb/fftAICb/d5/zvY9TJryzZWquOM17qzFgkPGGK6CGF/9fNk1UE5Sy/ HVSpPX1rSfYEddtEhWcG03Z+lJB+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pr9u6a2vl4hd/lLleaFY6Hvvu3fc2Fugcux6cvEeXMba6ebfbNvs66x28Do7m+ju+Gh 0dp/PMJ5t62VzF5OvFgscTwh735X9YuTPb6reRlu6l3tuSM4MfPfxAkih43tXSb5v/5lLJP5 7cNGJ59NtSkR0yR8tB435Mn9uf4kmsfdJK5dp/nFKcnEb7lHf7dI/WD4NS+da35BEy/D1i1M P2sXmHT63bQ9ksZowqQoe1nCjfdaA5dffnC89A2duu75F57wWwcsOHuf/VXHTtc/3gcslViK MxINtZiLihMBl6/+0JMDAAA= X-CMS-MailID: 20231104005753eucas1p19e4ec0196f5ea297f59fb86b2a648b53 X-Msg-Generator: CA X-RootMTR: 20231104005753eucas1p19e4ec0196f5ea297f59fb86b2a648b53 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231104005753eucas1p19e4ec0196f5ea297f59fb86b2a648b53 References: <20231104005747.1389762-1-da.gomez@samsung.com> X-Spam-Status: No, score=-2.6 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,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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]); Fri, 03 Nov 2023 17:58:05 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781592999967022965 X-GMAIL-MSGID: 1781592999967022965 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 e77d4856442c..0572a3ec2cf8 100644 --- a/lib/test_xarray.c +++ b/lib/test_xarray.c @@ -674,6 +674,139 @@ static noinline void check_multi_store(struct xarray *xa) #endif } +#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) != 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 = 1UL << order; + unsigned long base = 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 = 0xdeadbeef; +static unsigned long some_val_2 = 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 = 1UL << order; + unsigned long index, base, next_index, next_next_index; + unsigned int i; + + index = pos >> PAGE_SHIFT; + base = round_down(index, nrpages); + next_index = round_down(base + nrpages, nrpages); + next_next_index = round_down(next_index + nrpages, nrpages); + + check_xa_multi_store_adv_add(xa, base, order, &some_val); + + for (i = 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, base + i) != &some_val); + + XA_BUG_ON(xa, xa_load(xa, next_index) != 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) != &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 = 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, next_index + i) != &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 = 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, base + i) != NULL); + + for (i = 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, next_index + i) != &some_val_2); + + for (i = 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, next_next_index + i) != 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 = 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, base + i) != NULL); + + for (i = 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, next_index + i) != NULL); + + for (i = 0; i < nrpages; i++) + XA_BUG_ON(xa, xa_load(xa, next_next_index + i) != &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 = IS_ENABLED(CONFIG_XARRAY_MULTI) ? 20 : 1; + unsigned long end = ULONG_MAX/2; + unsigned long pos, i; + + /* + * About 117 million tests below. + */ + for (pos = 7; pos < end; pos = (pos * pos) + 564) { + for (i = 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; @@ -1804,6 +1937,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); From patchwork Sat Nov 4 00:57:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 161508 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1397481vqu; Fri, 3 Nov 2023 17:58:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGbvBX4/PHnlI1qfU/iR7gDvjc9a5Ja4zXcINU64rWXCyGI+dUoK2/aOu9TEKGBGMrhGU0V X-Received: by 2002:a05:6871:650c:b0:1e9:f73e:636c with SMTP id rl12-20020a056871650c00b001e9f73e636cmr27218677oab.43.1699059494982; Fri, 03 Nov 2023 17:58:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699059494; cv=none; d=google.com; s=arc-20160816; b=FwO0gcEoYCt50vBGdzC9KT2bYzVofZBEe3HKlscp1+1G9kNHTRPrjHCoYAp6ycxmLB gEqGJSTUWuyQKiN6vGsxMRvgF8CrSHrb95RRpWdJq7TsLUTfuJJEJ+GjY0s1WQJfciRw vb8asO0ttFLE/SJv/45zAHqVA5WCEsSkCZkdQpF/ygLjkd8pOafCCasVN+wdzOhOzdG4 WspCuiYXr+KsurvMRZGVuwj6GzY3/DFxH2ZLYw7fLUZCbjvegHEqfOy20W434Krxxefi 3CeP60E0YzXEyzRtMWowBO4EM9NdOl9MlbM6L7RgXs4xptr5tmJF12QqU6mvU3hV3PW7 SFyg== 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=vq5XfVrMOKsVUO/n+Dl3zxrCVLfn8cbM3pwCIF/gzn8=; fh=ATjfU8IIUJMRKS1BXjl/oCZ/z4wqJuaZwT8Kl1aPZcU=; b=lfa7NzCkWj+YgPtQl1qd2QXEalvygaLOM4zY77/SQFLeSELrRF/YjnzqY1qX+j9OEW 86qp8BeP+plgzgPRyFuHjI36lqQUQdZrwbg+X6Q+mnH1ECizYiQert0kAfLCm+lbGeF6 y3nRtncpisSE4glkLLzjNUF84kImDkEGzlsUhuWAe15LDkNqpwua7vulBD1UKyW6U4rb +Ec+l5UtCe5x4seF6e/wSfZRZkAkbBys58yVNk4DXr+ytQ0gp62KT1AwayiJARq03sAB 8lVcefxBZSGfvduGcX5rF8UoZ3DUH7sbTk17yR+bV4xaSDA3cT9fmFpuIQVaLIt8X0sC SX0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="jBZy/u1M"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id g132-20020a636b8a000000b005bd0f2f41ddsi2462846pgc.206.2023.11.03.17.58.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 17:58:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="jBZy/u1M"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 EACE681043AD; Fri, 3 Nov 2023 17:58:13 -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 S229864AbjKDA6H (ORCPT + 34 others); Fri, 3 Nov 2023 20:58:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231161AbjKDA6B (ORCPT ); Fri, 3 Nov 2023 20:58:01 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32520123 for ; Fri, 3 Nov 2023 17:57:57 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20231104005755euoutp02c0ee3a3361ee8cc1fd9a395ec3ad545f~URZc4GmEy2782627826euoutp02i for ; Sat, 4 Nov 2023 00:57:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20231104005755euoutp02c0ee3a3361ee8cc1fd9a395ec3ad545f~URZc4GmEy2782627826euoutp02i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1699059475; bh=vq5XfVrMOKsVUO/n+Dl3zxrCVLfn8cbM3pwCIF/gzn8=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=jBZy/u1Ms8cnxeTGdvUvcIozvCIeQAkvCHW6AQE1leYyotj1xKkjXTaNCoIgtOdHY vI+NzQokythU5oUJw4tI8InTJBVA692ydctB8Jom21KGsKcZdiNjp9NDDpWwiArTnj Ob9Dw76g4nsBAfwFTVzhQHuvZq0J7Vbzz0jafn0U= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20231104005754eucas1p11b66a647fe97391b9fa01478866aef21~URZcBCPZC2693226932eucas1p1P; Sat, 4 Nov 2023 00:57:54 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 4F.9E.42423.21795456; Sat, 4 Nov 2023 00:57:54 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20231104005753eucas1p161414dd7c5eb9cdc6863fb543459c242~URZbP8LD_1997019970eucas1p1g; Sat, 4 Nov 2023 00:57:53 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231104005753eusmtrp2d538881ce4ad2745aad6b017becbfe07~URZbPetd50448904489eusmtrp2v; Sat, 4 Nov 2023 00:57:53 +0000 (GMT) X-AuditID: cbfec7f2-a3bff7000002a5b7-39-65459712a792 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id F5.E9.10549.11795456; Sat, 4 Nov 2023 00:57:53 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20231104005753eusmtip1c1658ebb8c51dfb882a49f7d92a06a35~URZbEkNXB1691316913eusmtip1M; Sat, 4 Nov 2023 00:57:53 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 4 Nov 2023 00:57:52 +0000 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Sat, 4 Nov 2023 00:57:52 +0000 From: Daniel Gomez To: "willy@infradead.org" CC: "gost.dev@samsung.com" , "linux-kernel@vger.kernel.org" , Pankaj Raghav , "mcgrof@kernel.org" , Daniel Gomez Subject: [PATCH 2/2] XArray: add cmpxchg order test Thread-Topic: [PATCH 2/2] XArray: add cmpxchg order test Thread-Index: AQHaDrnwqmHp5sYBP0uShsjDRRtCbA== Date: Sat, 4 Nov 2023 00:57:52 +0000 Message-ID: <20231104005747.1389762-3-da.gomez@samsung.com> In-Reply-To: <20231104005747.1389762-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] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42LZduzneV2h6a6pBstnc1pc3jWHzeLGhKeM Fr9/zGFzYPbYvELLY9OqTjaPz5vkApijuGxSUnMyy1KL9O0SuDKOvP7AUvBVvOLv6i6mBsY1 wl2MnBwSAiYSWy6sY+5i5OIQEljBKLH60mVWCOcLo8SRq73sEM5nRol5fWsZYVo+/F/DApFY zijxYu1RZriqWYcPsYNUCQmcZpQ4dIoVbvDNo2vYQBJsApoS+05uAisSEdCXWHnpLCNIEbPA K0aJd0cnsoAkhAWMJZpXHGeBKLKQ+LH4KlARB5CtJ3FgjjdImEVAReLQl6nMIDavgLXE+76X YOdxCthI7Fm9Hmw+o4CsxKOVv8BsZgFxiVtP5jNBvCAosWj2HmYIW0zi366HbBC2jsTZ60+g 3jSQ2Lp0HwuErSTxp2MhI8QcPYkbU6ewQdjaEssWvoa6QVDi5Mwn4GCREJjOKXHo8HaoBS4S a5b0Qy0Wlnh1fAs7hC0j8X/nfKYJjNqzkNw3C8mOWUh2zEKyYwEjyypG8dTS4tz01GLDvNRy veLE3OLSvHS95PzcTYzAdHL63/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Yd+7l5B+O8Vx/1DjEycTAeYpTgYFYS4XX0dkkV4k1JrKxKLcqPLyrNSS0+xGgK DKOJzFKiyfnApJRXEm9oZmBqaGJmaWBqaWasJM7rWdCRKCSQnliSmp2aWpBaBNPHxMEp1cC0 eI2wk7Cc9bP/Mso8v0Xc9V7IxfTx2Z15aDh5soFZ+pQ9v6Z9nxDed/DnhcURfIcO2y38fd5m zqqNx6KZF26t3XSo/nD4S53tnQ12F8V2+ylNZF8Ttn+/wve7jDav9s8Qd+py+nCVY+atq1Ov zyhfseLEz7tB7evDZzL5VPAf1PH4ZdD2r+jP3Duhgd8edoiEnMrhndczzaz2IYOXq3xFSLfM 9+1XZiu5PHqvHbhDpDb58rPIpwnGNRN0+RfPYONxOils9mLWnKTYktnhl3slf5urFb9rtfSc f0Oj/O/T/V+9y1mmvp29R6hgz65pPhvOfGYPZBNz42u/kag2v6WGMadP6Oa9SF2Wnqo6lfPv lFiKMxINtZiLihMB5WI4kJIDAAA= X-CMS-MailID: 20231104005753eucas1p161414dd7c5eb9cdc6863fb543459c242 X-Msg-Generator: CA X-RootMTR: 20231104005753eucas1p161414dd7c5eb9cdc6863fb543459c242 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231104005753eucas1p161414dd7c5eb9cdc6863fb543459c242 References: <20231104005747.1389762-1-da.gomez@samsung.com> X-Spam-Status: No, score=-2.6 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,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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]); Fri, 03 Nov 2023 17:58:14 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781593009312657466 X-GMAIL-MSGID: 1781593009312657466 XArray multi-index entries do not keep track of the order stored once the entry is being marked as used with cmpxchg (conditionally replaced with NULL). Add a test to check the order is actually lost. The test also verifies the order and entries for all the tied indexes before and after the NULL replacement with xa_cmpxchg. Add another entry at 1 << order that keeps the node around and the order information for the NULL-entry after xa_cmpxchg. Signed-off-by: Daniel Gomez --- lib/test_xarray.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) -- 2.39.2 diff --git a/lib/test_xarray.c b/lib/test_xarray.c index 0572a3ec2cf8..3c19d12c1bf5 100644 --- a/lib/test_xarray.c +++ b/lib/test_xarray.c @@ -423,6 +423,59 @@ static noinline void check_cmpxchg(struct xarray *xa) XA_BUG_ON(xa, !xa_empty(xa)); } +static noinline void check_cmpxchg_order(struct xarray *xa) +{ +#ifdef CONFIG_XARRAY_MULTI + void *FIVE = xa_mk_value(5); + unsigned int i, order = 3; + + XA_BUG_ON(xa, xa_store_order(xa, 0, order, FIVE, GFP_KERNEL)); + + /* Check entry FIVE has the order saved */ + XA_BUG_ON(xa, xa_get_order(xa, xa_to_value(FIVE)) != order); + + /* Check all the tied indexes have the same entry and order */ + for (i = 0; i < (1 << order); i++) { + XA_BUG_ON(xa, xa_load(xa, i) != FIVE); + XA_BUG_ON(xa, xa_get_order(xa, i) != order); + } + + /* Ensure that nothing is stored at index '1 << order' */ + XA_BUG_ON(xa, xa_load(xa, 1 << order) != NULL); + + /* + * Additionally, keep the node information and the order at + * '1 << order' + */ + XA_BUG_ON(xa, xa_store_order(xa, 1 << order, order, FIVE, GFP_KERNEL)); + for (i = (1 << order); i < (1 << order) + (1 << order) - 1; i++) { + XA_BUG_ON(xa, xa_load(xa, i) != FIVE); + XA_BUG_ON(xa, xa_get_order(xa, i) != order); + } + + /* Conditionally replace FIVE entry at index '0' with NULL */ + XA_BUG_ON(xa, xa_cmpxchg(xa, 0, FIVE, NULL, GFP_KERNEL) != FIVE); + + /* Verify the order is lost at FIVE (and old) entries */ + XA_BUG_ON(xa, xa_get_order(xa, xa_to_value(FIVE)) != 0); + + /* Verify the order and entries are lost in all the tied indexes */ + for (i = 0; i < (1 << order); i++) { + XA_BUG_ON(xa, xa_load(xa, i) != NULL); + XA_BUG_ON(xa, xa_get_order(xa, i) != 0); + } + + /* Verify node and order are kept at '1 << order' */ + for (i = (1 << order); i < (1 << order) + (1 << order) - 1; i++) { + XA_BUG_ON(xa, xa_load(xa, i) != FIVE); + XA_BUG_ON(xa, xa_get_order(xa, i) != order); + } + + xa_store_order(xa, 0, BITS_PER_LONG - 1, NULL, GFP_KERNEL); + XA_BUG_ON(xa, !xa_empty(xa)); +#endif +} + static noinline void check_reserve(struct xarray *xa) { void *entry; @@ -1934,6 +1987,7 @@ static int xarray_checks(void) check_xas_erase(&array); check_insert(&array); check_cmpxchg(&array); + check_cmpxchg_order(&array); check_reserve(&array); check_reserve(&xa0); check_multi_store(&array);