From patchwork Mon Nov 11 21:53:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13870698 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10775D2E9E6 for ; Mon, 11 Nov 2024 12:55:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 42E536B0092; Mon, 11 Nov 2024 07:55:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F8756B0088; Mon, 11 Nov 2024 07:55:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 03C816B008A; Mon, 11 Nov 2024 07:55:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A2D2D6B0083 for ; Mon, 11 Nov 2024 07:55:07 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 642E5AC8FA for ; Mon, 11 Nov 2024 12:55:07 +0000 (UTC) X-FDA: 82773806640.20.E0E71BB Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by imf18.hostedemail.com (Postfix) with ESMTP id EC5A91C000C for ; Mon, 11 Nov 2024 12:54:44 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf18.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=shikemeng@huaweicloud.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731329619; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2DK7vPaNmdtVaqar58Rue2/gKQZM3vD+yRmZcg90Pvg=; b=bbKPMyKKJ/aSNzBztLOacjXuLNjEf4WkM3CRq5yiQ/sElI6xsY8cdC8WpwIYhqS1Wpe0O9 bsZfgpzvuMKEAp3/NAfC2Y3x8GWcVZze8LGMrnvAT0OGlXcGvfeQkTmRhNL0fm1EkHHaiP Jp2pjklcKfXRcSXG++p02J5EQsNwDwY= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf18.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=shikemeng@huaweicloud.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731329619; a=rsa-sha256; cv=none; b=jgAgJkquvSuMbHRiDNZnZe66BvI//yLbajld9EdTRFBkgKGLGJnWyWrAUO0+IUBBT6Txzn 61uf7lTSBMmZnoNS2H/oyDm+asYwSj6t1y++UlvZwIA80F/7jytZhUDLwDWW6nx4oPj+L4 OOxcws/nE0x0GHk75bZCjjQ09DZczSI= Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Xn8dT264Fz4f3nTB for ; Mon, 11 Nov 2024 20:54:37 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 559801A018D for ; Mon, 11 Nov 2024 20:54:56 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.6]) by APP4 (Coremail) with SMTP id gCh0CgB3n4Oe_jFnllryBQ--.36628S3; Mon, 11 Nov 2024 20:54:56 +0800 (CST) From: Kemeng Shi To: akpm@linux-foundation.org, willy@infradead.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH RESEND V2 1/5] Xarray: Do not return sibling entries from xas_find_marked() Date: Tue, 12 Nov 2024 05:53:55 +0800 Message-Id: <20241111215359.246937-2-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20241111215359.246937-1-shikemeng@huaweicloud.com> References: <20241111215359.246937-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgB3n4Oe_jFnllryBQ--.36628S3 X-Coremail-Antispam: 1UD129KBjvJXoW7AFyrArW8Xr4rWF17uw1xKrg_yoW8KF15pF W8Ga40gF4xtr4jyry0yayUXayF9wn8XFWFyay8Gr1SyFnxJ3W0yr4jkryDtF9rZrW5Zw43 C3WFq345Za1DJw7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPFb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M2 8IrcIa0xkI8VA2jI8067AKxVWUGwA2048vs2IY020Ec7CjxVAFwI0_Jrv_JF4l8cAvFVAK 0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4 x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l 84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I 8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AK xVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lc7CjxVAaw2AFwI 0_JF0_Jw1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG 67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMI IYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E 14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJV W8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUswZ2 DUUUU X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: EC5A91C000C X-Stat-Signature: 7bu1b696myiiiaxouaoxs4z11cb6bt1d X-HE-Tag: 1731329684-587693 X-HE-Meta: U2FsdGVkX1827dfuwNlJpFqw5Ep/8GaF4L3EfOIN5VUfzlAgNH1SskOE+SdnjAA5prjGcQqdRCf1DCbwB5WW4BE77dQzeHIXAFAy4MCAp4BWi9wS02AHv7praAiRoIrZzQwH54RB0leudpxOq8OtxPlDWUirpBjOgeK6QRl3Uyu9cSoNkliphF2Qa/oOLXzYtlsMqUjGP4i9iSdhZqq6a/OSPa7/H6ZP5snR7xun1gpn4HRWBC2QtxphXCwhG/RfeuAzjMMmQOLi3JNkH/0AoGPp0tqKkOu1ghzs2n/PYrEkSWhDF6P/BeU4c+kZBMOisFUgJiYjVRzmB5+QpCzLevjBMgKj6ufD42SCl6qykmqhoB4lnZuJYXiwLFZnulTgxoBCAkUOe7bb0onDC2qEr6o3NyNbH7pd9xjsIeaoHMrOA50ZMUqducj+kYdyT1ZyuiHsMRRhyBqtuKGpiAmFgcs17UTzCxxnFWDjCLqXuUgGscdG64JSaUNCighfY4Sdw0gdq2Wjh3aQNxA2FgkK7lVugjBpGiuEKO6MB6ZFc30nzYnJtLiYEM22OWBfnfGN9NyrTOpUzvRWvpuIQh8YnszTr01vg7ycgtOoQXWC8A/9iEbsF9sbzsvAwTUfNPX2gqI5fn0rZYqNDSrpuwoBTHQqvNRkUHT5toMPhtjGJ05cGF3qjYFk93BHWR7lBDledQUKxSCbLM0/6bbyi9UEmoA2dQNb6bnQ2w3pLVh8HTqvvzH4t/t4++H6R5AkxRKSe14mfkeLo/03arXiuBxVYNltR/vc4hu95AdLxkjiqbpmD4aY5Eh+PfBKxgi2CyaoUXeVNQ0XZcP7YMbufeC6M+lBUrXh04v4OEmOc/TNQ4QaVAewQ5syNuXDbDiCoRQEgwT15HQeRugO7thzCH1JeKwdjgqthCDBke4ZvngA+2Uwmo56LAmK/LcD6UnTD9d0Ywydtd/y8+4i4VAQDHY 8BWH1U8+ RVjZ9ggciF1c0e7iieMaL/eTFrik3ADpfLt6e8RxX31SOuRTR0DKxQGDSGN47QUaqTi1Oe5cqDdpRLWVcpcUFBvaw8UsHADXBukYhGx7/nwFBVqNcj0IYnuH66Q5st8u5m4yIPICIRgabWN97RMM5W+bU6CE0KEYwRQkbDLmfSFQnTU7/A6GN26G5yI6XpUFTnH06skhlP3ZIYvzB9GttFIjqHA6ZmlQLJkpT4rQATgDGrcJlPOSLGTKct8PgINWHtdOmEKxhXtivNTTRlEJ9cJFr0+xgVV/RdKFbi559S4wlZEcauN+QuAwGV4HH6bpyo9Xd X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Similar to issue fixed in commit cbc02854331ed ("XArray: Do not return sibling entries from xa_load()"), we may return sibling entries from xas_find_marked as following: Thread A: Thread B: xa_store_range(xa, entry, 6, 7, gfp); xa_set_mark(xa, 6, mark) XA_STATE(xas, xa, 6); xas_find_marked(&xas, 7, mark); offset = xas_find_chunk(xas, advance, mark); [offset is 6 which points to a valid entry] xa_store_range(xa, entry, 4, 7, gfp); entry = xa_entry(xa, node, 6); [entry is a sibling of 4] if (!xa_is_node(entry)) return entry; Skip sibling entry like xas_find() does to protect caller from seeing sibling entry from xas_find_marked(). Besides, load_race() test is modified to catch mentioned issue and modified load_race() only passes after this fix is merged. Signed-off-by: Kemeng Shi --- lib/xarray.c | 2 ++ tools/testing/radix-tree/multiorder.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/lib/xarray.c b/lib/xarray.c index 32d4bac8c94c..fa87949719a0 100644 --- a/lib/xarray.c +++ b/lib/xarray.c @@ -1382,6 +1382,8 @@ void *xas_find_marked(struct xa_state *xas, unsigned long max, xa_mark_t mark) entry = xa_entry(xas->xa, xas->xa_node, xas->xa_offset); if (!entry && !(xa_track_free(xas->xa) && mark == XA_FREE_MARK)) continue; + if (xa_is_sibling(entry)) + continue; if (!xa_is_node(entry)) return entry; xas->xa_node = xa_to_node(entry); diff --git a/tools/testing/radix-tree/multiorder.c b/tools/testing/radix-tree/multiorder.c index cffaf2245d4f..eaff1b036989 100644 --- a/tools/testing/radix-tree/multiorder.c +++ b/tools/testing/radix-tree/multiorder.c @@ -227,6 +227,7 @@ static void *load_creator(void *ptr) unsigned long index = (3 << RADIX_TREE_MAP_SHIFT) - (1 << order); item_insert_order(tree, index, order); + xa_set_mark(tree, index, XA_MARK_1); item_delete_rcu(tree, index); } } @@ -242,8 +243,11 @@ static void *load_worker(void *ptr) rcu_register_thread(); while (!stop_iteration) { + unsigned long find_index = (2 << RADIX_TREE_MAP_SHIFT) + 1; struct item *item = xa_load(ptr, index); assert(!xa_is_internal(item)); + item = xa_find(ptr, &find_index, index, XA_MARK_1); + assert(!xa_is_internal(item)); } rcu_unregister_thread(); From patchwork Mon Nov 11 21:53:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13870701 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00165D2E9E4 for ; Mon, 11 Nov 2024 12:55:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CB1866B008A; Mon, 11 Nov 2024 07:55:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 84EBF6B0088; Mon, 11 Nov 2024 07:55:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5DDE36B008C; Mon, 11 Nov 2024 07:55:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 15F7C6B008C for ; Mon, 11 Nov 2024 07:55:08 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C3675AC9E0 for ; Mon, 11 Nov 2024 12:55:07 +0000 (UTC) X-FDA: 82773807396.13.EAC6616 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by imf20.hostedemail.com (Postfix) with ESMTP id 08C501C0016 for ; Mon, 11 Nov 2024 12:54:11 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=none; spf=pass (imf20.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.56 as permitted sender) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731329533; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AvN8u3WWaJBIVDWP+6egm58xZqsw2NfS5dOoXYLl3U0=; b=IPpfy9jdBaFtnAzNX20IrbocaUg3SV2Wqw121xHeVq2zNm4zqxSX5oIsMsg0FPnX8+ox/p /ZvyP03mmbPQ3SpFhWUBq+q6uw7/PSv2kBHrpQM9Pjr5DzDhIU8YGRg9dOgl6X/A3K1vrR dxh785Qpv2ZuORQ2HnEGcm12CK0IEZA= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; spf=pass (imf20.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.56 as permitted sender) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731329533; a=rsa-sha256; cv=none; b=6EpAPjsiVaM3RNj2RlxD2lNNerRz+7oCxyKtXOHNChp9ulwUhqcYU+bzADQ1z+F3VtYkit /OxfYmyl92zdxu/TS4NwvL34IXyE+MG27Y91VHEZN3BRYRg2tt3P5iNHmv3z3huiiEUeC2 EwhgM//1dEfEzITrQ95qdnBXp+WYvZo= Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Xn8dV3N2Fz4f3jd6 for ; Mon, 11 Nov 2024 20:54:38 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id A12A31A0359 for ; Mon, 11 Nov 2024 20:54:56 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.6]) by APP4 (Coremail) with SMTP id gCh0CgB3n4Oe_jFnllryBQ--.36628S4; Mon, 11 Nov 2024 20:54:56 +0800 (CST) From: Kemeng Shi To: akpm@linux-foundation.org, willy@infradead.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH RESEND V2 2/5] Xarray: distinguish large entries correctly in xas_split_alloc() Date: Tue, 12 Nov 2024 05:53:56 +0800 Message-Id: <20241111215359.246937-3-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20241111215359.246937-1-shikemeng@huaweicloud.com> References: <20241111215359.246937-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgB3n4Oe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2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07jhxhLU UUUU= X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 08C501C0016 X-Stat-Signature: nxaxhjrqnrud7fqdjsmajceztwbguu5x X-Rspam-User: X-HE-Tag: 1731329651-254975 X-HE-Meta: U2FsdGVkX19cdXzJT6djPjdnE63CWHzp7c2L2no5DMgN0GlGT8DkVmzzL0dzADZMDGSUwQ7VaZNt1aXOSXVGe0kx6cpkwX6a8F1oFroBafzyLpGE/BMemwovqL21lOSmB+y7cWQr4gyOYSsVTmdREQ6jWrTvTfDItfOdZG6mQso18kQq5dY4fXaspLvViAcG2BiT6VZ9pxoOs6JGFnS7ND1ERnRzVYhwJ87VgJMj5VnBs+KbcbgdRqLiWRNil38b1njJaR0vjOPZvx2Vw3cGTCjpDG0U25NEaM+uWjnzsBWyjHVnGhPY34OygNf+GdL0Z9HCVtGOID4pCYT0eUKtUowJEfOx8d4Dts024urO1zooTL6ByVnnDM3IGCgX4RqBH3KVIWYfA4WImObRGUcRK4AGzzCS7tORyqfglXKcxkncIEIiiEFNx7lCFEX/bgjzd2QJiy43WR7GyR3CzqbWZq/YPvv+anR/EzVrJXId1wUPoMqioIuPCOLYx7J6thcdz+TA2O8qgm5QrP4T04t755ENz07f27rtxhUar+SLvSyjGjMnJU2RRtePl4k0lyH2IabfNXRGE7mRnCCNZVKdpFDDYTBvSDvG3KgEe+9JPCkGuYfTnjDPiq95PzjlxaRGC2u3izXNsz/b3KvoB7ctymL4X1quEuJ7rNpWnvWolY9Vbcuyy1Br22YgjMjd8nv2mcrX7T3aLjuIrWVhy+2+YY6Qi6FAtKkCEPlzDDjx6mXEAZvq/7Bl3FXUCaT/RoD3UWjxK+s5oUcdxjtjyKiw1WSgglwjl0imOOhPgifvG1Yg8tlDQ6n6bqEE3H1avit/tCC3mTaLMQAfwLn/0qXggw9ksNiJxXHdUqJJrICQdzerbT/CJRWMFbJ1CZWRN+I3TYeRPMnkzvO4trZwtLQcpHdhq0TblM7N/xfwhfAkFB5OL46YrjfLOdNyfYr+pjRcQVWgjhHF34nfE0B5Rqd yN+U2VVO vMevIv5C0z1JDVAjkf4OcHrdpM0Riq4mWxpeE4FLjcYjA+kv/8dSUMZzPQcUD02Sq/WUPHKcjwsu7HD38OtRwg8luuS8qia9FwgIcPmNqHdh0mmH6Q4W2lr96L6Yg+2NJwCm/1AzfNs4PamA5pKsdFLZRh0dLmKPJrSjaIUlKf7kILzwyeO2AHYqcpLqs1KsNoabRyBPBHysMYJYD5B5rCD/Z2O5KTyeM6SydXV8o/cy58FdFCJUkWpbkeCB3XmBnt9DWiH88GGmu8/JJRbqv4CLvRD1fl5PGYTXerrkeGQwyh5P6qDvdG0/k6DrpYVlJ1Llx X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: We don't support large entries which expand two more level xa_node in split. For case "xas->xa_shift + 2 * XA_CHUNK_SHIFT == order", we also need two level of xa_node to expand. Distinguish entry as large entry in case "xas->xa_shift + 2 * XA_CHUNK_SHIFT == order". Signed-off-by: Kemeng Shi --- lib/xarray.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/xarray.c b/lib/xarray.c index fa87949719a0..b9fd321a02ad 100644 --- a/lib/xarray.c +++ b/lib/xarray.c @@ -1022,7 +1022,7 @@ void xas_split_alloc(struct xa_state *xas, void *entry, unsigned int order, unsigned int mask = xas->xa_sibs; /* XXX: no support for splitting really large entries yet */ - if (WARN_ON(xas->xa_shift + 2 * XA_CHUNK_SHIFT < order)) + if (WARN_ON(xas->xa_shift + 2 * XA_CHUNK_SHIFT <= order)) goto nomem; if (xas->xa_shift + XA_CHUNK_SHIFT > order) return; From patchwork Mon Nov 11 21:53:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13870696 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78D95D2E9E3 for ; Mon, 11 Nov 2024 12:55:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA8276B0089; Mon, 11 Nov 2024 07:55:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D574F6B008C; Mon, 11 Nov 2024 07:55:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD1DC6B0089; Mon, 11 Nov 2024 07:55:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 9F7F26B007B for ; Mon, 11 Nov 2024 07:55:07 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 58962816EF for ; Mon, 11 Nov 2024 12:55:07 +0000 (UTC) X-FDA: 82773807732.27.63BBB1E Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by imf23.hostedemail.com (Postfix) with ESMTP id CFE3F140017 for ; Mon, 11 Nov 2024 12:54:35 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731329474; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xc/oxACnMqcXbQlGVAuXnI+BvNhV2gjX2/T1F73aeMs=; b=RntAUVXQhKdPgcnw8hPs3ZmfXGVU5iFmjlA4J2AjShO2Yo8yXHen8nUqB97WWV+VDNGehl uCmjaYiX96umnVNUeqWybTsXdxVcfTEgYNu4x8ZB5CKttoqUyRS6iEiH7ntFqQiQEy+5FI naSBhc2H41c004Oq/jn8PwSbxUfCqeQ= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731329474; a=rsa-sha256; cv=none; b=c1/Z5z0naYvFWzQOAk9ouFDQjam+nzu95Z3/E6LtIWV0otRY5gkYBzv0Sj2Vpkp/zB2YVN /nCv7ixKU9KMZUAMAJHnmDtDcjPSxs8+VfTpD4KtNJTaEGdfhY09I6HTBCKt7vDGO6+7Lk iR3fNEt1UE/g/cRyxUkrMhzFqx7+O64= Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Xn8dT6F3gz4f3nb8 for ; Mon, 11 Nov 2024 20:54:37 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id E3A2C1A0568 for ; Mon, 11 Nov 2024 20:54:56 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.6]) by APP4 (Coremail) with SMTP id gCh0CgB3n4Oe_jFnllryBQ--.36628S5; Mon, 11 Nov 2024 20:54:56 +0800 (CST) From: Kemeng Shi To: akpm@linux-foundation.org, willy@infradead.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH RESEND V2 3/5] Xarray: move forward index correctly in xas_pause() Date: Tue, 12 Nov 2024 05:53:57 +0800 Message-Id: <20241111215359.246937-4-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20241111215359.246937-1-shikemeng@huaweicloud.com> References: <20241111215359.246937-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgB3n4Oe_jFnllryBQ--.36628S5 X-Coremail-Antispam: 1UD129KBjvJXoWxuFyUWFWxCF4fJFyrAFy5Arb_yoW5Gr1UpF WDGryFyw18Jr1I9rnIqa18uw1Fg3WrKa13trWfGr1ftrZxGr9Fy3Wjkr98XF9xWa18Aa47 CF4rWrn8Ga1DJ3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPFb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M2 8IrcIa0xkI8VA2jI8067AKxVWUWwA2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK 0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4 x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l 84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I 8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AK xVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lc7CjxVAaw2AFwI 0_JF0_Jw1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG 67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMI IYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E 14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJV W8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUaTKu UUUUU X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: CFE3F140017 X-Stat-Signature: qceupc6d3xf3xkrpr1tdsshk1apmbwhw X-Rspam-User: X-HE-Tag: 1731329675-728302 X-HE-Meta: U2FsdGVkX1+7OKWHZKk2rRedH/d319nK4L9vuI5dFfzTkIX9xBTivWsc4iZ0hxaGSHZdxJ5ERnlHr2yb/JqLU0Hj+6zFF3XwBkzme4FpGvyZ/KjFTv2BB2G5FWTdQya8QKbMXpPL02sCCNapLa+RZ9HpYIz0ad0IKLvHL7iXG1tmhG6oLriOZm0jzMA3SEO6ec9oOVw7eJ0WoBEgnO3gpVdiiR7ApWUvjylwAYEr+gdg3P+DQkeLgBKTPfNshhUMZbU3YvbPXfOzS85/mLqpjaumJbQGj9u8ChWWTsfM3tIkANdkVA+kR1hGN1JvSgNUnUgwhE0inO7VfXVJ1yZLsy+FSZEqbLGVkic4QpRa4DHt9q31cucZSdw3X+2C4QRFZCniMekKTHnePhOcftT3WpXApA6xG0pfnpJtkTsOt498vb4qkuMLd9sIYIqyHwW02k4T28FbvCwSxyh9Q1D8bfNUAm5EZp5zEpFzgQykAOPuiMt2JXQyy8zt+tw5npDtOP1ZxAkCd3t04nsnWfgxmQlrgdrqFxnqMd+qrpjt8O7V+7+j2/qgUHodHjweTcCY+v+DQp+2CORZNqxq4VyYaFO2FB5Z2gKqQQjCU/82H1AlvuARXgaQe1PT2tJk70SNHQ86II5js8OF6QoqVrklchLY31eHntC2NREyOF+WDOb3p03hnHx6oE1iyQF27flu5Yi1NdWn7V+pGKnXpEQA7kWQUAF7DuVraO7opCShhGZV3wlbaaq4twRqgNgUPwLRNmVQCWV3yciPFBmYcLw393+xHiO5PkJjxU44YWISIlCrvsKNHzv2HMgnU+BJZUFFHCAklKKbuV3ZvIfuiAYZ+1D1Ju2i9w1u43w2gAcMYhgWkZr/tDpOLY9zQ0k9lpjL/ocAdaYn6logR7jHbIKexsbxy0F0v0Gr4ZYSlD7RHsbJASU0grMZIr9nQhFNwlTjvxyNf3QqmmGXiAAAGLj LIO8Dn5/ /YPuk84Zc+jI3SG0Nx/bM4KH71pRdu/gPR2ZbOozN2MNBtvw4rAdugyc8jr6bS2BR4psuxUrJxiBqsQnzqV3IayUDi80Mxj32tRTHkjbsWrC4u6EVjwID6VHAQnydy2YUz+uP23VzaqPQcmxE6PHGeVMEg6KDmL3s5gKYwnpm8XszKjaKthe65z26JxiO6iligJiknxPK1jkfHS2UQLKxpWrYMg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: After xas_load(), xas->index could point to mid of found multi-index entry and xas->index's bits under node->shift maybe non-zero. The afterward xas_pause() will move forward xas->index with xa->node->shift with bits under node->shift un-masked and thus skip some index unexpectedly. Consider following case: Assume XA_CHUNK_SHIFT is 4. xa_store_range(xa, 16, 31, ...) xa_store(xa, 32, ...) XA_STATE(xas, xa, 17); xas_for_each(&xas,...) xas_load(&xas) /* xas->index = 17, xas->xa_offset = 1, xas->xa_node->xa_shift = 4 */ xas_pause() /* xas->index = 33, xas->xa_offset = 2, xas->xa_node->xa_shift = 4 */ As we can see, index of 32 is skipped unexpectedly. Fix this by mask bit under node->xa_shift when move forward index in xas_pause(). Signed-off-by: Kemeng Shi --- lib/test_xarray.c | 35 +++++++++++++++++++++++++++++++++++ lib/xarray.c | 1 + 2 files changed, 36 insertions(+) diff --git a/lib/test_xarray.c b/lib/test_xarray.c index d5c5cbba33ed..6932a26f4927 100644 --- a/lib/test_xarray.c +++ b/lib/test_xarray.c @@ -1448,6 +1448,41 @@ static noinline void check_pause(struct xarray *xa) XA_BUG_ON(xa, count != order_limit); xa_destroy(xa); + + index = 0; + for (order = XA_CHUNK_SHIFT; order > 0; order--) { + XA_BUG_ON(xa, xa_store_order(xa, index, order, + xa_mk_index(index), GFP_KERNEL)); + index += 1UL << order; + } + + index = 0; + count = 0; + xas_set(&xas, 0); + rcu_read_lock(); + xas_for_each(&xas, entry, ULONG_MAX) { + XA_BUG_ON(xa, entry != xa_mk_index(index)); + index += 1UL << (XA_CHUNK_SHIFT - count); + count++; + } + rcu_read_unlock(); + XA_BUG_ON(xa, count != XA_CHUNK_SHIFT); + + index = 0; + count = 0; + xas_set(&xas, XA_CHUNK_SIZE / 2 + 1); + rcu_read_lock(); + xas_for_each(&xas, entry, ULONG_MAX) { + XA_BUG_ON(xa, entry != xa_mk_index(index)); + index += 1UL << (XA_CHUNK_SHIFT - count); + count++; + xas_pause(&xas); + } + rcu_read_unlock(); + XA_BUG_ON(xa, count != XA_CHUNK_SHIFT); + + xa_destroy(xa); + } static noinline void check_move_tiny(struct xarray *xa) diff --git a/lib/xarray.c b/lib/xarray.c index b9fd321a02ad..3fac3f2cea9d 100644 --- a/lib/xarray.c +++ b/lib/xarray.c @@ -1147,6 +1147,7 @@ void xas_pause(struct xa_state *xas) if (!xa_is_sibling(xa_entry(xas->xa, node, offset))) break; } + xas->xa_index &= ~0UL << node->shift; xas->xa_index += (offset - xas->xa_offset) << node->shift; if (xas->xa_index == 0) xas->xa_node = XAS_BOUNDS; From patchwork Mon Nov 11 21:53:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13870699 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 401C5D2E9E3 for ; Mon, 11 Nov 2024 12:55:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7926C6B007B; Mon, 11 Nov 2024 07:55:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 42E086B008A; Mon, 11 Nov 2024 07:55:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 25D906B0093; Mon, 11 Nov 2024 07:55:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id CF1AC6B007B for ; Mon, 11 Nov 2024 07:55:07 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 61713161885 for ; Mon, 11 Nov 2024 12:55:07 +0000 (UTC) X-FDA: 82773808278.24.14E9696 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by imf06.hostedemail.com (Postfix) with ESMTP id 5FA69180008 for ; Mon, 11 Nov 2024 12:54:33 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; spf=pass (imf06.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731329514; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bxIw4umX4p8FjSyJOZOfGED/8t0TaNg5KTYmBw60MZs=; b=fyAjtHa5tzIplwsI0AAV9sICxj9T4KXNz7maKbEomGrNqz3Q4A2BUsI2CbW370OGrXLz4N CdSzFLB/Lofqo68mdJXF4/km/RDyvXZ1Ghuk3Q/Zedxj3819T+St7PrDqiaE1U/NkPH2Uf HresWY8wj9ywF+cjNHm/73aLBltVf8Q= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; spf=pass (imf06.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731329514; a=rsa-sha256; cv=none; b=ky1/SomWIDzel2JaOSzq2rVENPPpyRal67S7Hv8PfeMjjCEagwzY8vjpwBjSiB2aGNNT1n qponKVn5oixlS4Cbqj/lX/DbF2Hbvq1VC2iVFKBTD6S9P7wnzmuIVwSUhvDKOeAyY5qW/b ZyQMgGfrOHJKDi3xBboyOBaYk42E0Fc= Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Xn8dV1Jvnz4f3nbG for ; Mon, 11 Nov 2024 20:54:38 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 39CCF1A018C for ; Mon, 11 Nov 2024 20:54:57 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.6]) by APP4 (Coremail) with SMTP id gCh0CgB3n4Oe_jFnllryBQ--.36628S6; Mon, 11 Nov 2024 20:54:57 +0800 (CST) From: Kemeng Shi To: akpm@linux-foundation.org, willy@infradead.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH RESEND V2 4/5] Xarray: remove repeat check in xas_squash_marks() Date: Tue, 12 Nov 2024 05:53:58 +0800 Message-Id: <20241111215359.246937-5-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20241111215359.246937-1-shikemeng@huaweicloud.com> References: <20241111215359.246937-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgB3n4Oe_jFnllryBQ--.36628S6 X-Coremail-Antispam: 1UD129KBjvdXoWrtFWxKF1Dtr4kXFy7Xw4kCrg_yoWxtwb_Za 10yr1vyr1UCrn7XwsIkFs8tryjkryvqF9rKFW8Ja43ur10qry5WF4vqr15Aa4kZw4ayFy7 JF45Zr1Y9r15GjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbqkYFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l87I20VAvwVAaII0Ic2I_JFv_Gryl82 xGYIkIc2x26280x7IE14v26r126s0DM28IrcIa0xkI8VCY1x0267AKxVW8JVW5JwA2ocxC 64kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM2 8EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq 3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8w Aqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE 14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCY1x0262kKe7 AKxVWUAVWUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02 F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw 1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7Cj xVAFwI0_Gr0_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+cHJ5cmDypjQomiMHn9v5ikmkkPU4bw/pQ4a0/xWDccURLniWQ4q7dDnU5FLu+96aTNIx6G5EXMwo9mWoFKrkKqhGiGyFHmUG5Qi3I8ZSBTfj5I4RUxO5+injXLkJWRzprOLSlKulF0xtn0TCL4XfDWi1GFEK+zBXHcNf5PIAQ/ipWpR0c+MhrkhzuD8/cYvupuTwMxQnd+keJqbkj2IH wh+xVlJy LIHf+IXYr3tfarJszXMc0/qYGP2h3EArNyFIlSOBWcVZCYaFVOy6cEhj5GMnY7lnF9FQtZdfNS8haMgcrbY+Lx4D4f2N/UF+YMp/EkSwtx1SxJC+owRjaVB/lwehq3hj6zjpYrdGMI26VtT1Av3MXioaa5npyGUU7mHZZ6yIGaB8uiV5VeTBpeZLB6b2WOB5OyyKRV08k3ichafhXDfhpC/olmg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Caller of xas_squash_marks() has ensured xas->xa_sibs is non-zero. Just remove repeat check of xas->xa_sibs in xas_squash_marks(). Signed-off-by: Kemeng Shi --- lib/xarray.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/xarray.c b/lib/xarray.c index 3fac3f2cea9d..4231af284bd8 100644 --- a/lib/xarray.c +++ b/lib/xarray.c @@ -128,9 +128,6 @@ static void xas_squash_marks(const struct xa_state *xas) unsigned int mark = 0; unsigned int limit = xas->xa_offset + xas->xa_sibs + 1; - if (!xas->xa_sibs) - return; - do { unsigned long *marks = xas->xa_node->marks[mark]; if (find_next_bit(marks, limit, xas->xa_offset + 1) == limit) From patchwork Mon Nov 11 21:53:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13870700 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BBD1D2E9E5 for ; Mon, 11 Nov 2024 12:55:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E15B6B0085; Mon, 11 Nov 2024 07:55:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 71B7F6B0093; Mon, 11 Nov 2024 07:55:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5426E6B007B; Mon, 11 Nov 2024 07:55:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id CFC8F6B0085 for ; Mon, 11 Nov 2024 07:55:07 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 653B0418A1 for ; Mon, 11 Nov 2024 12:55:07 +0000 (UTC) X-FDA: 82773808152.21.5851C4C Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by imf11.hostedemail.com (Postfix) with ESMTP id 43EB340002 for ; Mon, 11 Nov 2024 12:54:11 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731329514; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YVrUUmNB/6qCylmXgGwaFI/+5BomZYbmrTRX2XpHfnA=; b=uwE75y5Ac5bvyYNtnSC06+g9rHFXkQwIseMKIkkxSJzIRTehnWB7mr6LDeNfvyrRBix5Gr 4azm1h+8y3gVRiolCK7mPQhOczj6xnLSxpr03aP7Jtt+p5N62f+q0sFSKQ59EuOU9Yqvv0 UP7dDvOEoU44tI37R0yN/czMee4/9vE= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.51 as permitted sender) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731329514; a=rsa-sha256; cv=none; b=okZir6rxDBv+DkUk5xZXTCe4T5U2gVj0GMQSg3+E8oe/hN2hXe1T0JTjMe02t8ftIHqvGY jkYm2ZTh7Z22uB67gJgUQ9LESXZf2IvzNbhrqrq0qER38LcgY7wG2JRQS8jbOg7yeHOscp jRWMLy84RBwcI1c1sQVgK+y2E73trqo= Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Xn8dc3Lrsz4f3kk6 for ; Mon, 11 Nov 2024 20:54:44 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 882151A018D for ; Mon, 11 Nov 2024 20:54:57 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.6]) by APP4 (Coremail) with SMTP id gCh0CgB3n4Oe_jFnllryBQ--.36628S7; Mon, 11 Nov 2024 20:54:57 +0800 (CST) From: Kemeng Shi To: akpm@linux-foundation.org, willy@infradead.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH RESEND V2 5/5] Xarray: use xa_mark_t in xas_squash_marks() to keep code consistent Date: Tue, 12 Nov 2024 05:53:59 +0800 Message-Id: <20241111215359.246937-6-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20241111215359.246937-1-shikemeng@huaweicloud.com> References: <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2ogGoKKi75rd0XHLSzF0yxs3jLJTMTTSa8FE0rsgTre3ZEwYx3iYK6sNv6qxzJH4ISRKWMf1jk3YR6ZVq23nsmoKRoy4BGLeg2hScZrAJ2455TqBti4KyOcEoHg6QFahAlPkFDxdbbAmh+vs1VCcqKVU4zbeS7OkqR9+TQ+8/5tLoFk/FX7aJjIqXf8guBJbYikPXMw+ kVVZZMxe bBmi2ZcGA4dhO9zWWwdEqlIBdDj1K8eyfilrtcQNKaDyu1iWhKijPzhIVz+7jNCikl3J0IqqTtQ1iqHDrMHuFM2dJ2mxt5H0XIwSaTvPVMV2m3qUATvYvx7R73J4jMDXSTEILe3V2Mp0e89UeO7gwABtGVHTEmP9At0HxX67LdTXmTfKU0f4pV8dYEfqNXegqhLQ1uqlkNPqJMWpJkamJkNHL5g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Besides xas_squash_marks(), all functions use xa_mark_t type to iterate all possible marks. Use xa_mark_t in xas_squash_marks() to keep code consistent. Signed-off-by: Kemeng Shi --- lib/xarray.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/xarray.c b/lib/xarray.c index 4231af284bd8..a74795911f1c 100644 --- a/lib/xarray.c +++ b/lib/xarray.c @@ -125,16 +125,20 @@ static inline void node_mark_all(struct xa_node *node, xa_mark_t mark) */ static void xas_squash_marks(const struct xa_state *xas) { - unsigned int mark = 0; + xa_mark_t mark = 0; unsigned int limit = xas->xa_offset + xas->xa_sibs + 1; - do { - unsigned long *marks = xas->xa_node->marks[mark]; - if (find_next_bit(marks, limit, xas->xa_offset + 1) == limit) - continue; - __set_bit(xas->xa_offset, marks); - bitmap_clear(marks, xas->xa_offset + 1, xas->xa_sibs); - } while (mark++ != (__force unsigned)XA_MARK_MAX); + for (;;) { + unsigned long *marks = node_marks(xas->xa_node, mark); + + if (find_next_bit(marks, limit, xas->xa_offset + 1) != limit) { + __set_bit(xas->xa_offset, marks); + bitmap_clear(marks, xas->xa_offset + 1, xas->xa_sibs); + } + if (mark == XA_MARK_MAX) + break; + mark_inc(mark); + } } /* extracts the offset within this node from the index */