Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2819198rwd; Mon, 15 May 2023 17:59:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7npEvOs4xr5E1QTSE1VIs8MugnNUsHYD7p1SgmxssWdQIVCkkwPvP1t1SQTTuKVL5iLaaN X-Received: by 2002:a17:90a:384b:b0:24d:dc79:5901 with SMTP id l11-20020a17090a384b00b0024ddc795901mr36554301pjf.26.1684198749011; Mon, 15 May 2023 17:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684198748; cv=none; d=google.com; s=arc-20160816; b=Vi6lgzKG4xUp2UmBaCoNxy6ZUW3g9vzZYukp9R+0z9G2ol2JfJ5qDPBiqiBd/kJYjm pzok0hRw8Xqf1SLBGekFmD55NXbhCufThpzpYGjnUHYVx/2ZCoFL0WlLmrK8teO2PvjV ACQHWiQmvghrevOP5qDP3psk/UyyKY2h/HGerrzqwHYG1ieSndD7phdtiaz9a9JjLJFt cDLStmP/lqXsu9WNTf3HqtWqOhUeLeiXmXIKxlnC08h02qIehLYVGxpXgwheF4fumIDY kdhn2NSzxX73ZlKKkcF+9p7Fgnt5tDrJE4hsq/Ji87aGnPczcNf6aOC4bW9QJhLz0J2b K5Ew== 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:cc :references:to:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=DJoDWdNGnr8LfrrtOHTqflM+YgBUQb3SWktW3/kS37w=; b=y3cBV2s85TW4J0WtMNHyYBBhyh+f9tXJX/6DjTTX/s8xYf8Qy5RG78IgI8iMhKfDbk gYUez8ZuSFPSUmMqT0nT9nlCEBJlDfBf0wdfO1SmkPSPgHdThBke74XypmP1mtOgM6W/ QA453XVwBNV0cMTsjzD5TeI8ij6ZFeoGVuFUtt2LaPTh4hOEeYX50ujB3aPFiCO8gnAh lf3ZpXb4F8W2Kpn/me81AT6GlQwZAaOES3ea+aI1qPdFac3VEsCgNoMmuMDgPXdeAqFc S+uf/oznA1lpxuNqQhtmkOZ9MlL0zSOdoAHlskyi3igI/wQ083I4aW4sllkDOoENrvbH UgFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=BpM149hK; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n7-20020a6543c7000000b0052868a865d1si10935836pgp.272.2023.05.15.17.58.56; Mon, 15 May 2023 17:59:08 -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=BpM149hK; 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 S245580AbjEPAhJ (ORCPT + 99 others); Mon, 15 May 2023 20:37:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231416AbjEPAhH (ORCPT ); Mon, 15 May 2023 20:37:07 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72BF7F1 for ; Mon, 15 May 2023 17:36:45 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1aad55244b7so102924295ad.2 for ; Mon, 15 May 2023 17:36:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684197405; x=1686789405; h=content-transfer-encoding:in-reply-to:from:cc:references:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=DJoDWdNGnr8LfrrtOHTqflM+YgBUQb3SWktW3/kS37w=; b=BpM149hKj/TSgrXsWD9M6zauXFPC7+FfHKgadrWcRUWrMc7Zn0lMjno1yG/1dKCAUs 2IzZ3PdEotteAKfOWca8JZZyj/Mb8eJagIMesi5Kh7G9cy7iMsGBG1UPd99zfCTkK2yZ 7vskCWyG/7bHlyzVTp2ULOJBiUO/Ewl+qdxldFBqCHE+OjRG9+8lAchj7EKizcs17kI8 5OaN4C0fmrkfw+RE+kFwF9lCGJRkWfP75+PTi6kYRmuMvxD0kq7Fmhgfrsq8PizmaDpg KqQcLRYL9hFnWyaKOPIe7zpJx8nD1No3Sut/UGobXHj68ygECqt9V3w7SvQQHCYxluw1 gpIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684197405; x=1686789405; h=content-transfer-encoding:in-reply-to:from:cc:references:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=DJoDWdNGnr8LfrrtOHTqflM+YgBUQb3SWktW3/kS37w=; b=NXGDs1qj1IceONGKqmov2BT12gGfQzUhl8FyO820vKahd/AvPrh5GV85Yki07vCEmx v9Rq9TCaB59hMdhY9F+Mbcp4wYQu8ndmjrH4XP8HmdeeFWy7qlep/8cpQsSY8kRbm3RI 3nDsMHIbAEI8jke4iNDVRc1B+pRR5eSb9MdS4JoHAIsH8viLwd0xCkK9NnidqqR6+huL 0njLq+kjbfXGIEE3XB399Mo4wCU2kK9VVQgbPXPD5xB+ZJRIVTbyuAPXxf0+C1NL+CJe 31+Z8kW3Onn3sdGh4rn5K64KpiOvM1vG/sQg2DhuV/U34+K0ycLiB8kpbscv+lTFNLE8 HENg== X-Gm-Message-State: AC+VfDxDyEaQGS+E2hgRIdOxch7/Mw0y2vDuvOKYKfvM/29NiDDYAgSi 8y9UG7haoc5e4LHX1ZLZspBR7A== X-Received: by 2002:a17:902:9049:b0:1ab:19db:f2b with SMTP id w9-20020a170902904900b001ab19db0f2bmr37736748plz.36.1684197404921; Mon, 15 May 2023 17:36:44 -0700 (PDT) Received: from [10.200.9.178] ([139.177.225.227]) by smtp.gmail.com with ESMTPSA id jo13-20020a170903054d00b001a641e4738asm14174195plb.1.2023.05.15.17.36.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 15 May 2023 17:36:44 -0700 (PDT) Message-ID: <7dd764a5-3543-0e5a-e57c-3d5c6707626d@bytedance.com> Date: Tue, 16 May 2023 08:36:40 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: [PATCH 10/10] maple_tree: Simplify and clean up mas_wr_node_store() To: "Liam R. Howlett" References: <20230515131757.60035-1-zhangpeng.00@bytedance.com> <20230515131757.60035-11-zhangpeng.00@bytedance.com> <20230515185810.esnbqaybs5ivttwq@revolver> Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Peng Zhang From: Peng Zhang In-Reply-To: <20230515185810.esnbqaybs5ivttwq@revolver> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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 在 2023/5/16 02:58, Liam R. Howlett 写道: > * Peng Zhang [230515 09:18]: >> Simplify and clean up mas_wr_node_store(), remove unnecessary code. > > This change fails the userspace testing for me. Can you tell which commit this patchset is based on when you run userspace testing? I'll have a look. > >> >> Signed-off-by: Peng Zhang >> --- >> lib/maple_tree.c | 75 +++++++++++++----------------------------------- >> 1 file changed, 20 insertions(+), 55 deletions(-) >> >> diff --git a/lib/maple_tree.c b/lib/maple_tree.c >> index d558e7bcb6da8..ff4aa01cf88b6 100644 >> --- a/lib/maple_tree.c >> +++ b/lib/maple_tree.c >> @@ -4066,46 +4066,21 @@ static inline int mas_wr_spanning_store(struct ma_wr_state *wr_mas) >> * >> * Return: True if stored, false otherwise >> */ >> -static inline bool mas_wr_node_store(struct ma_wr_state *wr_mas) >> +static inline bool mas_wr_node_store(struct ma_wr_state *wr_mas, >> + unsigned char new_end) >> { >> struct ma_state *mas = wr_mas->mas; >> void __rcu **dst_slots; >> unsigned long *dst_pivots; >> unsigned char dst_offset; >> - unsigned char new_end = wr_mas->node_end; >> - unsigned char offset; >> - unsigned char node_slots = mt_slots[wr_mas->type]; >> struct maple_node reuse, *newnode; >> - unsigned char copy_size, max_piv = mt_pivots[wr_mas->type]; >> + unsigned char copy_size, node_pivots = mt_pivots[wr_mas->type]; >> bool in_rcu = mt_in_rcu(mas->tree); >> >> - offset = mas->offset; >> - if (mas->last == wr_mas->r_max) { >> - /* runs right to the end of the node */ >> - if (mas->last == mas->max) >> - new_end = offset; >> - /* don't copy this offset */ >> + if (mas->last == wr_mas->end_piv) >> wr_mas->offset_end++; >> - } else if (mas->last < wr_mas->r_max) { >> - /* new range ends in this range */ >> - if (unlikely(wr_mas->r_max == ULONG_MAX)) >> - mas_bulk_rebalance(mas, wr_mas->node_end, wr_mas->type); >> - >> - new_end++; >> - } else { >> - if (wr_mas->end_piv == mas->last) >> - wr_mas->offset_end++; >> - >> - new_end -= wr_mas->offset_end - offset - 1; >> - } >> - >> - /* new range starts within a range */ >> - if (wr_mas->r_min < mas->index) >> - new_end++; >> - >> - /* Not enough room */ >> - if (new_end >= node_slots) >> - return false; >> + else if (unlikely(wr_mas->r_max == ULONG_MAX)) >> + mas_bulk_rebalance(mas, wr_mas->node_end, wr_mas->type); >> >> /* Not enough data. */ >> if (!mte_is_root(mas->node) && (new_end <= mt_min_slots[wr_mas->type]) && >> @@ -4128,47 +4103,36 @@ static inline bool mas_wr_node_store(struct ma_wr_state *wr_mas) >> dst_pivots = ma_pivots(newnode, wr_mas->type); >> dst_slots = ma_slots(newnode, wr_mas->type); >> /* Copy from start to insert point */ >> - memcpy(dst_pivots, wr_mas->pivots, sizeof(unsigned long) * (offset + 1)); >> - memcpy(dst_slots, wr_mas->slots, sizeof(void *) * (offset + 1)); >> - dst_offset = offset; >> + memcpy(dst_pivots, wr_mas->pivots, sizeof(unsigned long) * mas->offset); >> + memcpy(dst_slots, wr_mas->slots, sizeof(void *) * mas->offset); >> >> /* Handle insert of new range starting after old range */ >> if (wr_mas->r_min < mas->index) { >> - mas->offset++; >> - rcu_assign_pointer(dst_slots[dst_offset], wr_mas->content); >> - dst_pivots[dst_offset++] = mas->index - 1; >> + rcu_assign_pointer(dst_slots[mas->offset], wr_mas->content); >> + dst_pivots[mas->offset++] = mas->index - 1; >> } >> >> /* Store the new entry and range end. */ >> - if (dst_offset < max_piv) >> - dst_pivots[dst_offset] = mas->last; >> - mas->offset = dst_offset; >> - rcu_assign_pointer(dst_slots[dst_offset], wr_mas->entry); >> + if (mas->offset < node_pivots) >> + dst_pivots[mas->offset] = mas->last; >> + rcu_assign_pointer(dst_slots[mas->offset], wr_mas->entry); >> >> /* >> * this range wrote to the end of the node or it overwrote the rest of >> * the data >> */ >> - if (wr_mas->offset_end > wr_mas->node_end || mas->last >= mas->max) { >> - new_end = dst_offset; >> + if (wr_mas->offset_end > wr_mas->node_end) >> goto done; >> - } >> >> - dst_offset++; >> + dst_offset = mas->offset + 1; >> /* Copy to the end of node if necessary. */ >> copy_size = wr_mas->node_end - wr_mas->offset_end + 1; >> memcpy(dst_slots + dst_offset, wr_mas->slots + wr_mas->offset_end, >> sizeof(void *) * copy_size); >> - if (dst_offset < max_piv) { >> - if (copy_size > max_piv - dst_offset) >> - copy_size = max_piv - dst_offset; >> + memcpy(dst_pivots + dst_offset, wr_mas->pivots + wr_mas->offset_end, >> + sizeof(unsigned long) * (copy_size - 1)); >> >> - memcpy(dst_pivots + dst_offset, >> - wr_mas->pivots + wr_mas->offset_end, >> - sizeof(unsigned long) * copy_size); >> - } >> - >> - if ((wr_mas->node_end == node_slots - 1) && (new_end < node_slots - 1)) >> + if (new_end < node_pivots) >> dst_pivots[new_end] = mas->max; >> >> done: >> @@ -4429,7 +4393,8 @@ static inline void mas_wr_modify(struct ma_wr_state *wr_mas) >> >> if (new_end == wr_mas->node_end && mas_wr_slot_store(wr_mas)) >> return; >> - else if (mas_wr_node_store(wr_mas)) >> + >> + if (mas_wr_node_store(wr_mas, new_end)) >> return; >> >> if (mas_is_err(mas)) >> -- >> 2.20.1 >>