From patchwork Wed Sep 11 14:27:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13800672 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 1A11BEE49B7 for ; Wed, 11 Sep 2024 14:34:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9F725940044; Wed, 11 Sep 2024 10:34:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 97FBD940021; Wed, 11 Sep 2024 10:34:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 82012940044; Wed, 11 Sep 2024 10:34:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 62611940021 for ; Wed, 11 Sep 2024 10:34:21 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 117D3A183F for ; Wed, 11 Sep 2024 14:34:21 +0000 (UTC) X-FDA: 82552702722.01.3F15A2B Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) by imf08.hostedemail.com (Postfix) with ESMTP id 3F47C160003 for ; Wed, 11 Sep 2024 14:34:18 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=nIKkcip5; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.167.43 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726065231; a=rsa-sha256; cv=none; b=7JfxgzHMfz80b/tcu23bDyCxb/926Dpq5DK3dMj3/qGlmVR4eZU5CI9X9LAOt3soyFdfAD sUfswvf5r/4Ge0vvFNLMDGOVJCJeeTNoGfE9wCZZe93M0pq7OBaADXFT6A031Bz01JzHb6 /jouQ9nmY9jkBTvipjlzdKGZmR/XGk4= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=nIKkcip5; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.167.43 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=1726065231; 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=Ygpw7FxSB/yx0zV3y7V+rBISO6KLRv2H2pMHFRZocv0=; b=pi48kkjV+r2Pvkn8yv2xXwv5OQ4RzTeerxrlD3Te+zaqsHCWKxz8g49+PyKGJz3WrklQnR dxQ5u/T5B/FNUM+ZptFMiSedG98yH/QiRFC4NkS+M546AeDzX0bLCK7jP1p/yxOIyqoZWS AQkXYxXrgK/IAY81myyflWq10yRI65M= Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-5365392cfafso6739113e87.0 for ; Wed, 11 Sep 2024 07:34:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726065257; x=1726670057; 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=Ygpw7FxSB/yx0zV3y7V+rBISO6KLRv2H2pMHFRZocv0=; b=nIKkcip5EAqCsqSdKj1w5lraR8fwBQMylFPxwOMArwsi8Xpuc1rqzOsbPZZxsV/hd1 KWWPsxfAu+D1f0jmnDFZX/0/e2TNZvm7gQedltdgpP59QTNuF3FikS1br9y8xix5C+Wp iaHn8IT/nEuUNdDZvpNyKflzJvrTMalUtactduRRnV+s56jZ47xPNWjSCpNbE8D08t1V LtCA8QF1W2VL3sRrjfVFqfT/ueHE/RR3WQtjZWN3YGWP6Qz3VjTpTV4Gwgaf/+Iu7rl8 OCUnnszxshQYpQbgm97f5TNpmFBwbekAMvfaGhpb8nStd2OW4yunQSxh2H4WrPSN6T8y e7AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726065257; x=1726670057; 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=Ygpw7FxSB/yx0zV3y7V+rBISO6KLRv2H2pMHFRZocv0=; b=KY4gr3NVXYZ3duVnTpHP3i0UC4+IH7ox/3/1s9p37dF10Ouq0W0htrsuYhMdZ4DFrQ YQYs63Ov3k0eWGH2aDDXO1E+Kby5vPPT83M3Dhu+drkbyw/F2ecbHQkUfIR/6Q7V8v93 eGC4uQOIFxSJ9cp3ydWeIcz8b1dd1/DJMUbnSqfS7SYcmcjxB1iZGWChH8D0UbD7FdnZ amgqNxWFI6h6U1V9YdeFPfyszXtv2I5JOdjPLx2KYeS1i6C/rbexjc1NJP1EpRvVsvmJ TexB37zJTc8W/ZNleQDkB3Hn1pnVLWD+szvBu8BrhotkbQ8rRplSNJHv1p5Of3C50bbu u5sA== X-Forwarded-Encrypted: i=1; AJvYcCWHoE2lWs2TFgcpyBXC/CfVuT6gGgDiSMfAQ+JYAJOQvTSmWEYEojGculwlUgtwnFCYJkj8e0T0ow==@kvack.org X-Gm-Message-State: AOJu0Yy3+wQiWywVX4L2OaEgdRb9ib5Md2B6+wSzHaMBtdSvdkYTh5BB bs7sjF3VQWdS1F+AQUq1swnQ8fU4WdpBCBDu+mG3jKCNPGU1pZi9P2Zi9w== X-Google-Smtp-Source: AGHT+IHrKZLSPc0Ce55W4LLGb3Z5A3ZVTkWPGTjr8me6CAHLwM7s7DfDmAPUBCN9PcDbUpU7ret9yg== X-Received: by 2002:a17:907:8688:b0:a8a:86f8:4eed with SMTP id a640c23a62f3a-a8ffaa92959mr432715566b.10.1726064954259; Wed, 11 Sep 2024 07:29:14 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25cee6bdsm621948366b.179.2024.09.11.07.29.13 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Sep 2024 07:29:13 -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 2/2] maple_tree: goto complete directly on a pivot of 0 Date: Wed, 11 Sep 2024 14:27:59 +0000 Message-Id: <20240911142759.20989-3-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240911142759.20989-1-richard.weiyang@gmail.com> References: <20240911142759.20989-1-richard.weiyang@gmail.com> X-Rspam-User: X-Rspamd-Queue-Id: 3F47C160003 X-Rspamd-Server: rspam01 X-Stat-Signature: yb3xt31crbii66d6w6agb9hmrd8gfqph X-HE-Tag: 1726065258-857610 X-HE-Meta: U2FsdGVkX1+SEHKzksJpXLhyO8+LGode4aScEHUlrTaV6AUHpbxtNeUi5e96CvTh8HQ09Xc3tz0JlHC1q2LYOlJxMweO85O4IJJFTCGmLZwqibDjPDLtlghY+QCDmgA1xCsRoZSS88PKjWVzzlWGFyleZe3MWdApGVhU6vIN99fPxFbAjFfRtFqgJp2Qm8BK+WiSbYddwSl3NkWbbyvHBzG5VtGLIZtrq6XoodXvHYu1IdiGylkJFYswk7C1/bXHV/0meThMy99JzQkdgQ7weYpxzo0Mczb1URQp6hn/XEDPK4/3bdyBoUBTZnGHDLf/3A3XRRvYaZmcvzecbWBfintm5F+zAm3T9xTMldK3UcUWcBe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sP6tadg6KFi1kU8K/tRgZkOsds3xtX41zQ8hISKFlE= 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: When we break the loop after assigning a pivot, the index i/j is not changed. Then the following code assign pivot, which means we do the assignment with same i/j by mas_safe_pivot. Since the loop condition is (i < piv_end), from which we can get i is less than mt_pivots[mt]. It implies mas_safe_pivot() return pivot[i] which is the same value we get in loop. Now we can conclude it does a redundant assignment on a pivot of 0. Let's just go to complete to avoid it. Signed-off-by: Wei Yang Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 6fd62b7ef240..f7bb3f686548 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1942,7 +1942,7 @@ static inline void mas_mab_cp(struct ma_state *mas, unsigned char mas_start, for (; i < piv_end; i++, j++) { b_node->pivot[j] = pivots[i]; if (unlikely(!b_node->pivot[j])) - break; + goto complete; if (unlikely(mas->max == b_node->pivot[j])) goto complete;