From patchwork Tue Dec 20 14:26:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vernon Yang X-Patchwork-Id: 13077942 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 4C99AC4332F for ; Tue, 20 Dec 2022 14:26:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DCA48900003; Tue, 20 Dec 2022 09:26:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D7846900002; Tue, 20 Dec 2022 09:26:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C3F7C900003; Tue, 20 Dec 2022 09:26:43 -0500 (EST) 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 B25FF900002 for ; Tue, 20 Dec 2022 09:26:43 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 851FA120A4D for ; Tue, 20 Dec 2022 14:26:43 +0000 (UTC) X-FDA: 80262910686.26.23404B4 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by imf18.hostedemail.com (Postfix) with ESMTP id C325B1C0009 for ; Tue, 20 Dec 2022 14:26:41 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=MjWc8w+J; spf=pass (imf18.hostedemail.com: domain of vernon2gm@gmail.com designates 209.85.216.43 as permitted sender) smtp.mailfrom=vernon2gm@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1671546401; a=rsa-sha256; cv=none; b=jNkJdNXE28L6ULceXOKkm1YAPiYKioZWr/a8hvPIdFe4BveQYmkAzjUDnCkUGgxP6HfY7l OiZJ19fUUPo2ItRAMX0xM4OAotP1e4LsbbFNpi2oTVcDA0Yk4WyNeepAJAftIymwsAKI6s h0aCx3d+HClDJbB0p5woWPSHNxLvX9E= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=MjWc8w+J; spf=pass (imf18.hostedemail.com: domain of vernon2gm@gmail.com designates 209.85.216.43 as permitted sender) smtp.mailfrom=vernon2gm@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1671546401; 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=WdykleZ4reuZUDGuALMZqWmYTc5/lzRFBIQz0bC+lNM=; b=dMGwRu7RQ+dSHTZU8N/5TFkWDHdkCiY9IfogQ6t0gx0p7U/xrrWCJJGR8/Zsc2K2bM6t1Z NYMZ1JoFXhRhCrx1j3ECUDbKqEiy3GWD7pdOnzcdrFJXfZFLeIG+XMsdrfrfOqNon6hTGd 416JtiVVM0KrLxCzm0uMEqqT1tN6DVo= Received: by mail-pj1-f43.google.com with SMTP id u15-20020a17090a3fcf00b002191825cf02so12279199pjm.2 for ; Tue, 20 Dec 2022 06:26:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=WdykleZ4reuZUDGuALMZqWmYTc5/lzRFBIQz0bC+lNM=; b=MjWc8w+J1L/tQILl3fKHOTFPdPs4BkgGvNq9Ml0XhG6X+6LIzrSZQOi3N6Dt2yivwF x1VWHknuFzz/h9fQO6fsK+pGbqdDG9ykURDlJPWXGCLIWAfKmcaP6+gjc52dxFKODS1A VPtN5QlkkET/bPsQltPV7i/6/QA+N9vRe74+/204GPE7KL9Zry5fXf1didvfwwwKbFMk eJpotQlOzt/ox/8DO57kgjajFvSe9QllroD4IwNLNqdPIs3WYTP3fUrUczTvExvA4efz 58wPCroWJz1YGYjBTPIe5C8uvianCzXItcy/sHWPhhtUlyVwjRZL+W4uEUK7SF5dsBdM WHtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=WdykleZ4reuZUDGuALMZqWmYTc5/lzRFBIQz0bC+lNM=; b=UC0ygUiCE7G9Zc1tT/4yfAWA24I8iMGLpUgZKX6XDLivvbgSMLf/2zmpF0Lxw5mTRW +jQUOXyM0InFn28O5zHiw8N1quhWcKZk/skimjWxFa6i0I9VpjGDAL9yP9ZlvLGcVEhn 6rvrN6aVRifN3sIlcS/mk6RZRxMi4gePDXwi6/WVSdbhlmFrGs0GmLoAAEHxNKXNA0wn CSGTbmIEqIJamkgQ5N9RCwQp6RCf+DkifuabeobCvFSLNeoliOWojcKUnPt56tD9eP3I eWKCnJnj3wF/1nA+l8QRjIWk5iFY71CUwzzfnPKXKLMIaEX/+1zfHSJOSVHuNyzGQJxK Xypg== X-Gm-Message-State: AFqh2kropCr+jwK/AekHrqtqZAXe0GZCTQQZzFE7yCeAymU1V2JXDWFq 3x5XEIEZq7pWJRh5HbysKk0= X-Google-Smtp-Source: AMrXdXsBSW0EHE7rAoMotD3hOgcA/OPQtakxM4iNqFUFItIPYliZloQamq8otuQdfILXanPorw0cxQ== X-Received: by 2002:a17:902:710f:b0:190:d69c:1418 with SMTP id a15-20020a170902710f00b00190d69c1418mr12103783pll.2.1671546400816; Tue, 20 Dec 2022 06:26:40 -0800 (PST) Received: from vernon-pc.. ([114.231.52.81]) by smtp.gmail.com with ESMTPSA id ik11-20020a170902ab0b00b001897bfc9800sm9383398plb.53.2022.12.20.06.26.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Dec 2022 06:26:40 -0800 (PST) From: Vernon Yang To: Liam.Howlett@oracle.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Vernon Yang Subject: [PATCH 7/8] maple_tree: refine ma_state init from mas_start() Date: Tue, 20 Dec 2022 22:26:05 +0800 Message-Id: <20221220142606.1698836-8-vernon2gm@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221220142606.1698836-2-vernon2gm@gmail.com> References: <20221220142606.1698836-2-vernon2gm@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: C325B1C0009 X-Rspamd-Server: rspam01 X-Stat-Signature: t3m6151h3a9wiefetrfuohoke3em34y4 X-HE-Tag: 1671546401-226395 X-HE-Meta: U2FsdGVkX19zGCAPdP1WTa5fmjSn5PoYxBYsUlu+/HVR8zXBRDMMkC9OosEdqryBz/sUZUkBW3ybMgnWUJWhv9DfQraWEiM9rRCCb5CR4PuqA9hp9VWN5i19DdGe/4kYzgh8lU9LS68GZI3VXICYUpnUYxQIK8ZCWtIYTMIB5xgJnddZxCLOpTGSyEcUNWiPj0FdOa03oPdzOqWo8ouQBqOMW1JtytwmX1GdwpN+8KuWKMsdIBd3b6t7uSg58PZNyLg81GF3QlNLVEGGxxZ5Z+tGe4GxHSweRoY+vT4Z/XvNoFTTi3VtXDTz0Vzt7fA24L/BbGb8FtpSU1BBRy5k72bhNtCMbgnpaWr0gqrSdGDYn+Hs7JpBDneNf8SqrbIyVx3qyFKbs/7VftlqAkrCt/PBjxu98MliaWV3Z6bJjzmYc8DcBIroWC+cP/MCX/w3XksrV4YiO7Qk4CWgVMpLqfJejfhIsQZ4QZ4L5A069xqRsXjwWfX76mG8raKBw8KJmoGQZMFuRJvI48/CCBvHikwpMOiEFBr+tmQzFqY9IC0hrcIw1kbDMDLsvqnSzEIlL7NG7znlQAwCBi4R6TNhXjyZhVWBN04HrcLoa0gvNJeZpIxOAC4sgocyFPfSyMjbtLLEBC+XzL3TJz1SmxjHwzwm95j7pkawEoTm7+2gXKcoLgWehEytQfgmnLyX7CbhtT0p6ZG/ZdCutUMOCRuhBE575YkLIpcnFg6GIenm7HmNzY+eAaNuF5sEkveXBs8Ge1VPAHFXJN55aUpIOOypTPJ4cMWyHWED9ay19w90ePr4MdHVxjDocCOxHAKIDr2gHFikaSMkxJxuQwre6igDDoQB2PoJLaYFTZz8laLKkyPS9hk3mVG199pfIa2HK6unPADQKPKcYjsvOTS3tCw2iq4ghuuwPcLJarbcOCQULCEs1SLWTL3RZ5PBJGk5gBbOT1M3TTxGRKnmHqVirpC wXI2rsAf l5VHiYJ0ZHWutqjE101SweE4LhqjZJXJh7y04rmzJkSSEE9ng5Xc6AqQUTfXKnQSsLsyc26+EO2ILPyoq7X4ON68Y2pKa3UQ4IsDl0nLUFQjYafJ/mjq3CTSIZzbxxbynfTyr7dHfXIIZvaWE950MHp3Zz8N9zb/qyXA4O+d/G863P8U= 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: If mas->node is an MAS_START, there are three cases, and they all assign different values to mas->node and mas->offset. So there is no need to set them to a default value before updating. Update them directly to make them easier to understand and for better readability. Signed-off-by: Vernon Yang --- 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 e7dde4a1d6cb..16cdcf309e97 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1329,7 +1329,7 @@ static void mas_node_count(struct ma_state *mas, int count) * mas_start() - Sets up maple state for operations. * @mas: The maple state. * - * If mas->node == MAS_START, then set the min, max, depth, and offset to + * If mas->node == MAS_START, then set the min, max and depth to * defaults. * * Return: @@ -1343,22 +1343,22 @@ static inline struct maple_enode *mas_start(struct ma_state *mas) if (likely(mas_is_start(mas))) { struct maple_enode *root; - mas->node = MAS_NONE; mas->min = 0; mas->max = ULONG_MAX; mas->depth = 0; - mas->offset = 0; root = mas_root(mas); /* Tree with nodes */ if (likely(xa_is_node(root))) { mas->depth = 1; mas->node = mte_safe_root(root); + mas->offset = 0; return NULL; } /* empty tree */ if (unlikely(!root)) { + mas->node = MAS_NONE; mas->offset = MAPLE_NODE_SLOTS; return NULL; }