From patchwork Sat Sep 7 08:49:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13795161 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 B1F1FE6FE55 for ; Sat, 7 Sep 2024 08:50:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F8C36B008C; Sat, 7 Sep 2024 04:50:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 681126B0092; Sat, 7 Sep 2024 04:50:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 56F3D6B0093; Sat, 7 Sep 2024 04:50:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 3C0A96B008C for ; Sat, 7 Sep 2024 04:50:35 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D71F71609C0 for ; Sat, 7 Sep 2024 08:50:34 +0000 (UTC) X-FDA: 82537321188.26.76F9F82 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by imf11.hostedemail.com (Postfix) with ESMTP id 0FE524000A for ; Sat, 7 Sep 2024 08:50:32 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="O7qVI/l2"; spf=pass (imf11.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.51 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=1725698935; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references:dkim-signature; bh=P2WwYUfzR6zC3Dz2NYj6+ze9q0tWarjPk2ZkGpAiH3g=; b=Q7VGIOOK62PNVdlqN8Q3TUZz9gwMenclmbIN9lXx51G9gl21NHIyFZo/2NBhEs4i7FTeQc OHBfcVTkmJJu4NFOjZtcwABOx1pDEIf5sj4TQKrIyXHrJxcUiZEi9ipUorx/mtXFlTVGqk +qfjFGgYk4X6waRHXiUhLYOvEblwwpo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725698935; a=rsa-sha256; cv=none; b=ptceM4NUXVHmTf5XQNehg1Vt+JDRV/xF23BAjo6+snxC92iIeTbldaYkfNzkP+6a0rEUkf YlQ/qskQkhd5hjTLzWXsJ2gbYffp4JZHmMQQgE7Oybf6rFJ6zvnm0kujwtGq4iIbTUpa3P 3XgIVj6jwQnvKDP3ErTDbUXy4II6eRg= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="O7qVI/l2"; spf=pass (imf11.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.51 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-5c24ebaa427so5855379a12.1 for ; Sat, 07 Sep 2024 01:50:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725699031; x=1726303831; darn=kvack.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=P2WwYUfzR6zC3Dz2NYj6+ze9q0tWarjPk2ZkGpAiH3g=; b=O7qVI/l2Fr0ZGhlWpTBkmqc4N8YoU94F+wdo0JAwFV9pFH8jsbbUVFOfie3jLy6C3Y LFeDB5QxjM7Qo3gsynb0EPO/OGbJz85XowiQtp7hnFImKzD6b+EkOaXS+700SdWKCwYu v1F8n2tUu7vCKmiMLlD558Ab8VB/08Wxyss7S81BKtCgR0HHAZSSy17nTa3NtZo23Uo2 fSKUCR7wEVzDUhLULyDaXuarsrhXUzAMTl1arA/AQPQw1Q5UD1LEicI2glpOTdsefMmQ vi7XLFoup5+bGOFF8/6Z424/Pd1JdkQobuGs638VcWvwkE8ZTwXhHzUVjSXtkR8ZHFqp 7P5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725699031; x=1726303831; h=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=P2WwYUfzR6zC3Dz2NYj6+ze9q0tWarjPk2ZkGpAiH3g=; b=QLUlnPeQSYDmM5vxdFWu02QX0YyUbXclsmX1twh0OZrMlBhJGNNe92ul30uaCgfuOw a5QeIKlVgn/uDG/fsgzp4NAancupRbdd5nWrNvoDJLY+vdhwxKrRQP+C6myVjJoA7f7D QobqbqBm1jbjpXFGZQeFa8D6GBjtQb4jchleYZClKuZkduuwVMLmXdNXPbep/z84dvfp siiVZ1Dv65fYTSp3zHKnmSW484IpWjJuYZ1wpkps+Osp2kBrWwtvJPDBUVZRS/FQLaQf 7qXR9l8lbvbi28Z5zSQk341aS0kEYz7uCbpm6d9tT1IHEKe1D1+FcTcoKMTMzre/uIIi Wb2A== X-Forwarded-Encrypted: i=1; AJvYcCVl46lazsgbCqM5a1Z4Ar0Bl/N8pFqCQR/8dTJSJC4la9cUjUABkb8W8fGSZ0JAi00tA7/zy8JNPg==@kvack.org X-Gm-Message-State: AOJu0Yw6cDonAfS3UJKuU+n9Aq2OFkQMT9eD0F89bKWdCZL9LIO9PEky qWxubbosjVB70Zsl3jfON8twBNRnd/qWajkEeNEKtRc/QDB/zi/n X-Google-Smtp-Source: AGHT+IHgUX3hbrWnUU2USmuxHUvaBlHWd0M5acSQsLGx3XvQsbAt3+VAwArqDgQXg+8SoRUTIM8m5g== X-Received: by 2002:a17:907:c06:b0:a87:370:8dfc with SMTP id a640c23a62f3a-a8a8603e91fmr519607766b.14.1725699031055; Sat, 07 Sep 2024 01:50:31 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25d65742sm47433666b.216.2024.09.07.01.50.30 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Sep 2024 01:50:30 -0700 (PDT) From: Wei Yang To: Liam.Howlett@oracle.com, akpm@linux-foundation.org Cc: maple-tree@lists.infradead.org, linux-mm@kvack.org, Wei Yang , "Liam R . Howlett" Subject: [PATCH 2/2] maple_tree: memset maple_big_node as a whole Date: Sat, 7 Sep 2024 08:49:27 +0000 Message-Id: <20240907084927.1547-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240907084927.1547-1-richard.weiyang@gmail.com> References: <20240907084927.1547-1-richard.weiyang@gmail.com> X-Rspamd-Queue-Id: 0FE524000A X-Stat-Signature: zkct3hariqb7uzqqocfepr6uwi6bg9an X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1725699032-598870 X-HE-Meta: U2FsdGVkX1//eESYaeFIvBHeeVFj2PuBcqf/GEu8M9owTbKVumLq7Gt5mh9VNKeJKFhwNxICc+nxQ1HzuxmCzcHUyirQwFTyYBavNC/KhQUhaAKm6bWbq6CYvcgyeisr/jM9HLPOW4pYRq4zJOdaBPDd3c65rWqeR18GwrODToDYp4kkMxCCwa7CtJnLkUtTdZnPi+/2moZZqnKbnTStlvQXiW+O1T2ie+qYYsR4FVXR607SkcfIa5x6C1E1VcfxSm2FLKFU0Y7ZTDM5ovV1PgLYBNPJMKKEkMeoHjJrVJtFsHCwnUactG2SdfwLfnezL6164rVrlVlHD4CnDviVYpgZRWrHfwgEvTD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+nFz1n2yVHQOexbDxpxvNHyw52EdRZWXdeiG X-Bogosity: Ham, tests=bogofilter, spamicity=0.066479, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In maple_big_node, we define slot and padding/gap in a union. And based on current definition of MAPLE_BIG_NODE_SLOTS/GAPS, padding is always less then slot and part of the gap is overlapped by slot. For example on 64bit system: MAPLE_BIG_NODE_SLOT is 34 MAPLE_BIG_NODE_GAP is 21 With this knowledge, current code actually clear the whole maple_big_node and even clear some space twice. Instead of clear maple_big_node each field separately, let's clear it in one memset. Signed-off-by: Wei Yang CC: Liam R. Howlett --- Liam: This looks obvious, so I just run the ./maple test to see it doesn't break anything. Do you think I need to add a benchmark and run a perf for this kind of change? --- lib/maple_tree.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index d8f10773e451..911c5e04e634 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3134,10 +3134,7 @@ static inline void mast_fill_bnode(struct maple_subtree_state *mast, bool cp = true; unsigned char split; - memset(mast->bn->gap, 0, sizeof(unsigned long) * ARRAY_SIZE(mast->bn->gap)); - memset(mast->bn->slot, 0, sizeof(unsigned long) * ARRAY_SIZE(mast->bn->slot)); - memset(mast->bn->pivot, 0, sizeof(unsigned long) * ARRAY_SIZE(mast->bn->pivot)); - mast->bn->b_end = 0; + memset(mast->bn, 0, sizeof(struct maple_big_node)); if (mte_is_root(mas->node)) { cp = false;