From patchwork Wed May 10 06:10:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 91896 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3400148vqo; Tue, 9 May 2023 23:23:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5JAwfvla6sGt5f/M1GLPBaMlCM4kKAg4OwIgsNcLGX9tjzdA1oZgWfeYkqkGC3rdCWTu9o X-Received: by 2002:a05:6a21:6d9f:b0:100:b8fc:8c6c with SMTP id wl31-20020a056a216d9f00b00100b8fc8c6cmr10410806pzb.19.1683699789418; Tue, 09 May 2023 23:23:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683699789; cv=none; d=google.com; s=arc-20160816; b=xD3hMC538xL+5G+krQJzjvjzwW4wQLQe1/eDUdyReGT3z4M/1x43l8pg+0S1+ej1AT UUCHFxQrsILUvDZ4hSCGka6MuBKLN2UqLtBG498FHr5Kt+shMCO3f3dlk8ld+SUJQEzj F8OOks2z4PBNtvEekKC3cz/Q00LhdwRmELUW1FwCe8fs5fbs2E7uBcWAZxbU9f8GFdTU 94WX2Q61b56RYU8z8MgPTxZc//dVnkuNxGCpXv9lqbKKAy68ZL5yUIsv37rlR9D3f/h3 3uLNsJlC6BCdkBnEy9sMs77SFKbj26u1G9kBVyBFL4VuPDsWksnF++hMJrmFn3APJJvK K6Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=EveqtihCJt7fcxXdeINag7+zgOnp1O/guDL1F4v1dKU=; b=uZtV4za4QMLLzOcbsuhzogjt+i3GL/5zfodtRlcTO+xdCy/AGmRm9sYBuoo9f4gAmM jSWfr5nbb2eA2wUR+ebi4f1E2V9RSl7fKXQbOGP38yT4DmkKXSpJGq0Rl2JcedCsHzJ+ fO6a/zfWEnZVivIO22u1Fot7NFDSKzZ3qrHl9Q2kcm0sJuxBKeY68nJ1Il1nGleOODw2 PFHV4znR/0nC5gqWty72qzFWVMIAsnNiMRvZavBf5UO6tIlF2EmY65YlNac3cxFurOCV eaolot1Nle8uxUOwz938ZbUKXx+zoYZNWBIdI4c7ycOjIZjTFHUGWKFFrk7JTTVZF8yZ uu6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=gpLKjC+P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x24-20020a63db58000000b0052161765a25si3406693pgi.288.2023.05.09.23.22.55; Tue, 09 May 2023 23:23:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=gpLKjC+P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235873AbjEJGL6 (ORCPT + 99 others); Wed, 10 May 2023 02:11:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235676AbjEJGL4 (ORCPT ); Wed, 10 May 2023 02:11:56 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38B621BD7 for ; Tue, 9 May 2023 23:11:31 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-64389a44895so5551635b3a.1 for ; Tue, 09 May 2023 23:11:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1683699090; x=1686291090; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=EveqtihCJt7fcxXdeINag7+zgOnp1O/guDL1F4v1dKU=; b=gpLKjC+Pc646aikfwZbwfDgLcMm2FVJTiwwnMi35Hm39czV66fS8SZyARAVBeAditt OKSU+eQ6aRBnSjX/1XexuoIw4bRyUHN8bP7vdZejG43/PLnwlTaEQgp2PhUkvubZ0LO1 MBx9Q4oMHxNxES4P02pTtK67PajIYvYqHNKvmy0kaUMkSlX8+hGL/7gG7pBcRONzshXK iC+KU0Qy/dhgta1s8bv1ZfFg38KunrwTdgMaOxNk8ThUD/tXUl3Xp05/MXB8Sak4kMpO kIzhZMVMc3jnTvCF9n8lWbHnEtRgZwQMkPVc/iUcu+xfouov/z2r0pTS8jt5LGGbgbNS kRNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683699090; x=1686291090; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EveqtihCJt7fcxXdeINag7+zgOnp1O/guDL1F4v1dKU=; b=J86UeiEqZaYuR/tr7w35Qg+P0g20g8SSUxRav7SkXBmTe+6eOLpSaDxqmZyyMIt0DY Wt9wsKJCFu6HfrMklranOnhXXkBmOPcVScggmK9URV7KpdJT8WmPSxhzjb8QyIkXI1LK cAEY0hA6cXuaU9Xu7YlIiqJMAa+SFmxAEhmR4NBjyWji0+nRYm+LxoOAmUMv3i/kCADx ol+DC/zRWcGVRSRSXtIl5otToPpc+Ty0jUlvyL33ntrN7X0hcs+I0uEdHGzL2FiJySvf /VjDGhBgOPY4nw9rsJgTqK6R6/EoJuYVfnlxaVFomtNFwDlDvKj+YQMLraL/S6OfWQ1L PMyA== X-Gm-Message-State: AC+VfDzhIDP25imFeFeLFaE6vuB0xo01obPHuJb2I+ScNZ+ynHnV7rA9 l9Ng6TvaO5T0fs/y2gY/jYbZq8TVFuseDldx0wE= X-Received: by 2002:a17:902:ce8d:b0:1ac:2c8b:a0da with SMTP id f13-20020a170902ce8d00b001ac2c8ba0damr21092890plg.51.1683699090367; Tue, 09 May 2023 23:11:30 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.232]) by smtp.gmail.com with ESMTPSA id j2-20020a170902da8200b001ab19724f64sm2814159plx.38.2023.05.09.23.11.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 May 2023 23:11:30 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH 1/2] maple_tree: Drop the test code for mtree_alloc_{range,rrange}() Date: Wed, 10 May 2023 14:10:48 +0800 Message-Id: <20230510061049.53977-1-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765487190759311459?= X-GMAIL-MSGID: =?utf-8?q?1765487190759311459?= Drop the test code for mtree_alloc_{range,rrange}() because we are going to drop them. Signed-off-by: Peng Zhang --- lib/test_maple_tree.c | 389 ------------------------------------------ 1 file changed, 389 deletions(-) diff --git a/lib/test_maple_tree.c b/lib/test_maple_tree.c index 9939be34e516e..86d7f742d243e 100644 --- a/lib/test_maple_tree.c +++ b/lib/test_maple_tree.c @@ -97,42 +97,6 @@ static void __init *mtree_test_erase(struct maple_tree *mt, unsigned long index) return mtree_erase(mt, index); } -#if defined(CONFIG_64BIT) -static noinline void __init check_mtree_alloc_range(struct maple_tree *mt, - unsigned long start, unsigned long end, unsigned long size, - unsigned long expected, int eret, void *ptr) -{ - - unsigned long result = expected + 1; - int ret; - - ret = mtree_alloc_range(mt, &result, ptr, size, start, end, - GFP_KERNEL); - MT_BUG_ON(mt, ret != eret); - if (ret) - return; - - MT_BUG_ON(mt, result != expected); -} - -static noinline void __init check_mtree_alloc_rrange(struct maple_tree *mt, - unsigned long start, unsigned long end, unsigned long size, - unsigned long expected, int eret, void *ptr) -{ - - unsigned long result = expected + 1; - int ret; - - ret = mtree_alloc_rrange(mt, &result, ptr, size, start, end, - GFP_KERNEL); - MT_BUG_ON(mt, ret != eret); - if (ret) - return; - - MT_BUG_ON(mt, result != expected); -} -#endif - static noinline void __init check_load(struct maple_tree *mt, unsigned long index, void *ptr) { @@ -635,348 +599,6 @@ static noinline void __init check_find_2(struct maple_tree *mt) /*MT_BUG_ON(mt, !mtree_empty(mt)); */ } - -#if defined(CONFIG_64BIT) -static noinline void __init check_alloc_rev_range(struct maple_tree *mt) -{ - /* - * Generated by: - * cat /proc/self/maps | awk '{print $1}'| - * awk -F "-" '{printf "0x%s, 0x%s, ", $1, $2}' - */ - - static const unsigned long range[] = { - /* Inclusive , Exclusive. */ - 0x565234af2000, 0x565234af4000, - 0x565234af4000, 0x565234af9000, - 0x565234af9000, 0x565234afb000, - 0x565234afc000, 0x565234afd000, - 0x565234afd000, 0x565234afe000, - 0x565235def000, 0x565235e10000, - 0x7f36d4bfd000, 0x7f36d4ee2000, - 0x7f36d4ee2000, 0x7f36d4f04000, - 0x7f36d4f04000, 0x7f36d504c000, - 0x7f36d504c000, 0x7f36d5098000, - 0x7f36d5098000, 0x7f36d5099000, - 0x7f36d5099000, 0x7f36d509d000, - 0x7f36d509d000, 0x7f36d509f000, - 0x7f36d509f000, 0x7f36d50a5000, - 0x7f36d50b9000, 0x7f36d50db000, - 0x7f36d50db000, 0x7f36d50dc000, - 0x7f36d50dc000, 0x7f36d50fa000, - 0x7f36d50fa000, 0x7f36d5102000, - 0x7f36d5102000, 0x7f36d5103000, - 0x7f36d5103000, 0x7f36d5104000, - 0x7f36d5104000, 0x7f36d5105000, - 0x7fff5876b000, 0x7fff5878d000, - 0x7fff5878e000, 0x7fff58791000, - 0x7fff58791000, 0x7fff58793000, - }; - - static const unsigned long holes[] = { - /* - * Note: start of hole is INCLUSIVE - * end of hole is EXCLUSIVE - * (opposite of the above table.) - * Start of hole, end of hole, size of hole (+1) - */ - 0x565234afb000, 0x565234afc000, 0x1000, - 0x565234afe000, 0x565235def000, 0x12F1000, - 0x565235e10000, 0x7f36d4bfd000, 0x28E49EDED000, - }; - - /* - * req_range consists of 4 values. - * 1. min index - * 2. max index - * 3. size - * 4. number that should be returned. - * 5. return value - */ - static const unsigned long req_range[] = { - 0x565234af9000, /* Min */ - 0x7fff58791000, /* Max */ - 0x1000, /* Size */ - 0x7fff5878d << 12, /* First rev hole of size 0x1000 */ - 0, /* Return value success. */ - - 0x0, /* Min */ - 0x565234AF0 << 12, /* Max */ - 0x3000, /* Size */ - 0x565234AEE << 12, /* max - 3. */ - 0, /* Return value success. */ - - 0x0, /* Min */ - -1, /* Max */ - 0x1000, /* Size */ - 562949953421311 << 12,/* First rev hole of size 0x1000 */ - 0, /* Return value success. */ - - 0x0, /* Min */ - 0x7F36D5109 << 12, /* Max */ - 0x4000, /* Size */ - 0x7F36D5106 << 12, /* First rev hole of size 0x4000 */ - 0, /* Return value success. */ - - /* Ascend test. */ - 0x0, - 34148798628 << 12, - 19 << 12, - 34148797418 << 12, - 0x0, - - /* Too big test. */ - 0x0, - 18446744073709551615UL, - 562915594369134UL << 12, - 0x0, - -EBUSY, - - /* Single space test. */ - 34148798725 << 12, - 34148798725 << 12, - 1 << 12, - 34148798725 << 12, - 0, - }; - - int i, range_count = ARRAY_SIZE(range); - int req_range_count = ARRAY_SIZE(req_range); - unsigned long min = 0; - - MA_STATE(mas, mt, 0, 0); - - mtree_store_range(mt, MTREE_ALLOC_MAX, ULONG_MAX, XA_ZERO_ENTRY, - GFP_KERNEL); -#define DEBUG_REV_RANGE 0 - for (i = 0; i < range_count; i += 2) { - /* Inclusive, Inclusive (with the -1) */ - -#if DEBUG_REV_RANGE - pr_debug("\t%s: Insert %lu-%lu\n", __func__, range[i] >> 12, - (range[i + 1] >> 12) - 1); -#endif - check_insert_range(mt, range[i] >> 12, (range[i + 1] >> 12) - 1, - xa_mk_value(range[i] >> 12), 0); - mt_validate(mt); - } - - - mas_lock(&mas); - for (i = 0; i < ARRAY_SIZE(holes); i += 3) { -#if DEBUG_REV_RANGE - pr_debug("Search from %lu-%lu for gap %lu should be at %lu\n", - min, holes[i+1]>>12, holes[i+2]>>12, - holes[i] >> 12); -#endif - MT_BUG_ON(mt, mas_empty_area_rev(&mas, min, - holes[i+1] >> 12, - holes[i+2] >> 12)); -#if DEBUG_REV_RANGE - pr_debug("Found %lu %lu\n", mas.index, mas.last); - pr_debug("gap %lu %lu\n", (holes[i] >> 12), - (holes[i+1] >> 12)); -#endif - MT_BUG_ON(mt, mas.last + 1 != (holes[i+1] >> 12)); - MT_BUG_ON(mt, mas.index != (holes[i+1] >> 12) - (holes[i+2] >> 12)); - min = holes[i+1] >> 12; - mas_reset(&mas); - } - - mas_unlock(&mas); - for (i = 0; i < req_range_count; i += 5) { -#if DEBUG_REV_RANGE - pr_debug("\tReverse request %d between %lu-%lu size %lu, should get %lu\n", - i, req_range[i] >> 12, - (req_range[i + 1] >> 12), - req_range[i+2] >> 12, - req_range[i+3] >> 12); -#endif - check_mtree_alloc_rrange(mt, - req_range[i] >> 12, /* start */ - req_range[i+1] >> 12, /* end */ - req_range[i+2] >> 12, /* size */ - req_range[i+3] >> 12, /* expected address */ - req_range[i+4], /* expected return */ - xa_mk_value(req_range[i] >> 12)); /* pointer */ - mt_validate(mt); - } - - mt_set_non_kernel(1); - mtree_erase(mt, 34148798727); /* create a deleted range. */ - mtree_erase(mt, 34148798725); - check_mtree_alloc_rrange(mt, 0, 34359052173, 210253414, - 34148798725, 0, mt); - - mtree_destroy(mt); -} - -static noinline void __init check_alloc_range(struct maple_tree *mt) -{ - /* - * Generated by: - * cat /proc/self/maps|awk '{print $1}'| - * awk -F "-" '{printf "0x%s, 0x%s, ", $1, $2}' - */ - - static const unsigned long range[] = { - /* Inclusive , Exclusive. */ - 0x565234af2000, 0x565234af4000, - 0x565234af4000, 0x565234af9000, - 0x565234af9000, 0x565234afb000, - 0x565234afc000, 0x565234afd000, - 0x565234afd000, 0x565234afe000, - 0x565235def000, 0x565235e10000, - 0x7f36d4bfd000, 0x7f36d4ee2000, - 0x7f36d4ee2000, 0x7f36d4f04000, - 0x7f36d4f04000, 0x7f36d504c000, - 0x7f36d504c000, 0x7f36d5098000, - 0x7f36d5098000, 0x7f36d5099000, - 0x7f36d5099000, 0x7f36d509d000, - 0x7f36d509d000, 0x7f36d509f000, - 0x7f36d509f000, 0x7f36d50a5000, - 0x7f36d50b9000, 0x7f36d50db000, - 0x7f36d50db000, 0x7f36d50dc000, - 0x7f36d50dc000, 0x7f36d50fa000, - 0x7f36d50fa000, 0x7f36d5102000, - 0x7f36d5102000, 0x7f36d5103000, - 0x7f36d5103000, 0x7f36d5104000, - 0x7f36d5104000, 0x7f36d5105000, - 0x7fff5876b000, 0x7fff5878d000, - 0x7fff5878e000, 0x7fff58791000, - 0x7fff58791000, 0x7fff58793000, - }; - static const unsigned long holes[] = { - /* Start of hole, end of hole, size of hole (+1) */ - 0x565234afb000, 0x565234afc000, 0x1000, - 0x565234afe000, 0x565235def000, 0x12F1000, - 0x565235e10000, 0x7f36d4bfd000, 0x28E49EDED000, - }; - - /* - * req_range consists of 4 values. - * 1. min index - * 2. max index - * 3. size - * 4. number that should be returned. - * 5. return value - */ - static const unsigned long req_range[] = { - 0x565234af9000, /* Min */ - 0x7fff58791000, /* Max */ - 0x1000, /* Size */ - 0x565234afb000, /* First hole in our data of size 1000. */ - 0, /* Return value success. */ - - 0x0, /* Min */ - 0x7fff58791000, /* Max */ - 0x1F00, /* Size */ - 0x0, /* First hole in our data of size 2000. */ - 0, /* Return value success. */ - - /* Test ascend. */ - 34148797436 << 12, /* Min */ - 0x7fff587AF000, /* Max */ - 0x3000, /* Size */ - 34148798629 << 12, /* Expected location */ - 0, /* Return value success. */ - - /* Test failing. */ - 34148798623 << 12, /* Min */ - 34148798683 << 12, /* Max */ - 0x15000, /* Size */ - 0, /* Expected location */ - -EBUSY, /* Return value failed. */ - - /* Test filling entire gap. */ - 34148798623 << 12, /* Min */ - 0x7fff587AF000, /* Max */ - 0x10000, /* Size */ - 34148798632 << 12, /* Expected location */ - 0, /* Return value success. */ - - /* Test walking off the end of root. */ - 0, /* Min */ - -1, /* Max */ - -1, /* Size */ - 0, /* Expected location */ - -EBUSY, /* Return value failure. */ - - /* Test looking for too large a hole across entire range. */ - 0, /* Min */ - -1, /* Max */ - 4503599618982063UL << 12, /* Size */ - 34359052178 << 12, /* Expected location */ - -EBUSY, /* Return failure. */ - - /* Test a single entry */ - 34148798648 << 12, /* Min */ - 34148798648 << 12, /* Max */ - 4096, /* Size of 1 */ - 34148798648 << 12, /* Location is the same as min/max */ - 0, /* Success */ - }; - int i, range_count = ARRAY_SIZE(range); - int req_range_count = ARRAY_SIZE(req_range); - unsigned long min = 0x565234af2000; - MA_STATE(mas, mt, 0, 0); - - mtree_store_range(mt, MTREE_ALLOC_MAX, ULONG_MAX, XA_ZERO_ENTRY, - GFP_KERNEL); - for (i = 0; i < range_count; i += 2) { -#define DEBUG_ALLOC_RANGE 0 -#if DEBUG_ALLOC_RANGE - pr_debug("\tInsert %lu-%lu\n", range[i] >> 12, - (range[i + 1] >> 12) - 1); - mt_dump(mt, mt_dump_hex); -#endif - check_insert_range(mt, range[i] >> 12, (range[i + 1] >> 12) - 1, - xa_mk_value(range[i] >> 12), 0); - mt_validate(mt); - } - - - - mas_lock(&mas); - for (i = 0; i < ARRAY_SIZE(holes); i += 3) { - -#if DEBUG_ALLOC_RANGE - pr_debug("\tGet empty %lu-%lu size %lu (%lx-%lx)\n", min >> 12, - holes[i+1] >> 12, holes[i+2] >> 12, - min, holes[i+1]); -#endif - MT_BUG_ON(mt, mas_empty_area(&mas, min >> 12, - holes[i+1] >> 12, - holes[i+2] >> 12)); - MT_BUG_ON(mt, mas.index != holes[i] >> 12); - min = holes[i+1]; - mas_reset(&mas); - } - mas_unlock(&mas); - for (i = 0; i < req_range_count; i += 5) { -#if DEBUG_ALLOC_RANGE - pr_debug("\tTest %d: %lu-%lu size %lu expected %lu (%lu-%lu)\n", - i/5, req_range[i] >> 12, req_range[i + 1] >> 12, - req_range[i + 2] >> 12, req_range[i + 3] >> 12, - req_range[i], req_range[i+1]); -#endif - check_mtree_alloc_range(mt, - req_range[i] >> 12, /* start */ - req_range[i+1] >> 12, /* end */ - req_range[i+2] >> 12, /* size */ - req_range[i+3] >> 12, /* expected address */ - req_range[i+4], /* expected return */ - xa_mk_value(req_range[i] >> 12)); /* pointer */ - mt_validate(mt); -#if DEBUG_ALLOC_RANGE - mt_dump(mt, mt_dump_hex); -#endif - } - - mtree_destroy(mt); -} -#endif - static noinline void __init check_ranges(struct maple_tree *mt) { int i, val, val2; @@ -3448,17 +3070,6 @@ static int __init maple_tree_seed(void) check_ranges(&tree); mtree_destroy(&tree); -#if defined(CONFIG_64BIT) - /* These tests have ranges outside of 4GB */ - mt_init_flags(&tree, MT_FLAGS_ALLOC_RANGE); - check_alloc_range(&tree); - mtree_destroy(&tree); - - mt_init_flags(&tree, MT_FLAGS_ALLOC_RANGE); - check_alloc_rev_range(&tree); - mtree_destroy(&tree); -#endif - mt_init_flags(&tree, 0); check_load(&tree, set[0], NULL); /* See if 5015 -> NULL */ From patchwork Wed May 10 06:10:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 91895 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3399015vqo; Tue, 9 May 2023 23:20:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ57/dHM1Ipojt9drfD4OnNTUzyuXUx1ms4U/XDJ6n4BukuKo/S89yXkKt5es7py2ExySR+3 X-Received: by 2002:a17:902:f543:b0:1ac:6084:1f4 with SMTP id h3-20020a170902f54300b001ac608401f4mr18208421plf.27.1683699610865; Tue, 09 May 2023 23:20:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683699610; cv=none; d=google.com; s=arc-20160816; b=MJ8JhV2Z+Sftb3g6pqqOWcqKKb8Vh8Ako9trm2TLtjhhTe9S14SPnta6qSU1kSfQRP ytf8JvXP5kMpL6+xpOGa22wYHYfyg0WPwjh9D41vQcmW5GDF/E67L/4RGoqivy6W0KAU zgKfX9Do3L/F1hwss1O6Y+iyIWzLyvidY2XFygLEEBosSOfTOE6yBfZjzj7SIrb/nt5i w1z9SZiAgO/ihbNmnOMcErOz6REMjXUiSbwQL59PP6taNmVgUVfaEJWVf7guD6Wt4K8y xBWqFxa+/HX3bEN6F9GEg3bSgBGML2fGnQk+000oiLAS2ox2XiljH60eFvTvdekfEgWj OvTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Vx0UmPiglxMBycN8p78aITZtdcFTRru0fYxYXq+j1cE=; b=L1ukg+e7cQcigHHKFTHTPVY01gUwMF1xJHnTnCcjS5dh7cXpSuHS73L882a1jkDFjR XurNIP+C7V6JOStiFGPv0KAH6ghjrLbqRQAr38vNWEHssMLUoGOq7O+TuuE01l5+9pKa NkqhJlkcD7SfBHWKyQp+D9hLDKMeVuLmExu6R1ZLAQY39JaeiXYNcat0Q1D/zeaYgFgf i2rrp5aqOkS68ZdBdn0jGQeUIwdWVkzkw0pH/eFCUneFzvrQP854XR4mTgUywkYh0TVK 1lgWacXhgaaNuRSBBLL71gSpTgTmM1nxU4K64PhIElG72h1w2uCXUjx85BICuWQXxwA0 6BEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=fcgifp2z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u4-20020a17090341c400b001a96b39bb35si3645382ple.439.2023.05.09.23.19.57; Tue, 09 May 2023 23:20:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=fcgifp2z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235824AbjEJGLk (ORCPT + 99 others); Wed, 10 May 2023 02:11:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230188AbjEJGLi (ORCPT ); Wed, 10 May 2023 02:11:38 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF209195 for ; Tue, 9 May 2023 23:11:34 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1aad55244b7so52109115ad.2 for ; Tue, 09 May 2023 23:11:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1683699094; x=1686291094; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Vx0UmPiglxMBycN8p78aITZtdcFTRru0fYxYXq+j1cE=; b=fcgifp2zw/Gegdr5FvAbRDbAp0tmxTchx+/eA/Wy9E8eRmA/NBtx58jxefDu9Ya5TH F3O5wY3AtCcG6R7i5nNQ+/bW6nGu76pxmEnV46lTl3q/EWYSCHSEIZTExV5yqZTt3rh1 QLqUQ7obM00S5II8+1gmjinCGePCq3juH60BWi26ECtAuQ3UweDnmbBn83dY1SWSuTDF Qnf7ptsn0rM75J80a+52lmH2yskaNlhY292ccYIx4lmSmU27s5g6lwKYbxKBey+Xq9/y dRZjDTAe/1itAX7BhqCvuiV6EWBL3MIXjZKxNbww9qxkqrCgUtjKOFev+PZEtHmm/35I +3FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683699094; x=1686291094; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Vx0UmPiglxMBycN8p78aITZtdcFTRru0fYxYXq+j1cE=; b=QxCj6IrXrkHXGSPsfDIApGNXGei8m8L4AqCLv6XlmyQsWIAbEK4xGdaaG2cNa7AjdE 8Q0cPwzESa3qPQvRLXSAad3y9mNQG0rQGVrha/ME5Mr2zkiEVEI/ELeLeRPXCHrB2EVc YkC6aB8pW8GqPd1Hnd4VHT+tYNZLPdUawyNfYY+kCkogv+B8nMBMKZk9g303OMdv4RB6 sWLyRT7hE/oTr8yKMdggPgB6Tzv6jRAtbd5zxgwk1k1nqu0VXdGge9TwpJbU0zXvbhFr IoqtLjMY5ADVasLjt6NPLLnjDxPw2ymHIXpHwiPq5n3I1ajYXRRv+c+aegwVpDuAPvuf ODdw== X-Gm-Message-State: AC+VfDwZ/tNqOkmz3nim/0LH5L6Tdmixf5Ss+wzJ54Jwg5CNWiPZeIm6 niJvIFuvkdgfdz3CoSsGFagVDg== X-Received: by 2002:a17:902:f683:b0:1ac:8148:8c40 with SMTP id l3-20020a170902f68300b001ac81488c40mr11127867plg.53.1683699094081; Tue, 09 May 2023 23:11:34 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.232]) by smtp.gmail.com with ESMTPSA id j2-20020a170902da8200b001ab19724f64sm2814159plx.38.2023.05.09.23.11.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 May 2023 23:11:33 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH 2/2] maple_tree: Drop mtree_alloc_{range,rrange}() and related functions. Date: Wed, 10 May 2023 14:10:49 +0800 Message-Id: <20230510061049.53977-2-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230510061049.53977-1-zhangpeng.00@bytedance.com> References: <20230510061049.53977-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765487003032594868?= X-GMAIL-MSGID: =?utf-8?q?1765487003032594868?= Drop mtree_alloc_{range,rrange}(), mas_alloc() and mas_fill_gap(). mtree_alloc_{range,rrange}() currently have no users and can be easily implemented with mas_empty_area{_rev}(). mas_alloc() and mas_fill_gap() are just their internal functions, drop them together. Signed-off-by: Peng Zhang --- include/linux/maple_tree.h | 7 -- lib/maple_tree.c | 177 ------------------------------------- 2 files changed, 184 deletions(-) diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index 542b09118a09f..3dd6edccf83af 100644 --- a/include/linux/maple_tree.h +++ b/include/linux/maple_tree.h @@ -306,13 +306,6 @@ int mtree_insert(struct maple_tree *mt, unsigned long index, void *entry, gfp_t gfp); int mtree_insert_range(struct maple_tree *mt, unsigned long first, unsigned long last, void *entry, gfp_t gfp); -int mtree_alloc_range(struct maple_tree *mt, unsigned long *startp, - void *entry, unsigned long size, unsigned long min, - unsigned long max, gfp_t gfp); -int mtree_alloc_rrange(struct maple_tree *mt, unsigned long *startp, - void *entry, unsigned long size, unsigned long min, - unsigned long max, gfp_t gfp); - int mtree_store_range(struct maple_tree *mt, unsigned long first, unsigned long last, void *entry, gfp_t gfp); int mtree_store(struct maple_tree *mt, unsigned long index, diff --git a/lib/maple_tree.c b/lib/maple_tree.c index b37065a6f570d..49dfe81dfa1b6 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -5120,46 +5120,6 @@ static inline void mas_awalk(struct ma_state *mas, unsigned long size) } } -/* - * mas_fill_gap() - Fill a located gap with @entry. - * @mas: The maple state - * @entry: The value to store - * @slot: The offset into the node to store the @entry - * @size: The size of the entry - * @index: The start location - */ -static inline void mas_fill_gap(struct ma_state *mas, void *entry, - unsigned char slot, unsigned long size, unsigned long *index) -{ - MA_WR_STATE(wr_mas, mas, entry); - unsigned char pslot = mte_parent_slot(mas->node); - struct maple_enode *mn = mas->node; - unsigned long *pivots; - enum maple_type ptype; - /* - * mas->index is the start address for the search - * which may no longer be needed. - * mas->last is the end address for the search - */ - - *index = mas->index; - mas->last = mas->index + size - 1; - - /* - * It is possible that using mas->max and mas->min to correctly - * calculate the index and last will cause an issue in the gap - * calculation, so fix the ma_state here - */ - mas_ascend(mas); - ptype = mte_node_type(mas->node); - pivots = ma_pivots(mas_mn(mas), ptype); - mas->max = mas_safe_pivot(mas, pivots, pslot, ptype); - mas->min = mas_safe_min(mas, pivots, pslot); - mas->node = mn; - mas->offset = slot; - mas_wr_store_entry(&wr_mas); -} - /* * mas_sparse_area() - Internal function. Return upper or lower limit when * searching for a gap in an empty tree. @@ -5307,74 +5267,6 @@ int mas_empty_area_rev(struct ma_state *mas, unsigned long min, } EXPORT_SYMBOL_GPL(mas_empty_area_rev); -static inline int mas_alloc(struct ma_state *mas, void *entry, - unsigned long size, unsigned long *index) -{ - unsigned long min; - - mas_start(mas); - if (mas_is_none(mas) || mas_is_ptr(mas)) { - mas_root_expand(mas, entry); - if (mas_is_err(mas)) - return xa_err(mas->node); - - if (!mas->index) - return mas_pivot(mas, 0); - return mas_pivot(mas, 1); - } - - /* Must be walking a tree. */ - mas_awalk(mas, size); - if (mas_is_err(mas)) - return xa_err(mas->node); - - if (mas->offset == MAPLE_NODE_SLOTS) - goto no_gap; - - /* - * At this point, mas->node points to the right node and we have an - * offset that has a sufficient gap. - */ - min = mas->min; - if (mas->offset) - min = mas_pivot(mas, mas->offset - 1) + 1; - - if (mas_is_err(mas)) - return xa_err(mas->node); - - if (mas->index < min) - mas->index = min; - - mas_fill_gap(mas, entry, mas->offset, size, index); - return 0; - -no_gap: - return -EBUSY; -} - -static inline int mas_rev_alloc(struct ma_state *mas, unsigned long min, - unsigned long max, void *entry, - unsigned long size, unsigned long *index) -{ - int ret = 0; - - ret = mas_empty_area_rev(mas, min, max, size); - if (ret) - return ret; - - if (mas_is_err(mas)) - return xa_err(mas->node); - - if (mas->offset == MAPLE_NODE_SLOTS) - goto no_gap; - - mas_fill_gap(mas, entry, mas->offset, size, index); - return 0; - -no_gap: - return -EBUSY; -} - /* * mte_dead_leaves() - Mark all leaves of a node as dead. * @mas: The maple state @@ -6481,75 +6373,6 @@ int mtree_insert(struct maple_tree *mt, unsigned long index, void *entry, } EXPORT_SYMBOL(mtree_insert); -int mtree_alloc_range(struct maple_tree *mt, unsigned long *startp, - void *entry, unsigned long size, unsigned long min, - unsigned long max, gfp_t gfp) -{ - int ret = 0; - - MA_STATE(mas, mt, min, min); - if (!mt_is_alloc(mt)) - return -EINVAL; - - if (WARN_ON_ONCE(mt_is_reserved(entry))) - return -EINVAL; - - if (min > max) - return -EINVAL; - - if (max < size) - return -EINVAL; - - if (!size) - return -EINVAL; - - mtree_lock(mt); -retry: - mas.offset = 0; - mas.index = min; - mas.last = max - size + 1; - ret = mas_alloc(&mas, entry, size, startp); - if (mas_nomem(&mas, gfp)) - goto retry; - - mtree_unlock(mt); - return ret; -} -EXPORT_SYMBOL(mtree_alloc_range); - -int mtree_alloc_rrange(struct maple_tree *mt, unsigned long *startp, - void *entry, unsigned long size, unsigned long min, - unsigned long max, gfp_t gfp) -{ - int ret = 0; - - MA_STATE(mas, mt, min, max - size + 1); - if (!mt_is_alloc(mt)) - return -EINVAL; - - if (WARN_ON_ONCE(mt_is_reserved(entry))) - return -EINVAL; - - if (min > max) - return -EINVAL; - - if (max < size - 1) - return -EINVAL; - - if (!size) - return -EINVAL; - - mtree_lock(mt); -retry: - ret = mas_rev_alloc(&mas, min, max, entry, size, startp); - if (mas_nomem(&mas, gfp)) - goto retry; - - mtree_unlock(mt); - return ret; -} -EXPORT_SYMBOL(mtree_alloc_rrange); - /** * mtree_erase() - Find an index and erase the entire range. * @mt: The maple tree