From patchwork Mon May 22 05:06:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 13249766 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 C9F09C77B73 for ; Mon, 22 May 2023 05:07:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 678D090000C; Mon, 22 May 2023 01:07:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 62930900002; Mon, 22 May 2023 01:07:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 51B4F90000C; Mon, 22 May 2023 01:07:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 43EFA900002 for ; Mon, 22 May 2023 01:07:24 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0FD2BC0420 for ; Mon, 22 May 2023 05:07:24 +0000 (UTC) X-FDA: 80816707608.01.3F96749 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by imf19.hostedemail.com (Postfix) with ESMTP id 3AF3B1A000F for ; Mon, 22 May 2023 05:07:22 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=E+sf9AoJ; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf19.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684732042; 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:dkim-signature; bh=ryAjJK/jvO3d1/ZbH/fm/OkRmr2azDVw5I6QoB1NED8=; b=LPdf1s20fM9QXXWV/qWQ2yXtWBdDWFZKqcqhGZ2fWz4YFrIS6cTyEx6GAlFtrvfPnV/xpm TMqB+cmLZNHZ7Koztwfu6LJVBXam3UsbsuuA7wURO51BcCbqjxHMidZVujEnadaD+xeb6n JmFWOPfAsjydbnXEAbBZ+V+cllj0zis= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=E+sf9AoJ; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf19.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684732042; a=rsa-sha256; cv=none; b=GRiRFJXc/SThNx37taoOXiMHcg2y5kvMvPe4gilZeRKW0ttojkcBLjMwShENEU/MOeu9WK wEZRjMsjEis2RyiX4sjU/o/asJy6NAvSDgmQwg9vKidxdy6qLR6HdHr8wDLHFc1j/teh3T CyUKQhrYi4XuF3ty74oEjLgo+uvtXi4= Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-64d2467d640so4440449b3a.1 for ; Sun, 21 May 2023 22:07:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684732041; x=1687324041; 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=ryAjJK/jvO3d1/ZbH/fm/OkRmr2azDVw5I6QoB1NED8=; b=E+sf9AoJVl+JV6FsfkR4Ym5XfHy/qlWHgn7H3ghjaIqtwrmDk4FnwTgtCboieHks5a 7Xju63Rz4/hQXtTjifn3Q9wRx22XGUz+pCJWITfM6TaSYKsoLU1m7GIB/8cxEfraWRhS 8ce7qTdNdx0Rx5AX64dHcGo1GeiRMKueARhVfIFMquyHtvURi2LrwtmBx+f+ZN0H25Jn IR5e5SLGTGTpYPbpRZriNanszs4xQ2Sv8FTZCoWCx2LI56hrA+MREB3TjANB0qTaIm9G tPlFNj6QITqQQlWtPss9HM0QZsSkFNpWPI7R91rjhIRzTZw+TQz16JYxWv25eGrOJKY7 bY8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684732041; x=1687324041; 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=ryAjJK/jvO3d1/ZbH/fm/OkRmr2azDVw5I6QoB1NED8=; b=AkszpQJWlawSn/gNnPZxTdZSo+8Wh0Dc0zfjVd60QVTgZPCc8+4Zb1SnxWrAizETuF UCH7txyCjvTXDhXoJmJvfoC5vpuPJH24HKKJMzGC9yZKN/DqrscyzSNVi07kcX6lrrdp 9DzYVNsZa23do86W5XoJOhRY8x6+mkqlHx+aib14vhOqX3Bvou8XnuyTVsXyAJDi7jp8 3c915v4k3jkGQikhkG8vvNP5n3y8Hrok7iwYxfnOGhifRSI5rpwI8icDep7t1WvjYB2F 5a59Q52xMnKjwDVvpsnEMYHbExNXK13Fkya2TkKL76bzUN5J7hgM7p9qPB/Kl62tbgjS O1cg== X-Gm-Message-State: AC+VfDzsHluNfdFsqcoUjSNOvwkc5x3abvmZfLtPZiJl+mWjbcNthviR MwU3IKL3L0e7a5fFcROqdWSeIA== X-Google-Smtp-Source: ACHHUZ6Xjaki5a0wpYv6HPrx9PPhoRm0BZ5h3RO2p2wQiWSIZBHDnR5shbpMqf2VKAtyiIKtmnXE3Q== X-Received: by 2002:a05:6a00:845:b0:634:7ba3:d140 with SMTP id q5-20020a056a00084500b006347ba3d140mr13038011pfk.15.1684732040942; Sun, 21 May 2023 22:07:20 -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.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 21 May 2023 22:07:20 -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 01/10] maple_tree: Rework mtree_alloc_{range,rrange}() Date: Mon, 22 May 2023 13:06:47 +0800 Message-Id: <20230522050656.96215-2-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-Rspam-User: X-Stat-Signature: 9uad5amtx4o4og5gd5z337p8cahmsc8q X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 3AF3B1A000F X-HE-Tag: 1684732042-242092 X-HE-Meta: U2FsdGVkX1+Y8nfEqFYYqGJYIr3XsXqRduJ/hYfn6+IQDgKhBmCQroOGqD+U+3mKfViP2tBoMxoQK1qdcG9vA74FNlwdWA7dbTPbDLWUEui8b8ChGPe6vbnViRSaKO39nyko6PxmmnDhCqvQnDm5wXEyR6kgSNDWepSNnaTNBWJx8RRQgIie1mY//JzW/QdRvANduqWlNP1IFLL1FUR3fIUU/VIHN85oHqEa7xv7BWO7KZJAwDXo0CWl7K6MMt+RkNX1OaL4IKDtTHZqWTC4eqbaq1fNRyp3A1aFx58ewvhpKF3CacecL3VKYiOuI6Svey+CdyvmQyuzzfP3nzvJr5Dn5boOwPOiZYkviTG1XyrUsFGR10AQiN29BeCnr5WTLzKVmuT/GrADUGRGt+PVo4Ir0dw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Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Use mas_empty_area{_rev}() to refactor mtree_alloc_{range,rrange}() Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 57 +++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 4eb220008f72..96d102d60b4e 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -6493,31 +6493,33 @@ int mtree_alloc_range(struct maple_tree *mt, unsigned long *startp, { int ret = 0; - MA_STATE(mas, mt, min, min); + MA_STATE(mas, mt, 0, 0); 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); + ret = mas_empty_area(&mas, min, max, size); + if (ret) + goto unlock; + + mas_insert(&mas, entry); + /* + * mas_nomem() may release the lock, causing the allocated area + * to be unavailable, so try to allocate a free area again. + */ if (mas_nomem(&mas, gfp)) goto retry; + if (mas_is_err(&mas)) + ret = xa_err(mas.node); + else + *startp = mas.index; + +unlock: mtree_unlock(mt); return ret; } @@ -6529,28 +6531,33 @@ int mtree_alloc_rrange(struct maple_tree *mt, unsigned long *startp, { int ret = 0; - MA_STATE(mas, mt, min, max - size + 1); + MA_STATE(mas, mt, 0, 0); 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); + ret = mas_empty_area_rev(&mas, min, max, size); + if (ret) + goto unlock; + + mas_insert(&mas, entry); + /* + * mas_nomem() may release the lock, causing the allocated area + * to be unavailable, so try to allocate a free area again. + */ if (mas_nomem(&mas, gfp)) goto retry; + if (mas_is_err(&mas)) + ret = xa_err(mas.node); + else + *startp = mas.index; + +unlock: mtree_unlock(mt); return ret; } 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: 13249767 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 CE9C0C77B73 for ; Mon, 22 May 2023 05:07:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C65390000D; Mon, 22 May 2023 01:07:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6773D900002; Mon, 22 May 2023 01:07:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 53F0B90000D; Mon, 22 May 2023 01:07:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 45FA0900002 for ; Mon, 22 May 2023 01:07:27 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0B2ED14068F for ; Mon, 22 May 2023 05:07:27 +0000 (UTC) X-FDA: 80816707734.17.C5FBF29 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf27.hostedemail.com (Postfix) with ESMTP id 384AA40002 for ; Mon, 22 May 2023 05:07:25 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b="GYE7/eh3"; spf=pass (imf27.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684732045; 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:dkim-signature; bh=8amRkLtdnjVq9cbmGyv8etEjiXwBdz+ISKHsxqN16tA=; b=XSCfJeF63alOo8HwHiY3TVU3CokO4FHEZCPSdGyfaOYdWx1aCMQ1cS0ad/S4POsgs46epY hwwrddkIFn0lfEdrBg07+9PCITcoKuLOFibwlBWWWBPPhEggX32v+LRncSo6NYrkJ8viV3 olf00OBp3+Fghme2kSHVusQJvb1pox0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684732045; a=rsa-sha256; cv=none; b=hH65fGaNrDG/Zo+ssHSsz2DtvwkBO9LtbkfAEURHokqgUBAl9VljUN4SF1J2p7d54o1hi0 2gC05Awvh0AVrYAgxyZQw7a3POUrZ0CpWBmy+RpqWc7AYJFCeKt0zMQtHg9JiiQRj3U64X 51y6+uZ1ojr7x42sYlfawe5X4OqHxmA= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b="GYE7/eh3"; spf=pass (imf27.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-64d2a613ec4so2491071b3a.1 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=SOQE3FlPnIj8HNfrEu5o6ahpw5dgzlcFYB1wjY6Qxkt7q7RnwLFH+0QbETI4SMhSan Pt8M5NXQTG6KSA3kv4vgGGgLcFP7PDwuUvlW8pBm8J4Qr2Nyjd41m8KK5XVm+tpeuu0Z nJFCsl58fZQgf01D/N+0t+Tnm1Ah0+TsMM6Y8XzqGC4Q8I9siUAkYrDfTw1+4xsWp0Q6 Ce7FYZwzd1gEkyB12S+4l7vHvnC6Ez3Cv9kGpecPZXr7jeJsoCQw4t/XmyZdCOzsGKS4 qD5/BgHezI2CysSZw8IsPFgT2eKqZ0Bw4AlVu4bdPPyV4H3jqKUKCmDEOauSQCjrD2d9 y/6Q== X-Gm-Message-State: AC+VfDxLEf4VdXJAexjyOYaKQAQTvPkt96sCznmgZ9KjKutTaxo76Orc m/rdWA3Quda/D66CuZAICPepGQ== X-Google-Smtp-Source: ACHHUZ7HimVTIQoub3tu0mdIJwmiVfKwyk3rieE8LPbYzYmpwti5Dz/8eFWiSuI3fjzaDlWesoLrBg== 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-Rspamd-Queue-Id: 384AA40002 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: tycxj6mjttp1odfi8nac5ngzfyq6b77q X-HE-Tag: 1684732045-257757 X-HE-Meta: U2FsdGVkX18KG0q+E0M14p/If2ix5c/YwX63KEg7vPEdSx8iWcwnhIaj8fzYsSGVmju6gDS7tmnGvb6oMVJoSKAHnaQtBbZcOWnwN7D0D4qZCAu3RroK+b4AgB0eXQUbgYI5blcSYERG3yINxb/6I1UjQhg+6B/Nn2HTngLcwxh5swPgCw5J5C/mzMCf6ByJInjJShO8Q7hblgxE6EHUZ8PlTV7xKzSIwY6+N7N9istlZKVm9uIyRS9B8nD7RkcImtapa1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0dH/6mHNxning3wyz+Bg7XATept+Q+2b4qW9M6V5oMID/bpz8+3gUput6esfSxngeDV5mYLkC8Yu9JM712BEYXOqMCJxp1A2rSeP4= 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: 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 From patchwork Mon May 22 05:06: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: 13249768 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 47F95C77B73 for ; Mon, 22 May 2023 05:07:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA53290000E; Mon, 22 May 2023 01:07:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D5514900002; Mon, 22 May 2023 01:07:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C1C5590000E; Mon, 22 May 2023 01:07:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id B3C61900002 for ; Mon, 22 May 2023 01:07:30 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8270F1A06CA for ; Mon, 22 May 2023 05:07:30 +0000 (UTC) X-FDA: 80816707860.30.F63DC9E Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by imf21.hostedemail.com (Postfix) with ESMTP id 9D52D1C000A for ; Mon, 22 May 2023 05:07:28 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=EzLSK3cP; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf21.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.210.170 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684732048; 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:dkim-signature; bh=yWC57VvLqW+uV6e3VSW20kWo+uFlFhqhxKDmqi/M+s4=; b=q64FTgi5TJQgcHuHZ0TIE8F4V3C6OGdBoWXKFf1wDUDeWggKaSqXzVj1WU2E7S6IDkUPma Vb5uc71AERwc1LAexyoj22hRbrjpe//nadhsUjgIyPjTd+i+vkGvYCqFWnobL4kx3VThxm bm1yIgMRvE7X1JLTH10yneZBjG9i2/s= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=EzLSK3cP; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf21.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.210.170 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684732048; a=rsa-sha256; cv=none; b=fDsb4fLAoH2RqO2S+pN/sWkWXEbn8xfPqSJ+UPNuwkkrK6H2iJxsC2or11fkeZJQuFY33x 0vrdxjLut3yTYyMWugQPZn9rrL8uEqdmHhHjMuJ455WU24a8nAieQQMVyH0LtOnQW755DM 6yJLz+nxA4YbQ4mkcmk9UAA0zfbIy8Q= Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-64d3578c25bso3205157b3a.3 for ; Sun, 21 May 2023 22:07:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684732047; x=1687324047; 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=yWC57VvLqW+uV6e3VSW20kWo+uFlFhqhxKDmqi/M+s4=; b=EzLSK3cPy7whK/cuCX7ItKG6l3duMlUzxr2DN24N10lVm+CaqC7sQkl4JBdNua/aAQ zosKFg/rfFI7osQ8eZcIBIfKeDR03YZaXjE5O8+e2qadCDIp41XDnirHuK3FWoX8l3OU YcB4YJkxwNjDyYKJfPZHybJrX1aMBiy3UgCgsQoNlOLNB2szntp7ukZGP8Q+ZzNCsuPy V8JNyEch9NnjoH7EK7OtuSW0wVEcwlYQnqPEa9kzxzg0/vxd+qY1B24BapLesnKT1O6q iZbG3O4pP7gdt6Vx0E2R3HvXJKJDMX0BbBfYhgm7SDcOeyERTF0Kb1Cj892QnkPDOShu QbmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684732047; x=1687324047; 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=yWC57VvLqW+uV6e3VSW20kWo+uFlFhqhxKDmqi/M+s4=; b=G98+r2s6aDQI//90aXEBVGuwPlh+6fGMmyrgJK0pvX/Q6lT/6dibr+3zb9GOImusRP XL9jcid7bUIIkjjjz2nicOLvoITYI0CrgN8r/UPUgllcyRgKmk63GWnIwnf9TiniMCeR 6kdWXfwa+VJs4F/JU3pG5uZh7u1OfllMfMy34wbOmmBF/RxVe8jyxyxV/qhEnMB8G0Lg ERpa17WSaohnSoCwoleA2e+HJIjZb9HAFAiGeFAynPWzUoW0C1BtNnjD5k/snLDug2HM wwBEnA1Thnt3ADwnuye3I/TItNajQO3FlZWiGMiw42hgXdvf6CecYjX2dXovbISOSH2M 2dJg== X-Gm-Message-State: AC+VfDwh8OFiW7ORFVLAMF4Y3Nn1+aAb67sNcrbF1rowzz46kX/e4eRy DR974xGN7EQLmQ7Yp2a8ceBlFg== X-Google-Smtp-Source: ACHHUZ78HzvmR367cMVPT2DzYVrIahGxjmoDH/aFdaP1ySwjC4sDSZwePIHcLNsfO8g2Nn/oaa1aBw== X-Received: by 2002:a05:6a00:3924:b0:64d:5f1d:3d77 with SMTP id fh36-20020a056a00392400b0064d5f1d3d77mr4573175pfb.34.1684732047342; Sun, 21 May 2023 22:07:27 -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.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 21 May 2023 22:07:27 -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 03/10] maple_tree: Fix the arguments to __must_hold() Date: Mon, 22 May 2023 13:06:49 +0800 Message-Id: <20230522050656.96215-4-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-Rspamd-Queue-Id: 9D52D1C000A X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: n7pitmn69bp37prmetbphoakadyoy9dj X-HE-Tag: 1684732048-294002 X-HE-Meta: U2FsdGVkX1+AtpueW9E/WK9kiGp7JHRhMAYl2sDIXBP0yC8hiAL7zW8+WwsCbokPZsM6PIipXZfJSh9yuUURQz8xtbZ4A05RoI8EGM4OS2NwwJVRpx6N/ORwgq7gGuZ8S99LljSwV/7D9SWJvqe54e0BizjT86xmmAaDq8X7osc2xa0Ls+71bkUIOE+ILt6jJn+LT+GZ53woT79F3wfRVx7Q8ZFV8HwZyXyKSTMkvpqbapFhwXnBi1MONAAGN5XMjtIPIwgPb9JeDsx9Y1FrZpBi1hoUVISloLu3MggAVu2gTyjhTHCXKQl3hmzxIgWZqQsN2DHWfnOFYXa+t7RU9bHTqej/HOZgugPReiiWNDJSerG8ujTA+mX8SG6ebqwrNqTzaIWOvLjyF+/1n9zXjHeJ0PlQHdx6yPVn/pEcX3YrGh1pjiT5SJj7j0FFpqjy3BHD4GdcXVP3c1LuVrwCoNFOhTdODpp7QIsfLcM1rbppHzPSZdRb5uRJq524Wq9iJdhJGCWxCo3dSwo2BQs38/cbX2rR/FhczUymv/NL2u7IqA2B1ZjIerlvRB8u9lMG5pXNpijH9/KrHA/u6ESm2ZlO59WU6rD1ioafpCXZLi+VcUqIodRJ/naqb9YEO/QKfPQCczZ1F8l+5svLMDRZVqTFet9oVJoDLhzxMROMJT6ZM+VJ72BmgbdSZ95Z9oVWhTADjrgZ6fZp/NjzyMpUdA+iCSQSPVoWzI8nv4Sxe6HDXPAPAwUDbeI43ZhydYct7QUdRwmpUmye6AWW6chVtaOddjCUt4N8fa4PrD1iQNZp8DSv6Vw3t5R4jBHtzIyyvKJXvXru+CBHvsCloE+Pl7RBeen5DlaDErEjI9brG9Ldq6SdW9faiUKPxOd0XEWgRe1CYUMSWRTjMRzfNSQkmf1s0ShTtLaNBgyfpSMGiYjzGCZVg+669vRW96+XennV+RB64rHt2EjKD3TqP1m 2T++YdwT xqFTRpHnnqLBuXiIwy+ca2PdzsWMpRYPWY+lr9+EJS/xTYZQE2nJ14QjdlAl51nQwosVae//kg3OX6Gzsv04BtzGFzNlk4z3AL5yB366xtwa1c9Uw5YkxJG20q65hft36+AC+iD6KIQhOtKURl6Jxr5LFLWfvgadWEiAae+bO+X7mt6belBbeBl5rwc2I8uoeVwdVXDd9VGDdIu+d9GXmbCkvbxcXatB0jHJ3QoFCKah4LTpqtgbn9PwSGYTKe8rHL2D3CQ3nSW3e3GO1wZ4PUXHemylhoQ2o9RRBDXpxjBxsV8iecPle1/Lp8wfurGRoz+SiMbgzMCRf4AvNkCTWUUF9pAkjLgtzEkMWm9/OzK8r3EGNhkr8cbEEkgjy6aQY9a2dNuHPbgb3dkezVHQxiAXvHCyK5IbRDQbqsllCJMi7SvP6CukpU7SSTGo07GhLijauPWWQGzClTY9glbErPcZjpg== 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: Fix the arguments to __must_hold() to make sparse work. Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 263bd0ccc31b..3fe6a6685384 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1752,7 +1752,7 @@ static inline void mas_adopt_children(struct ma_state *mas, * leave the node (true) and handle the adoption and free elsewhere. */ static inline void mas_replace(struct ma_state *mas, bool advanced) - __must_hold(mas->tree->lock) + __must_hold(mas->tree->ma_lock) { struct maple_node *mn = mas_mn(mas); struct maple_enode *old_enode; @@ -1792,7 +1792,7 @@ static inline void mas_replace(struct ma_state *mas, bool advanced) * @child: the maple state to store the child. */ static inline bool mas_new_child(struct ma_state *mas, struct ma_state *child) - __must_hold(mas->tree->lock) + __must_hold(mas->tree->ma_lock) { enum maple_type mt; unsigned char offset; @@ -6204,7 +6204,7 @@ EXPORT_SYMBOL_GPL(mas_erase); * Return: true on allocation, false otherwise. */ bool mas_nomem(struct ma_state *mas, gfp_t gfp) - __must_hold(mas->tree->lock) + __must_hold(mas->tree->ma_lock) { if (likely(mas->node != MA_ERROR(-ENOMEM))) { mas_destroy(mas); From patchwork Mon May 22 05:06:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 13249769 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 7712EC7EE29 for ; Mon, 22 May 2023 05:07:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1211A90000F; Mon, 22 May 2023 01:07:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D208900002; Mon, 22 May 2023 01:07:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EDD2690000F; Mon, 22 May 2023 01:07:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id DEBE9900002 for ; Mon, 22 May 2023 01:07:32 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B34D34044B for ; Mon, 22 May 2023 05:07:32 +0000 (UTC) X-FDA: 80816707944.18.C6FC74C Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf19.hostedemail.com (Postfix) with ESMTP id E77DA1A0014 for ; Mon, 22 May 2023 05:07:30 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=EKjJchlG; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf19.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684732051; 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:dkim-signature; bh=BT/SFNbyjqRQKVOJvWMUTBqOO8oBgaqMrnpmlnOChNs=; b=7skEauciM6m0T31X8Z1WT1NldVMH9/xhuSwPu12ZlZE0mxV3R9o5I9TVEeD8GJxcVlhs2d 2mYI5uItDTuOjXZ8Wq9Oa9OWXZA5WmRHFa69IlAYSgyGvKSriB4HAbe5j2WhFmqgaGgsTO v1a077PI4hsKD1OVWQHH/IJoGtfRNaQ= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=EKjJchlG; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf19.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684732051; a=rsa-sha256; cv=none; b=NylPGiSUGUOk2nD8zGgKj4Q+tNm+zHRyiJTt0rbH/YvCmVqEq5q7Tr7VKbwYy+a6vyS3vf 0uQLj7SolaRng12sFcUttP9LcqKf1FJLqrkzxgFepSMLSG5YcXDgXBoqEn8Hz3fUi07v/z IQpuKhXG+wqcoSq1OY4Y+C3fFIg9cDI= Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-64d18d772bdso4779371b3a.3 for ; Sun, 21 May 2023 22:07:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684732050; x=1687324050; 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=BT/SFNbyjqRQKVOJvWMUTBqOO8oBgaqMrnpmlnOChNs=; b=EKjJchlGDXRmxJY8egKTtCPHJW2FBKY8xN7qIIKeMpGB4j4yfs4iePqfPdOGDGS203 IQjvd34wUy4iqm1NNQJMsANpzDUtvuiVQo71ID6Ql5b/ZD31hFk8zHJpgjT9hmu5H5CG W8AKwWnNxPTTL+axxU+uEI/qffJlMjhfvrBTBD4nxKkPe9Lqh0j9uCLHAV37edea/+S6 c/7Hxz7fmZF9O9S2PREteryTTvvviwB/5gf/KOkvxJ/j1jRMaiNomC+EdpaWZVIcIXEF ezrPNKmy3LltEsCoP28TpF/5IGnfNZZB7VItCs35pXc12CfQgdA9uAdfhOYdExojYMPD ahkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684732050; x=1687324050; 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=BT/SFNbyjqRQKVOJvWMUTBqOO8oBgaqMrnpmlnOChNs=; b=D3NJEaIIbXW/cjWwJJTi1LHGScvh27B4W5F6aDzDm2w648d5QWC+JYIK9K2nbULDOY PJOB8MDmVF3ydSyXzDkwcxpsRhGugyyw3iO8YXqdZMvFYGX7cI2vUm3qS9vLDR4OQTJa pgW9fYBspdc9RDRReJFycOx65KwOZITrcGWP2uTibAcZXfSKg7AiG5x8xUfHr+CiDlYm /eewz5kUy8KnMbzmM3WGeCxnOEhAdqW9miy5VMGiEjpeFuy77pxQeFyYuIhbtQ8uSbuI 6qkJ/0tdwpqekf8+UwBttxZWFkkhgcNjfrKCoD7eQkrxGCThkgUH8Jfidz/aa0t4GxWk aj2w== X-Gm-Message-State: AC+VfDw1KU5sqNh1mHEJCc0PVoIgnOs5ALN3iEDzG1kuKHz78ZGNewoy VHMHeIhGbFSKvzzIZbJx58oPcQ== X-Google-Smtp-Source: ACHHUZ48HsI5YZd3LN1vDcUYC1K6qWTTr5aUygORmW+ZGTHv31Rrj+0oY+hVYu/YmeCBOpKh0r58EA== X-Received: by 2002:a05:6a00:2185:b0:64d:46b2:9a58 with SMTP id h5-20020a056a00218500b0064d46b29a58mr7924134pfi.26.1684732050365; Sun, 21 May 2023 22:07:30 -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.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 21 May 2023 22:07: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 v3 04/10] maple_tree: Simplify mas_is_span_wr() Date: Mon, 22 May 2023 13:06:50 +0800 Message-Id: <20230522050656.96215-5-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-Rspamd-Queue-Id: E77DA1A0014 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: yucn16cux6ebfuf1xx58gapyp7gh8jws X-HE-Tag: 1684732050-871445 X-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t9i3SpSrSTx5CM/0+UvPxFq/G4IUaBUD97TE4QHwb0X6PlLpBL4+T+S1Od0DpmNKiTwxj1wBe2OkZ7f/c+vl95r//39nsdFZ0L8cDd1GyRKAmKPpxlLb/Wwv5cGzH1TxwZHAJ3+9YWtBCYFegNaMNSGDdCq6oirC+yY6FNfl0aG1pmHi4H4gaL4T1Hqs+12RGqIppzYPfMOAZc/5QXGCOdNwljfe6XcOiEApW89HMvwXTyJ+22uRw1mrw1Dls6gfFAG7dcoV/cf3EhwSw9UGraZWMSFv0zcsa+zmtjArXQTnohrX/NwL3XgsesF2urqLbTI38AeO82dIFo3t4x+ci2z55IzFBUI8HMMkk8UcePf6ZmLVIgpr6IRw9yqXnG3oGJuYFx8TJZ2NklJCddiXDQ++UtL3zIzKnwype1Gc= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000126, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Make the code for detecting spanning writes more concise. Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 3fe6a6685384..c47af84047a4 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3728,43 +3728,32 @@ static inline void mas_store_root(struct ma_state *mas, void *entry) */ static bool mas_is_span_wr(struct ma_wr_state *wr_mas) { - unsigned long max; + unsigned long max = wr_mas->r_max; unsigned long last = wr_mas->mas->last; - unsigned long piv = wr_mas->r_max; enum maple_type type = wr_mas->type; void *entry = wr_mas->entry; - /* Contained in this pivot */ - if (piv > last) + /* Contained in this pivot, fast path */ + if (last < max) return false; - max = wr_mas->mas->max; - if (unlikely(ma_is_leaf(type))) { - /* Fits in the node, but may span slots. */ + if (ma_is_leaf(type)) { + max = wr_mas->mas->max; if (last < max) return false; + } - /* Writes to the end of the node but not null. */ - if ((last == max) && entry) - return false; - + if (last == max) { /* - * Writing ULONG_MAX is not a spanning write regardless of the - * value being written as long as the range fits in the node. + * The last entry of leaf node cannot be NULL unless it is the + * rightmost node (writing ULONG_MAX), otherwise it spans slots. + * If this is not leaf node, detect spanning store wr walk. */ - if ((last == ULONG_MAX) && (last == max)) - return false; - } else if (piv == last) { - if (entry) - return false; - - /* Detect spanning store wr walk */ - if (last == ULONG_MAX) + if (entry || last == ULONG_MAX) return false; } - trace_ma_write(__func__, wr_mas->mas, piv, entry); - + trace_ma_write(__func__, wr_mas->mas, wr_mas->r_max, entry); return true; } From patchwork Mon May 22 05:06:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 13249770 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 E15FEC77B73 for ; Mon, 22 May 2023 05:07:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 825DF90000B; Mon, 22 May 2023 01:07:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D68D900002; Mon, 22 May 2023 01:07:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6C5E590000B; Mon, 22 May 2023 01:07:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 5D3B9900002 for ; Mon, 22 May 2023 01:07:36 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2DDD3160462 for ; Mon, 22 May 2023 05:07:36 +0000 (UTC) X-FDA: 80816708112.03.2D3BE78 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by imf25.hostedemail.com (Postfix) with ESMTP id 584F2A000A for ; Mon, 22 May 2023 05:07:34 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=ZSCKQFXL; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf25.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.210.173 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684732054; 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:dkim-signature; bh=eo5rcY2cJVWJgq5aXNebmW2HhW0q7JfmSI/nM1R46gk=; b=ab/6gy1HFqw9gBypdzICr8ms/N0mRRDwj3gCMdsV8mhCapMmbbjeQSsIzeCIA5Z4XyBbsu 1MeGbA5FxQ7qGah3TP8IM3maywjxoyebLcKlurJrt78y4Zf7ao94RmaUlK2d54q41vH8In 6hXhouoEzLJjLO9xviCCg0ObXYi7ahU= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=ZSCKQFXL; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf25.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.210.173 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684732054; a=rsa-sha256; cv=none; b=s8xj5GJbKsaaiuZ9APombOUESQ9VgLHQB7UBsqyFp1PTOeC//xuFDFGQZPEdA7/JJTraNv C2/imWopoZfOdZAfMTDSqKPIl1e5r/0LfyrqWdc3QmLZDnKCKmc0Q/G5b/px3FWLzhCfLZ aQ+JeWJYzMeiwAiIHbPnvlffhwuIZo0= Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-64d30ab1ef2so2133537b3a.2 for ; Sun, 21 May 2023 22:07:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684732053; x=1687324053; 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=eo5rcY2cJVWJgq5aXNebmW2HhW0q7JfmSI/nM1R46gk=; b=ZSCKQFXLVBYNVkVOOzDNCt0Mcj4KMH0eT5hciFj/maxy7uR2Fkn3XI9lMlN5I5K2mq Gkw8OaXA1zC3gwyZmCX2kCRi6LHedI7vC7pGlQ/tq/vEkC3qx84ASPAf41r2VFRD1XBm Qq35xPIr91V1EpeXuEklHJyGwYOOSZuXcKpt7zcnKzZgmUmXG7hRA8dpYUo1ZjYK6p9J f/UBHZMxPM3XmWhjiUvQ3km319KaunvQEQg7Wos7iycBYkWIlOSSwDwri3+W/KsmllFu OfpLB1SibWVW3lTR6xYe6IJvXPIhv0Nt/Z5NcrMSHbdAEZqqBED9UAwJNrLOiZY7L84J F0vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684732053; x=1687324053; 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=eo5rcY2cJVWJgq5aXNebmW2HhW0q7JfmSI/nM1R46gk=; b=MavUUnTHy94oDQtxrkoywqkhziS+xKFi2o5IDPb2aDFSmlPvsXDPvPlle146fFy+ln 5wZsHd7zRMrxMUwgZq9tTQuPBL0zJXAZh/S1zJLynM97135xlB4DDTLXlJFB97IaDlH+ FaTW30zjFX6kIr6h+dlUTFPrKulJHRJvN5LroY15XHmDC61MVtO2Vmj4wg0KtqDtRHJy GEz05F+wtC15SUsZBSA0oKPLZt1r90OmL1eQmdDOWJdCXdpXkcJxIhxl4yxCKbJYYSPg eXj5jFGGzK/On8UIcg3op3It3iujqPezU8GXS/t9Bpa4i6689/JTMM5XbfwgjnIVblfG cZ4Q== X-Gm-Message-State: AC+VfDwtqp2cQw4m/GjQNotZ8jxCCxW4csoy//Dj7VUhIuxhpfI8z33s Zqjc6CM7ms3Pb17JT0sboZlFOQ== X-Google-Smtp-Source: ACHHUZ4MzY2LZNzu/pNjw410E/5PK7X/ZtRiKyw0Xmd7JdlNmnRSaFHeU1cNLXN3WvcR/RrqWRLy2A== X-Received: by 2002:a05:6a00:9a4:b0:64d:2e8a:4ccb with SMTP id u36-20020a056a0009a400b0064d2e8a4ccbmr13674329pfg.14.1684732053316; Sun, 21 May 2023 22:07:33 -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.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 21 May 2023 22:07: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 v3 05/10] maple_tree: Make the code symmetrical in mas_wr_extend_null() Date: Mon, 22 May 2023 13:06:51 +0800 Message-Id: <20230522050656.96215-6-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-Rspamd-Queue-Id: 584F2A000A X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 8oqupijdwa69q9w3g1nw6gbg8yk5uu4a X-HE-Tag: 1684732054-910854 X-HE-Meta: U2FsdGVkX185T+C5gxlhErK1C0AH/FK/coDIKFvSPCV/upH4l3yLi169sSEkOfiGHQYwGmk0mJ+CDQvD+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pYRTTURnjnUgBPBZ1P/Jtx7UsT5iiu/B0KNdyiQG2En/wyoqWF2ltzHK8lUU+4HghqavX9hn5LH0X+sPomNLg6dpWdVX3xrnm8UFkTb+ZhBm+LbBTRXZyIGKCNiAKu8+JlB0fo3HglUgfLzeMS0X45bK1BK3OVdJh2KMlSuJeNXj9QrIjHipA5Bt5hSm435SvdDpV+ns79tITwyHz5/krpkJZRKJQnFqhH3l5JzfOUaEkwBsRA1sOodbFlYcAeYxGWPGLFeoNBtvJPDNKi67pbWC9iTFUUwx9a02rRSNeGHvak9+GkpcyyxxqPHR82iP7BMT2rj7LElEgP7G+GR 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: Just make the code symmetrical to improve readability. Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index c47af84047a4..562507979a4b 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4265,19 +4265,21 @@ static inline void mas_wr_extend_null(struct ma_wr_state *wr_mas) { struct ma_state *mas = wr_mas->mas; - if (mas->last < wr_mas->end_piv && !wr_mas->slots[wr_mas->offset_end]) + if (!wr_mas->slots[wr_mas->offset_end]) { + /* If this one is null, the next and prev are not */ mas->last = wr_mas->end_piv; - - /* Check next slot(s) if we are overwriting the end */ - if ((mas->last == wr_mas->end_piv) && - (wr_mas->node_end != wr_mas->offset_end) && - !wr_mas->slots[wr_mas->offset_end + 1]) { - wr_mas->offset_end++; - if (wr_mas->offset_end == wr_mas->node_end) - mas->last = mas->max; - else - mas->last = wr_mas->pivots[wr_mas->offset_end]; - wr_mas->end_piv = mas->last; + } else { + /* Check next slot(s) if we are overwriting the end */ + if ((mas->last == wr_mas->end_piv) && + (wr_mas->node_end != wr_mas->offset_end) && + !wr_mas->slots[wr_mas->offset_end + 1]) { + wr_mas->offset_end++; + if (wr_mas->offset_end == wr_mas->node_end) + mas->last = mas->max; + else + mas->last = wr_mas->pivots[wr_mas->offset_end]; + wr_mas->end_piv = mas->last; + } } if (!wr_mas->content) { From patchwork Mon May 22 05:06:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 13249771 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 12ACBC77B73 for ; Mon, 22 May 2023 05:07:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D6CA90000C; Mon, 22 May 2023 01:07:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 98409900002; Mon, 22 May 2023 01:07:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84BF790000C; Mon, 22 May 2023 01:07:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 76290900002 for ; Mon, 22 May 2023 01:07:39 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 41AAE8044E for ; Mon, 22 May 2023 05:07:39 +0000 (UTC) X-FDA: 80816708238.15.B1779BB Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by imf01.hostedemail.com (Postfix) with ESMTP id 6999740006 for ; Mon, 22 May 2023 05:07:37 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=jgMP8vdB; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf01.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.215.171 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684732057; 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:dkim-signature; bh=gZz+uQjmpOdIMxeiaJgwUz4BoyhUknFLXJa8Z3V7HsI=; b=b807Ked13KXsxrcr7V2MFBDaO56YaWA1hBPGTfJM9fc/9CNdoNVoZIW4/IYTSxQZ5P6HIo U0DrBKKPSULdO9+7S7fNfrQYET7+C//98HMwIho6cu1sL7XVbIWRsu+qGCTXOp4rj2sIDL GEwbkHQHqlOvDN+AT8GYJSOKtMXvz+E= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=jgMP8vdB; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf01.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.215.171 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684732057; a=rsa-sha256; cv=none; b=rilqJt3ZBoylxapt+SpY+Jqxscl8eMLU6t4P/jsDytoNW1+KPaJ6vW5vgp0iUEhihCQok8 QAUaoWH7mpuT+22QNFet/9hKw1f8KJOGelZa3n5pD3fTKfDBVY+6eL5Qa5CoMrjgPuJwSd cy8Yj0MOe14aPtDWqLjVhzM/eJDv9mA= Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-517ab9a4a13so4978077a12.1 for ; Sun, 21 May 2023 22:07:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684732056; x=1687324056; 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=gZz+uQjmpOdIMxeiaJgwUz4BoyhUknFLXJa8Z3V7HsI=; b=jgMP8vdBmcOPewxDkJjBZQcf60lixgiNyhCEEOeGGUIpPNqCfsdnSzzeIL2MICM/0R dmJuRkdPDnNnSfKA/dr8EkxfvxBIxP3R4j2iiulIlRGcVDmX8Lct+JSE/lMFq5EGDBJD MKnUiIMoKHSCObK01IPby8K5It8XOEKZYIVlGoZ/mgPiqAD4vHLsmTpUhZE3oIODEi3b gvn0IAyhVkAuotI9HrMW1aiOaWcC/Lor8mMrbNnXu6jNXIDwgJtEi3y5StnbZsqWkZvM nF9BxiVrMtuDUA0UL2yAdW5NJdF+KXKc+Ue8A0yBVtprddy7h6bpFr1gPiOXTD9l0MZY 9rFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684732056; x=1687324056; 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=gZz+uQjmpOdIMxeiaJgwUz4BoyhUknFLXJa8Z3V7HsI=; b=YxKQnTEXnoIGbysXqK/PUUwVAn0v26zp9AbDGj8iuZOei4GmRQhozAYbpsdg67aOPB s2WSZhTlyPqITrIN2Urpkn54OR/moy0rgkeniURpyXslQ5LicKDq05t6YY92oMG8M2H+ YWQz3icUhDGjbxbNGYNqFch0VAEP1unluqrs6O2JN6kmrExPfb38OKcL5P42nUdW+vGc cto+khir7cXCOBG269Tred3Q3/OItPt7V8/oJ2FKqgRCvzJOKp6VuderdNYQz370WwPr jea0ST6z2WndiXWMehGyEJhg1xeF/opBBZL/AiqmeRMZ7yZC0P7selbtPJU0N9mbsCPB kKdA== X-Gm-Message-State: AC+VfDwrLfzFKz9ITQtYCRoAP7fY3RQT7kFIUFgNADJUxioZuv8pPIJ1 pFcQSOEK1UQOrDLgOYUMQVQOWw== X-Google-Smtp-Source: ACHHUZ7kqirc8A3D4h9wAwED0RDK5kYc00X56oQezZL6FCZscI345O1qs97um4cy07jU4YV8E3R45A== X-Received: by 2002:a05:6a20:440b:b0:10b:e88f:598f with SMTP id ce11-20020a056a20440b00b0010be88f598fmr916141pzb.51.1684732056314; Sun, 21 May 2023 22:07:36 -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.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 21 May 2023 22:07:36 -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 06/10] maple_tree: Add mas_wr_new_end() to calculate new_end accurately Date: Mon, 22 May 2023 13:06:52 +0800 Message-Id: <20230522050656.96215-7-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-Rspam-User: X-Stat-Signature: jmi9qsjywib4werjku8uy7uhgdiwob83 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 6999740006 X-HE-Tag: 1684732057-204487 X-HE-Meta: U2FsdGVkX19s3V7YvaTSS5MkX9pYJh67uvexlsiZJHLR3sH3KEY4QKVVmUwwokeDHPfB/xrzPViiBRNf7724MfX7ylz38YGl3RrU0LudmHY2fTuYvx4f6RLfeoQAvFXlNxieWC2FSXTS2XLMJSOM07Y+zokm36J119j8Hn/hO61cSt2DOwbrRb0Iik7zdMl/UFKi692CRlqsT02vHZItX+nsGsJFE43+cKg1+jwzobJIqqbjoscLgUSRzkYqDXwsfl+ElRT9EZf0idlB7Sd1e68AFdIn24TPdkmi17dGnfY9y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v+T5uRWiBSBa4rFYO4SIMp3LaKyuJ16iw+b2Hn56Jk1sGhSH1UHeHRY6lHbmU6NZW9MucUgj3Q= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000655, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The previous new_end calculation is inaccurate, because it assumes that two new pivots must be added (this is inaccurate), and sometimes it will miss the fast path and enter the slow path. Add mas_wr_new_end() to accurately calculate new_end to make the conditions for entering the fast path more accurate. Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 562507979a4b..0550a07355d7 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4297,6 +4297,21 @@ static inline void mas_wr_extend_null(struct ma_wr_state *wr_mas) } } +static inline unsigned char mas_wr_new_end(struct ma_wr_state *wr_mas) +{ + struct ma_state *mas = wr_mas->mas; + unsigned char new_end = wr_mas->node_end + 2; + + new_end -= wr_mas->offset_end - mas->offset; + if (wr_mas->r_min == mas->index) + new_end--; + + if (wr_mas->end_piv == mas->last) + new_end--; + + return new_end; +} + static inline bool mas_wr_append(struct ma_wr_state *wr_mas) { unsigned char end = wr_mas->node_end; @@ -4352,9 +4367,8 @@ static void mas_wr_bnode(struct ma_wr_state *wr_mas) static inline void mas_wr_modify(struct ma_wr_state *wr_mas) { - unsigned char node_slots; - unsigned char node_size; struct ma_state *mas = wr_mas->mas; + unsigned char new_end; /* Direct replacement */ if (wr_mas->r_min == mas->index && wr_mas->r_max == mas->last) { @@ -4364,17 +4378,15 @@ static inline void mas_wr_modify(struct ma_wr_state *wr_mas) return; } - /* Attempt to append */ - node_slots = mt_slots[wr_mas->type]; - node_size = wr_mas->node_end - wr_mas->offset_end + mas->offset + 2; - if (mas->max == ULONG_MAX) - node_size++; - - /* slot and node store will not fit, go to the slow path */ - if (unlikely(node_size >= node_slots)) + /* + * new_end exceeds the size of the maple node and cannot enter the fast + * path. + */ + new_end = mas_wr_new_end(wr_mas); + if (new_end >= mt_slots[wr_mas->type]) goto slow_path; - if (wr_mas->entry && (wr_mas->node_end < node_slots - 1) && + if (wr_mas->entry && (wr_mas->node_end < mt_slots[wr_mas->type] - 1) && (mas->offset == wr_mas->node_end) && mas_wr_append(wr_mas)) { if (!wr_mas->content || !wr_mas->entry) mas_update_gap(mas); From patchwork Mon May 22 05:06:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 13249772 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 C23A6C77B73 for ; Mon, 22 May 2023 05:07:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 651C390000D; Mon, 22 May 2023 01:07:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6017E900002; Mon, 22 May 2023 01:07:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A27E90000D; Mon, 22 May 2023 01:07:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 3BF3F900002 for ; Mon, 22 May 2023 01:07:42 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 169C4160498 for ; Mon, 22 May 2023 05:07:42 +0000 (UTC) X-FDA: 80816708364.06.9233C38 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by imf24.hostedemail.com (Postfix) with ESMTP id 42502180007 for ; Mon, 22 May 2023 05:07:40 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=YlZq8Qee; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf24.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.210.180 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684732060; a=rsa-sha256; cv=none; b=7+yDHKZd2aAn6+l3GAMd3f2sJE0gpyoNklGRVo80iAt4FFfAUoEOLDVlNyFwiu2FTmeUXi GC3JqWLLQG4U4TW/gzAiRIZyiGj6QoLzOZRFCJtErN++YkDM3DdWrFnIC6LSWR1bGaVx8G 8fx6ZaS6AvJSUP0by2yWP7OVtocseEc= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=YlZq8Qee; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf24.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.210.180 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684732060; 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:dkim-signature; bh=BDMhWhfLT89+67MaNw9E+3uh4JNyHlNzHsoiSP1QJPc=; b=W+68ViyvA3Bb1AEzKMoWyshwINB3jDmlxZb09JaAlv1twhevHCQ7GKgb08RDn+YtTp/x4O P/lXaCzDeT8IVk97PHHl5KWJz75Yo+gXtebtYGnKiTduDjQPOP+E4VroIFWOCwYNrU8wFG MOB0koI2UCPs9Rayp8AwkAUidaXpCWo= Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-64d2a87b9daso2509940b3a.0 for ; Sun, 21 May 2023 22:07:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684732059; x=1687324059; 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=BDMhWhfLT89+67MaNw9E+3uh4JNyHlNzHsoiSP1QJPc=; b=YlZq8QeeFnwwN2PMnEu5ygiKTeL4TXc//yTBc0oVeHrSXzMJ8uRzfTDuP/PHlcM7UW hB9faQCix3KctJUaLZtd2UmZWfZ8Mfvt+myVSFtECmxjw+131ONog441mxQnYKz6dX/G FSnXiGW4od/KD+uyoierDNkcRBeklQL4FdrVA4CEWtOQ4uiJsFFsNHRgKdBvfALKLTVg DiFw3TJH9fb+KQulmNmJ1EB91in05l8bU2ap+Q70ZEOc1OoIOwCQuPhzBfcNlI7ADW01 xedz/T1eaNokKIMlAOtxmDXSzEUaUcieUHu/oXtk7OoUM6aiztzo2QZUarBT18g6KS/c Kp5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684732059; x=1687324059; 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=BDMhWhfLT89+67MaNw9E+3uh4JNyHlNzHsoiSP1QJPc=; b=OJPOM9G33KtN6F+gf7GjiYxFrQXnW3B+n/bqhTQyHWNzIgDscVPuR1/dobIZdpY/63 5H1mHAEBQgy0oCsOec3WLgWMvTPQMiEbrDR7IOAWyXv3v5NmswNQUcLBbHxOQU9WPNIq a0Fz7R4vYti8RUzALniTGSnSAoWCcBuW6WeEX2oT9AmD5UY47WjIdi4SwHaenu8b04nA Cwb99c5LgEs8ihfNA9WTNToWUjdL1/h65Eo/ptCPCjMqG8zwnk6YNT0FbVqw8Me3M80w torJWol3MppFLbLri0ig0QvuRoN7RBWRCeT9eAHL7YZHA3hzIHcxBIA9uY3RLXgoF9Xj o0Pw== X-Gm-Message-State: AC+VfDx1oCIkgKAbEsa2GWkZ4tXrhhiS5vHb1bc9xCReOfrXxGBw3EwB tvwqR8IPFPaqx6tMiasSJa2Ovg== X-Google-Smtp-Source: ACHHUZ4G3ndXt0xInsw23oUAUWy0+eARJcOZ0g5BmWYjBmghjVZs6D0v9IRLXKJFPEcYPqYrYeIEyA== X-Received: by 2002:a05:6a00:845:b0:64a:f730:154c with SMTP id q5-20020a056a00084500b0064af730154cmr13394825pfk.13.1684732059192; Sun, 21 May 2023 22:07:39 -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.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 21 May 2023 22:07:39 -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 07/10] maple_tree: Add comments and some minor cleanups to mas_wr_append() Date: Mon, 22 May 2023 13:06:53 +0800 Message-Id: <20230522050656.96215-8-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-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 42502180007 X-Stat-Signature: xb45h77egwbcuqkhkbmwrqqdbmcy75ix X-HE-Tag: 1684732060-661756 X-HE-Meta: U2FsdGVkX1+vCDgofdV6ScSQ+ICXwUhN+me/SitVbFCGDa/4WRioxQneUBy12qhWYD0SxG6j1YEHHoeCKJRKrYzRqXM7Z6M7Tywxx0qc/dKTf+XettrStwgJxTUrMydfAMNflkMpJ9KletR8oqqDX0gKo2D55XK0sMZ8sK0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Kgz8lVazAbC7b3VW4dGMkBSQ0RmCGft3wH1DfgpZaZVVzf3LLR6SySt5BAd0rGFrgjNc0XcM9Km8rxOq4fFLRhpctwJhweatytDlO+U0JyROj69GlP5folKEJnIRqC/ISgOk/HZVv9UvHts6Er2FO+oyvaoM+RYrv25K5ZIWleRDfbfKBTo4oGresuKHvFlY1Ax5zHLfDtAZIZNiSdtHFEbM= 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: Add comment for mas_wr_append(), move mas_update_gap() into mas_wr_append(), and other cleanups to make mas_wr_modify() cleaner. Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 0550a07355d7..afbfdcdde5db 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4312,6 +4312,12 @@ static inline unsigned char mas_wr_new_end(struct ma_wr_state *wr_mas) return new_end; } +/* + * mas_wr_append: Attempt to append + * @wr_mas: the maple write state + * + * Return: True if appended, false otherwise + */ static inline bool mas_wr_append(struct ma_wr_state *wr_mas) { unsigned char end = wr_mas->node_end; @@ -4319,34 +4325,30 @@ static inline bool mas_wr_append(struct ma_wr_state *wr_mas) struct ma_state *mas = wr_mas->mas; unsigned char node_pivots = mt_pivots[wr_mas->type]; - if ((mas->index != wr_mas->r_min) && (mas->last == wr_mas->r_max)) { - if (new_end < node_pivots) - wr_mas->pivots[new_end] = wr_mas->pivots[end]; + if (mas->offset != wr_mas->node_end) + return false; - if (new_end < node_pivots) - ma_set_meta(wr_mas->node, maple_leaf_64, 0, new_end); + if (new_end < node_pivots) { + wr_mas->pivots[new_end] = wr_mas->pivots[end]; + ma_set_meta(wr_mas->node, maple_leaf_64, 0, new_end); + } + if (mas->last == wr_mas->r_max) { + /* Append to end of range */ rcu_assign_pointer(wr_mas->slots[new_end], wr_mas->entry); - mas->offset = new_end; wr_mas->pivots[end] = mas->index - 1; - - return true; - } - - if ((mas->index == wr_mas->r_min) && (mas->last < wr_mas->r_max)) { - if (new_end < node_pivots) - wr_mas->pivots[new_end] = wr_mas->pivots[end]; - + mas->offset = new_end; + } else { + /* Append to start of range */ rcu_assign_pointer(wr_mas->slots[new_end], wr_mas->content); - if (new_end < node_pivots) - ma_set_meta(wr_mas->node, maple_leaf_64, 0, new_end); - wr_mas->pivots[end] = mas->last; rcu_assign_pointer(wr_mas->slots[end], wr_mas->entry); - return true; } - return false; + if (!wr_mas->content || !wr_mas->entry) + mas_update_gap(mas); + + return true; } /* @@ -4386,12 +4388,9 @@ static inline void mas_wr_modify(struct ma_wr_state *wr_mas) if (new_end >= mt_slots[wr_mas->type]) goto slow_path; - if (wr_mas->entry && (wr_mas->node_end < mt_slots[wr_mas->type] - 1) && - (mas->offset == wr_mas->node_end) && mas_wr_append(wr_mas)) { - if (!wr_mas->content || !wr_mas->entry) - mas_update_gap(mas); + /* Attempt to append */ + if (new_end == wr_mas->node_end + 1 && mas_wr_append(wr_mas)) return; - } if ((wr_mas->offset_end - mas->offset <= 1) && mas_wr_slot_store(wr_mas)) return; From patchwork Mon May 22 05:06:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 13249774 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 AE41CC7EE29 for ; Mon, 22 May 2023 05:07:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4CB6C90000F; Mon, 22 May 2023 01:07:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 47D0D900002; Mon, 22 May 2023 01:07:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 31C7590000F; Mon, 22 May 2023 01:07:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 234BD900002 for ; Mon, 22 May 2023 01:07:45 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id EC3CE4044B for ; Mon, 22 May 2023 05:07:44 +0000 (UTC) X-FDA: 80816708448.20.B6F418F Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf10.hostedemail.com (Postfix) with ESMTP id 1CC0AC0011 for ; Mon, 22 May 2023 05:07:42 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=fw0PRf8Q; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf10.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684732063; 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:dkim-signature; bh=qKVnArPifyAdGV9PIImrukiWg2xfu85fuVT0WT/x1lU=; b=n+H9T2FoUgG6nxWNCOzck8OaO3tY+Kc3FudWw6Fzu21Lq/6ghGaMrPYWooBDXl6BHGD3ob O6L0YSUkmqhgy4Y5f/Cefxb2fOkNdfZtbNzp1cPOHisECBMnL7h5Mr34lWMPDZbi5Po4oX NCy7Zpi0eiJLnbnq0wMESVfAb9j9LsU= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=fw0PRf8Q; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf10.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684732063; a=rsa-sha256; cv=none; b=lm5y66bkJf2mIWHu6+n9EHd2zySwKJ9bCyzf7VP3eBpz8xfhI/gXPSOfyS59MMVK8/rAc1 MHPOQi3ncw+zZNNf7/orHUIa2IY7eK5Lobdeapr8SBOCSrQ3W8chYWgjcNTFwaufyCTINd KIrkXgtJD9iCtLC2OloZ2ASfy6roAM8= Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-64d2b42a8f9so2715930b3a.3 for ; Sun, 21 May 2023 22:07:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684732062; x=1687324062; 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=qKVnArPifyAdGV9PIImrukiWg2xfu85fuVT0WT/x1lU=; b=fw0PRf8Q3oQzgqHErNvDCU259xWd4Me2ceXFQD8pISEEcIEQZmk7bW7OJ3mBQ0eywD v7wNxQOQTVF4JZf9ON/6V5aCR3dkMK/NNESMj6wazF1zAw2gwqe+5A9004QgW40Jn8wf NRquXTchX9dImyrXbMIRvklOEHCfUofQg2xsBQ54kLTzcXz6ITsMt/ENw3oUKSUkw01t ZugU1Bcs0+eIsKfAO0I/jngb59O1PU0WvWi6+TwcGR4tuPzFQajmv63m1xEB1W3F+6HZ hJT0pSolSpSQKQ/rqzJP5/QiQVzYL5TvoE5uUy4y/Z8Tftr+0PeYqUwLgjtERfdeYo2D hh2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684732062; x=1687324062; 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=qKVnArPifyAdGV9PIImrukiWg2xfu85fuVT0WT/x1lU=; b=Nt30E+ayXgc7HW8ogJk4UBSLgOkdUXg8kzBqeViae6tEsWd4JwSUPXZLnua3O+8Rut OZ91RZPrLIxqWT8bFWPOINKZMciDdSfMwQxmMWIBH9CoqzCbgIvX0v+FQurdIpTUK78Z ljlaqV1KjODWOAa02JaItK7GJN+O/hgvXv171iqhQDvhluZSdsfVSfpu6+yrLQaQvZ0Q alY8OGD8fZM4cTCCTtJcf1kyoqMoZfomymD1O5Ik3xF6CguNSEGEVwecdmP5c9h9n3fX BZ4sSvQ8O9PBRJohmBtGQYJhJuu0W7mxzBEjesC8Jj1srf4mUrYJaqKjRRhaMHtTdpvD xLGA== X-Gm-Message-State: AC+VfDyLVnyHSlSSaXWQSuygqbqxCG6BQ0ZdVJ37HWGMOwPFMeazyquV MqMWn80U9FMTaoyaJ/fDfb0n4i29YjnNHu9O/o8= X-Google-Smtp-Source: ACHHUZ4ZdOhjPoifK2FNOzw1Dpvr4gjGQyxiMVErjYNnHLBNabOF7Yl4YngE2n94wMJZLny9Vh53Og== X-Received: by 2002:a05:6a20:3956:b0:107:17f6:940b with SMTP id r22-20020a056a20395600b0010717f6940bmr11393229pzg.41.1684732061987; Sun, 21 May 2023 22:07:41 -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.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 21 May 2023 22:07:41 -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 08/10] maple_tree: Rework mas_wr_slot_store() to be cleaner and more efficient. Date: Mon, 22 May 2023 13:06:54 +0800 Message-Id: <20230522050656.96215-9-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-Rspamd-Queue-Id: 1CC0AC0011 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: sembeaitq93cn333t69hxcyd6x3d5oar X-HE-Tag: 1684732062-731007 X-HE-Meta: U2FsdGVkX1/eXU/L/Kom1P6tYFkhIstvVi2d2kTkXClQKnof93dVZMFxeYf89jmN4eY5fru2Rs8wtWpS2TqZXf+Fhm+otiF82UX4E+v2Wyn433uqy/+PYzVMTq2AWCRhfBRaM7tQTlOffJwEAP/1cRZ5jO7/bdxd+K1qC6f7UrNVCiaDb6hEcIunc+PMjdmNhgRUcBoe51d9jIxDt4Mas3yII9U7a2VdbuB82+UqGPObSoa6HZgtPM5W2LykWt+v2kHOfOxqvO4P/TbYQVilNrWTkvcDzQEGvMTNms6O4SGLwZ0SwjteFLBx3nJwSlMMLfvUl2ic/jjQaD9XCZCEPtJK3TFgKkPDgc0wC1GYEJDajFqfHN4eML/uAuvTbRnkaNMVu+D1kUfAX80Jc2eVd+FXrKFvo41xH7dKdkgnYN2oGM2dKKRoBmY2eeBiWsaZuvEWjoGQqT3d0LrlnbiIUQycl7vnMND9k56OwoIOESzUkGP7jopbNiEdcUxFiM7O8O1e31DOasiYbIw5zpB6kJ/JUUnbWIcvdQ+1Kd881HHY/NjjIBwRwlAUnnRiqNNEQbqHEsCZOKmy3PBVnFUQTbAGvbuN+mg767RGsp56l0IOku+ZDECG+kez185Yyg6WbmzOEmlQ2ohmCzNc1CHYvuHO+gZlvTe/CLkAACMNiLfkE3jRPOELO7vihLVS+GJwa6oWOG9lIWzZUXrO1Y+SIEwZ0V7yT5NMLh20H7fXer8L07r1YJPNXRLO/Vxbvy2ClsRpT6YXMdeIawT4AWjTMd/Mhn7J6vXi73O4tWbW1K6oqk0Ozs/hib5AMbA6qPB/pMQME7vbMhe7//iYP7dzYEJ6SnQQYBNS9D60zbbQ/HX0yIe1tKyOdM9H96U6A8uFz6fX/CET+ymN1WmMDk0mNsm4BdkgNh6q9cMJZDdhZrC5Ccvj+6Sp5Kw8cq8TVMfJI7s2acLvOexgIhBvwNu Jic2T0Ib 34xTiuAe2vG8vLnteBRnL4s7b1nA+BJYdvkjnec9gIXoVtXhiHplBEHLvEYZspZ2hpRZFjuR6Dw8a+ZT7Xs4jo7d06vIudMdA6i92CjU2pKwlGCSHnZI86zu83ELad9l573G4vJSW730HYN5vz6IjI0B4GOnWKM46+idWDOwmdc3IVV2OLS0xdFcB7BT+Vxx+J5y7roPb3lDZ7DkNZha1Hzf/XI5jX311/FnW4qswB7YzEXZk2JmDOcyuCdmujSQ0f6ia4EVJpX9mdKtVncm/HUcp/yZCnY12qJinKlYYGRt592oQAyOxYvx3zSiq0D/KrAlAoyNioQLgJu+vWPMYRZAmqZxQ/VdMH+ww/KOURZr38udJwj2Dp9v9N2Liq9shWKGFcc2n3OTmbnpKXVyqb1QlHOA4SVsrtS0VfD3rPLrAMghQmGNynCQVyOIhtWrcO9opAHVjMhaayNKX+j+ZeE2qV0xPLW83/m8HrxeLs6ZgR+MXtt6QsT6IsQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000055, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The code of mas_wr_slot_store() is messy, make it clearer and concise, and add comments. In addition, get whether the two gaps are empty to avoid calling mas_update_gap() all the time. Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 53 +++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index afbfdcdde5db..1fc872f7683c 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4203,49 +4203,34 @@ static inline bool mas_wr_node_store(struct ma_wr_state *wr_mas) static inline bool mas_wr_slot_store(struct ma_wr_state *wr_mas) { struct ma_state *mas = wr_mas->mas; - unsigned long lmax; /* Logical max. */ unsigned char offset = mas->offset; + bool gap = false; - if ((wr_mas->r_max > mas->last) && ((wr_mas->r_min != mas->index) || - (offset != wr_mas->node_end))) + if (wr_mas->offset_end - offset != 1) return false; - if (offset == wr_mas->node_end - 1) - lmax = mas->max; - else - lmax = wr_mas->pivots[offset + 1]; - - /* going to overwrite too many slots. */ - if (lmax < mas->last) - return false; - - if (wr_mas->r_min == mas->index) { - /* overwriting two or more ranges with one. */ - if (lmax == mas->last) - return false; + gap |= !mt_slot_locked(mas->tree, wr_mas->slots, offset); + gap |= !mt_slot_locked(mas->tree, wr_mas->slots, offset + 1); - /* Overwriting all of offset and a portion of offset + 1. */ + if (mas->index == wr_mas->r_min) { + /* Overwriting the range and over a part of the next range. */ rcu_assign_pointer(wr_mas->slots[offset], wr_mas->entry); wr_mas->pivots[offset] = mas->last; - goto done; + } else { + /* Overwriting a part of the range and over the next range */ + rcu_assign_pointer(wr_mas->slots[offset + 1], wr_mas->entry); + wr_mas->pivots[offset] = mas->index - 1; + mas->offset++; /* Keep mas accurate. */ } - /* Doesn't end on the next range end. */ - if (lmax != mas->last) - return false; - - /* Overwriting a portion of offset and all of offset + 1 */ - if ((offset + 1 < mt_pivots[wr_mas->type]) && - (wr_mas->entry || wr_mas->pivots[offset + 1])) - wr_mas->pivots[offset + 1] = mas->last; - - rcu_assign_pointer(wr_mas->slots[offset + 1], wr_mas->entry); - wr_mas->pivots[offset] = mas->index - 1; - mas->offset++; /* Keep mas accurate. */ - -done: trace_ma_write(__func__, mas, 0, wr_mas->entry); - mas_update_gap(mas); + /* + * Only update gap when the new entry is empty or there is an empty + * entry in the original two ranges. + */ + if (!wr_mas->entry || gap) + mas_update_gap(mas); + return true; } @@ -4392,7 +4377,7 @@ static inline void mas_wr_modify(struct ma_wr_state *wr_mas) if (new_end == wr_mas->node_end + 1 && mas_wr_append(wr_mas)) return; - if ((wr_mas->offset_end - mas->offset <= 1) && mas_wr_slot_store(wr_mas)) + if (new_end == wr_mas->node_end && mas_wr_slot_store(wr_mas)) return; else if (mas_wr_node_store(wr_mas)) return; From patchwork Mon May 22 05:06:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 13249775 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 79A1CC7EE23 for ; Mon, 22 May 2023 05:07:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 170C4900010; Mon, 22 May 2023 01:07:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 121AB900002; Mon, 22 May 2023 01:07:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F02C3900010; Mon, 22 May 2023 01:07:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E044D900002 for ; Mon, 22 May 2023 01:07:47 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C62F4C0420 for ; Mon, 22 May 2023 05:07:47 +0000 (UTC) X-FDA: 80816708574.08.E82B3E2 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf21.hostedemail.com (Postfix) with ESMTP id EF3821C0007 for ; Mon, 22 May 2023 05:07:45 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=BKOlFfw7; spf=pass (imf21.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684732066; 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:dkim-signature; bh=zXcykhEsvUWhqgulB/awfwAbXbqU+zgrczKRgN6cHyY=; b=U6s+JOYZxojihArmtAV9QOuRUIvBu7vzLiZwc2Mzu1Ulliu2Up7LCtw0TJ/qIASP7ztmo4 6gNfya5yK105CoRzaSuMfY8+AiDmINgr1m1V3pQ/7zgHJ4MAbyGOhKuGxN65ppi0q0MQRN jl0fND6tboz2PkJ0lYDdagaCC09IG58= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=BKOlFfw7; spf=pass (imf21.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684732066; a=rsa-sha256; cv=none; b=0XbTlq/amElfzEyuSiy6QZQpTxLhA3Kfy9D77hIhcI6xCFSx0oO0O34yrUKHkZ1bnN5Q+2 Dt3+fUnpCjOl2u9RMz8Jr15KraRYi3aTJgMRdm7T1lzOhMvBdE3a89IpdssFq56VLnNuKd ZM9Aebt9Wa1qcItrcGHsB9uVrQq9DE0= Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-64d2c865e4eso2485348b3a.0 for ; Sun, 21 May 2023 22:07:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684732065; x=1687324065; 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=zXcykhEsvUWhqgulB/awfwAbXbqU+zgrczKRgN6cHyY=; b=BKOlFfw73MQsx7LKzihVb1eW2ku1Xa0uxS543oAZwXAeguF1RrGxaXVIbOQY17SQAQ kV1Uhnt0EvCzfgZCQJRhJA1pjbp8GCJmlUxZ8ozuWFSLCFY8c/MplHp2+j7uwMSrHVBa zU4r2Q45Vv1cofp/3n9tPjiEhbtoj/DxS6hNtjdbzivBv8C2Czl+xRXGAS+dhMiWKz0r /CIdRyWY17x9u18PW8dv9F5DlJFuCEK3kFjIekHWt3qgvtdh/p5TxWQX/VTgOScLeSHE 7x32o2kDITVj9QcRo0K2UK8/Mgua27wg8lQIjh01Up1//2t3VGz9t58HMSjr+JHyVx+X DncQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684732065; x=1687324065; 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=zXcykhEsvUWhqgulB/awfwAbXbqU+zgrczKRgN6cHyY=; b=epk21wUYFvH5Ivgzu1Szb24s/kbvhZLn5NlQZVxKGPsNGRfhrpp8BrYaEpgfdjtQal 9zVGEJmi8fG5PHpXrjFzTp6s9e6k0I0R/l6PPiSGEValC1kAcLMq2/YkXieIt+bAd/x8 bsrgiGOK2Rru2w0KjTIuRcaty9BhVIItz4WCZGFEzcwQewXFjzjG1RLHuXvRTD/P3+lI 6HshhVW7wohNyn4/Nbsl5gj0Q4RS4csV26wDc/zRrtlq4CMfAwPAsc89YI+K3ITidR7g nOi1BcIl3x37GC6vlEbndNfbFLwZeX/JHGzc/MLLftscKxXFs4ZYdhRgFFjGlvPz3Pbo 92MQ== X-Gm-Message-State: AC+VfDwrNaCBegLriI2NOtsM4/I8f3/m25IZKPtp4sK5x6YilPU67ZZB Q2ufvHUKR9VlqfAUObuKgXG2gg== X-Google-Smtp-Source: ACHHUZ4GwWTWE5gkEqNoMIf2XcDiWGmxfbFx8zj08GpTeiP2eOnG/1Io/VG9zQ4q7LRUwyQxcVeeSA== X-Received: by 2002:a05:6a00:1803:b0:643:6aed:3a9 with SMTP id y3-20020a056a00180300b006436aed03a9mr12429588pfa.0.1684732064880; Sun, 21 May 2023 22:07:44 -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.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 21 May 2023 22:07:44 -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 09/10] maple_tree: Simplify and clean up mas_wr_node_store() Date: Mon, 22 May 2023 13:06:55 +0800 Message-Id: <20230522050656.96215-10-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-Rspamd-Queue-Id: EF3821C0007 X-Rspam-User: X-Stat-Signature: yanx9539woh8x9pxbp7e98zqgfkidew9 X-Rspamd-Server: rspam01 X-HE-Tag: 1684732065-487965 X-HE-Meta: U2FsdGVkX1/IoiJBzjmsovzxxoQMfjjpQITHmh2K3+PapmB3V1Hj8ID6moQWhhoP+2ClTP84FUWoXptTWw7tyXxVeFT89MNzrqklOJJnNcpsG6q4AabJB+cuqBS0Gk8mFDOGuO3A8gjAKTvhTC0wk464bUeSGtiHRrwdWUjah5a4folXTC6PQpMEmSzygus5lW/V18yvs8A6elLuIjILaFu218fsU4y7VkT+YnLIEcLblS6AMWunfHAJiBjBuDFTXJkEwOd7uVKsvsYb2d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3JWjvA8St223kc5oO+TWy5x9LxdfVVYg+W9pEXk0MD1aN5rtgW7g/MhWc50deaPBQ4ug1OX3izlCDeTF1fMFuc= 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: Simplify and clean up mas_wr_node_store(), remove unnecessary code. Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 87 +++++++++++++++--------------------------------- 1 file changed, 26 insertions(+), 61 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 1fc872f7683c..aa1472c45757 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4075,52 +4075,27 @@ static inline int mas_wr_spanning_store(struct ma_wr_state *wr_mas) * * Return: True if stored, false otherwise */ -static inline bool mas_wr_node_store(struct ma_wr_state *wr_mas) +static inline bool mas_wr_node_store(struct ma_wr_state *wr_mas, + unsigned char new_end) { struct ma_state *mas = wr_mas->mas; void __rcu **dst_slots; unsigned long *dst_pivots; - unsigned char dst_offset; - unsigned char new_end = wr_mas->node_end; - unsigned char offset; - unsigned char node_slots = mt_slots[wr_mas->type]; + unsigned char dst_offset, offset_end = wr_mas->offset_end; struct maple_node reuse, *newnode; - unsigned char copy_size, max_piv = mt_pivots[wr_mas->type]; + unsigned char copy_size, node_pivots = mt_pivots[wr_mas->type]; bool in_rcu = mt_in_rcu(mas->tree); - offset = mas->offset; - if (mas->last == wr_mas->r_max) { - /* runs right to the end of the node */ - if (mas->last == mas->max) - new_end = offset; - /* don't copy this offset */ - wr_mas->offset_end++; - } else if (mas->last < wr_mas->r_max) { - /* new range ends in this range */ - if (unlikely(wr_mas->r_max == ULONG_MAX)) - mas_bulk_rebalance(mas, wr_mas->node_end, wr_mas->type); - - new_end++; - } else { - if (wr_mas->end_piv == mas->last) - wr_mas->offset_end++; - - new_end -= wr_mas->offset_end - offset - 1; - } - - /* new range starts within a range */ - if (wr_mas->r_min < mas->index) - new_end++; - - /* Not enough room */ - if (new_end >= node_slots) - return false; - - /* Not enough data. */ + /* Check if there is enough data. The room is enough. */ if (!mte_is_root(mas->node) && (new_end <= mt_min_slots[wr_mas->type]) && !(mas->mas_flags & MA_STATE_BULK)) return false; + if (mas->last == wr_mas->end_piv) + offset_end++; /* don't copy this offset */ + else if (unlikely(wr_mas->r_max == ULONG_MAX)) + mas_bulk_rebalance(mas, wr_mas->node_end, wr_mas->type); + /* set up node. */ if (in_rcu) { mas_node_count(mas, 1); @@ -4137,47 +4112,36 @@ static inline bool mas_wr_node_store(struct ma_wr_state *wr_mas) dst_pivots = ma_pivots(newnode, wr_mas->type); dst_slots = ma_slots(newnode, wr_mas->type); /* Copy from start to insert point */ - memcpy(dst_pivots, wr_mas->pivots, sizeof(unsigned long) * (offset + 1)); - memcpy(dst_slots, wr_mas->slots, sizeof(void *) * (offset + 1)); - dst_offset = offset; + memcpy(dst_pivots, wr_mas->pivots, sizeof(unsigned long) * mas->offset); + memcpy(dst_slots, wr_mas->slots, sizeof(void *) * mas->offset); /* Handle insert of new range starting after old range */ if (wr_mas->r_min < mas->index) { - mas->offset++; - rcu_assign_pointer(dst_slots[dst_offset], wr_mas->content); - dst_pivots[dst_offset++] = mas->index - 1; + rcu_assign_pointer(dst_slots[mas->offset], wr_mas->content); + dst_pivots[mas->offset++] = mas->index - 1; } /* Store the new entry and range end. */ - if (dst_offset < max_piv) - dst_pivots[dst_offset] = mas->last; - mas->offset = dst_offset; - rcu_assign_pointer(dst_slots[dst_offset], wr_mas->entry); + if (mas->offset < node_pivots) + dst_pivots[mas->offset] = mas->last; + rcu_assign_pointer(dst_slots[mas->offset], wr_mas->entry); /* * this range wrote to the end of the node or it overwrote the rest of * the data */ - if (wr_mas->offset_end > wr_mas->node_end || mas->last >= mas->max) { - new_end = dst_offset; + if (offset_end > wr_mas->node_end) goto done; - } - dst_offset++; + dst_offset = mas->offset + 1; /* Copy to the end of node if necessary. */ - copy_size = wr_mas->node_end - wr_mas->offset_end + 1; - memcpy(dst_slots + dst_offset, wr_mas->slots + wr_mas->offset_end, + copy_size = wr_mas->node_end - offset_end + 1; + memcpy(dst_slots + dst_offset, wr_mas->slots + offset_end, sizeof(void *) * copy_size); - if (dst_offset < max_piv) { - if (copy_size > max_piv - dst_offset) - copy_size = max_piv - dst_offset; - - memcpy(dst_pivots + dst_offset, - wr_mas->pivots + wr_mas->offset_end, - sizeof(unsigned long) * copy_size); - } + memcpy(dst_pivots + dst_offset, wr_mas->pivots + offset_end, + sizeof(unsigned long) * (copy_size - 1)); - if ((wr_mas->node_end == node_slots - 1) && (new_end < node_slots - 1)) + if (new_end < node_pivots) dst_pivots[new_end] = mas->max; done: @@ -4379,7 +4343,8 @@ static inline void mas_wr_modify(struct ma_wr_state *wr_mas) if (new_end == wr_mas->node_end && mas_wr_slot_store(wr_mas)) return; - else if (mas_wr_node_store(wr_mas)) + + if (mas_wr_node_store(wr_mas, new_end)) return; if (mas_is_err(mas)) From patchwork Mon May 22 05:06:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 13249776 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 762D5C7EE29 for ; Mon, 22 May 2023 05:07:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 12179900011; Mon, 22 May 2023 01:07:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0AA96900002; Mon, 22 May 2023 01:07:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB420900011; Mon, 22 May 2023 01:07:50 -0400 (EDT) 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 DB176900002 for ; Mon, 22 May 2023 01:07:50 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B16284044B for ; Mon, 22 May 2023 05:07:50 +0000 (UTC) X-FDA: 80816708700.26.BCFC143 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf28.hostedemail.com (Postfix) with ESMTP id DE21CC0007 for ; Mon, 22 May 2023 05:07:48 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=AzHzNd0m; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf28.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684732068; 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:dkim-signature; bh=4yOLk/7tHD7/ODqSb7roZU5d9FbnbbLKf36QePLl4Fs=; b=3XVMv6m9cJog2tSXMKnAU6IqnEWI5DbtRJ8juVI9PeY/Q9OKIaRdnmEhCVo/3OQDPg761I /9rqJlhT8aqSFnu+1OpbKv6iJX2JNW7XHo+IgCzB4OQ8b3PAweLX16NaFToZ02qOW0G8Kr 2gRK5AV2Rv2nLGQ1swjDCgBbqxXgkcA= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=AzHzNd0m; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf28.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684732068; a=rsa-sha256; cv=none; b=ojTs7fwUS9wIwTgBE/ztyHQPF2tURknI2i+EN03/tUhW6zl48NBLAozH701Hnn8Fb9D2Mc zA49RuYLfBAMBTMRxcqIfCbzMRYnakF1NX9u6+73opOn0q0FDQuGwwUAlZvE2RkJJlnP69 npKhkoW/80p0bQ7cmt5hnYSNCcIQIAw= Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-64d30ab1ef2so2133663b3a.2 for ; Sun, 21 May 2023 22:07:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684732068; x=1687324068; 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=4yOLk/7tHD7/ODqSb7roZU5d9FbnbbLKf36QePLl4Fs=; b=AzHzNd0mvm+jLZUdv/e7B4MQC3FEjUAXCF3VVAaoRyZSNx71MXEV51MxVvMQPGTRnL beZ/HAieLZVm6erPnazYr8lxJ/KMnHLGwVLS9rpwqD4TZwtSOLNIx2ilFdPluS8Fo5wH aulAdvKjGbORvC5pYRoimAsxCsbmmub7MiwaCjUVNgDxrPoNguk1B2QxFs2f/4u0BDxC ghdjhr9rKY4kS7OZrxzDsus7afl7TirEZO6XG2XE9PaDtCnJIS3J6uHgXmphvXYrsd64 V0VVSCQSKamOqt+7V9vZLiSj9VDqYA4y4mi6VfOkA+OqJDHu8LZDsc5yOBZRw9CnQDtp /E8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684732068; x=1687324068; 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=4yOLk/7tHD7/ODqSb7roZU5d9FbnbbLKf36QePLl4Fs=; b=IJcC2HyP8ob/93uYysH47VyosApu/nZiPKlOiPxlnNTPGiOgyw5Vrh1OjVbAoEia9M 41dHPNMR5EmFXe6W+mDSb7IJmwmdS78tNYS9TitC5VuIgF24VBsAxYUaCOWOZfHH4TFG PMO5t01hY3eNAQbe71tCO8PXT7Tb9xpAew5OzbUTSEcdjh59tzEnIacC2C9X3CnHsetJ f4DVm3zE+oXv21y0BFmz/EY46kDESnq1NvPafFLccK4UFy0QKHtM+4uN3yI03UuIMxvB pfEjm7LCqVWVNBA6DmASv2PrwrfLhPabVFzp68m6FOZWiKJFNtyRLyq9bSuxJdqFXWQM LfhQ== X-Gm-Message-State: AC+VfDwQ+hwSageXnR/UK1B2dqRLeoSe045LzgkUjL0ae7yomJFVd1FW nc9DRQcl77dL8uSkps9BvC7+NQ== X-Google-Smtp-Source: ACHHUZ4VTPblQwvMklYDFzU1McTkdLu8cOzHgLuHXQ1smW7pdssNegVfLfyh8uucTfzZ0+l2hFIQ4w== X-Received: by 2002:a05:6a00:c8d:b0:644:c365:50d5 with SMTP id a13-20020a056a000c8d00b00644c36550d5mr11924837pfv.6.1684732067735; Sun, 21 May 2023 22:07:47 -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.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 21 May 2023 22:07:47 -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 10/10] maple_tree: Relocate the declaration of mas_empty_area_rev(). Date: Mon, 22 May 2023 13:06:56 +0800 Message-Id: <20230522050656.96215-11-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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dUZMmIwj0QYGnL5d4l0vxRcSarl1A+HG67B DnGWGdQl m6svlgFAlRqZMKgxl1xBZH6uRwZ+ZE4cYmcYn5iuQFl8NojuF3hDKwC+KusSzZOtwJDadg+cvrlqZ210cjYAl+r4tLp3orLd5lAJEv4lIBS9fosci5eQk2N4aL2sL8ShP7WhHBbCX4vKenjsaf1zGGCQsSjUvsiQ+xTu+SLzn9KzwrVx5OtQelN8GFtcttYkGX8GKGG2+akSlTyR5TrlUE2ZE7Cq8bc7cOjX3GMM+xV8ROuSvG5XJHBHl+eEFCQ+6bqyYkbNcsiCSWXZknK9ddw7l1Sfu3rbauunVX5exumP++0Q5u3ZznXeO4xSMJ7uGVnb4vCapkiJH9a7bJRwoHbNOAyvGc424C+MT+Zq84aIi9HbKOT0wTytT0hN6CKx+wbzMGCgeJ3yi3QtRR7BvGGxCSZVNLyhOPBAHPhm0V0lsZ1zhAR/BmuWBoBiAobSl5BDhY1tU8Uvk/yA= 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: Relocate the declaration of mas_empty_area_rev() so that mas_empty_area() and mas_empty_area_rev() are together. Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett --- include/linux/maple_tree.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index 85559a34a098..c4681cb8414f 100644 --- a/include/linux/maple_tree.h +++ b/include/linux/maple_tree.h @@ -474,6 +474,12 @@ void *mas_next_range(struct ma_state *mas, unsigned long max); int mas_empty_area(struct ma_state *mas, unsigned long min, unsigned long max, unsigned long size); +/* + * This finds an empty area from the highest address to the lowest. + * AKA "Topdown" version, + */ +int mas_empty_area_rev(struct ma_state *mas, unsigned long min, + unsigned long max, unsigned long size); static inline void mas_init(struct ma_state *mas, struct maple_tree *tree, unsigned long addr) @@ -497,12 +503,6 @@ static inline bool mas_is_paused(const struct ma_state *mas) return mas->node == MAS_PAUSE; } -/* - * This finds an empty area from the highest address to the lowest. - * AKA "Topdown" version, - */ -int mas_empty_area_rev(struct ma_state *mas, unsigned long min, - unsigned long max, unsigned long size); /** * mas_reset() - Reset a Maple Tree operation state. * @mas: Maple Tree operation state.