From patchwork Thu Sep 19 23:48:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13808060 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 A7548CF397B for ; Fri, 20 Sep 2024 00:40:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A5F306B0082; Thu, 19 Sep 2024 20:40:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E65C6B0083; Thu, 19 Sep 2024 20:40:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85FD86B0085; Thu, 19 Sep 2024 20:40:04 -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 67D8F6B0082 for ; Thu, 19 Sep 2024 20:40:04 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id F1788C1122 for ; Fri, 20 Sep 2024 00:40:03 +0000 (UTC) X-FDA: 82583259486.16.E62CC21 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by imf11.hostedemail.com (Postfix) with ESMTP id 3CDDA40006 for ; Fri, 20 Sep 2024 00:40:01 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=NQ6oeYMM; spf=pass (imf11.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.167.50 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=1726792651; 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:references:dkim-signature; bh=ObZSJRmm/PkmjsdzQOfsxXRSxgzCJYW53vLYfBRGd7w=; b=uSe3hrVKxmf56Wwet3SiuFd9KxneYzNk3nKuxRfxA/LbE7RbIG+42MrJHJ3lL+IjAeBnkl RbgGCdz+MkyCdGLdeG1e3s5Cz7aQyrZJHPS9V0SL7xmyUI/zsD2MBfn77j2RV+HAY7topm Oy3TM5g6ZJDQKnaWgLXLHstJP9H9faQ= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=NQ6oeYMM; spf=pass (imf11.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.167.50 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=1726792651; a=rsa-sha256; cv=none; b=g1al9Ggn/4ukf8lCfT9oE9CPr+mlV2oNal6Sz8dhtG3GU44X5obxLsGyZ5Y1euVclDUm8C irATBqbxFHvUIJBYkoandidjX88zkE5+a8lF2wCIaE11eF25IrP9UofpU768GoNJfGg5p8 yNvIqLoXthyGiW/M1YAyOd5pqsrwe5I= Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-53653ee23adso1281554e87.3 for ; Thu, 19 Sep 2024 17:40:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726792800; x=1727397600; darn=kvack.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ObZSJRmm/PkmjsdzQOfsxXRSxgzCJYW53vLYfBRGd7w=; b=NQ6oeYMMzl1ltEqWvPhWMeVY9NIeUCVmngOdkYxODKOUJhHnBRsaQJtejOHW4kWLaY zxHdYdERd0eO5FPboSaGQbBmb1up/lSzJmVzk88k/a83i1U0E735zgypxRPgFeBJo+LP BRWyoGBWs5vlK4E2JI+lmKIFG6GV+Mcjrwsz9g3mWITpDErjky6BEAeevz6//rS2IoNl UZR/bBdPkJoxaEP+5uYfbAovToqYgxyXpXQje2MXplR6M6kn0og6gyTa1WXnivLGkYIv 6NTyIzeqXSzXmoHlD0pfabPTFQac6mFzcBwI+y4bLSur73618W0zWyt5eHqD12saB5Yy RGpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726792800; x=1727397600; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ObZSJRmm/PkmjsdzQOfsxXRSxgzCJYW53vLYfBRGd7w=; b=oLNTUYTHVeTw8YVJx9bkUyKS2Xhz2B2HjbFvMkMYJRsgJ65TJ6r3r+S9Si15hDMosi QsPvYVq4Jez7mkhs/59zzjiFK6sthuSU0KvQMX325ra471jpaM8GxSzfCXcTO8Xi9bys x+HW2nI8pk9AbePoaMN4BwqrcQJiNv4bKDXyjtUdC8z/cNNRY/1hlvNNsvffTN7lT1Cw eT/PCY5XfsoUIUASUOh/k9BAl6BuBgCeOjGOQkPscKEZEA6ApbE1HoNyf3jGygF/kBka KkcWkD/1xAElPf+EAZcgzol5JvHcHssIPB82TCkQ+8GH/nwekmKkil+v60IBSQ2uOSU+ 6K8A== X-Forwarded-Encrypted: i=1; AJvYcCVGH1zsWRGQzcvaoXf/LcLNubeHhPdTJzJPCKYNWRtfhJHadm1nkEYEWzqMoVMgmN7tsYFkaSUDcw==@kvack.org X-Gm-Message-State: AOJu0Yx1LzxwsrEZ60+ILOQ36WDALpEki6GmdK/YV5tvbyNsIZPg5hSq I2wsIN/8Z1fel1IfhJBMglT7v99EZWvIy86mgDJujL3aA0MhZ9/1 X-Google-Smtp-Source: AGHT+IGCDhv4yjoK+WZQXHrZk5Ji0P28vOsOC9fljvZWlUQQbwvU32242RNcQIN/XfnSelgEdPAt1g== X-Received: by 2002:ac2:4c4c:0:b0:52e:9481:eaa1 with SMTP id 2adb3069b0e04-536ad162918mr376433e87.23.1726792800059; Thu, 19 Sep 2024 17:40:00 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9061096762sm778167166b.37.2024.09.19.17.39.56 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Sep 2024 17:39:58 -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 Subject: [PATCH 0/4] refine mas_end of mas_mab_cp() Date: Thu, 19 Sep 2024 23:48:28 +0000 Message-Id: <20240919234832.24237-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 3CDDA40006 X-Stat-Signature: egri6bfnf459wje8t6p8cmk1fwgex1oe X-Rspam-User: X-HE-Tag: 1726792801-376289 X-HE-Meta: U2FsdGVkX19srSTZtp17ysMX412SUc08ww/QNPLaBHHHFF1JGj51KitC131C599Knz5LCQkdqSRcXhIX2soxtYB+GblSa0moZpBT/R5b2xCIu8rR8Nj2pF0iQk8dXz+9vFC0HtyD+/PyPF7KDFngHgy6LHC6tkKSlo3wj5UxQF8DqZVkorlrZsF8xXwXMdg9bkc/PBVLyIVqZV7iYXHkjfW9m4e5ng/50gI1JJlfpioWgDOh8hSj0ybIj5IW0MSXvxB2Rfv1loruDoxg5Xdlqf3KbspZNekxUANEZumtRbPWEQl1k7wP/RQRlFilcur2HwuX1Fn8C5kDDoCd3DQuHsYfP3/y9qiJvB2j242KATf31IQSl95Q2bVgICG4Jrkeaf3Q0BYG09637QqlF8xxw0x0X0Df8Rm4UbVsd81f17u9wRRloU4JOVetcideCF0afwc6T71KxhC2J2JcEkF0mjdiiz/dQqkTj/0ZNuYix28s/oR48eDRbnD0Ar/nHPm6bok2NOHrXWB8tWqkZ79Phccpyrk/c3xfMNlsGUFDASH+jpBsE7+u++5C7qY+m2WRC/5NAXHTEfbMYWiLGGQwsGEB3ZU6yGrLrC/3o2YmdD5eMXzdF6Me0qySSvO4mYeDh0Sf2KvJShxGwJvHsL/G3hDJW/VUib4LJlT2aP8+xu+jvci5wZXbrw/yvEYSdr2hdaullSLkd3mWTTqG81CYlx4UApZ3wbgUa9Vq0t5s0hgnTkDXyubCp0IPrLROUguUbxaos5T0rlPwPZZB3M7+Fj93UQRrVLeapTQMG8uTk2qfCb4kRPuXfviumm7Ash3ko/73nwRqwhsFoHSBFdtf3GjZrl7ddluWHLao73csx1kUAOaaI9QQRAXKxdMsrcmko3DrTrbVf0+tuFTq2XxPxcRj97qUmlPDqXbI2+WXd07rXTJEGEda69SeOEKsA/xvgLCLgzToirqQDVsbBdU Fb8lkq5G qH1bzFXoBWd7iyNCwldSRNRTnroDwLZzaX0DkF0x4U2P1klczhWD3L1mmydwVnDYYYdEHQ76tn8x+S2oUg9gKCirDnJr7WDERXLb/H7AKAGDMgI4PtjQAUM1KuFMkzCCxirXkcvZQ77pv94v9Sup/OAtrSeVuFx52rQ6kb97KNNJoWdzBAIhdj4QHd223XqISPrAgo/qGRF16GpuWFUr2NvKm/UUe2bdYR+FLzimyfD96lpwymJ9C/tLBlRoju99iFj7RkVA+o+CKTLX5yFnX6f1nSkljaOLwV6vVXd0Ta5FgBT6TPYqcab3RWdw4qwoW7RfXD1Je1BxmakWw6CaF136Pz6XfDRMqCSxdhwINz2cQCrLGB0UmCsYKYebKN2oGr5O0TzbtlDoTSa/gkIbl/a0IX6SHwOmcoPMuFgYnAtzgce739+Mak/MEnSUPSeDXuOLGNjulmuk9jcA= X-Bogosity: Ham, tests=bogofilter, spamicity=0.068224, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: mas_mab_cp() copy range [mas_start, mas_end] inclusively. For some usage, the mas_end passed could be refined. Patch 1: if we know the end of a maple_node, we don't need to copy end + 1. Patch 2: this one tries to leverage mt_pivot_count() for optimize the code. Patch 3: the maximum end of a maple_node is mt_pivot_count() instead of mt_slot_count() Patch 4: after above cleanup, we are sure mas_end won't exceed mt_pivots[], so we can remove the check in mas_mab_cp() Wei Yang (4): maple_tree: not necessary to copy mas->end + 1 maple_tree: use mt_pivot_count() to replace mt_slot_count() - 1 maple_tree: copy to mt_pivot_count() instead of mt_slot_count() maple_tree: now we are sure mas_end wouldn't exceed mt_pivots[mt] lib/maple_tree.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)