From patchwork Tue Sep 24 12:39:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13810897 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 8D6BACF9C6F for ; Tue, 24 Sep 2024 12:41:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 90D386B0093; Tue, 24 Sep 2024 08:41:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 89FB26B0098; Tue, 24 Sep 2024 08:41:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 70E0F6B0096; Tue, 24 Sep 2024 08:41:44 -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 524096B0093 for ; Tue, 24 Sep 2024 08:41:44 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 14F2D141A1C for ; Tue, 24 Sep 2024 12:41:44 +0000 (UTC) X-FDA: 82599593328.11.4870E60 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by imf19.hostedemail.com (Postfix) with ESMTP id 458931A001D for ; Tue, 24 Sep 2024 12:41:41 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=POt2Pgi0; spf=pass (imf19.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.44 as permitted sender) smtp.mailfrom=richard.weiyang@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=1727181583; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references:dkim-signature; bh=DTCX2QOThzsuQGVtvyCK7mVFsPrbNpg/YVipOq7FEAY=; b=bDHzdp1hQPMBk7aj0jrWGeQsJUgdrk7RtOc1HXirb4tCcnpWZXiaU492bJKhxUZa84NROk oMBvJhJc6HfdGnI/Q0G+IvXItYNJfG+ffAt9yHkNNU5rh1ZN4ASghCz6KrmhinivxKP9zO kscNh2Q1sBCBdXeQ2A+oxQJaLvM5dk0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727181583; a=rsa-sha256; cv=none; b=yyj6LKI9kJ44/nLKxwZTVdiKzIdeg0yQZNWu7mDZ887puol8UqYylLWBDf2L4LCgEeHKVc NLTwNohXTvRAtcSdpu1L2wftMWsoKwKPKiJ9koeiH6d3iZhDkq9E5yw3Vd1bGCR7AjcG37 dz56ETM6bOzgM9MJ+2UbPVJ60uKdxzE= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=POt2Pgi0; spf=pass (imf19.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.44 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-5c26815e174so6894116a12.0 for ; Tue, 24 Sep 2024 05:41:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727181701; x=1727786501; darn=kvack.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=DTCX2QOThzsuQGVtvyCK7mVFsPrbNpg/YVipOq7FEAY=; b=POt2Pgi0FIX9nEbQhLNbzOlBnMxnSZq9okmLj9MQL3pWXOLbDDjW7mnFkFH4z1XKqi BDmCYXArVeSDHRDm9co1Wj0P85riA9HqFwMdlPZqXe6OZsvIKQNOc2aAzjVL9Mb3S1DL a+cM8DJj/HIvE4WXjJK5ZBNZeaOGz8hnvg9mpfAPI84CvEOJG1oHfB2jaitsTIO6dhDK 5vJTHuNPFoDifnXAZ3kFr/q59/RhUYEDzKU0VV5IPao7jhR3/oJRotYKk9Mv9P/+eOFc XE2cvNZRlr/LaMVNqojHcGZFFuNW7mx8xEAwLGkkk/zF2pSH8s3cXWKWlRPoMyy1o7My i4kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727181701; x=1727786501; h=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=DTCX2QOThzsuQGVtvyCK7mVFsPrbNpg/YVipOq7FEAY=; b=BEjvuPpNWqCs4F71s2xfp222t+vw2gfXgwZoA7DMfftdwVbvw5p9F3mb1QnW9snoGj 0+aiChRqNLWDIhbJnPtDXGhYEeLzYlQ8XJKORLITHaTjkJSr0NzCgOZ7dSV5s3UUmP1S tHy9+YvYk0vVrJWu4CoDHgXQNRH2Qzm9YhyH1I2zD7XqC+bxWf4li16Q5nTGUXhcske6 cUER0AyJScUmdlnu2t+mjm/cUZqD1Xi62pFF+aRObJ2jkFEIPTwWZPjTZJLjOMufbn1q S1oZzxjbFU3ljERZfTGBQcu9Vo7H9bdMf/Thv/H0XZH6cYdZFKkY1im1thCt3g26/7iJ I4Fg== X-Forwarded-Encrypted: i=1; AJvYcCVnFEuTHOcVv7XOguaxGcXJbaQizLLjdSinjw9Co2T+XFABReLJL+0JN01IdVNmScP4hTEgBN7p/w==@kvack.org X-Gm-Message-State: AOJu0YzEpq6k7Oe0wopiC+oY9PmaFmshGeoIVv+YkHp9p1AH+z7olB2i SoI1k49CFHZq6Yp8DFsOvRpROCq/U+bNlyD8whA9C3USlTxU3ToV X-Google-Smtp-Source: AGHT+IH+XP6lIGGVxVF9U71t98fzOQtKGbu57SrPwdbiI8wl2USUAsjdeJpinlo18qkAYo0Pny21Uw== X-Received: by 2002:a05:6402:13d6:b0:5c4:6568:736c with SMTP id 4fb4d7f45d1cf-5c4656874bcmr15847420a12.0.1727181700529; Tue, 24 Sep 2024 05:41:40 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c5cf4d78b1sm717610a12.87.2024.09.24.05.41.38 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Sep 2024 05:41:38 -0700 (PDT) From: Wei Yang To: Liam.Howlett@oracle.com, akpm@linux-foundation.org Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org, Wei Yang , "Liam R . Howlett" , Sidhartha Kumar Subject: [PATCH 3/4] maple_tree: simplify mas_push_node() Date: Tue, 24 Sep 2024 12:39:53 +0000 Message-Id: <20240924123954.18933-4-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240924123954.18933-1-richard.weiyang@gmail.com> References: <20240924123954.18933-1-richard.weiyang@gmail.com> X-Stat-Signature: bx3d8agdiqzi7ptzrddzo847s86n4x68 X-Rspamd-Queue-Id: 458931A001D X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1727181701-7520 X-HE-Meta: U2FsdGVkX18n780AtaolJiDuU00cw5uyuDhbqYoqY5iS5NOqvlLf7fXt9kGmgIKambw3eelx98y3oaokny+LLmqrScLta72Cr11zfJ2w4+jwEFvgiPpgTRD9X5zJC49tceOw/mZ7yNhCWitigopXm9lKGMEIbRAbWEJ2uuR9zeyt/2iUSnp6I8nkoXsljPo5KydTCMUav3GRDqGWRsLhYEdhZVtq4KekIyoXb4NtMpx4GQ0gLpcnX5MtxUJSBOzYMJp1OD1JHlvvplSKEri1qZjwmutCY5QvcyqfwQg+cnT+i1H8/J3Tyox2+U+1UeUSGZLCJkOdEwfYJepTbRjfOykSxJIB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QzxO1ij+w14C2WCHGqLd+u2YiFgwPjA670Q6FszpAGKTccsI7lPaYt9OtRgm87cXecCd6p4DPsRK58VAldbytlq3f X-Bogosity: Ham, tests=bogofilter, spamicity=0.000165, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When count is not 0, we know head is valid. So we can put the assignment in if(count) instead of check head again. Also count represents current total, we can assign the new total by increasing count at last. Signed-off-by: Wei Yang CC: Liam R. Howlett CC: Sidhartha Kumar Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index c1fb67540cc9..1cbc5f7ca40d 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1192,19 +1192,17 @@ static inline void mas_push_node(struct ma_state *mas, struct maple_node *used) reuse->request_count = 0; reuse->node_count = 0; - if (count && (head->node_count < MAPLE_ALLOC_SLOTS)) { - head->slot[head->node_count++] = reuse; - head->total++; - goto done; - } - - reuse->total = 1; - if ((head) && !((unsigned long)head & 0x1)) { + if (count) { + if (head->node_count < MAPLE_ALLOC_SLOTS) { + head->slot[head->node_count++] = reuse; + head->total++; + goto done; + } reuse->slot[0] = head; reuse->node_count = 1; - reuse->total += head->total; } + reuse->total = count + 1; mas->alloc = reuse; done: if (requested > 1)