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/FPOxjnvvqod4iRiYPxEKMEB7OSCK+jt0uqEG9KYmVValF+ fFFpTmrxIUZpDhYlcV7VFPlUIYH0xJLU7NTUgtQimCwTB6dUA5OywD1Wa6/Et5f51NiDwgUO WzCw3pR9XvksJu/gUca+67dChb/t+n7me1DohaemXGIvVHmZH0z8xf/65xx9IVZvkXk80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+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);