From patchwork Tue Oct 15 12:07:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13836274 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 61B24CFC29A for ; Tue, 15 Oct 2024 12:08:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D2F5A6B0093; Tue, 15 Oct 2024 08:08:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C91116B0095; Tue, 15 Oct 2024 08:08:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE45E6B0096; Tue, 15 Oct 2024 08:08:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8806E6B0093 for ; Tue, 15 Oct 2024 08:08:29 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 25DBE1201A7 for ; Tue, 15 Oct 2024 12:08:21 +0000 (UTC) X-FDA: 82675714128.22.30CFC0E Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) by imf22.hostedemail.com (Postfix) with ESMTP id 82533C0016 for ; Tue, 15 Oct 2024 12:08:18 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="jvKxZl/z"; spf=pass (imf22.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.41 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=1728993917; 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=s82n18uX65YlaY3Zrmh/b7hAZA3lY4DlogWu8YT9Tdw=; b=3Ko24cGKZKpMVdzu2cCTSGn1Inzp3mScQ0id7jBWsOFFCHd1pvanXFlaGwRgGUEu9GgtZK tADuTPSq8qvUpQCKntUchGi4UTiFteQLwHQXYrFiYXWUDz5d1eKMYZAFKvkb6jdUhwnSzW cA00Bviy0wiLMgmMWp0CPsGmlxGdC4A= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="jvKxZl/z"; spf=pass (imf22.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.41 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728993917; a=rsa-sha256; cv=none; b=k9gpp6GuxQOTc9jmSurydsom8w5Ehm5LPTC5X3fh6eIwSEZDH9C9CoshmYFm3sRwgOvS7g 5praj1djxNLIDLUJXswCcxx296OwX3TUoIBaLj6WtogBbFPkD/XR7Lqfyy20jxSCL5sGJO yDruOBJgmFE+kbl3la6YdS1uEVMv3bc= Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-5c9362c26d8so9000655a12.1 for ; Tue, 15 Oct 2024 05:08:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728994106; x=1729598906; 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=s82n18uX65YlaY3Zrmh/b7hAZA3lY4DlogWu8YT9Tdw=; b=jvKxZl/zhlOBVG2e3UxM1ABcsO6i5a3drRCNIXjQCDdoyuCknxdtsmyEPE4o3hN67C HkLa6EbVpckk0RftLFK3juzBCFVHYqmzCJKjdPsADgm5FNdtA3Jd9fyo+FLXMfNmLD0o fJRcedLurKl38ThJs6gNQWWile7iG2HpUD23Orxku03OCPUB4q76E01oCjsqulmeNJUQ ekA7a+IBo7pcT+6+mkWpMnKtbE4CjtSvk2MIsX/cM+p0OOfjNEmJlYea8SvnskTR9Pvi S9e0evOBoKOCmxLltuXRtGrI6raGLgIXKnVdy80sKNCk16cdWeLObx5x8eQyPbZjSzUy Qj/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728994106; x=1729598906; 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=s82n18uX65YlaY3Zrmh/b7hAZA3lY4DlogWu8YT9Tdw=; b=kiWD5Qk2o0SBjJgPJVDgWfuYk+APN5RY9zazv6K2yjgY/glfh0Md+ht7SUwjWkHwet 2NJRY7sSVwJjZmiKhU02Q4OPKDCPx80vTEco9Hwf8fVarBv5/OaB/h16UIogxPf+P0dd R1q9qPuO6a5EoSGWwKe2IvHwWCSgvENCrXOmwAkrI+hogyraijk3DXhGWHHJ1Qqzi0yN d1Jp/fi9Dph27pEeRb9Nl3yxbSbxguSeo2J7CGWjTEQjo7eMzHIvI0ZMrsbnPMOj0Ggo Kf2LPFgb5ip3DYK7ROhgBxU4+ygJCNtHOJ0miBeJrn1t9TdzdVyFUDm2dxcxE/bHPIvY tT+w== X-Forwarded-Encrypted: i=1; AJvYcCXzSTUfLFwEnj0xZFtTazW9+lzox5fIdTR/gfKT9I2QDS+R0ac9KZY8Rv57gLt6nUjk8Ty51/7LFw==@kvack.org X-Gm-Message-State: AOJu0Yz5UPBdRW/TA9wHmkgT7+o6qS3ahIMRJXwKmCwNgwZXQ8ug/Fiz jt5o0I/ClzRKXmDWu5hVTDIsvYEXmzKfMZhSWz4/tmsAVgxOgKROMv9/7T6a X-Google-Smtp-Source: AGHT+IGD9AawcnG2BwKUXycWqcPDeiYkbxKsmoFPiyXS4a5xjMBfbVjb6zXO8qRfR8Ogu3FKl5575Q== X-Received: by 2002:a05:6402:2690:b0:5c9:6c7:8b56 with SMTP id 4fb4d7f45d1cf-5c994817c03mr271257a12.7.1728994105550; Tue, 15 Oct 2024 05:08:25 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c98d4f9519sm631237a12.30.2024.10.15.05.08.24 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Oct 2024 05:08:24 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org, Liam.Howlett@oracle.com Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org, Wei Yang , "Liam R . Howlett" , Sidhartha Kumar , Lorenzo Stoakes Subject: [PATCH v2 3/3] maple_tree: simplify mas_push_node() Date: Tue, 15 Oct 2024 12:07:46 +0000 Message-Id: <20241015120746.15850-4-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20241015120746.15850-1-richard.weiyang@gmail.com> References: <20241015120746.15850-1-richard.weiyang@gmail.com> X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 82533C0016 X-Stat-Signature: 9yqu9rxm7jtwpwm7pwzzhpew1mc3mq9x X-Rspam-User: X-HE-Tag: 1728994098-940579 X-HE-Meta: U2FsdGVkX1+TyXw5wPYg/eqGQ3P7LOupeyKUcMirhOTVUJ3oxoXrNnKpuKbdgnMVVtexqwgQEUsgv+J7g5mo/zvPKzdlMmOL9wm40nN+izMYuqva/iBP1I6iDq5NkGXsUcE2jQCUWcHLJONZYh7C4ZZX/c6Y0aPJR0E0OS5D0ZE7Oyy1EanhnCyqCOGILNuE/HxpAXYYEJpXqNvLFZQeN01QTiaRpFyPnYgXe0iH1wStRid0p70C/wBWt5ACMQEZxHLqQm4Ad13p43Kdo2RvW7W4It3PRa7XNIRA7ZSGeNWQ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S+0zp0qsFkHu4Ow6kiIlGbHySpBslh/QBISYd1aldSrhbVkjtZsDRELtVazzAAOqImK1bPU69+RuAsLbsJl84qd0ZSI2R9FrbPnHGA22M2A8pBbT9uJ0VUgqyag55Rfc X-Bogosity: Ham, tests=bogofilter, spamicity=0.000044, 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 checking the head pointer again. Also count represents current total, we can assign the new total by increasing the count by one. Signed-off-by: Wei Yang CC: Liam R. Howlett CC: Sidhartha Kumar CC: Lorenzo Stoakes Reviewed-by: Liam R. Howlett --- v2: refine the change log --- 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 ab398461754b..afb59bb6a641 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)