From patchwork Tue Apr 25 11:05:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 87366 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3328035vqo; Tue, 25 Apr 2023 04:15:56 -0700 (PDT) X-Google-Smtp-Source: AKy350YBXCvyuQXm4rkrqtU4xYsBAGyjs49xT373LOryRSKi9lcertOObd3tleXGcCxBuWLgWHlY X-Received: by 2002:a17:90b:3842:b0:234:e0c:caaa with SMTP id nl2-20020a17090b384200b002340e0ccaaamr16885317pjb.6.1682421356319; Tue, 25 Apr 2023 04:15:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682421356; cv=none; d=google.com; s=arc-20160816; b=RV6IvWWFsPbpIN+o5LatmMtFGdzfs5V8hn+LyUQjzvJNkDrQIZThAixjbrzB9XRaQ3 1I5urDSOcc1LPyRX7TxRfxzSadwJ1rcyKFfk+Nu67GUFBZicp7/ka+dIf4LVOnZ/+8Cp dqVAcX9QwBt3LOwnHQoq7sV5UsIIYjoaDDJA7JnuOOlckhneyUZyBPRz++Nk05V1qpF9 5Jpm9SvRP2T59JkR4gynLmwrRN/swESotaS5DopYcD4r592ARHXnaGLOj5+lTLmUJ/Ee pKXL1qQfvUuu74LK9aJKjnunezW7dSbgeQryPBnnlijp0C9m4lO85MDI6tJoZtlooY1h uddQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=adf/xVVZ+zD1y6dwSMZy7eTiJ3ZJr+5S82v3Bo6axPQ=; b=vxkP6oSPl1xA90XU3QDYRJCJ3uP/0pqUm1V7g3qZKfDf7f9CynaiSt3SE0MEiJNc2/ wUoiIJy7NYPMdxqh9CknkIh9R0uaCXh9jqOCpzaJa5Tm9WpPBuAHwCwBBtYpmLsoWqqG W+9Ga1NvVz6fQacVXII2I5QjnJVSM5GrqDZ3TkfUpdMYLZjFk8z8JI82/h7bNbpd0m4X 70WgBWHNZQQ5RYvQlcw0LEYDl2hFcZrei9zTjlHGiIrAklTZIZZJYH68mo5JHXipD44N Z6z365HrJuTJJDewzMFN4GsS3UitHBPIFIhC9c7TzO96QlgpJO3xGLx+NAe7qphUteYH v+Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="Qg/Eb8jh"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nu10-20020a17090b1b0a00b0023747b24923si14472265pjb.53.2023.04.25.04.15.40; Tue, 25 Apr 2023 04:15:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="Qg/Eb8jh"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233916AbjDYLGF (ORCPT + 99 others); Tue, 25 Apr 2023 07:06:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233898AbjDYLF6 (ORCPT ); Tue, 25 Apr 2023 07:05:58 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E10EB558F for ; Tue, 25 Apr 2023 04:05:28 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-63b5c4c769aso7413575b3a.3 for ; Tue, 25 Apr 2023 04:05:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1682420728; x=1685012728; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=adf/xVVZ+zD1y6dwSMZy7eTiJ3ZJr+5S82v3Bo6axPQ=; b=Qg/Eb8jh+M7A1BjNkJA0ETdhpSJNmHPQqY7kHY12vMVLnl1kdHdvkXB4if/LEJNcQ5 /1LNuehfPKitPB3/5yv9OLAuhw799I6ciManueoWOAOynBw1CWPSJwwq7GxIxWdDsCzN naRUqvc2fV0nM8rhoZ1l1nNrYS66KlT/jRC4W1CsIMeKe0PoIvySiXB8XjS+DHlft/NM fZHyu90UDLxs+cplyvIGFAikzgye2S15dQ1zbi/9kb+dH6OV4iV+CspPnU1KIUXqBT7J qA2QnXHcRQ4FVt6MfpPeeOr+TBMq90cvSRy6vcvX4sHyef0DMH8MM3BjdFREbtnczCbm zWpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682420728; x=1685012728; h=content-transfer-encoding:mime-version: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=adf/xVVZ+zD1y6dwSMZy7eTiJ3ZJr+5S82v3Bo6axPQ=; b=XatKBQa+VQCbnJ+5B1G6RiHmTaPKv4Wn35eV/XswKo7m2GNxovGk1V5F8AwyNNLYbK FQSv0+0ehjB0LcMVvpmJVnToHlT5nrWUz21QHkWVY3cTShkhcyVDvi4fTI+1kXRD63Tk iR6cGU6ihW8GZB4Dumm4+l/gMxY92miyKA400vSmwOofLNZE0VSqmF0wxk86B4rYc4ug pNOpziRn2XZ3bc68hJE1i0L9ZaVh8kF+kl8rhX02T1dKkTBjXYhh8Ix02tZ0WVOlkIqG uDyJmh7w3pc2A8HGEyVdkPaq+NbAMHfWfS7c/yp/xSUO+0cPeIP66ByOZDq2lY1LpCfR l98A== X-Gm-Message-State: AAQBX9fh0W2CQpgmU7qoCvDA/LbasetkQrGzhQoxHa5l4ckDkLAqnB+3 N550hoD3NBrc3r+B8uirbeqTjxFpWULzylzHfB8= X-Received: by 2002:a05:6a00:1516:b0:640:dbe5:e2ee with SMTP id q22-20020a056a00151600b00640dbe5e2eemr7068367pfu.10.1682420728409; Tue, 25 Apr 2023 04:05:28 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.236]) by smtp.gmail.com with ESMTPSA id u3-20020a056a00158300b0063f3aac78b9sm4422169pfk.79.2023.04.25.04.05.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Apr 2023 04:05:28 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH 1/9] maple_tree: Fix allocation when min is equal to max in mas_empty_area/_area_rev() Date: Tue, 25 Apr 2023 19:05:03 +0800 Message-Id: <20230425110511.11680-2-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230425110511.11680-1-zhangpeng.00@bytedance.com> References: <20230425110511.11680-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764146656021631982?= X-GMAIL-MSGID: =?utf-8?q?1764146656021631982?= Make the allocation valid when min is equal to max in mas_empty_area() and mas_empty_area_rev(). As Liam R. Howlett said, VMA doesn't make this allocation, so now this bug won't trigger. Also add some checks for invalid parameters. Fixes: 54a611b60590 ("Maple Tree: add new data structure") Signed-off-by: Peng Zhang --- lib/maple_tree.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 110a36479dced..72099b4b32169 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -5289,7 +5289,10 @@ int mas_empty_area(struct ma_state *mas, unsigned long min, unsigned long *pivots; enum maple_type mt; - if (min >= max) + if (unlikely(min > max)) + return -EINVAL; + + if (unlikely(size == 0) || unlikely(max - min < size - 1)) return -EINVAL; if (mas_is_start(mas)) @@ -5344,7 +5347,10 @@ int mas_empty_area_rev(struct ma_state *mas, unsigned long min, { struct maple_enode *last = mas->node; - if (min >= max) + if (unlikely(min > max)) + return -EINVAL; + + if (unlikely(size == 0) || unlikely(max - min < size - 1)) return -EINVAL; if (mas_is_start(mas)) { @@ -5380,7 +5386,7 @@ int mas_empty_area_rev(struct ma_state *mas, unsigned long min, return -EBUSY; /* Trim the upper limit to the max. */ - if (max <= mas->last) + if (max < mas->last) mas->last = max; mas->index = mas->last - size + 1; From patchwork Tue Apr 25 11:05:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 87356 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3323155vqo; Tue, 25 Apr 2023 04:07:22 -0700 (PDT) X-Google-Smtp-Source: AKy350YHCWOcKX7enKVYkFgK67+pGVISJlr9QRT7PStvyP5cGjaGNXSm3d4NIASg2UIy08Arhz1D X-Received: by 2002:a17:90b:3756:b0:24b:a5ba:6ac4 with SMTP id ne22-20020a17090b375600b0024ba5ba6ac4mr8562891pjb.17.1682420841844; Tue, 25 Apr 2023 04:07:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682420841; cv=none; d=google.com; s=arc-20160816; b=xqLqN9YKPT4YyT0XEkZk6RVkFYlv1ToizywVh40rXgi6KyAVoJ4T+g8/HrBpTVQDyp B7GVz1O9N7vn+fZhVuI3RIJBSCnh9wJWSpfVHknwct0LaK5DkyHt40COQH9+ZjV1qqkK 3UepvyoTn+qL8sDqxtMr8jy6BLx7A0l5XTQjt7THZU+WGpW6TZFMKmwt639UmpFwNqiq nyFzjbkLiokQB3CbWUWPyBu75j6AccMy9IQOawHkZO+U979ctuPJ98BfX5K09AJNBNRa XVKt5YsVTxCnX5IFzDzwzFeo57earkgWPdN2mkiLhSGjf/yPFV92s5hYso+Cfukd0Z0n xvtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=k3gtz2twduYMn314aWKPdPXlwzAEr/ThikDxq/EAqMc=; b=bWXQokbWMHVWR39fknStLxJu2rvFl8HQpyGGhYEzjb3TGk61HcLCNiPxl+uBGaf08b IvhzLWz4yi/neJv7Cu2zx1bb+//6u/XV0SLiIHxd8SOVLrrVc5cUjM8nhXljZ9ACMwf0 8nhg/5HWi4x63CEqPDKd3vu+ZyXp66l931hKUP2sPMMksLIqUWsyrReSQyms2+Nk6tZ6 ek+buslSBt/54TMQaxXBc06aB2aINt+gT2Ew0m3swdg/xSoBcNNbv/qWwJtPDbep3EBo Wo3nLfn0bM63TP+njk0EJypE8q2MsTYkjWKAdAMb5HY8ucyAn/corr05udGKjYHDJ3Qj YggA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=QmK+bpu3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q14-20020a632a0e000000b005143b5917e8si12755361pgq.770.2023.04.25.04.07.09; Tue, 25 Apr 2023 04:07:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=QmK+bpu3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233745AbjDYLFf (ORCPT + 99 others); Tue, 25 Apr 2023 07:05:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230195AbjDYLFd (ORCPT ); Tue, 25 Apr 2023 07:05:33 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C4E05FDD for ; Tue, 25 Apr 2023 04:05:32 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-63d2ba63dddso4532384b3a.2 for ; Tue, 25 Apr 2023 04:05:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1682420732; x=1685012732; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=k3gtz2twduYMn314aWKPdPXlwzAEr/ThikDxq/EAqMc=; b=QmK+bpu3OrfPdSwq5btASAzKm3wgRczj/+suiuqNcMy2NwVbP4ROvdfevWx4rQNazE z51Uz+aGBN2J44RqQUvlScXgks+MkypgIVZPjhcPt8g1vNU6HSKACdUnLJH86h3Trf5x 29A4FD1yH8yNeYxbdMGM1UejkWDX+SNrdDJtE8vfWm8swblZ77+lqF7zKpuickVwqdC4 oAnQBvIRl6pV+0feNB+9re2SLlggZIRIT1Z67T0xC9ipIzv87BVHDvgkdSQ1gdFZnefA DXoZ2TKFJCZFzR8vjJJb5NhBPKZIus1BetzLfmTTHhYzAZW9qSZtdi+W+BOt1gqG8q5m iEtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682420732; x=1685012732; h=content-transfer-encoding:mime-version: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=k3gtz2twduYMn314aWKPdPXlwzAEr/ThikDxq/EAqMc=; b=V/0cHUk/NP1HzrTZzlK4rLuKt+/ddwWS3W+/A6HwDSbtzycw0rqZMc/yqydoZwTBnO IVbAkk2MaYTwK68PPrg8EljtZYGIAtJKCir5zJTkKcRNcIhxLB38bWAQ/7cOQLORyIeV 56oV8Gsh9DpZgLcw29snB4ulS7GJfIcBPH4sCexM/iVMf5KB0qoNyo6JymSQP4pDeV3z P7KuriAGRE9XnApXAcRtX4yyJJmMsNQHm98LcoTQluuvCiXnJ2eEq3DuNxbsp5euIcsB eviLVMTCsx2uXH1oM4tYLFiIVfqU/YQAVPamwJ5mtXO1tN591aVmRpSWruqRMdhx4E3K afPA== X-Gm-Message-State: AAQBX9fJ9EfzbdC2Fw/tc31QX6+NkaIFHzRrHwLkUzSHGlmDQQ/TpWn5 oMVzefIEn9S94TjvoZqebwuykw== X-Received: by 2002:aa7:8884:0:b0:63d:2c2f:e3a2 with SMTP id z4-20020aa78884000000b0063d2c2fe3a2mr23868065pfe.18.1682420731840; Tue, 25 Apr 2023 04:05:31 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.236]) by smtp.gmail.com with ESMTPSA id u3-20020a056a00158300b0063f3aac78b9sm4422169pfk.79.2023.04.25.04.05.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Apr 2023 04:05:31 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH 2/9] maple_tree: Make maple state reusable after mas_empty_area() Date: Tue, 25 Apr 2023 19:05:04 +0800 Message-Id: <20230425110511.11680-3-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230425110511.11680-1-zhangpeng.00@bytedance.com> References: <20230425110511.11680-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764146116318861119?= X-GMAIL-MSGID: =?utf-8?q?1764146116318861119?= Make mas->min and mas->max point to a node range instead of a leaf entry range. This allows mas to still be usable after mas_empty_area() returns. This currently has no user impact because no one use mas after mas_empty_area() now. Fixes: 54a611b60590 ("Maple Tree: add new data structure") Signed-off-by: Peng Zhang --- lib/maple_tree.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 72099b4b32169..aa55c914818a0 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -5320,14 +5320,7 @@ int mas_empty_area(struct ma_state *mas, unsigned long min, mt = mte_node_type(mas->node); pivots = ma_pivots(mas_mn(mas), mt); - if (offset) - mas->min = pivots[offset - 1] + 1; - - if (offset < mt_pivots[mt]) - mas->max = pivots[offset]; - - if (mas->index < mas->min) - mas->index = mas->min; + mas->index = max(mas->index, mas_safe_min(mas, pivots, offset)); mas->last = mas->index + size - 1; return 0; From patchwork Tue Apr 25 11:05:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 87363 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3327619vqo; Tue, 25 Apr 2023 04:15:12 -0700 (PDT) X-Google-Smtp-Source: AKy350YrwCuA00RKI+0rGS9lC+mBnHc0O+ONKu/HTvsgKPJdjAW+pNuf4rEqFQx25qxbPvFx6EEI X-Received: by 2002:a17:90a:e657:b0:24b:9255:ce16 with SMTP id ep23-20020a17090ae65700b0024b9255ce16mr10366642pjb.46.1682421312199; Tue, 25 Apr 2023 04:15:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682421312; cv=none; d=google.com; s=arc-20160816; b=hRKjYADeI63Qwz/5Cc3MHQaHAYIEWQZD6joRWufeVmOIfQzpjMsdLjZ6aU+972AuCa /hV/7M/8TjdWTGCzLSdVambWL/dUFXsxB4j0MzJModbHlkTjATrOUmecZVgpEWJGXlt7 wzcs+Q+sf2imdDStxFvmFlxtwuUY+IBA0CwDoPsqUbTrcncXo0alZFBPD8luLRbUV72B XMKDEYcVV0dBCJjjzwWaBibhtXZeUOw4I/Y/TFPD31MJAGpwwl4JvDAoZxvs3dREPMNU Parph/wLyO2+vNxEcxRJmciqUwIVtS9C/2Q9tBTCpNryUT0hbwq44li2T8r31y9eBFZ5 Ux8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=s+OVqkfyvyT9tLRaTTTVeLMx7p1ihu2PyK06f3NH+m4=; b=O5lGEXWhOvPGwHaAehj00BkSPqdZO/meCfLMbAKRHIilJgMb+E0DsNcld1kB6LT3y7 YrYUi7Yz956VBlH4CFRs6NdZ3usdwL6P6imzBJB6r9rS2dkJRO++W35C3x3eRWZHMShU 7e3OCqPHmOmJqf/XqGsibca8GO7+9fBBj7r5LzzXv4GmIBmHKDjqR+eIvWTJsfH7xB7u yQ8jQzz9VG9t5PGAa7SxWBQQ93eWRFnrMRIDu0IoAal5alCizcNOaq1RTtVMzU1GWnPU I2f7uua1+KOagYIWa4Dn2gnAu7rH8/gpdgkgjwjNN4S9wFA0IQwN9rQRSUqj9e6WbD6J 21uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=TvmnBK3T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 88-20020a17090a09e100b00247ad11b6d3si14094442pjo.88.2023.04.25.04.14.59; Tue, 25 Apr 2023 04:15:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=TvmnBK3T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233898AbjDYLGK (ORCPT + 99 others); Tue, 25 Apr 2023 07:06:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233907AbjDYLF7 (ORCPT ); Tue, 25 Apr 2023 07:05:59 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B70A65FDD for ; Tue, 25 Apr 2023 04:05:35 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-63b4e5fdb1eso6802593b3a.1 for ; Tue, 25 Apr 2023 04:05:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1682420735; x=1685012735; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=s+OVqkfyvyT9tLRaTTTVeLMx7p1ihu2PyK06f3NH+m4=; b=TvmnBK3T5BGsKLcDBxe8I1B94ng08H2tuzNDpEqZoy1+LctQIiW4WT3RZcb/tHl2on 88ugTHoHu/LoNQs3vW+n1rhZKd/FtaELuBuuVd9rZJaB3jLXbc9nJVemoKn7pNdJPu7Z tyP3oAFD0+vym5HdffMKGu7KU5rXjbuZg3OIOmHOrpOLXiQYYysfM2OhZ1NIR8Q30bND 9Vb81GryXrwM+H52qTtiRELs/L3RGJ2omGxGUOjbzntjCSK3Xs6nlbR+6Jx5RgRGdyZI lvvTm032rA91XCwcpNpNFMrfC2Q9p97isiUAo5q0FefmZnH99JIs+GggNcuX0YNXfn/I FG1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682420735; x=1685012735; h=content-transfer-encoding:mime-version: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=s+OVqkfyvyT9tLRaTTTVeLMx7p1ihu2PyK06f3NH+m4=; b=JucePTNgPflyDoXISeME0Ftfet3w98LZzkn7TfdFf7c+R8fszVdNkgtaZwHv7PQaJq 8oVmqstOAHexCOsTh4LGvn+D3eYOtHHoyP6m5cH+GJSUWyZCLi4B6zwDNFfHIYIXHnI0 6sKif6qP6QoFwdcEIJZluNwDbq6puHCHox/r//x+EA1R3JHS8dVJ5aMu3f0eeLdmRefX sfAu+R/Wcr/LqlM/oZ8tMc+xVLNZ655M7a0tR3fBs5yDj9JmxTR/WNUouAOj7Xc0N9fS yEgHC/wsJZeOLuTzKzp4FvWgJFH6xoVmLUS7XD6K/gnJj+dlWsYsy7/afTfqRJKgxjU4 0ZYg== X-Gm-Message-State: AAQBX9c4sUsRP8Q9zBJbXO9IXMz2qeu5W4+J4tmlAkt2q2l2HfvkN+I/ 05eOyzVA191u29/Jxz5WvyesGQ== X-Received: by 2002:a05:6a00:1401:b0:636:e52f:631e with SMTP id l1-20020a056a00140100b00636e52f631emr22180035pfu.1.1682420735189; Tue, 25 Apr 2023 04:05:35 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.236]) by smtp.gmail.com with ESMTPSA id u3-20020a056a00158300b0063f3aac78b9sm4422169pfk.79.2023.04.25.04.05.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Apr 2023 04:05:34 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH 3/9] maple_tree: Modify the allocation method of mtree_alloc_range/rrange() Date: Tue, 25 Apr 2023 19:05:05 +0800 Message-Id: <20230425110511.11680-4-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230425110511.11680-1-zhangpeng.00@bytedance.com> References: <20230425110511.11680-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764146609710674777?= X-GMAIL-MSGID: =?utf-8?q?1764146609710674777?= Let mtree_alloc_range() and mtree_alloc_rrange() use mas_empty_area() and mas_empty_area_rev() respectively for allocation to reduce code redundancy. And after doing this, we don't need to maintain two logically identical codes to improve maintainability. In fact, mtree_alloc_range/rrange() has some bugs. For example, when dealing with min equals to max (mas_empty_area/area_rev() has been fixed), the allocation will fail. There are still some other bugs in it, I saw it with my naked eyes, but I didn't test it, for example: When mtree_alloc_range()->mas_alloc()->mas_awalk(), we set mas.index = min, mas.last = max - size. However, mas_awalk() requires mas.index = min, mas.last = max, which may lead to allocation failures. Right now no users are using these two functions so the bug won't trigger, but this might trigger in the future. Also use mas_store_gfp() instead of mas_fill_gap() as I don't see any difference between them. After doing this, we no longer need the three functions mas_fill_gap(), mas_alloc(), and mas_rev_alloc(). Fixes: 54a611b60590 ("Maple Tree: add new data structure") Signed-off-by: Peng Zhang --- lib/maple_tree.c | 45 ++++++++++++--------------------------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index aa55c914818a0..294d4c8668323 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -6362,32 +6362,20 @@ int mtree_alloc_range(struct maple_tree *mt, unsigned long *startp, { int ret = 0; - MA_STATE(mas, mt, min, max - size); + MA_STATE(mas, mt, 0, 0); if (!mt_is_alloc(mt)) return -EINVAL; if (WARN_ON_ONCE(mt_is_reserved(entry))) return -EINVAL; - if (min > max) - return -EINVAL; - - if (max < size) - return -EINVAL; - - if (!size) - return -EINVAL; - mtree_lock(mt); -retry: - mas.offset = 0; - mas.index = min; - mas.last = max - size; - ret = mas_alloc(&mas, entry, size, startp); - if (mas_nomem(&mas, gfp)) - goto retry; - + ret = mas_empty_area(&mas, min, max, size); + if (!ret) + ret = mas_store_gfp(&mas, entry, gfp); mtree_unlock(mt); + if (!ret) + *startp = mas.index; return ret; } EXPORT_SYMBOL(mtree_alloc_range); @@ -6398,29 +6386,20 @@ int mtree_alloc_rrange(struct maple_tree *mt, unsigned long *startp, { int ret = 0; - MA_STATE(mas, mt, min, max - size); + MA_STATE(mas, mt, 0, 0); if (!mt_is_alloc(mt)) return -EINVAL; if (WARN_ON_ONCE(mt_is_reserved(entry))) return -EINVAL; - if (min >= max) - return -EINVAL; - - if (max < size - 1) - return -EINVAL; - - if (!size) - return -EINVAL; - mtree_lock(mt); -retry: - ret = mas_rev_alloc(&mas, min, max, entry, size, startp); - if (mas_nomem(&mas, gfp)) - goto retry; - + ret = mas_empty_area_rev(&mas, min, max, size); + if (!ret) + ret = mas_store_gfp(&mas, entry, gfp); mtree_unlock(mt); + if (!ret) + *startp = mas.index; return ret; } EXPORT_SYMBOL(mtree_alloc_rrange); From patchwork Tue Apr 25 11:05:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 87357 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3323189vqo; Tue, 25 Apr 2023 04:07:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7QEIzM2SCgr4RN1Bv6itWP7vPj+Cm4IYZ2C+UzGJOYa8C50mXxjnq/A8RKd2hbKFXknAnM X-Received: by 2002:a17:902:d507:b0:1a9:8769:36bb with SMTP id b7-20020a170902d50700b001a9876936bbmr4157933plg.54.1682420845260; Tue, 25 Apr 2023 04:07:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682420845; cv=none; d=google.com; s=arc-20160816; b=PJosftaQ/CQTQmP88oXXljV/O+1IVlNo6Jq0LmwOwHgtSg7kaikmpVRTyRtXeA6vqN lHShxtL/mQAy13KuyJ+zgdkR+h9TnYbhLtwbgs91ASe8DqO0xdROf6QlIlCmsLBIXv/p UqOH3LxE67NVEaGGBORx3aoLl3Lk0Gxn+GAKElDzi33cdev1nMaxRDD4sxGPrpp13Nt2 lysn2Imu/l6/Qzf1lpAGLPYJjCXjtCv+D52fLq4AhL8hqx37YDgPOYJ6KT0I3sg1+dqr GUbpJrdxHCguFiOoUHLKW0b1DVIcoo4oV6AoEEK8QUZhjvyZ3+gAfw9uE6gYYJ7KBYZo U00Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=I2GjseRaZiiYKMGFnELwsfMhZhXtBsHUr2pHKO1ngQg=; b=Ar50x3C3sQJu3+6qljKz14UaIExUiGq6Zl3tmy/Uxt5yc9+SOO43nrashipRgB4EQ8 RlqiWAn6SB2S2bnYiH5WH87IwSaxMuHupYTj/eOhztD23TougJLGS/AShAZXBM4oF2/2 0rmTRUlukXdz83Q6572QWTqr7UQuH+6VbJZHj4H1j5qcHqyE1i7jl4nsKIs1GIIBRenW A76XRX7vldqZoCJBW9LJq5MzfXRznUnE+LHawBNawzXwj7hi0VIS6mQkU7ks/KrWzrTp APaOBoImszdMXAfyV0jp9TVqWe4K5JQEzlpG+iLNXzOLm5N2yLJk0ZCxFvbPuI/KbZYt 0Ojg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=fHIvqUmZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 21-20020a630115000000b0051374678f95si13266300pgb.808.2023.04.25.04.07.12; Tue, 25 Apr 2023 04:07:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=fHIvqUmZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233886AbjDYLFo (ORCPT + 99 others); Tue, 25 Apr 2023 07:05:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233788AbjDYLFk (ORCPT ); Tue, 25 Apr 2023 07:05:40 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFA0D12C9C for ; Tue, 25 Apr 2023 04:05:38 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-63b5ce4f069so7034069b3a.1 for ; Tue, 25 Apr 2023 04:05:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1682420738; x=1685012738; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=I2GjseRaZiiYKMGFnELwsfMhZhXtBsHUr2pHKO1ngQg=; b=fHIvqUmZ5phg4ETfqPuneR+uYrbeTFZNsqI5XZ3pc1dHVDhJLXx+0FexrM2XAJvjaz DMzNPe20gZ+NCvxomVoNk7+UR79+C4T1KVvfdllMBQIDgMY2UOCW0DZxkYp6oq2Foui9 Ad9oYzSTeGVri7alkJmHqYVcyUWCNAu61TGufp92Z8nGIMFj2zHiAVh9QMlyZMs8/X3n JaD5Z0SXR5QS9EAY/zo799iZxw/XCaMS5nZZFNEXsZ0uC8UWjlS5NmmnRb97ispvDyTB fJlLf2vgbq63ZL3bQSR/z4beNrVcaH7kTiLmle7C9I7G5kwKfFlFnPgkfKKqhnrV3Mw7 FUxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682420738; x=1685012738; h=content-transfer-encoding:mime-version: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=I2GjseRaZiiYKMGFnELwsfMhZhXtBsHUr2pHKO1ngQg=; b=PYuY0KzMPMDIjyRFbDRUduMsmW2BLuYO5GB1fiDKRB7Yz1p3oBON3Q5VLHMVh18DLd ecgo4y6DHJAoJM5LruxoTG3yMkVcAIOc3lARaWUGlRAk759kCUe4XDAgGC6TiZq4pdI4 ei5Mw6DYimuYiaAxpAOlgvdXruvtwF2FN9GLydKfzNjlrm/o0q3tE7F7uXdw9y+/PeuY 8zQE7pRfD0F9eJYCNExNX2ZiOkm8HMb5KE1Wo3WHHsNcUviCunwcEsXreaPPyRspilQO VA6KczwBgBygmijpRsVDsRFOfQ9mdlIi6nshjsNBBuDoXrhaSAYrMqnLbZY5lZcwKEIw NVpA== X-Gm-Message-State: AAQBX9dymllCaZViv+aG4H+FfzSKnPZ9me7MPIGJb8+ak7H/Nve9m+CS OI9tz75cHm1Zg2StZYnIOvjmmA== X-Received: by 2002:a05:6a00:1581:b0:63b:8a91:e641 with SMTP id u1-20020a056a00158100b0063b8a91e641mr22828410pfk.11.1682420738337; Tue, 25 Apr 2023 04:05:38 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.236]) by smtp.gmail.com with ESMTPSA id u3-20020a056a00158300b0063f3aac78b9sm4422169pfk.79.2023.04.25.04.05.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Apr 2023 04:05:38 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH 4/9] maple_tree: Update mtree_alloc_rrange() and mtree_alloc_range() testing Date: Tue, 25 Apr 2023 19:05:06 +0800 Message-Id: <20230425110511.11680-5-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230425110511.11680-1-zhangpeng.00@bytedance.com> References: <20230425110511.11680-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764146120329347909?= X-GMAIL-MSGID: =?utf-8?q?1764146120329347909?= From: "Liam R. Howlett" The previous changes to the gap searching made this testing fail. Unfortunately, there was not a safe update order, so fix the testing now. Fixes: e15e06a83923 ("lib/test_maple_tree: add testing for maple tree") Signed-off-by: Liam R. Howlett Co-developed-by: Peng Zhang Signed-off-by: Peng Zhang --- lib/test_maple_tree.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/lib/test_maple_tree.c b/lib/test_maple_tree.c index f1db333270e9f..30f2ebff95d75 100644 --- a/lib/test_maple_tree.c +++ b/lib/test_maple_tree.c @@ -102,7 +102,7 @@ static noinline void check_mtree_alloc_rrange(struct maple_tree *mt, unsigned long result = expected + 1; int ret; - ret = mtree_alloc_rrange(mt, &result, ptr, size, start, end - 1, + ret = mtree_alloc_rrange(mt, &result, ptr, size, start, end, GFP_KERNEL); MT_BUG_ON(mt, ret != eret); if (ret) @@ -680,7 +680,7 @@ static noinline void check_alloc_rev_range(struct maple_tree *mt) 0, /* Return value success. */ 0x0, /* Min */ - 0x565234AF1 << 12, /* Max */ + 0x565234AF0 << 12, /* Max */ 0x3000, /* Size */ 0x565234AEE << 12, /* max - 3. */ 0, /* Return value success. */ @@ -692,14 +692,14 @@ static noinline void check_alloc_rev_range(struct maple_tree *mt) 0, /* Return value success. */ 0x0, /* Min */ - 0x7F36D510A << 12, /* Max */ + 0x7F36D5109 << 12, /* Max */ 0x4000, /* Size */ 0x7F36D5106 << 12, /* First rev hole of size 0x4000 */ 0, /* Return value success. */ /* Ascend test. */ 0x0, - 34148798629 << 12, + 34148798628 << 12, 19 << 12, 34148797418 << 12, 0x0, @@ -711,6 +711,12 @@ static noinline void check_alloc_rev_range(struct maple_tree *mt) 0x0, -EBUSY, + /* Single space test. */ + 34148798725 << 12, + 34148798725 << 12, + 1 << 12, + 34148798725 << 12, + 0, }; int i, range_count = ARRAY_SIZE(range); @@ -759,9 +765,9 @@ static noinline void check_alloc_rev_range(struct maple_tree *mt) mas_unlock(&mas); for (i = 0; i < req_range_count; i += 5) { #if DEBUG_REV_RANGE - pr_debug("\tReverse request between %lu-%lu size %lu, should get %lu\n", - req_range[i] >> 12, - (req_range[i + 1] >> 12) - 1, + pr_debug("\tReverse request %d between %lu-%lu size %lu, should get %lu\n", + i, req_range[i] >> 12, + (req_range[i + 1] >> 12), req_range[i+2] >> 12, req_range[i+3] >> 12); #endif @@ -777,6 +783,7 @@ static noinline void check_alloc_rev_range(struct maple_tree *mt) mt_set_non_kernel(1); mtree_erase(mt, 34148798727); /* create a deleted range. */ + mtree_erase(mt, 34148798725); check_mtree_alloc_rrange(mt, 0, 34359052173, 210253414, 34148798725, 0, mt); @@ -880,6 +887,13 @@ static noinline void check_alloc_range(struct maple_tree *mt) 4503599618982063UL << 12, /* Size */ 34359052178 << 12, /* Expected location */ -EBUSY, /* Return failure. */ + + /* Test a single entry */ + 34148798648 << 12, /* Min */ + 34148798648 << 12, /* Max */ + 4096, /* Size of 1 */ + 34148798648 << 12, /* Location is the same as min/max */ + 0, /* Success */ }; int i, range_count = ARRAY_SIZE(range); int req_range_count = ARRAY_SIZE(req_range); @@ -2660,7 +2674,7 @@ static noinline void check_empty_area_window(struct maple_tree *mt) MT_BUG_ON(mt, mas_empty_area(&mas, 5, 100, 6) != -EBUSY); mas_reset(&mas); - MT_BUG_ON(mt, mas_empty_area(&mas, 0, 8, 10) != -EBUSY); + MT_BUG_ON(mt, mas_empty_area(&mas, 0, 8, 10) != -EINVAL); mas_reset(&mas); mas_empty_area(&mas, 100, 165, 3); From patchwork Tue Apr 25 11:05:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 87359 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3323455vqo; Tue, 25 Apr 2023 04:07:55 -0700 (PDT) X-Google-Smtp-Source: AKy350ag2k9qb/ZIegcE9dd42ny+OvksgjFo3kn+qKZsxfuF57WrvcCLX1FTFkuOMWdGWG4SsJP1 X-Received: by 2002:a17:90a:5890:b0:246:7040:a0a7 with SMTP id j16-20020a17090a589000b002467040a0a7mr16484372pji.47.1682420875085; Tue, 25 Apr 2023 04:07:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682420875; cv=none; d=google.com; s=arc-20160816; b=qiVwxWOp/SO90CnOhJKh1MqgK/9EBJl8tNNkV+nHrA3NFoeOEr6nnEGyUhpTSYS7sV xrsrNmZiw5BnWgOlSZCxY7wF3SsBtRypfuTQeTEWMByyJ4x18xPYpYy7maDXAdLBRct6 FK4MWCdQBWYY9NzBr4Rh/b4ygED0atZ3PipgY6F8T6C/wg0voyT7+63bc5QpjhYVF4Th 0r0IP6NK98SSgOHK2t2/ELOPpstVGH6q2I6+o+zACRckOPtdMOmtXPnwde7DdkCybTkm VZ+F0ZfACsEazWQVxtvKmd7+8Q9HwR+XlMSTfjpe+Ca6QDyct2L4L5j8rDX9jJRt4LU+ pcHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eeRfJQ/YCl9FjXRKTZNgTU7Yw5RZfHp0FYZQ2Hd7Tj4=; b=OpnUCgqsNFr8f95/IdzSKeYF8MS82iAWcRuiQhA6Jpfp++340arEUkRLXF0fTkYgNR RrJ14G4S9Ayaf1sC3tujxy3Oe/bVWWvszov1Mhh6FMftKZBsmkTKeRSJ/96jR7S5Gtg2 2+5ptOigTPe+9CYJNnLElTgi9W4IKS8AtzxMbuLBXg4g22Ouk2O4qvQahGuwVWtrDHmN j2dxAv4hEOri7COCOaasiMmvDP9CdHg4WyIR5GJVgKgCJkX6uVGOULN6tHt+DJQ+oftI TFsVbtPW3HSwF2MOUBTnr93w/juvJr2eA/Dnqoju348zm46/23NwRn8UBppZCHD6f8UQ OPYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Svev8byb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e125-20020a636983000000b00524f00fee68si8976298pgc.372.2023.04.25.04.07.41; Tue, 25 Apr 2023 04:07:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Svev8byb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233950AbjDYLGS (ORCPT + 99 others); Tue, 25 Apr 2023 07:06:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233896AbjDYLGE (ORCPT ); Tue, 25 Apr 2023 07:06:04 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6CABD328 for ; Tue, 25 Apr 2023 04:05:41 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-63b4a64c72bso4511884b3a.0 for ; Tue, 25 Apr 2023 04:05:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1682420741; x=1685012741; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eeRfJQ/YCl9FjXRKTZNgTU7Yw5RZfHp0FYZQ2Hd7Tj4=; b=Svev8byb/gTZnb0la5Wq4707w9wE4BQLB2oUjKyzCWd+gRkSVi8vfkItPYdxARqJ4q MbPTHUJfAQd0OtkvuRzZg/QTqPrBEBr9rwuyy0A/TIReFKimAy++ysDDQzOYAVSC58hO wXAfc8a4HYNGlD8F9FCsEvqUQe/eQVdcJe1K4sAYzQYoGX435meNMA1h35cA1gr5ge3D /auP7Lm9p3cXrA3H4B/b25cb1+45DqjELlJj996ww1QbQoCfhHQwB3ihcbibdbC3zOdm sVpm3ren90VMIxe337JJ7kwUre+g9lTypagafMBqfSY8eURnFRGQ2R91hUchRs38WWTT PbzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682420741; x=1685012741; h=content-transfer-encoding:mime-version: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=eeRfJQ/YCl9FjXRKTZNgTU7Yw5RZfHp0FYZQ2Hd7Tj4=; b=NSI3Ju7p/Wf3pEZ52P9/KH8TSuFy/enVjFGFPk6UykAvXDYPCUxwioHajzGRsSqa3h Mi2y5Ie/yBJySUz5L6H/wodEdj/D4gtVxKIwxug9wzWqyeNjVwQwMQG2mpq8+0g8Yw5i Fr4fCznDs2JWo0X6oXsOtW5oIyANUnGtg3TnwcmfbdXJIr5wIetUjz07OTCmKyU49iwp ib0MWhyIy/awIqb87l4qXWF2W5P6nEz8BDZUMasy4+qCxyPwn+d3sDBICIN42CVZsJFc vgxlbCXV2qLI1zU2/Ff4D+DbpJ9ibbhyrsIxAwOt8Uq4zq8jY4A/dnspV/6kbphotawq 5dNw== X-Gm-Message-State: AAQBX9dAIYi6Y/GVb7B8ARmRmjflNsIkxqyKKPAVzY/T3wL9pCejNDgO FF0YbhvjbYGdEbub9ljrMD/pEA== X-Received: by 2002:a05:6a00:1a50:b0:627:e49a:871a with SMTP id h16-20020a056a001a5000b00627e49a871amr24354476pfv.23.1682420741370; Tue, 25 Apr 2023 04:05:41 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.236]) by smtp.gmail.com with ESMTPSA id u3-20020a056a00158300b0063f3aac78b9sm4422169pfk.79.2023.04.25.04.05.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Apr 2023 04:05:41 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH 5/9] maple_tree: Remove an if statement that cannot be true Date: Tue, 25 Apr 2023 19:05:07 +0800 Message-Id: <20230425110511.11680-6-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230425110511.11680-1-zhangpeng.00@bytedance.com> References: <20230425110511.11680-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764146151599180947?= X-GMAIL-MSGID: =?utf-8?q?1764146151599180947?= Because the commit 06e8fd999334b ("maple_tree: fix mas_empty_area() search") is merged, this if statement cannot be true, so delete it. Signed-off-by: Peng Zhang --- lib/maple_tree.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 294d4c8668323..7f4b2ce84ce61 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -5084,9 +5084,6 @@ static inline bool mas_anode_descend(struct ma_state *mas, unsigned long size) return true; } } - - if (mte_is_root(mas->node)) - found = true; done: mas->offset = offset; return found; From patchwork Tue Apr 25 11:05:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 87358 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3323250vqo; Tue, 25 Apr 2023 04:07:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ66Fjwl784fjFC8goasgAuFAbiJgC6BOsHF8mUXtX4rNv0b96HEBiA61oMBbn7YsewgKN2t X-Received: by 2002:a17:902:d507:b0:1a9:8769:36bd with SMTP id b7-20020a170902d50700b001a9876936bdmr4105577plg.36.1682420854132; Tue, 25 Apr 2023 04:07:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682420854; cv=none; d=google.com; s=arc-20160816; b=IDPFbZ9GGV33eOQw1o57ZyvD+swFKdnthMSvXWa8d1QFnxl3IujBYxUGR6mEx8WDTE dfG3U6F4w/ZXy8yq/XSUc2W3IGUxMCnW6DB/ltBej5bWx9CQao3EdhIXbgq6oUg9N2RR +4Ii8L8xa/Jn016ZkhWqjNCTj/1FD++jEySiY4V7bpGKvFsKbOEg6b7uOc/JWR2Aj4tl 1pJxQLRKNYseA6lcxoB35cqkqQJMnVxvaeGz9SOl7Wud2CHq2pIQvBJVQnkGPER1x0Ol 1iQluikbe953GgRw9ubrpzwGo4+acQVOEATa8xmdP1frPxqnYzCP4PwDtJ50DyqLxJQC jNaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Uhpet9rFKKSbNY/rO+kxNiiukorlrEmSdc9GCeX7BVQ=; b=qtxm4x5qv2jJKfzjf12LIgqOE2G1xS5B1FRxhhXNddW3YEtBcB566/rnhTI7CFWDbX +tvXcwaHvbpATVUZsRoNc2fbmduk0g3ubwUfccvqs814LbBXvPxpg69KUVk6QIF4OZy2 3YGFHDCgiHYRdw4BqRsXRYOsiniBp7iMj34N9xB6zhY3SF6peuHyfw+F+8ISXSDUbYxj s3o3eWnKZ6sCXDAN2XViTVpTUrMU6zOLwJ0JW4J/56xRT+TKqAKdi/CCkfY4RPJEtjHL HT60w44MgFxpqJzIemCz5wsOPKWtD/bf2HiMipeGXL3DadxOkVcLyr2NDxBug1y3ua3f +DBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=kRDCATpM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u1-20020a1709026e0100b001a6783cf26dsi11254213plk.255.2023.04.25.04.07.21; Tue, 25 Apr 2023 04:07:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=kRDCATpM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233873AbjDYLFw (ORCPT + 99 others); Tue, 25 Apr 2023 07:05:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233888AbjDYLFt (ORCPT ); Tue, 25 Apr 2023 07:05:49 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 383D012C97 for ; Tue, 25 Apr 2023 04:05:45 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-63b60366047so4504872b3a.1 for ; Tue, 25 Apr 2023 04:05:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1682420744; x=1685012744; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Uhpet9rFKKSbNY/rO+kxNiiukorlrEmSdc9GCeX7BVQ=; b=kRDCATpMOFuEPi6tXPsOXLZpTjhUGeNU5eTbsWS/STvZypZztv1c2WheEeS2ZqnMTC kpd1b3dOaUmTKyXaj+z9CyulDGeZtQwWDI4jrkMX22GZUDqIUkdI7glYxD+jmHZth1/E i0VsY7k71T7rtEZsPr0RtaW/qwJYwCCfnFrPYFo8E6rV4sJwqA/Wvf75YGIZtKQjP8gN tXmWXV7YanL+BeCwrwhNMS0CbG66ajylBFYygIuyhlINtNPvpz2OfsBg7buDGPs6x44o m5vs7IxRJ7cIHDTdtX9SfH9SC0bt7BMfYOLlFrjKRITZjTGinAox/LUHikSJzJkWe5Qz ySKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682420744; x=1685012744; h=content-transfer-encoding:mime-version: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=Uhpet9rFKKSbNY/rO+kxNiiukorlrEmSdc9GCeX7BVQ=; b=LlaxBhN1XuUQqbz9ANQ8G3BC4I6v5N0u+fB6KyPa+lOdUvXnbskdZywi1ive1q+0Bm 06rwv/2Ke3sYuy/mSQe/H7HOY4cKNlrSG9116fIKRB+mBA89e/plIGJgRkJkrabwCPNL DuSs73NxOooGuAT/+VaTuE5YAG5QSY3hvZ8X61riWECkqTbyACoB5nQICzK+6Fy0UdTn 08LBUYWViFc/4QYAS/4o+o1NCt0NzDiKJ4gp01Ndxsjtrrjp/zkd481MdIg+eJvaM3LL iJL1OsAAGQr1ImTtbX3Wpv7I+cOhQv75NysmDn2nHjzA6bCDNKq/P39lcMJxp/KlgAv2 yddA== X-Gm-Message-State: AAQBX9e5RIRrqVOY5RrzRCgDli37YNdsx+IcVN6u0L1qZ8cFyBfWi7Cp DM2tGoNo/JXKlRvECEovZJHHcwi4aEZs/sX4a9o= X-Received: by 2002:a05:6a21:998d:b0:f1:ff77:4a32 with SMTP id ve13-20020a056a21998d00b000f1ff774a32mr23584687pzb.9.1682420744512; Tue, 25 Apr 2023 04:05:44 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.236]) by smtp.gmail.com with ESMTPSA id u3-20020a056a00158300b0063f3aac78b9sm4422169pfk.79.2023.04.25.04.05.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Apr 2023 04:05:44 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH 6/9] maple_tree: Remove a confusing check Date: Tue, 25 Apr 2023 19:05:08 +0800 Message-Id: <20230425110511.11680-7-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230425110511.11680-1-zhangpeng.00@bytedance.com> References: <20230425110511.11680-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764146129600280806?= X-GMAIL-MSGID: =?utf-8?q?1764146129600280806?= After this loop, we are at the last slot of a node. Our purpose is to find an entry that is not NULL, but the pivot is checked here, delete it, and change to mas_logical_pivot() to get the pivot. Finally, only check whether the entry is NULL. Why is this confusing? If the pivot is equal to 0, but if the entry is not NULL at this time, it will return NULL because of the pivot, but it should not do this, the entry is valid. Signed-off-by: Peng Zhang --- lib/maple_tree.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 7f4b2ce84ce61..83441ef2e1f57 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4742,17 +4742,13 @@ static inline void *mas_next_nentry(struct ma_state *mas, return NULL; } - pivot = mas_safe_pivot(mas, pivots, mas->offset, type); + pivot = mas_logical_pivot(mas, pivots, mas->offset, type); entry = mas_slot(mas, slots, mas->offset); if (ma_dead_node(node)) return NULL; - if (!pivot) - return NULL; - if (!entry) return NULL; - found: mas->last = pivot; return entry; From patchwork Tue Apr 25 11:05:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 87360 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3323850vqo; Tue, 25 Apr 2023 04:08:33 -0700 (PDT) X-Google-Smtp-Source: AKy350bXxJtVHp4qDgZ7uLxDhR99lvBDSYkDr1aG/MTmMcYhRClwPaTQAQp9PZc+5eAZXr27PtN2 X-Received: by 2002:a05:6a20:72a4:b0:f2:c90a:9e0 with SMTP id o36-20020a056a2072a400b000f2c90a09e0mr14279151pzk.3.1682420913361; Tue, 25 Apr 2023 04:08:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682420913; cv=none; d=google.com; s=arc-20160816; b=rJZHFdHMksi9pJXGP6TBtFDZz/bjZayo7NYEelfB1myiO9Et7UMrN3sKkwdDKAk9kS IzAZDvYYQc295IY0YKWczfZjbI3Jpn9/BmIWi/26Ek1ae3uIguTqnhn+QrHrigxmSRrR rrBkkVA42SK173uE3QDSixk9zaiiGVVlnCZX1DlLIDfSVfvP6Ado5HmdMj9qHyRhnkr2 +4rTLa1sscpGM432u/PoC5cJRfRLeSiFPKONgEg+uYUjj7bjFAt9Q6b8T/SrOfrLGXop WmiFpxS+ZhV7ea2MdWbapMylQorHbRs65+KqVNyIj+yYN60nSC1jxlUfS1cmZLE8bTT9 6hpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3wyOOQxSifE+UQ7Biie0VeiE7Xg3ne8+bvtiq6zNGpc=; b=Tyg8NsADcj8CPiN+qa+SmcSaYQDNDlVJ2ORo+gQhd/oZK7K+kX4pwbM8Mn74lciC+v /CR/4ni4cGvIqSV96Bk25OWMqvTO8j07m+mVfB4uHbbkUEDqicMR7uvafzqGZumSE1FT L85Of4zuslfxN+KyHrad8l5MqONFiOWzQMGQM8JaYECKUHwWIoU4zVulD7Qrm1M/RrZq Aw2cRGX5I31VFC1uOwN9wRZ+ytwOB0w9vVTlSiFoca4KA4fSaMhSjg25EIqegqQy6TT7 FNcaBk0+f95L+WpA0PL1l/+AvrKYqB8dOLsejqaB0IQWqTRz+1++1FtRNiJLxkb6m17K sIrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=jipQmnHi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h8-20020a632108000000b0050faaed4f76si12785862pgh.751.2023.04.25.04.08.20; Tue, 25 Apr 2023 04:08:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=jipQmnHi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233963AbjDYLG3 (ORCPT + 99 others); Tue, 25 Apr 2023 07:06:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233931AbjDYLGR (ORCPT ); Tue, 25 Apr 2023 07:06:17 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 415D812CB5 for ; Tue, 25 Apr 2023 04:05:48 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-63b7b54642cso4131733b3a.0 for ; Tue, 25 Apr 2023 04:05:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1682420748; x=1685012748; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3wyOOQxSifE+UQ7Biie0VeiE7Xg3ne8+bvtiq6zNGpc=; b=jipQmnHiGZqHhFj+pjse8A990ppkL1/uxO9HRdscpit7rhuWxH1VtL8WteZPa//UVl d+QYWMUc3Pd0xNIJ5KCnsF9R2zsXUbxhe79MilPyoF5EbgQWgrgD5Yx/Z643QyvsML8e Y/jlWVM3tUMLV/IXawWDmC1VAS3dP/bzZfDjJDUx7QS7NhTg5FRO+N5DpeKFva0YH+ux jJWMrmPke8pBOQm1JHvFPXk9am07Mtp+Z4X0pBvH9tYeY/Ky6BThaNUVjVEk3qJFoxRR s2JD+th6vAVyzSwwRovJ2WxkiFVq+PiDC67vi7LzP0ZtSLmtotp3zsqbzMeCtXArnENH cbUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682420748; x=1685012748; h=content-transfer-encoding:mime-version: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=3wyOOQxSifE+UQ7Biie0VeiE7Xg3ne8+bvtiq6zNGpc=; b=AKOyMqkEcgAWfpd5yja7UolAR7ZUTvwMTC/ix/83lgugveVukpQydg38PHfOf4UqO+ 7R1+zmPaHMoS736BEAaNbieixEI3EjJ9zpwmVVlB7ebo6ceN2mSocNKKb+sgwYwd9ICH h2nzaG+Uzo420/bmul4ngVhAS2vAL6s9pyoz+2MqPg4tkYX/I/f4AHLClA+rH7l9u4ph HueN2Jasot26bY7dW7SoWmfl+A8s6YXfG2+I2xmpbaXM9OuhMG+L2FyVh2Icr1jeik4W jmNyxICwlneZoBzWoaFA5fRtRd7WntG5aX4P94Mt+clbLeGSy0eAYgYyUn7Xl+QI0tKF y7Hg== X-Gm-Message-State: AAQBX9fBeRMZi4wfT+/Ft90HLpg4hh5BGxWvDKa0asSvKH8JOfGucWCQ D7ueEmvOiyhNNDVG+pj27D6F+w== X-Received: by 2002:a05:6a00:1887:b0:624:7c9a:c832 with SMTP id x7-20020a056a00188700b006247c9ac832mr22104593pfh.8.1682420747660; Tue, 25 Apr 2023 04:05:47 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.236]) by smtp.gmail.com with ESMTPSA id u3-20020a056a00158300b0063f3aac78b9sm4422169pfk.79.2023.04.25.04.05.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Apr 2023 04:05:47 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH 7/9] maple_tree: Delete redundant code in mas_next_node() Date: Tue, 25 Apr 2023 19:05:09 +0800 Message-Id: <20230425110511.11680-8-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230425110511.11680-1-zhangpeng.00@bytedance.com> References: <20230425110511.11680-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764146191864526556?= X-GMAIL-MSGID: =?utf-8?q?1764146191864526556?= When offset == node_end is satisfied, go to the parent node, mas->max will not change. So there is no need to update min on the move. Signed-off-by: Peng Zhang --- lib/maple_tree.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 83441ef2e1f57..8bfa837b7b752 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -4616,7 +4616,8 @@ static inline int mas_next_node(struct ma_state *mas, struct maple_node *node, enum maple_type mt; void __rcu **slots; - if (mas->max >= max) + min = mas->max + 1; + if (min > max) goto no_entry; level = 0; @@ -4624,10 +4625,6 @@ static inline int mas_next_node(struct ma_state *mas, struct maple_node *node, if (ma_is_root(node)) goto no_entry; - min = mas->max + 1; - if (min > max) - goto no_entry; - if (unlikely(mas_ascend(mas))) return 1; From patchwork Tue Apr 25 11:05:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 87362 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3327081vqo; Tue, 25 Apr 2023 04:14:10 -0700 (PDT) X-Google-Smtp-Source: AKy350acckYMnym1zVeygoDdtvnciujROrv6FGJ3KRZiF04qCwwaslALP8SKV9vbo3Uuv9xjHKkM X-Received: by 2002:a05:6a20:c901:b0:cc:a5d4:c334 with SMTP id gx1-20020a056a20c90100b000cca5d4c334mr18943022pzb.10.1682421250018; Tue, 25 Apr 2023 04:14:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682421250; cv=none; d=google.com; s=arc-20160816; b=exR4lc+alGKKDj/cKTqD6QguqctKeZMuCb1WAa4LAVdXg19pY5gd9wY0t5rfPe+VOl 3CG/AkMUYi5m97Sa6AtkaUvg1Uzi9PsEPXLjuEBqtYtJRSAOgo3kwlosKFUbivnGz+fM 1QTVAjpwv1usp0w5bBS8NkPna1+DXJO13gRbq4iG9vaq/1qA8ZiRiKyyDsjeMsO6Yc/V 3DKXd9o7n1+PtghN76Dc5CfEy0PreDd+/0Z4BzEeFcTvFAglrkHX/GYAk14FwjSIuRDH 9ro6F5tWy7uGE7Zkl2zF6v1fdGYmFVPr6Mrk+zxUsjfetE8m7rEQdmSKQwSETOmXmkqR +hKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/5HiaDQy1gV5OijIvJDqywUjC7+FvWItMLIDy/cp2lo=; b=As2fjTMz497wW0E0gSWPC6r/9pzw5yMaVnWpAAM2u2EUp3P1oCPtgDxcLQZOIbTLue +GL4XP4g8MXZAFWQE0tCv3U+iskgDl/fhzeS0t9fS361hjHwZGjqh6GwgHj22EDzM392 ggZFDg7dxl9KFHqqzR7IHAnZInHg1GfqQh3QIkibNt+6M0vWe3teVbsgJfGCvZfV+HcY Eb3lq0qr6fyEblMw4y2yQaBFdYtEbULKTpNFVZo8HI765Mb7FbCZJQI3ox3KKf+d11dT Om/tA7htjKkYmBCCvHNlv4rZNjHx/ecnN3ARiKl3zpBpQNwyQDT/yAPeHhz2wMnGiZl3 vr2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Jmn8+k2S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f23-20020aa79697000000b0063b8a054e06si13417028pfk.259.2023.04.25.04.13.55; Tue, 25 Apr 2023 04:14:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Jmn8+k2S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233809AbjDYLGC (ORCPT + 99 others); Tue, 25 Apr 2023 07:06:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233788AbjDYLF5 (ORCPT ); Tue, 25 Apr 2023 07:05:57 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FFD87ABF for ; Tue, 25 Apr 2023 04:05:51 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-63b4dfead1bso4700984b3a.3 for ; Tue, 25 Apr 2023 04:05:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1682420751; x=1685012751; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/5HiaDQy1gV5OijIvJDqywUjC7+FvWItMLIDy/cp2lo=; b=Jmn8+k2SfFfgMhLQds+Cr0nlYahkoptl1RwDbzAx8AZV4daLWkUna/d9KpjCx2Rfy9 rmCt9o71sj3yTlbe6K2B/hk/W22x/AoY5gUneeoO2WZBUgG67nocT5AJKOv91QCs4JN+ DZCnL7fxyHriXlCninrD3Zk7URi4nUfnyi5EmbP/3Gha1H6bcYRPYa70gVOJDs6+9d0S qnpA6xJhk/rQJkofq1EEOa8tqw8D0zjeLVXFud06M0NuAFQZVoamUgVTSmw9Qqf/CECK aW9WKvh1ndvQxmuIyREMN2Zd+vYx5GuyPdQSabCRBc2itdPqh0hvHYca5F8MEElf7xn+ 3LeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682420751; x=1685012751; h=content-transfer-encoding:mime-version: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=/5HiaDQy1gV5OijIvJDqywUjC7+FvWItMLIDy/cp2lo=; b=JImxG/15/ZMWVbuUB4mDZm9pAsS8pR01sCQWrZ4vZvEW50TRZH9Is8AjlWZmqdLl1v 0yHE+OUc2/2/oHOfI5VV29iExnbugnmCtn/IcUY65dv/VRJwhCZ+W5uGZkSTGdPKG7AC N/dEUMeiIGHob3hPdSnxk7lxrVaiBwxTJXaB6uzpzLukWFNzTH9CDdgAgjyY+m8enkjY bwBeT+OlDZkucKUj2Wak0RyOe7QJ7mq9+YdRdQogfKWyosj3NlEmspYBpigr0ti4Eb2h TjHuzbSSUPNbWJ4uUO6PpPg+20SwEX2PnbOEQpUyY1XhznAopZB/dOCAfkfo9TQMNK9m qvBg== X-Gm-Message-State: AAQBX9eRenNvFqdlSv9aZwAPCxpPk9xCj4yv2wJmESS9W+SrUE3z5Evy rxUqf+B7os9FHefnMZKvOnxJ4Gu00uDaZlyYkes= X-Received: by 2002:a05:6a00:2d20:b0:634:7ba3:d142 with SMTP id fa32-20020a056a002d2000b006347ba3d142mr24767709pfb.10.1682420750817; Tue, 25 Apr 2023 04:05:50 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.236]) by smtp.gmail.com with ESMTPSA id u3-20020a056a00158300b0063f3aac78b9sm4422169pfk.79.2023.04.25.04.05.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Apr 2023 04:05:50 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH 8/9] maple_tree: Remove the redundant check of mas->offset in mas_empty_area/area_rev() Date: Tue, 25 Apr 2023 19:05:10 +0800 Message-Id: <20230425110511.11680-9-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230425110511.11680-1-zhangpeng.00@bytedance.com> References: <20230425110511.11680-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764146544528414820?= X-GMAIL-MSGID: =?utf-8?q?1764146544528414820?= In mas_empty_area(), after mas_awalk() returns, if EBUSY is not set, then mas->offset must be valid, no need to check. Same in mas_empty_area_rev(), so delete it. Signed-off-by: Peng Zhang --- lib/maple_tree.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 8bfa837b7b752..964214de2ed18 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -5305,13 +5305,9 @@ int mas_empty_area(struct ma_state *mas, unsigned long min, return xa_err(mas->node); offset = mas->offset; - if (unlikely(offset == MAPLE_NODE_SLOTS)) - return -EBUSY; - mt = mte_node_type(mas->node); pivots = ma_pivots(mas_mn(mas), mt); mas->index = max(mas->index, mas_safe_min(mas, pivots, offset)); - mas->last = mas->index + size - 1; return 0; } @@ -5365,9 +5361,6 @@ int mas_empty_area_rev(struct ma_state *mas, unsigned long min, if (mas_is_err(mas)) return xa_err(mas->node); - if (unlikely(mas->offset == MAPLE_NODE_SLOTS)) - return -EBUSY; - /* Trim the upper limit to the max. */ if (max < mas->last) mas->last = max; From patchwork Tue Apr 25 11:05:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 87364 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3327641vqo; Tue, 25 Apr 2023 04:15:14 -0700 (PDT) X-Google-Smtp-Source: AKy350aelg67TlYgLMEu/UVYKStfTF9jXuHKYDCgpWuMuC9Ye5YoDy/yIXzxxqpFh3fMCaUJq3Df X-Received: by 2002:a17:903:2345:b0:1a9:72d7:771 with SMTP id c5-20020a170903234500b001a972d70771mr8205028plh.67.1682421313964; Tue, 25 Apr 2023 04:15:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682421313; cv=none; d=google.com; s=arc-20160816; b=IjsiycKwY6h3IMpaoVgeiTRFpY8RuPjqCndd3KISYX6xG7UCihlcy+7T4BMg61d86n Wp95mrLAglTjFX8FKWYXW1QiS2ocPhFYyBAbzgXVmt238+pW1TyTOWuvdcAeL/DC7Xnn Jnx7/VBpU1nuB3Di2aQw6wnw5M7enbJlyGU3mg7dia/R2ReB24/3u0q5MD3dh+M3HanX F/vpDDzTp4/kYFIFGon5pXErKozt2BbDu2dkH6nR0JpgaVCNmi2EesF5PLJsW04RTZYl 6ihFundw40V479NrkzmKIGu+lXHl4qU6iqJwLLeOqeA7IrTKhAegh/RpNWR6u2kvcExx Plbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SdvAl/rsZlyn6jAT/y3p3/RJdLkd5U9SZ/gjDoLgWfw=; b=waiGsjhCLpjrX+ezDcwpy7xP2EB5Ef7cuk083nxYsPCk2TVUjxD018fp87cXMkLS0C Csle7MILzN1dws6e94sw6YMSuaRE4NhcMKcsBr93LV5shpJvuRfAF1CV3Yy1fZq2KAp2 CWXou2VhZ+caZgScF2vIpKop4h3R08iH0u2eeKolx+g8r9ziHOB4XjMC9zy295eQxSCT khgtoZiXwDBU+MIcTUHO7Xz8dYnvZOntVihPys58ThVFCfzME3dYbwNrdtu1b2HSOVaC ddfWWGTZxAb7eALfZNt9crrPfXl2n0cHB5HEQuP27hyadZt+8J2MYfP+N1h6dgJjnOt0 4DHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=WZB2irIo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m6-20020a170902db0600b001a637201992si14175104plx.488.2023.04.25.04.15.01; Tue, 25 Apr 2023 04:15:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=WZB2irIo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233862AbjDYLGW (ORCPT + 99 others); Tue, 25 Apr 2023 07:06:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233901AbjDYLGE (ORCPT ); Tue, 25 Apr 2023 07:06:04 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B064B12CA4 for ; Tue, 25 Apr 2023 04:05:54 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-63b50a02bffso4706316b3a.2 for ; Tue, 25 Apr 2023 04:05:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1682420754; x=1685012754; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SdvAl/rsZlyn6jAT/y3p3/RJdLkd5U9SZ/gjDoLgWfw=; b=WZB2irIoBxS6GfGWbmO853Yh/UPd4puaaWuwwy6+RSHHRD9B00WbRPCkiKPVrIbRII 1pcfPq9bubluGJJeyOkwLw/XxAmdroXH+PyguDhLNWvGNXvKzmSCKSKO6fYtvqXgbO04 iz99DVGSY1h2LtWFUVD+x7fZ0tz+TLSL781orthWvsF2rwarXtXFcU4IV/V5a7zQRQq8 wuPrNWCDq6Ow9r9Vn27Ha/PmX//TkDUedK1Mow/rbV9iqKf015dWHpqGcO+uuA500v// WqsfSrj40q7HE8zDHZhcIzZCKsjjFNTglOGyr4KegnKNRbr3XDs9pNjqWtA0TXgPVef1 xngQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682420754; x=1685012754; h=content-transfer-encoding:mime-version: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=SdvAl/rsZlyn6jAT/y3p3/RJdLkd5U9SZ/gjDoLgWfw=; b=XIcupWrDYFCFTEM4Ww3q/sQNKQgMbDwP1oPqpxtfzzIaH1nibyNudh4KFuM5TbYMFl 0P93kPteUSyjnoUY2fcC6qIsbaNl0xLEMtrvfTqevRYEVBoHaJxCGicjnck/F/jLvKZ1 cn1QMg2lckkM/qVG1TtZOvDH4w1bfjlYAYYNoxg8zoG12mtDEWFb+gOECYhPmsulTE25 M7HeyftagLJ5JLAXI9lDGwLmpqnSI30I9MRu58T4AH9Xmu93w0eGve1ztXOyFBhEAxP7 buC+0irYkJDB/dKp8xk1rPp96NZ3R4p9fuUaMmRmzMkONbYW4HU3eCo5BKnzIY9ZyAoT wqsA== X-Gm-Message-State: AAQBX9d36nlaaWn1kDmwsF5LKENUrkfoi6bPPXdEp5+8G1EZ3FrWclRe FUtAA0Kd1nXi+Etco449F9QWaA== X-Received: by 2002:a05:6a21:1014:b0:ec:86a7:4fa5 with SMTP id nk20-20020a056a21101400b000ec86a74fa5mr19512176pzb.30.1682420753957; Tue, 25 Apr 2023 04:05:53 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.236]) by smtp.gmail.com with ESMTPSA id u3-20020a056a00158300b0063f3aac78b9sm4422169pfk.79.2023.04.25.04.05.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Apr 2023 04:05:53 -0700 (PDT) From: Peng Zhang To: Liam.Howlett@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang Subject: [PATCH 9/9] maple_tree: Move declaration of mas_empty_area_rev() to a better place Date: Tue, 25 Apr 2023 19:05:11 +0800 Message-Id: <20230425110511.11680-10-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230425110511.11680-1-zhangpeng.00@bytedance.com> References: <20230425110511.11680-1-zhangpeng.00@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764146611369921196?= X-GMAIL-MSGID: =?utf-8?q?1764146611369921196?= mas_empty_area() and mas_empty_area_rev() are a pair, move mas_empty_area_rev() so that their declarations are together. Signed-off-by: Peng Zhang --- include/linux/maple_tree.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index 1fadb5f5978b6..3130c1f822ddf 100644 --- a/include/linux/maple_tree.h +++ b/include/linux/maple_tree.h @@ -470,6 +470,12 @@ void *mas_next(struct ma_state *mas, unsigned long max); int mas_empty_area(struct ma_state *mas, unsigned long min, unsigned long max, unsigned long size); +/* + * This finds an empty area from the highest address to the lowest. + * AKA "Topdown" version, + */ +int mas_empty_area_rev(struct ma_state *mas, unsigned long min, + unsigned long max, unsigned long size); static inline void mas_init(struct ma_state *mas, struct maple_tree *tree, unsigned long addr) @@ -493,12 +499,6 @@ static inline bool mas_is_paused(struct ma_state *mas) return mas->node == MAS_PAUSE; } -/* - * This finds an empty area from the highest address to the lowest. - * AKA "Topdown" version, - */ -int mas_empty_area_rev(struct ma_state *mas, unsigned long min, - unsigned long max, unsigned long size); /** * mas_reset() - Reset a Maple Tree operation state. * @mas: Maple Tree operation state.