From mboxrd@z Thu Jan 1 00:00:00 1970 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 637FFD149F6 for ; Fri, 25 Oct 2024 23:58:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 785716B00B8; Fri, 25 Oct 2024 19:58:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 70FCD6B00B9; Fri, 25 Oct 2024 19:58:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 587696B00BA; Fri, 25 Oct 2024 19:58:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 370616B00B8 for ; Fri, 25 Oct 2024 19:58:58 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 94A3FACCC8 for ; Fri, 25 Oct 2024 23:58:17 +0000 (UTC) X-FDA: 82713792336.11.F58EC20 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) by imf03.hostedemail.com (Postfix) with ESMTP id C377820016 for ; Fri, 25 Oct 2024 23:58:45 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=mYLXaL4v; spf=pass (imf03.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.42 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729900657; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=YU4iezoimY3xDJuyaUhpglbz+tA7vUR6FZSc0nbsZ3w=; b=W8/HlMRNDeSFvjnPeSPb/NhErNSHkNU6HZc1F5foxOdtvViWYMaRQ+gySo6Ru4SQ25a6u6 uGo91DxPHvl9I8Ta8Gtr3BSLHqSgg15HVHx9mw9hbjQkrx1tRxCcO8EID4EaQTaB21tDLo /TW2iRg4D48b+YF5PLzTeS4XuavPLYE= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=mYLXaL4v; spf=pass (imf03.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.42 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729900657; a=rsa-sha256; cv=none; b=tQsC1Km+wZtfUZv5QqKjOnaUhN+5Mu6/SRxGeD+YT9PxDgmLiKy7b7l753BaAyPiM4ywt6 p0VbzneM/GqciIazYx7iJBYP7Sc7Ogr5jPStyyBOMqc27bigfrrBd3b9OMIhugGC0/LCjy H2fGMBmzde7egYuTpy/cOm4NfK/k8Lc= Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a9a850270e2so416543666b.0 for ; Fri, 25 Oct 2024 16:58:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729900734; x=1730505534; darn=kvack.org; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=YU4iezoimY3xDJuyaUhpglbz+tA7vUR6FZSc0nbsZ3w=; b=mYLXaL4voElfo9h864AWmu2HtMiZwa3nCEnRPIg9XNtTOS+8r852e9I1J4OEjwq+tJ 40N048K2LXjN3uH600TDjhs5LjnfNPzzyKpWiL8u00WQiRAbzvrL2bVs7L4MopLNz0ft vRYrv+DrY131R1AvBHul8AnczYmC17O/X54pRkT2xozTo2n6AQWt+S5KbxusrECw2yAC k66QTbR2b1H0AOLt+sqWeWatkU6YIVAf403yVcUz4uqPjXfjph1G8W7aSv9WkQvo9SQ7 Y519JGcp8f2726B4yx+Gx8v6HRB77ajQB9UxO7sTCkLh9tSWD74tkQtYgL5XCsdzTYT8 14Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729900734; x=1730505534; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YU4iezoimY3xDJuyaUhpglbz+tA7vUR6FZSc0nbsZ3w=; b=vLpnMuVEKn7TXpubjJq44XuxZ3dq4Lmo/VAxfC1pW/JT4t4mNj/xTvqVgu64GifZqE lO6YJ0JOTDVpLb2nhKkKoEFdrp+k9UD4Lb1A83lBeV2FPR02kSqhnVhFJi+HWGcV811c wjliZ813wBWpR9zraehZJTg2rP+3gj6VGLUuCczOgQGVqn1F8Oz3GUxqqGkLgwpLBS5f 8O/0rPPfBwSceQ/4Odze84KK3wMhBpU200h18WexAYNO78J1Vm1nPSGiwBkJ4WQiPYGx T9VfKgKrWFoNM/ujnGYabsJ3DJ2nceEiuWu73w3xlo+7QSKbrfIZSjyZYQ7dNHOAi4X9 8b4g== X-Forwarded-Encrypted: i=1; AJvYcCVF6+08Q5+ih8InbkIWN5K5wNf/roMv7NjXjpS4y8PtQzjdrcTpSi7vckrT6BsnJ3WvpsC2+2VPug==@kvack.org X-Gm-Message-State: AOJu0YzQRCdzFkdtTYYw6YRrLj3/n2sq5fAObZnpPiZlv0s3R2Aw9ogX cZWdtPEiN9oYofVK+vlh1Vb8WV5bY+Somsu8lTTDtoxFWwuqcuxJ X-Google-Smtp-Source: AGHT+IGUBfWXLxnVctUo8oJPkToHu9+i4Y7W4o0ODoEGnhUkm2Z10Z1aAtwT/eOETNjd5+yXPaCusg== X-Received: by 2002:a17:907:1c88:b0:a99:e1a1:473f with SMTP id a640c23a62f3a-a9de619406cmr65118166b.57.1729900733315; Fri, 25 Oct 2024 16:58:53 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1f030c40sm116889266b.84.2024.10.25.16.58.50 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2024 16:58:51 -0700 (PDT) Date: Fri, 25 Oct 2024 23:58:50 +0000 From: Wei Yang To: Sid Kumar Cc: Wei Yang , linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, linux-mm@kvack.org, akpm@linux-foundation.org, liam.howlett@oracle.com, willy@infradead.org, surenb@google.com Subject: Re: [PATCH v4 16/17] maple_tree: remove unneeded mas_wr_walk() in mas_store_prealloc() Message-ID: <20241025235850.5o6l3k2u2so6hxrs@master> Reply-To: Wei Yang References: <20240814161944.55347-1-sidhartha.kumar@oracle.com> <20240814161944.55347-17-sidhartha.kumar@oracle.com> <20241024012038.zf3dpqsflnyi4wce@master> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: C377820016 X-Stat-Signature: 56sjydx75srpzgir5ph56ezqirutkeo4 X-HE-Tag: 1729900725-551103 X-HE-Meta: U2FsdGVkX1/HbpEtddmcLL42ojE0kkDYaD/qJe4lp2hftYUC002hh9myXwkUrsx/F67T4mgu5mJDIhtSnu9onIDoLaCakD+vD/hL/hEefoQsvETJSTvYDhIg0IarPrFKr99mPsPcQQsiYAZkPFr+7fC3/U3XXzYcB+PXQlx6ZsqWsFUT9w3W/1kl2TMvVjzbBjhl/UKHLd8gR/aVDuEE1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7UVTqTQwLDyLGfwzY5r3eLztBWFzFVmPYYdqK0Iegxk1R+QKdJchtvYmQY1k0wyGQsYb94rWiHENwGLkw5B4RV4iE2t9hgtAotTa0ngIwF7e6fhUm6k3FQeV20xQoYcVv6AbQnbUiEfXkyp4cLh+chKTTX/VrUM/GY10g89OuAK34SPPbCXYNw6FCqkT2KkOcQ/8H8HXdHFUUcdcJygJ7S9xk4wwZBubtQYEym5oAQ/I5hMMBlvgrV33Be/476GuBd/8+sd8KgOaIQlcMu66uuvFwahPLvniJoxJjHlEoCSiCFOxuSgOGHu22vXLM9D8csUNck0OsczNYoOzkrHpCCVd05Jf1mycFcsVpCskel/smVD1aokKDHm57hNAg5IYiqGs2ciHLBtcdOra5Z2xHShDqRC28hcHgmYRnyoSQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000074, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri, Oct 25, 2024 at 03:54:04PM -0400, Sid Kumar wrote: > >On 10/23/24 9:20 PM, Wei Yang wrote: >> On Wed, Aug 14, 2024 at 12:19:43PM -0400, Sidhartha Kumar wrote: >> > Users of mas_store_prealloc() enter this function with nodes already >> > preallocated. This means the store type must be already set. We can then >> > remove the call to mas_wr_store_type() and initialize the write state to >> > continue the partial walk that was done when determining the store type. >> > >> May I ask what is the partial walk here means? >> >> It is the mas_wr_walk() in mas_wr_store_type() which is stopped because of it >> is spanning write? > >Yes, this is what I meant by the partial walk that's already been started. >It's the walk done by mas_wr_store_type(). > >> I may lost some background, so the assumption here is mas_wr_store_type() has >> already been invoked and the store type has been decided, right? > >Ya users of mas_store_prealloc() should have already called mas_preallocate() >which does: > >    mas->store_type = mas_wr_store_type(&wr_mas); >    request = mas_prealloc_calc(&wr_mas, entry); > >to set the store type and allocate the nodes. > > >> > Reviewed-by: Liam R. Howlett >> > Signed-off-by: Sidhartha Kumar >> > --- >> > lib/maple_tree.c | 18 +++++++++++++----- >> > 1 file changed, 13 insertions(+), 5 deletions(-) >> > >> > diff --git a/lib/maple_tree.c b/lib/maple_tree.c >> > index 8c1a1a483395..73ce63d9c3a0 100644 >> > --- a/lib/maple_tree.c >> > +++ b/lib/maple_tree.c >> > @@ -3979,9 +3979,6 @@ static inline void mas_wr_end_piv(struct ma_wr_state *wr_mas) >> > wr_mas->end_piv = wr_mas->pivots[wr_mas->offset_end]; >> > else >> > wr_mas->end_piv = wr_mas->mas->max; >> > - >> > - if (!wr_mas->entry) >> > - mas_wr_extend_null(wr_mas); >> > } >> > >> > static inline unsigned char mas_wr_new_end(struct ma_wr_state *wr_mas) >> > @@ -5532,8 +5529,19 @@ void mas_store_prealloc(struct ma_state *mas, void *entry) >> > { >> > MA_WR_STATE(wr_mas, mas, entry); >> > >> > - mas_wr_prealloc_setup(&wr_mas); >> > - mas_wr_store_type(&wr_mas); >> > + if (mas->store_type == wr_store_root) { >> > + mas_wr_prealloc_setup(&wr_mas); >> > + goto store; >> > + } >> > + >> > + mas_wr_walk_descend(&wr_mas); >> This one does not descend the tree, just locate the offset in a node and >> adjust min/max. So not look like to continue the partial walk to me. >> >> > + if (mas->store_type != wr_spanning_store) { >> > + /* set wr_mas->content to current slot */ >> > + wr_mas.content = mas_slot_locked(mas, wr_mas.slots, mas->offset); >> > + mas_wr_end_piv(&wr_mas); >> If not a spanning write, the previous walk should reach a leaf node, right? > >Ya that's true. > >> I am not sure why we don't need to check extend null here. Because we have >> already done it? > > >Ya we extend null in mas_wr_store_type() which has already been called at >this point. > > >    /* At this point, we are at the leaf node that needs to be altered. */ >    mas_wr_end_piv(wr_mas); >    if (!wr_mas->entry) >        mas_wr_extend_null(wr_mas); > >Thanks, Hmm... if we have already done this, why we need to do mas_wr_end_piv() again? > >Sid > >> > + } >> > + >> > +store: >> > trace_ma_write(__func__, mas, 0, entry); >> > mas_wr_store_entry(&wr_mas); >> > MAS_WR_BUG_ON(&wr_mas, mas_is_err(mas)); >> > -- >> > 2.46.0 >> > -- Wei Yang Help you, Help me