Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp837202rdf; Fri, 3 Nov 2023 17:58:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG1K94vhZvnfjvG5Ae+fDQ9kMNRWTJGZCWya2/sRdieqLUdt6dR3XnC8GlQQZ/TYjdvoE1y X-Received: by 2002:a05:6e02:3888:b0:359:4199:1fe2 with SMTP id cn8-20020a056e02388800b0035941991fe2mr11220939ilb.8.1699059502137; Fri, 03 Nov 2023 17:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699059502; cv=none; d=google.com; s=arc-20160816; b=A4BCqg1IjHLjdNdeeW1IFHdxSaugyLy8WBC8UHvSN7cUPm9U9EqBiJqctFiJ9XQkeQ drjpbJVEc8MiArbdw0bXwaiXwNkD7dF/4Q4lsyGsO7VOMYr2dKN+dFJSFi7kMW8cGLlr vZIIYjTrufYDwGN9duyNo2mv0D1OcnyBt1FxMONhv79+Gw4agTJfzbqIVVZTCw9xBsrr 5esJnxBOxn/po27mvXCbdjcMPZBMSHyA55ZfWIIgjflbyn6EWIEnaaFAqI3PVH6GNcCZ XUMga21l8OFBqR/rszXHEBEKSQ6eVaD0RM2/c4NcXgc7wrAbff4VfP5/szOM9jraEEIZ yosw== 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.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id k3-20020a633d03000000b0057cbd803b30si2660466pga.654.2023.11.03.17.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 17:58:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; 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.38 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 fry.vger.email (Postfix) with ESMTP id 0DC828083DCC; Fri, 3 Nov 2023 17:58:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231686AbjKDA6H (ORCPT + 99 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] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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/FPOxjnvvqod4iRiYPxEKMEB7OSCK+jt0uqEG9KYmVValF+ fFFpTmrxIUZpDhYlcV7VFPlUIYH0xJLU7NTUgtQimCwTB6dUA5OywD1Wa6/Et5f51NiDwgUO WzCw3pR9XvksJu/gUca+67dChb/t+n7me1DohaemXGIvVHmZH0z8xf/65xx9IVZvkXk80vc4 9MIb4/9sb4u+eVf37HKPSAumq62shYxnjr6WZbikKxm5hqlpDfOKjDTtfN27ofIpJ6RS+vkK C2M+znx22ebywXsvj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d+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=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email 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 (fry.vger.email [0.0.0.0]); Fri, 03 Nov 2023 17:58:18 -0700 (PDT) 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(+) 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 =3D xa_mk_value(5); + unsigned int i, order =3D 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)) !=3D order); + + /* Check all the tied indexes have the same entry and order */ + for (i =3D 0; i < (1 << order); i++) { + XA_BUG_ON(xa, xa_load(xa, i) !=3D FIVE); + XA_BUG_ON(xa, xa_get_order(xa, i) !=3D order); + } + + /* Ensure that nothing is stored at index '1 << order' */ + XA_BUG_ON(xa, xa_load(xa, 1 << order) !=3D 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 =3D (1 << order); i < (1 << order) + (1 << order) - 1; i++) { + XA_BUG_ON(xa, xa_load(xa, i) !=3D FIVE); + XA_BUG_ON(xa, xa_get_order(xa, i) !=3D order); + } + + /* Conditionally replace FIVE entry at index '0' with NULL */ + XA_BUG_ON(xa, xa_cmpxchg(xa, 0, FIVE, NULL, GFP_KERNEL) !=3D FIVE); + + /* Verify the order is lost at FIVE (and old) entries */ + XA_BUG_ON(xa, xa_get_order(xa, xa_to_value(FIVE)) !=3D 0); + + /* Verify the order and entries are lost in all the tied indexes */ + for (i =3D 0; i < (1 << order); i++) { + XA_BUG_ON(xa, xa_load(xa, i) !=3D NULL); + XA_BUG_ON(xa, xa_get_order(xa, i) !=3D 0); + } + + /* Verify node and order are kept at '1 << order' */ + for (i =3D (1 << order); i < (1 << order) + (1 << order) - 1; i++) { + XA_BUG_ON(xa, xa_load(xa, i) !=3D FIVE); + XA_BUG_ON(xa, xa_get_order(xa, i) !=3D 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); -- 2.39.2