From patchwork Sat Aug 31 00:10:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13785721 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 7B0CECA101A for ; Sat, 31 Aug 2024 00:11:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0ACA48D000F; Fri, 30 Aug 2024 20:11:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 05D1D8D0002; Fri, 30 Aug 2024 20:11:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E68028D000F; Fri, 30 Aug 2024 20:11:23 -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 BB0998D0002 for ; Fri, 30 Aug 2024 20:11:23 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 58A814077E for ; Sat, 31 Aug 2024 00:11:23 +0000 (UTC) X-FDA: 82510611246.15.DB966EB Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) by imf14.hostedemail.com (Postfix) with ESMTP id A6C7B100010 for ; Sat, 31 Aug 2024 00:11:21 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=RZudUqfM; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf14.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.42 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725062980; 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=m1UfV2ZlMmhz219R8ml4r1+BEeAzfjqk7L8sWpHy08I=; b=hFJ6p0b1YTx8fG2j4FZ71oaOb9JQ5ycWkBkJv/fAe1YcBM9qQzWo/UcqKYPdBA+GsmvR33 Q4AWZuPMlRolqIM28BdtgZxVUCxkTCyZhwzsMJzoVz30QpafDaNS0nyFREmncVlNkB1Z+d Vm9FAGwji72DkawsUe2jVokRyBEJ9TY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725062980; a=rsa-sha256; cv=none; b=KrIeX+vu2ormcPCQuZV9JZ5jeIQspBmyV5IsBohL7V8Kgv7HbmePEbrozKOceOYhITtjsN NowjEULVvrrsIiOGZYCGu5U2lGveIET8bddRtrogVtvCLY6dQD5q2PJPhIiTvn3vgCpi7B vtQodmBYiDqpyuZLpptmsl4AXOLpfyw= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=RZudUqfM; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf14.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.42 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-5c0a9f2b967so2498058a12.2 for ; Fri, 30 Aug 2024 17:11:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725063080; x=1725667880; darn=kvack.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m1UfV2ZlMmhz219R8ml4r1+BEeAzfjqk7L8sWpHy08I=; b=RZudUqfMXv60vjrHFI1Wp/gSzIyNTcCw0FBN+iP+kBJrbf7f3Ar6lrESjHZcRXHc+v kumcSCclLY5+0riG4unI6V2RujTyF4NUa1xziY/U7XKjJkXL/lKG1TrIUeb1LSUvqEze dWlP7hebmeZTuikWfJEJFP3PRGWR0cBRauN0tcAwGUiHjienw9GqUcoH95N+EkGDsJYo gtX32BNyZ8XTBFeR0Cv/SI4hWnqbag0hAsm3K1pxEVZUPF7pM4Snwm1YsZ1rB8kvladu wdMPd2HdQfeoOzIrJj4opm4FBPBNMCFbMMlq01iWYfAbXifQZYH8GN1WFt1iRFymUzgz bCzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725063080; x=1725667880; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m1UfV2ZlMmhz219R8ml4r1+BEeAzfjqk7L8sWpHy08I=; b=mZUomha1eIdq32JQtK2OTf3Ko/FIVbDhkyz6X0E3UC1DtIo7dQ+QvRTbliXKn3xKRW xEhosA/ENRjY7AjGM4TFcVUfb8BztfW2a8Bm8k6Nq9iDeXxSRI3b7LPQPhOb+qB3lKpI N8LZ1ubHIa8qjWy4ZnIqwbHKfWQDs341o+jHxkFJATo5bfj7Rh0ajwqaQ+PKRivGCOM1 7ddJ4XBMBjEYfbIrteyLUua5oaR1fZg1530I5F/m3LHgXUh7g3ez8vvcIQeJE1weA3JR kiPlsP6oaxc3Pq9R+teIxatN9EEdS59NutFIlgsBnb+jggiija61pUqJyrcpdI5663sE 5hNg== X-Forwarded-Encrypted: i=1; AJvYcCXU2GHiFtyVYyA9e43W3FmHRiBffQscOPr9LVy2TyIN4XVIwIUbT4/GGsojiFUu4Hx72ia9tETRbg==@kvack.org X-Gm-Message-State: AOJu0YwT3mR2OvDNUg9UYYuaqRpkHnjKfMXN/WLPL7d3hPsDbFdbtRp4 9OwSTiopkO5Dd9B19GUP95SQ75/c3Er8QGsifVJP3/A2pDZERoCY X-Google-Smtp-Source: AGHT+IGF9OnV2ZP/CQ1TnFB3e3YAbv2ltZO7wUCsRf27gtK9+pZdNJxTAFGmCtwt9vIK2yPlmZmJFw== X-Received: by 2002:a05:6402:40cc:b0:5c2:4434:7303 with SMTP id 4fb4d7f45d1cf-5c24434733bmr488994a12.17.1725063079490; Fri, 30 Aug 2024 17:11:19 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c226c7c1f7sm2420730a12.42.2024.08.30.17.11.18 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Aug 2024 17:11:18 -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 Subject: [PATCH 1/3] maple_tree: use ma_data_end() in mas_data_end() Date: Sat, 31 Aug 2024 00:10:51 +0000 Message-Id: <20240831001053.4751-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: A6C7B100010 X-Stat-Signature: u8ergqhdndgqxmwrcttoc1zww9ouj5tk X-Rspam-User: X-HE-Tag: 1725063081-427914 X-HE-Meta: U2FsdGVkX1/EqPrghXvE+gXHkAWwzlq48wffz+j//K8+pPKcFdFDWvY4Mkws9G/uYBGGsxHt8P3mEaUhNqNk1Dcv+MIgK8ySf1RRHOFQy4g6zdTSxYstm9Ew2GdqtUKB8LG+93wHpWvKJnpgxUBvymfEMuAzugFzy1LqC+8lJW84X3LbFA7TlgVQI3EY8R2/trRWYkiUCYamRR5a1u27IfL9E+L6piGgzyT1W2k6lE87Z+wgNISVY5bmRY9ZQs6NJh2hxgN46g824LCMXd3OMh8IOe2H9GXlhYbgez+cD/Oh7CqS2E54Rofx0NrXqWXRgj7fp3Borbzxed+kC6Atc0otN2MEqbUotBN5XBF+HKViCEtWHYF5bopgm1daYM4V4J4eFfinBZAXDL77ChBrAGApRFPF1JhNtzphuUAk4atyZtP7smXGIRmZ/2m5T270/rA4mLCyPomkThnF84i6MHRrIfj+CCngXDoinlbNCuYAptR0K9otT/kG4jIcrMJs680dziNUFIyRHdbE0THUO+ZjrpwX8ScwtYiMRie5rBE1piK9b2eRlUEVYSnZ8j7v2mqVUENoZQuCfeH6/qeB4g3Uoozzccjt6N/ZYFfAjcgfttnIYIMVnx29wvg/W8bT7kcpogEerpeE4JsRPt3Vz/6WPooBAXBO8CBWcCwMFus5txDJnDOc/k5kquv42Kh8ZCfpQwbph2f3wcwEne04kyOkrClS6g55GnRsODY3mo/Z1jULraQ44JPcixbTpUaD1F4Vya6Lw2+r5h0p0RUbanunEPhDLBSdob/F5Z4yNuoXYx/Epq5sT3qEQB+J/TmMpuCXHTjfivvV5Psw/nQ9gZ0nvUKjB3hXlczeApvdCUbPaH5KCo4R4IAvpqeF0FphiIaHUI1Z0KIx0daCDNP/tl/3caSJDEZ2qqmxSWin1d3OBtnO6d6BCCXNpz7xg7wISSLQgpO+/bpsFC742Fa bQZYiVlT zMY/8ZkT54xjAdiaSL9X8RDR4o9qLr+2ik8nDMrGeSXcGm4dhj9IAT8QGuZv4cRSZOSz2Nm5t+2GRyYvRwJ3uOFOM3OeFfe7eFJ/uWeIr4m8s/RLPiNOxbZRxxAurWcxpwq7SdYlon9xbuGJ0kOopSEq9DJDheM71Z7Hhuz7O0N5j4R5VDv7qGxXDVWDJL/QScQOe1qP18GuO7GKqDuDYhuK2GU5DpdlZqMT8InABL+eKoAjx8CC/Veqezzbr84f9xn002YIscZMvuHkaoeJz2qadQh7DyYpkoQ8RjRSRLxzyA3xaDVWRXA09JhRTij6gN/fbtTzyGy6MzFmaFcq1lLLQrKj7SIxdrGKTFz9bJejIdXOucSpMKb9INIRcckrUh+9uKcNjFGCCLkDPzr9j1Ic7RYM2HUjgbgu+s0nOCq9bWQcXdMZx93eL57xIJhlz0huD2kcTMv2VKeTTd3eLlg7DNJ3y2jUVgCQhgPZyqFNt9+U= 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: List-Subscribe: List-Unsubscribe: These two function share almost the same code and do the same thing. Let's just call ma_data_end() in mas_data_end() to reduce duplicate code. Signed-off-by: Wei Yang --- lib/maple_tree.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index b7d747a7938e..85668246f944 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1435,28 +1435,14 @@ static __always_inline unsigned char ma_data_end(struct maple_node *node, */ static inline unsigned char mas_data_end(struct ma_state *mas) { - enum maple_type type; - struct maple_node *node; - unsigned char offset; - unsigned long *pivots; - - type = mte_node_type(mas->node); - node = mas_mn(mas); - if (type == maple_arange_64) - return ma_meta_end(node, type); + enum maple_type type = mte_node_type(mas->node); + struct maple_node *node = mas_mn(mas); + unsigned long *pivots = ma_pivots(node, type); - pivots = ma_pivots(node, type); if (unlikely(ma_dead_node(node))) return 0; - offset = mt_pivots[type] - 1; - if (likely(!pivots[offset])) - return ma_meta_end(node, type); - - if (likely(pivots[offset] == mas->max)) - return offset; - - return mt_pivots[type]; + return ma_data_end(node, type, pivots, mas->max); } /* From patchwork Sat Aug 31 00:10:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13785722 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 9946ACA100A for ; Sat, 31 Aug 2024 00:11:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0862A8D0010; Fri, 30 Aug 2024 20:11:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0365C8D0002; Fri, 30 Aug 2024 20:11:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E17F48D0010; Fri, 30 Aug 2024 20:11:24 -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 A92A28D0002 for ; Fri, 30 Aug 2024 20:11:24 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1EEDBA8739 for ; Sat, 31 Aug 2024 00:11:24 +0000 (UTC) X-FDA: 82510611288.04.257A2E4 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by imf03.hostedemail.com (Postfix) with ESMTP id 5809620009 for ; Sat, 31 Aug 2024 00:11:22 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=mRXlBI7d; spf=pass (imf03.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.221.52 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=1725062991; 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=/PDOqFddIwYebCrc81iMhqzpcwiuq97Qi+r0yOj1hmU=; b=AfENWy1imwMR1Q6oKIOhpGG7BX8EUVI+HyMbzi7WYN3aYmzqm26+sa0dWaiWRQd7s80UuP k4nX/ljBdd4P7ptnXaHo0evpkorBYJ4sm9VhThVZJtQYTPr/I6dTxrK/i8pgpz7iCgnncI zgDVNX1YoI306N+AneneaaP9LbWE9hw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725062991; a=rsa-sha256; cv=none; b=18mSxcGbGCcfTyLbTwpcLxfiwGK5xHhKDIZ8Ejxw36db5aMCcuUDpcGVi43eKs27QZwgEm shnzRgQmrSDHzdzqQyDR1fDYyQyVQitm7nuN4AR5hIKs5vS1IqM5rl5jnAavR9rY5Pb11L bPc22BpFjTOSzlQ28E6Ew9QTczmKXXM= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=mRXlBI7d; spf=pass (imf03.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.221.52 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-3719753d365so1788604f8f.2 for ; Fri, 30 Aug 2024 17:11:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725063081; x=1725667881; 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=/PDOqFddIwYebCrc81iMhqzpcwiuq97Qi+r0yOj1hmU=; b=mRXlBI7dIhN2azJB4wf2JGIsKAsCgb3Is3aAg+fbs9q0L6V5GU9Rmwtpsz9lb6bRIA yGgd9H6x08tWAcqbUeElhTj2eEdbwidZoIiP92UitUMDci1I8Ds4It2C1tOHjo392gXc OF9OHYqyOJeWhsg3+YWr6PFcsGAe2d4TbXDT4QVbLST6cFthrLzr5qXZ5q7izS9r0num sTXEEXh44XlEUrST5XO3uSpOgxMpV6L2mKob7aWhWdb1QXPSrECPJmBE12plYj295J18 0pXWTGBUBd9I+T0TLjycSx2kBsdz+8RsiTJTn6QTg7yMxEQisp2Tq0lOJzMM4k5fTYbQ 9lOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725063081; x=1725667881; 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=/PDOqFddIwYebCrc81iMhqzpcwiuq97Qi+r0yOj1hmU=; b=OcX84KreXcyU7rHKWDCG0PRvgImpVSQvkjil+D5RgWcavhiu08jX6rRlgVnpFd0V8b /ApEVCvND/V20+SV+bSOsKJBvfQlJSo1nK8bsITCZbDHU2+lzl0T8Ic57kh+OC/MXZmN 43wo6/4FMK+zJT/EmO9HXG9HxILdHmSf6uRasGMTW4tXvcTAIxmKC7EdveIPTu+h2oCo F44wFQBoqFBnkiTaXvmrYq6hWouuWn9gPtt0xSxKllmqQlaiJBkAYcjKuOk98m9pDBUg HIRAh5SS8IuH0OgydAMzmXFqrYsgGpQnsEY68wfzu/4U8/KTbZE8tbjLEVndycw+A6ZY zcYg== X-Forwarded-Encrypted: i=1; AJvYcCXnSbf+QweIY0ZNVGLMYeZlHRyYuFf3nlVg92EEk+6uvp9ILx6Yfoh+hXx3ZGcMldNvQT39SkTaaQ==@kvack.org X-Gm-Message-State: AOJu0Ywj04fvFtLT3vjH/kMgA/RnhBiiFpNb7ie5k3ENpF9A/IkEcAz9 r96zDmER3KpXI8BVyWXpWbZf4B6xdVpLlWlMIL6dfnK1hdJlHBAO X-Google-Smtp-Source: AGHT+IFaboOxSA8IFfXZ35U43P50lxsi+RMivNvAN+oLHSqlBdpCDtUm+CjAJYYorTbDb4m2OUJ9VA== X-Received: by 2002:a5d:5c87:0:b0:374:b69f:9 with SMTP id ffacd0b85a97d-374b69f01d2mr1951345f8f.29.1725063080617; Fri, 30 Aug 2024 17:11:20 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c225ac5ae6sm2435941a12.0.2024.08.30.17.11.19 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Aug 2024 17:11:20 -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 Subject: [PATCH 2/3] maple_tree: use mas_safe_pivot() to get the pivot range Date: Sat, 31 Aug 2024 00:10:52 +0000 Message-Id: <20240831001053.4751-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240831001053.4751-1-richard.weiyang@gmail.com> References: <20240831001053.4751-1-richard.weiyang@gmail.com> X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 5809620009 X-Stat-Signature: i5sea3nhce7pox5hwbswp68qruwe9je6 X-HE-Tag: 1725063082-203841 X-HE-Meta: U2FsdGVkX198mSOK07TCRxhMaYEUmYIpfXN1i96akAZru6fSHZ1OYD5BGDeqePwjnTdgTZxkws3OlKyY/nIgpWg5KcA85WsiUaWH095BeAix7cBOz8fgKYUAGzCmt/GGaeNuYWAN7fx3d/zbHFrgTAWNy0UlaTQVgkYEezRsHMRUPbH3Z02DLUq1y4y6LaUu4Fn5N7ZBV2vsOMn+aDkdx7QxP33OAVS5SvB6dxw8qL/BMfZiEQQlubdel098bYQdZn/CAVBIj4mM5cPvI122c4IJvbi27ao95e20IucvL3PIxQep+EGn104mScWa01Vs9hsx0/qiNnXWGMJU6PWdBRnb5137eSF8BN7d++IR1dKks7lviFlWnvCKsRN+KGhbtByldeb2wYmBJklRG4/BSOZcQmurdlowXaxcbOmFZZrWFM1QwZ2Pyzn1CSm7aTlZ2gNSZT7Eqy2lgoxnQUNrraKOE8TTzspAGFvgIQrqC4uZt4FNwrtUCBARfjsqjph5EQ+Ggb9NA1dQcKqyTso4+61aDHwyrWrl7qpCxd1sn3TKW543sY8obr6wnMWQtVjVY+KjLVjxslMz8t9H7wWt9jWHHIKxJod25MNxYdWDci1GPxg/uObZOI0pYUPdc2hkxtnFN/pa2ZCCmvqaIYNHbv1Scnx3mFfwhevJtCAhYVRL4Qjen5qmyEHWsrl4CCt3bkksbl9hdU3AodAZOvn+49WJVC338wRZlcop9imPXuCI1YibusKvaEmrcbupJTs5RI1LqhgmBKYPqnjZS7J1bZfynpPMFFyqlGwN1nM1+bPWwgc2ENBDHOHeY+qxoFq4DrM+WDrdvZWqpKGFu/5oI2LnJxZb0GO8W28tAAW/+8RzCZr4Pc/brjt32d+TRUWMaKrhq9NUHHCCFRvtgwTh4y28Z3ny67NMVmg7kVILxphrXg0kvN4YnSwUrd4yvcYX3lNz8bUBscKUwDaZxPN TtsscUdn dc98hsDJILID+saMCIuVwSt7Fp7/tPGk2rQSPn9fmtvjDQd6BEN+Y7brW1EHYOUIFR7vWlD/BJsyT0st+GaVPQlqDVyFFXKDwOx8P3YeUD9CJjNkEIdXoXOHuj4vfKBjJoR3mRXlLqA2YPjESeFIQvzPlxqPHBGc1QnweMNcUPs2sNovv+x+lqp2a1gJlmQlJU3j5hAWnOD44bilozaJqL4df9CRB4YjzA4XqjODGRD+sE51FqXRqLTmbmo6cFpet3poXFui/sbZo/xoCzcYAmp1LHpiHAVzpEx2LYti2bu+Q8BI2YLnc4jPuFi1NQyR7fMX9XJkl+UYIsWuDlw/qA4fD2wvvU0plhV4Ts/YVmfOTg93vx92H+7XJ6Ao+5zjDR9XDZgMy920T1H5pR9tqCqXy23YahyyjaFuxdGTDPT+4mI+0gFcHJXzMqqCrEfaDNDu93JF1dixEr5Qz0iZbl4UZZfY2mqHCw+jybAu8prgy3aM= 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: List-Subscribe: List-Unsubscribe: Before modifying data, we need to walk the tree to locate the maple_node. Also we get the range boundary at offset/offset_end. For the upper boundary at offset, we have defined function mas_safe_pivot() to get it. Let's leverage it. Signed-off-by: Wei Yang --- lib/maple_tree.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 85668246f944..17533c246749 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -2185,7 +2185,7 @@ static inline void mas_wr_node_walk(struct ma_wr_state *wr_mas) while (offset < count && mas->index > wr_mas->pivots[offset]) offset++; - wr_mas->r_max = offset < count ? wr_mas->pivots[offset] : mas->max; + wr_mas->r_max = mas_safe_pivot(mas, wr_mas->pivots, offset, wr_mas->type); wr_mas->r_min = mas_safe_min(mas, wr_mas->pivots, offset); wr_mas->offset_end = mas->offset = offset; } @@ -3987,11 +3987,9 @@ static inline void mas_wr_extend_null(struct ma_wr_state *wr_mas) (mas->end != wr_mas->offset_end) && !wr_mas->slots[wr_mas->offset_end + 1]) { wr_mas->offset_end++; - if (wr_mas->offset_end == mas->end) - mas->last = mas->max; - else - mas->last = wr_mas->pivots[wr_mas->offset_end]; - wr_mas->end_piv = mas->last; + wr_mas->end_piv = mas->last = + mas_safe_pivot(mas, wr_mas->pivots, + wr_mas->offset_end, wr_mas->type); } } @@ -4016,10 +4014,8 @@ static inline void mas_wr_end_piv(struct ma_wr_state *wr_mas) (wr_mas->mas->last > wr_mas->pivots[wr_mas->offset_end])) wr_mas->offset_end++; - if (wr_mas->offset_end < wr_mas->mas->end) - wr_mas->end_piv = wr_mas->pivots[wr_mas->offset_end]; - else - wr_mas->end_piv = wr_mas->mas->max; + wr_mas->end_piv = mas_safe_pivot(wr_mas->mas, wr_mas->pivots, + wr_mas->offset_end, wr_mas->type); if (!wr_mas->entry) mas_wr_extend_null(wr_mas); From patchwork Sat Aug 31 00:10: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: 13785723 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 97315CA101A for ; Sat, 31 Aug 2024 00:11:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 67B9A8D0011; Fri, 30 Aug 2024 20:11:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 58FBB8D0002; Fri, 30 Aug 2024 20:11:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 393AB8D0011; Fri, 30 Aug 2024 20:11:26 -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 0A7F38D0002 for ; Fri, 30 Aug 2024 20:11:26 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 92D3EC0717 for ; Sat, 31 Aug 2024 00:11:25 +0000 (UTC) X-FDA: 82510611330.26.7E110DF Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) by imf04.hostedemail.com (Postfix) with ESMTP id C3AEA40020 for ; Sat, 31 Aug 2024 00:11:23 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BGFV9Lci; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.53 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725063062; a=rsa-sha256; cv=none; b=miHYEpsGc8Vcy9knn+l9FU+xu0B88ffktbuP6UtOiU1sxAvnDo2V2raCWufSBAAduks529 6fkqvU8F3ABZ6bWUxhoeodMeRCdCrJm9VVJPAw8jHLBC4qkkYACgMRMtDSYfKga29xNlLD jpXXhXLuqHLELRSonG5TkOG/u/OJG8Q= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BGFV9Lci; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.53 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725063062; 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=BNiQtbDNNf8A/Mj7fgmircx+5iCql02mBDuIFqsXGyE=; b=csbCoBEREXJMqwaPFw5GydVXEvZLfX7KubHdfGuTr5iUdlZn0H12OuZ7m4ciqXq+NYBKjU vi8xDLIM9kQIzcmQgVkl7a1n0A1WMYLC3T/KxMEVdstADlkgKJISeNqDtD7O5o31EQkGBk wWau6FGlQHBljnlKDVmV3MN3YDPEOUQ= Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a8683dc3b17so143170266b.3 for ; Fri, 30 Aug 2024 17:11:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725063082; x=1725667882; 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=BNiQtbDNNf8A/Mj7fgmircx+5iCql02mBDuIFqsXGyE=; b=BGFV9Lci6D1Mtvy5D+YpRHeClaUAXbSlKKJHNFwsMRvFT6JTWXqbSRIkWnwlVF2D1Q oEYIghjCOTRfLGaIp/wqFDydYgj56/m6oG45Iit7Rh1gVlsTMChxgKFce/x9HoAy+gF5 c5yQfaT4kekemIxTWe7jXaiOSoz3EVgpQQ9cproQOmnSJyJVDDMBTjI93/bqFyItE597 kgkgUrxPIAvr0BXmiQXkUHFYy4+eu9glIXNwhBAVjTlDOajHMr+ElqwG3S+OawYnT8sE PsmeGmQ6Uioh8zYADkF9BhlCqa/sL9Bx8sN9anuzJKkoB0LdKx3EJwLTNYxdZ+qQIPdg WtVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725063082; x=1725667882; 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=BNiQtbDNNf8A/Mj7fgmircx+5iCql02mBDuIFqsXGyE=; b=WXv+ifTBcLc77S1rBGBbokfsKk/Kzsw2+d9sb2LZbhTDCkO7KhImTCap3qjdit4QrW qBTamqwjxAEQZLFL/JJklYeqmyru0TIuRCCAsMbAFx+F1x49x1jANhowJUDp20irsyPY vz1wCZfzhwXS96FJcKVXimJ35wP4/6lsuGyksMZIGtF5zm1Kxqs3EAUtJDKdkQ0sCORn 2BrsIU7d9rl7NpLBBIibGKW1PCT7uVkfu9k7M7qLJaFsDrjIJDK9RWx+infbura822IG izMQbrue+pmNgzhsCWJke+HlrEE//JIqCTEjsyz3rrbYjjmmDb8zJ45i1Gyei7TkDeJu srGw== X-Forwarded-Encrypted: i=1; AJvYcCUIC+gBi3Q0amsKJcZbWrh3g89VWBOV1lGfXoMM6yBTBaFonOgr39POP6NzprIyQLR6rO2mAEzFyw==@kvack.org X-Gm-Message-State: AOJu0YwOIjuIkwV3+4yEHsgHBvKxg2bPmgi/uJ8T7gI24yjF0Z+TlIfv Xmc91+mpfgdrBJYEJ74C5Z3Nopz0/Hx/VB9MSUQsnauMvJ0hUXrc X-Google-Smtp-Source: AGHT+IHwczwFkM5glz7zfQTjlY059zjrO3HhzqBkp3Z9Zf1UeJ/QXdmz/uSDZyXRZEKxERVGU1ZBEA== X-Received: by 2002:a05:6402:1e88:b0:5bf:17f:4b7f with SMTP id 4fb4d7f45d1cf-5c21ed54d13mr7658987a12.22.1725063082110; Fri, 30 Aug 2024 17:11:22 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c226cd18a3sm2398376a12.66.2024.08.30.17.11.20 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Aug 2024 17:11:21 -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 Subject: [PATCH 3/3] maple_tree: local variable 'count' is not necessary Date: Sat, 31 Aug 2024 00:10:53 +0000 Message-Id: <20240831001053.4751-3-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240831001053.4751-1-richard.weiyang@gmail.com> References: <20240831001053.4751-1-richard.weiyang@gmail.com> X-Rspam-User: X-Rspamd-Queue-Id: C3AEA40020 X-Rspamd-Server: rspam01 X-Stat-Signature: 9rx9fi9m7jbcamwtaaze5p9eoqqkrxdn X-HE-Tag: 1725063083-123184 X-HE-Meta: U2FsdGVkX1+/H8bMr4EcusqUrPKwyPnWsnhbG3C3JV3qMPIbiNqU8fbopVzB1X2bi08a0S20LLWgGY7ikIM9O1vPRC2Tae32sfRadI4lnNrgcOG+rUk9Jm3nwXDEb1EmFtruLpFasHDvwRJc6PJjkEJckj3WVCfBEV+CwQLgfvoBUi/Xgdl7mLqifrUOjLShTH4rsgQNgrP41gGgBGCUQnbRVtGyl2RGrJgFVFxrsccqOhPt1ITu0zYGak0FRGhpbfJdsuNMWXQZ6wpt38xSJJp0vk/aktfJ8DzKi3vdGAMDXiygdWvtYcVOqlz5NV6sq407htX400p3aDeXR0PkU4Jdy9Z9/VBUtiHEUOy0ysnZRMQyL4p/qeW47w1oCSfzsdeD5btk2p6ub6IJw5xlygDs4mEqt6v+bsdt8gn8Nf4jLyGtZFCnmyCpbGuSeO8GJQ09na4n2exvLP7iRgrIXlLDSdtVcUkH/wX5arfXc9w5MmoWTGb4yJt+M7nH2C5KrJVmMjNqa2ye8ZA+vTj0/95NS6tsYwOzNOjjS0+KLQGo+7ZGgxKTR1XfOTMcGcwPjQUnvDt0GC7ZMmc1mZWb7eWxXdHU9uGwe2NGpZL8PAAajYSI5NoQChJbepQmTU0HRs2NWq6wnB7ZvdnhZ3xAFNHYfc0VjDINlkZDNte2OpRrJo6jG00oBMDQKJyMHBZQvox7THGPmlKqQPWTEhn6tAmppCwWOuAMchzlFb79+PJwebqHq7BWPF/+Ofw13ydN1E70O79nGPfso77mveMHpJcwFtn05kM2SEnokjaGOTWM9ECD/q0c6T4Yc65DTA906kdiibzfEZgGgoq2zyo7drty9FPXaZ51u/Y0VfRzhgTRf15YSyh9EDDfIyNzjme5tpbtVd9mhjAf/lgTgaTe8pF3inubyxsr7NZIqPtUFbMD6yWA4yU3qAL/HV/7cI9o9azgvKvJnuJUfjb8iJ5 oNyQh1Lu 0+Kg2eSmPn8xTQckAprSasOfenVgO95ubUIQS0QiG4dossLVmTob6zIme92hY/gaTf3JgsnFyGqXOvD4pUE3KNTjGYUCeq/VO6Ru5gGyRWZ3Mi2Bkc5wj2U8Uk8wttaoTAgSIL4AZmZ4QFvKI/GbRi/lsMiAWQSRhK/1LLYKx1KEJ/YuE6mnJIRkN5QBT5TOyFRXVoy3ZFVGKJ71LK5D8bEiPUrv7a3fm8Sa+PdsTNItBAjhl6vOFM9uE5S5HWklH4vxbsE/ktpSRzWJkQ09MpJtXoSLdCVpdMyzlWQPvxEoO0cU2PIV0PH84ko1qVwh8pV28cziUTZ4oi270eu+0jpex8blN9+opPGO2Mn+rArY7lVV4ksRg9M1oPy+XKF7fFSn1N2w3Z+VoZO46kb0RY36zlzwHTcgtWouqJKquszt7X6eG45riK5E1D72Rw/l/ZbzrP6IsWEPaB4JQSmLJPCPNj2MfVVJ6wM4nQKOQD5b5uc0= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000012, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 'count' is never changed after assignment and it looks a little more direct to use mas->end to locate the offset. Also ma_data_end() returns slot index instead of count. Signed-off-by: Wei 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 17533c246749..dda8e292c25b 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -2168,7 +2168,7 @@ static inline void mas_node_or_none(struct ma_state *mas, static inline void mas_wr_node_walk(struct ma_wr_state *wr_mas) { struct ma_state *mas = wr_mas->mas; - unsigned char count, offset; + unsigned char offset; if (unlikely(ma_is_dense(wr_mas->type))) { wr_mas->r_max = wr_mas->r_min = mas->index; @@ -2178,11 +2178,11 @@ static inline void mas_wr_node_walk(struct ma_wr_state *wr_mas) wr_mas->node = mas_mn(wr_mas->mas); wr_mas->pivots = ma_pivots(wr_mas->node, wr_mas->type); - count = mas->end = ma_data_end(wr_mas->node, wr_mas->type, + mas->end = ma_data_end(wr_mas->node, wr_mas->type, wr_mas->pivots, mas->max); offset = mas->offset; - while (offset < count && mas->index > wr_mas->pivots[offset]) + while (offset < mas->end && mas->index > wr_mas->pivots[offset]) offset++; wr_mas->r_max = mas_safe_pivot(mas, wr_mas->pivots, offset, wr_mas->type);