From patchwork Mon May 22 05:06: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: 97022 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1214782vqo; Sun, 21 May 2023 22:14:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ey+D0v1A+S3FVBxzaCP0VVt3nQgX6s8PRIfyr5Tx/GIi8LUdYohbegL1rJ2jC448UzORC X-Received: by 2002:a17:902:d382:b0:19d:1bc1:ce22 with SMTP id e2-20020a170902d38200b0019d1bc1ce22mr9688114pld.5.1684732462164; Sun, 21 May 2023 22:14:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684732462; cv=none; d=google.com; s=arc-20160816; b=B4Yz/B7ASz8giaCNINdDG+d+ty+9aHogNCuH2XVAvArLcVuIMC0WsI6J0eLTFGytoB h0vAFE6GQs8NTVDvWMAKD3m+/jxzkjYau4nZJDS/cdRS9xer5QCdpdaad6XF3WII99/A 6EtabVq4V9X9GtLhFIK9t9NqQchcPlLQjsK5YhNWzUZ0mX/Tum5oYdSdOPU3FLPWukVS WmOzQoE6uqne7koKT5MVaV+xurrQxpcB66TwJm9wLBoqg8dl5coWZDzGkWMPksJMiqs8 6UJRz5garMN9Zm5B0AVj63LP/qa/9KD6OsO53030iRQhJlUpIg9jjW54fwgqmvrOvhDn tt0Q== 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=8amRkLtdnjVq9cbmGyv8etEjiXwBdz+ISKHsxqN16tA=; b=lmb3b73cxartTjpL5mjYAQJvViTjpxf0z4HC2Ld03So1lZntfqaWsrCazZ74FzKIBg 9PqwfXTpWXLN725FsIf8UAwXDrSJ1sejGNUneTxlryg9nsRRPfqXNvYh4T7ZT8VZqClT jjCIUS4K+u0Xg6NwU1PfswYk/4tPlI0i4N9vJDz4To3WjVp5cqwKsGcqWBYEhsBYP0kh s9WbZ4l7+ow2JRyaJSLNLkCMEcAc2TvijguqQi4B5fArR9EFqI04AguGHx7M+/EDd8mi BubsteIx4h+GGCz0Ev+dB27obOnPsOymgF0PaJuST5A1lLVcGxo9/FbB/QU1MYpSRt9E +tXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="GYE7/eh3"; 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 iz11-20020a170902ef8b00b001a980a2b405si3818517plb.471.2023.05.21.22.14.04; Sun, 21 May 2023 22:14:22 -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="GYE7/eh3"; 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 S231767AbjEVFHy (ORCPT + 99 others); Mon, 22 May 2023 01:07:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231734AbjEVFHr (ORCPT ); Mon, 22 May 2023 01:07:47 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A706592 for ; Sun, 21 May 2023 22:07:24 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-64d15660784so2906667b3a.0 for ; Sun, 21 May 2023 22:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684732044; x=1687324044; 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=8amRkLtdnjVq9cbmGyv8etEjiXwBdz+ISKHsxqN16tA=; b=GYE7/eh3Hqti3Du8XPZUomicyjqafnfRSVXMJgGIMFX6+SBScSqdwET8DvURyQAI25 A2eaYMWJDwWyiQ/yLWt/12vUSj6bzkTk+pGFfX8gf+yVtmaOuB1FxffF70FUjmpqTzA9 lU0TUqzND5gyGUb0yKeIQJRajq4+VN2W1jz/CsH9wkCLeVYW5gqLkCAnJanNMSasF/uU O8hpWEr2WtH/xMH1UAsDv43QHtp1r+L/SgUI5S5gEN4rskUkm/mEGMOt2LBfYeUiKTBX sc9hVVsA3HUHuvjjFUGzixiTj+Q9J+BBY3yvg5bd5a9gEihrq+709FCyt5O91kotDEH2 G/6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684732044; x=1687324044; 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=8amRkLtdnjVq9cbmGyv8etEjiXwBdz+ISKHsxqN16tA=; b=XbwQScZwzJwh82qLgsej/xfEWSsLpGngFOfZT4aX1vtnKdpLInjGZDn89/tPW3qz0W 3YfIyHblBoV+4Xu5YhxGbuLBoI/90tbezdxi5+I1erB+LoQ9yac3dFOPffm1exx70Xbh nF2kL0reFrUe4RYjYYEJrpYxCmTBVRbC4AnY/nZQQlPT5/JYaiFfUHbgfNTW+n8RLCw9 DV0HNkcMomZUPy8XQJ8FD+f8G3JFXyuJ7bwCsuH3y3TVBsjg0/y2cxeQIwgPrhqUB2Z/ gtukROO+il16qoEb/lhhixlxZGJQ29FlwTRgXk671KQgMYKQfE9Rs0cKMTuydeUyS0e1 rzMg== X-Gm-Message-State: AC+VfDxtg1fDDCfJlGzgft5OuyknsgtVc5LLqQTMXyWN2dKrViz+bCMj TtzZOkUSP6aReJ/4D7Ps1zn7W4xWG/SjSdZSiSo= X-Received: by 2002:a05:6a00:1882:b0:64d:42cb:42af with SMTP id x2-20020a056a00188200b0064d42cb42afmr9286193pfh.4.1684732044137; Sun, 21 May 2023 22:07:24 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.249]) by smtp.gmail.com with ESMTPSA id t10-20020a62ea0a000000b0063b5776b073sm3247519pfh.117.2023.05.21.22.07.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 21 May 2023 22:07:23 -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 v3 02/10] maple_tree: Drop mas_{rev_}alloc() and mas_fill_gap() Date: Mon, 22 May 2023 13:06:48 +0800 Message-Id: <20230522050656.96215-3-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230522050656.96215-1-zhangpeng.00@bytedance.com> References: <20230522050656.96215-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 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?1766570026161452597?= X-GMAIL-MSGID: =?utf-8?q?1766570026161452597?= mas_{rev_}alloc() and mas_fill_gap() are useless, delete them. Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 108 ----------------------------------------------- 1 file changed, 108 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 96d102d60b4e..263bd0ccc31b 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