Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2259329rdb; Mon, 9 Oct 2023 20:04:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYzFNciQW1Lh4vFB329sA1vfYjzt1gbX0j//o15Rt8sWZhPhQbgzmQUO9x83aWqbwCrnIS X-Received: by 2002:a25:ce13:0:b0:d0c:b780:4c13 with SMTP id x19-20020a25ce13000000b00d0cb7804c13mr16935993ybe.25.1696907056421; Mon, 09 Oct 2023 20:04:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696907056; cv=none; d=google.com; s=arc-20160816; b=H21xu4n3kA6de1A3cL7LyHOYcINREYrEMBf1VsOM3fdJ+zKIfdiS6Qhxxz253C76Lm AolJHIgtHQWbz7faTbK5+8UvVW7DSu6B/NXJbNNE9Oa3FBQ7x9VcTxlorozKF6s+bDIe pqMvtsZwgNdfjKnAka6jN79nbTViMVQnXpKr0sdVAXdBsMJ6JLds+vDq7CvSkdD1+5jf 3ce25hac+2gHu+mBJmEgRhWK2lT82mTJpJDnLITbv5F6daxXzlXtDNW8fore4CT+SO5s BS0f2WgQ7me7qXY+IFdZck28P+MQIUh/Pr0arXbnJeHzC7lpM8GQhi2mv7u/I36T+H+H XEzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=MYJPot/yVsN2eIMJtsBswpwz3V3PaxdYOrydQnf75Uk=; fh=gZkX+VygZLnLEum/vYyNi3bhhvL28NlJoVfAZfl9YGw=; b=HrquBti56l2i/CUvcCAuMbFCsIHHxqnwJfHmnZ0FcCu6bMsIi6LWcqpqkWF8hNoabM qSHY+FVgTmlnGV8e1lnWrzEK/5pvnzBH50w34QzRu8DQA461ZRoygcy18PrcZ9MB/Ome 2uKuTVl1PQ1KJsVoFfN1N8Rou6bPh3Yndw/rpF4EfSnPnloS60lYyRC3w3JX9vQmkH+N 4JgCbSb7H0c1If33lXt2c0j1UgwAVZjqNkr95Nxp0GROtZtJ8e8kgR3hCd2+yqPYiMjX ea2afS2o25zCX8G0T5pZomPNUFqwT2sn/4ffdCi7pHhuvQLq+nw81ILoropGyRhEn4fy 0dZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=fUfWVTRE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id f20-20020a63f114000000b0056c55eb251csi11057438pgi.123.2023.10.09.20.04.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 20:04:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=fUfWVTRE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id D343A8256BFA; Mon, 9 Oct 2023 20:04:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1441937AbjJJDEC (ORCPT + 99 others); Mon, 9 Oct 2023 23:04:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1441902AbjJJDEB (ORCPT ); Mon, 9 Oct 2023 23:04:01 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A261A6 for ; Mon, 9 Oct 2023 20:03:45 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-691c05bc5aaso4589034b3a.2 for ; Mon, 09 Oct 2023 20:03:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1696907025; x=1697511825; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=MYJPot/yVsN2eIMJtsBswpwz3V3PaxdYOrydQnf75Uk=; b=fUfWVTREDo3VDLftRaOtJVgW+7y1nTnRLJhVOHyP++shq2aXGmxdri6dmyQIlI+iNF 7Qt90IZGM+jbEjFKFvuZyi4R85oZRxNzJcb4OJOba/fvy+FFG9CcJhUKI0ky01hYKXKd z7zrULa5YezNyfOptHOvWtVoZoq2ABry1VoWetf4uDrZHJDnLiOA043MLaIVZprUAEBH 1RJC7DzjLh35IaUXa15CpBKKfMa3UBd39WQnDFtwmfH/KuKNDetOj4EmPACG51yxE9PF 51Loj3hgqqpMONmi7Ulq8pOOHGwPwBj+BFwRKopotvDgLaRWCaRUXcwQwTqHfsoU0xhX XfkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696907025; x=1697511825; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=MYJPot/yVsN2eIMJtsBswpwz3V3PaxdYOrydQnf75Uk=; b=wsGUJ4WSUFJSWjS6bvtyWl3BUoSD24ki+oox2kmayglR1VDOBrfh294ulaL5XnBP1R vFYEpHM/aI3FpctMgvGAL0mQQ0Wz8y7fKM52spCXqgHxd7t4ltkekRsZyAf6SswzykUF UVBY1AYI984PdK6sX7O7FO7Ga2fmiLFH1VTQujnZqUtnbN7K9NSFJG2JvwGQRIDfRXBg EgbZL0d3MdSMZXwVy7dGywZuKPGUSHH3y8E5vZvg+vqWBt/5Cm20aMaLOtEJ6R13w0ed CACR3FB5c1oFux9Eq9uHsG2HEBtoXPLPGiuUIgtW/zUaMmApVexIuFLWA+vAhoBf4mBN oBPA== X-Gm-Message-State: AOJu0YzWSvsNaj3srDzgp3Pw0bO8P9ePbq/bg6QbBjqs7nDZVjifzQlb SnUMWwuehH2zMt/P4YG/O64Stw== X-Received: by 2002:a05:6a21:8cc5:b0:153:63b9:8bf9 with SMTP id ta5-20020a056a218cc500b0015363b98bf9mr17465286pzb.0.1696907025078; Mon, 09 Oct 2023 20:03:45 -0700 (PDT) Received: from [10.254.233.150] ([139.177.225.243]) by smtp.gmail.com with ESMTPSA id q4-20020a170902788400b001c611e9a5fdsm10343207pll.306.2023.10.09.20.03.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Oct 2023 20:03:44 -0700 (PDT) Message-ID: Date: Tue, 10 Oct 2023 11:03:39 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/3] maple_tree: use preallocations in mas_store_gfp() To: Sidhartha Kumar Cc: akpm@linux-foundation.org, willy@infradead.org, liam.howlett@oracle.com, zhangpeng.00@bytedance.com, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, linux-mm@kvack.org References: <20231009201639.920512-1-sidhartha.kumar@oracle.com> <20231009201639.920512-3-sidhartha.kumar@oracle.com> From: Peng Zhang In-Reply-To: <20231009201639.920512-3-sidhartha.kumar@oracle.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 09 Oct 2023 20:04:14 -0700 (PDT) X-Spam-Level: ** Hi, 在 2023/10/10 04:16, Sidhartha Kumar 写道: > Preallocate maple nodes before call to mas_wr_store_entry(). If a new > node is not needed, go directly to mas_wr_store_entry(), otherwise > allocate the needed nodes and set the MA_STATE_PREALLOC flag. > > Signed-off-by: Sidhartha Kumar > --- > lib/maple_tree.c | 22 +++++++++++++++++++--- > 1 file changed, 19 insertions(+), 3 deletions(-) > > diff --git a/lib/maple_tree.c b/lib/maple_tree.c > index e239197a57fc..25ae66e585f4 100644 > --- a/lib/maple_tree.c > +++ b/lib/maple_tree.c > @@ -5478,17 +5478,33 @@ int mas_prealloc_calc(struct ma_wr_state *wr_mas) > int mas_store_gfp(struct ma_state *mas, void *entry, gfp_t gfp) > { > MA_WR_STATE(wr_mas, mas, entry); > + int request; > > mas_wr_store_setup(&wr_mas); > - trace_ma_write(__func__, mas, 0, entry); > -retry: > + wr_mas.content = mas_start(mas); > + > + request = mas_prealloc_calc(&wr_mas); mas_wr_store_entry() does something similar to mas_prealloc_calc(). Now, making it do it twice would incur additional overhead. We encountered this issue while optimizing preallocation, but it hasn't been resolved yet. Previously, this problem only occurred when using mas_preallocate(). Now, this change would bring this impact to all write operations on maple tree. What do you think about it? Thanks, Peng > + if (!request) > + goto store_entry; > + > + mas_node_count_gfp(mas, request, gfp); > + if (unlikely(mas_is_err(mas))) { > + mas_set_alloc_req(mas, 0); > + mas_destroy(mas); > + mas_reset(mas); > + return xa_err(mas->node); > + } > + mas->mas_flags |= MA_STATE_PREALLOC; > + > +store_entry: > mas_wr_store_entry(&wr_mas); > if (unlikely(mas_nomem(mas, gfp))) > - goto retry; > + goto store_entry; > > if (unlikely(mas_is_err(mas))) > return xa_err(mas->node); > > + trace_ma_write(__func__, mas, 0, entry); > return 0; > } > EXPORT_SYMBOL_GPL(mas_store_gfp);