From patchwork Tue Jul 11 03:54:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 118232 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp228714vqm; Mon, 10 Jul 2023 21:03:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlFKaKX95moBgvKjES6NwczKNjcaGh8Pod02Q0jXFhJQ2ppw8FrCGgjiWgr0F8cU5jwvX60O X-Received: by 2002:a05:620a:2a0c:b0:765:6524:8458 with SMTP id o12-20020a05620a2a0c00b0076565248458mr18085637qkp.36.1689048220748; Mon, 10 Jul 2023 21:03:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689048220; cv=none; d=google.com; s=arc-20160816; b=rq/nfaTHQ/1/bJbl/qeYoywMeblnx0XR4zTJGzgYUmgX8MK1LPUNw/EDYDDQA+IUE9 jI47PvD1rv7PRgys+5rFFOE7j9SgDCXeNH0qKrYGgh+TTeGwDU26LCIKyfSTGzcmU76K X1CVSmC/7F9ZkRnO6X+bBu5QwVOFqQn8BbikHDMmqJJYzUp1ZrpA3Yn4HSShy0b7EwkE szTsAnrRIgqe6doSFsNrqsd3Z+f68iPh08THpACeTiWRUxoucJLxUncQZh7cCpXT09dK /FLfNYjQ9z0jCKR7/pyaM9FJGQKB/hYVn4OBsD+vwYJWaHxrKJQK1ZsTJUf3G2z9NNoz PVrA== 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=vnneOZGmz+RJtivDvKZ74LFhvf3KlKhvaFlPPXT7kZI=; fh=81zMPXlJ/0mWSoVHoYJN4yrrEe0a3g481gzTjD4iBRs=; b=b/Zef0e5HB34MMfS8CSxIkIa/K0oIbLcqZz41pyjX3g/lEhA+eik71sXdQQdIRqRdn 6KEX+STTI9EuPIzk8PiljCTy+D1vyjf3VYMey3fqfjdrSDa6+V60Q/RUmmwJP871Jlwn A8jCDEBUf+fJez35l/A7cEZmaadSnJLLgCeEryydkB3ny29d6lYIYFG21s2JiSWQ1Xlm o8FKiO+Sg0dkfDDt8S5UhZ9kKTBx/7okCN/pjWbGfVcsgHY1nt/nKB/L45UfCCsCCRDr ljEHQS4Plf+AlDUIBLkS3MDDYrl5h6uMTphSPyz1exOv8l3nvq47iH/uAj2g491PCVl5 TRZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Z4IrWlz1; 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 z6-20020a656646000000b0054ff8291783si682025pgv.424.2023.07.10.21.03.25; Mon, 10 Jul 2023 21:03:40 -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=Z4IrWlz1; 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 S231241AbjGKDzg (ORCPT + 99 others); Mon, 10 Jul 2023 23:55:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231139AbjGKDzY (ORCPT ); Mon, 10 Jul 2023 23:55:24 -0400 Received: from mail-oo1-xc2b.google.com (mail-oo1-xc2b.google.com [IPv6:2607:f8b0:4864:20::c2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8856BE42 for ; Mon, 10 Jul 2023 20:55:02 -0700 (PDT) Received: by mail-oo1-xc2b.google.com with SMTP id 006d021491bc7-5634808e16eso3725675eaf.2 for ; Mon, 10 Jul 2023 20:55:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1689047702; x=1691639702; 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=vnneOZGmz+RJtivDvKZ74LFhvf3KlKhvaFlPPXT7kZI=; b=Z4IrWlz1AVjCsHQerCU8etu0x4fMRgmj78dqWxOaEVokcj5JlvJ48wbsN1nYAt8aCx GyIG4fljUcmd36IPAIMorw1pVL0WKa1lCiJxTeiR8S2f1WdwstlfNNXOLV/lPYXe6w1h DVjrFkjamSlpBL0rycqTgq+TECck80TZzdXkKOcfQH4QVOG0MGoHytPkEiIPLoB+jvOb bIEAdvF5OtUo3o2laMkrVhKHijhKrDznzeOUJ0gGzpAgJ1tYhDAcKvPIU5b6T4kPx4Gg OKUPDT72H3ElLV4oau0mU8I3UjQjAbd0NEcN69RmvH/J8FLOzK114dRUY492oyqnmudr BFgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689047702; x=1691639702; 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=vnneOZGmz+RJtivDvKZ74LFhvf3KlKhvaFlPPXT7kZI=; b=hn5dIHyIlfLSOrZfzIEetLoCnTBlRnsdj8456s9GlWYGDEQu2se17A6Do7u+jo5IDF wwj4LFGqm6QxapxAl3YgSAI8AJECj8TiLynqCr0cxplO2iiaWOTURpXsvsk30YbGxQbz nm0BkkEK6v1667QPWh8TsvPXZegzUAXI99goOVDK8ZSwbutDjsUHlipw0Mwcfr3i6Jwz tly6wcoru++QnmAleaiy8IXvEkMIVhQherNdBil2EgXoYyINHC5zxSGP53WSJsZnVMPf 79W3ca74xxBVzDhPWHCDyCMPQEDPe3zso0Sw2fJDKr2UtMwIQV7cnM6vHqm5fUMxH4bH 1kfw== X-Gm-Message-State: ABy/qLZ4Kn1G6kPTusx/e7OEqlnc9out6J48FKjay7JjpjxEWGhiYZ7r xEH0fc7QmOfo7Vjj9OaknhLj5g== X-Received: by 2002:a05:6358:5e02:b0:134:c8ee:e451 with SMTP id q2-20020a0563585e0200b00134c8eee451mr10966324rwn.13.1689047701778; Mon, 10 Jul 2023 20:55:01 -0700 (PDT) Received: from GL4FX4PXWL.bytedance.net ([139.177.225.243]) by smtp.gmail.com with ESMTPSA id b15-20020a170903228f00b001b872c17535sm688329plh.13.2023.07.10.20.54.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jul 2023 20:55:01 -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 , stable@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2 1/8] maple_tree: set the node limit when creating a new root node Date: Tue, 11 Jul 2023 11:54:37 +0800 Message-Id: <20230711035444.526-2-zhangpeng.00@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230711035444.526-1-zhangpeng.00@bytedance.com> References: <20230711035444.526-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_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable 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: INBOX X-GMAIL-THRID: 1771095427336612726 X-GMAIL-MSGID: 1771095427336612726 Set the node limit of the root node so that the last pivot of all nodes is the node limit (if the node is not full). This patch also fixes a bug in mas_rev_awalk(). Effectively, always setting a maximum makes mas_logical_pivot() behave as mas_safe_pivot(). Without this fix, it is possible that very small tasks would fail to find the correct gap. Although this has not been observed with real tasks, it has been reported to happen in m68k nommu running the maple tree tests. Link: https://lore.kernel.org/linux-mm/CAMuHMdV4T53fOw7VPoBgPR7fP6RYqf=CBhD_y_vOg53zZX_DnA@mail.gmail.com/ Fixes: 54a611b60590 ("Maple Tree: add new data structure") Signed-off-by: Peng Zhang Reviewed-by: Liam R. Howlett Cc: Cc: Geert Uytterhoeven --- lib/maple_tree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index d3072858c280..f55e59bd9122 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3692,7 +3692,8 @@ static inline int mas_root_expand(struct ma_state *mas, void *entry) mas->offset = slot; pivots[slot] = mas->last; if (mas->last != ULONG_MAX) - slot++; + pivots[++slot] = ULONG_MAX; + mas->depth = 1; mas_set_height(mas); ma_set_meta(node, maple_leaf_64, 0, slot);