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/rA4mLCyPomkThnF84i6MHR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.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); } /*