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 76F8CEB64D9 for ; Mon, 10 Jul 2023 09:44:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 145596B0081; Mon, 10 Jul 2023 05:44:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F7076B0082; Mon, 10 Jul 2023 05:44:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EFF406B0083; Mon, 10 Jul 2023 05:44:54 -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 DD9D96B0081 for ; Mon, 10 Jul 2023 05:44:54 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A79574021F for ; Mon, 10 Jul 2023 09:44:54 +0000 (UTC) X-FDA: 80995218108.01.262D663 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by imf28.hostedemail.com (Postfix) with ESMTP id C3DFCC0008 for ; Mon, 10 Jul 2023 09:44:52 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=H+ZoOOqG; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf28.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.210.173 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688982292; a=rsa-sha256; cv=none; b=t3Jy5Uf2fVYg0eC1NxEow2jmgRBdGC0TCp5RJUSVWF4BKjNrzygpUvYKIiNta1lpsB2BBv TCO0z1iWmST23FxDJSL7LHFxPPx3wnmr0ROM3gM3djGMsAHoAdSSSaxjV81tMNph9v3y3Z CuNAduWNAWHNqgsoMCWO+2KQXoDKSxg= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=H+ZoOOqG; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf28.hostedemail.com: domain of zhangpeng.00@bytedance.com designates 209.85.210.173 as permitted sender) smtp.mailfrom=zhangpeng.00@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688982292; h=from:from:sender: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=VqM5Tg5znsJa61fz+y3eLpo4QkB80+ZsaFaKkQZI6jQ=; b=MFsVRXoTIm366q1lg8K86OUZASNLHIDShdVLGXPMBZfTyf6S/lqQ8mLRPHY9STCTft3CBQ hUJWM0AlRdzWxJ9eedWVT5ogXv9ENtnyretZZFH8Yl+nuAkbCZQNQY4rwwDycjRo95eXPL FztlokMuYLusQHXyXDxUEqzYR1yeKGo= Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-666ed230c81so3726057b3a.0 for ; Mon, 10 Jul 2023 02:44:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1688982291; x=1691574291; h=content-transfer-encoding:in-reply-to:cc:from:references:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=VqM5Tg5znsJa61fz+y3eLpo4QkB80+ZsaFaKkQZI6jQ=; b=H+ZoOOqGWs4EIYa2TAsb9wreWdccJm1VMw1A+iibfRK5gKQ7DDjA3eFNgx0XP2Juww BNcEB3nQ0x1q9Kxt7+zmHj5H9rvZCi9oBIDMNPTaTRoKrRMS7Vc9qGkvbMuJ5bL67B4Q cVYX08gq3dnUt4vYC3i+mqP5FcvnsPdeiAx4Ssqo5yBpNKwWA3EkP9nKJHN5Dj90OtkT 8cwzvu62Ekc2goKeuSp31NrrmjqLqVkw6Xz04mvnegsCYv9GdzMksDJghoRPqgiSHlNI 3G4TOlbzmfCbA4PN7GkaAaZD6agDjQFUSaDVGQtyyCtYUPE9IN9i7hPRFyqKsonuZp1/ /z3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688982291; x=1691574291; h=content-transfer-encoding:in-reply-to:cc:from:references:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=VqM5Tg5znsJa61fz+y3eLpo4QkB80+ZsaFaKkQZI6jQ=; b=V0nOjVoqJ+T9/Sz+x6q48XLr0zdxICXqJYSF+NQmHL3V8YpeeSkdkgJeX7Qs8bLVGj eD8CuC/BLrn42bS9qpt2SpMtpkaFdLE6P0VoFfli8kjR1MNmsUOni8XkQOogLAcYmAAK 9WVOA57O9cMvvhkqdKHZjYNK1i/NDha8epPnsM3oXe8El3T9ShkOOGnW+35hZynJUPMk TmqorRlyF0oAOR59i07MDgec7y6Jp1mmnTcMc3u/XULNgBBp6BJOnpWv+6seoy4KCLcA IEFw+kNA/xAL9QzsM8p16Vb6XeFw4YQ5kgsFCulyus7v8vFcIYePbG6yvCEFRwDZIJpo MS0A== X-Gm-Message-State: ABy/qLYDeDgwlCnp3Ii3j4/H0MdYZueP46iz8o5HY6BHeRYMtAYmcjxy qRtUX4Ui7AgH45hy/HuKZp/U9IQBhcNCZwkEKsw= X-Google-Smtp-Source: APBJJlGTYwe9q2auhQ4W+w5xLWKQ3wcgumMmirwT+NyCvqcc59o3omWbC/P3K/jCwXqxpjse355bUg== X-Received: by 2002:a05:6a20:4320:b0:118:e011:5e4c with SMTP id h32-20020a056a20432000b00118e0115e4cmr15874384pzk.57.1688982291369; Mon, 10 Jul 2023 02:44:51 -0700 (PDT) Received: from [10.90.35.114] ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id 12-20020a170902c20c00b001b7fd4de08bsm7821942pll.129.2023.07.10.02.44.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 Jul 2023 02:44:51 -0700 (PDT) Message-ID: <3c260876-2ee5-7659-0c02-17a68277567f@bytedance.com> Date: Mon, 10 Jul 2023 17:44:47 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [RESEND PATCH 3/8] maple_tree: make mas_validate_gaps() to check metadata To: "Liam R. Howlett" References: <20230707101057.29326-1-zhangpeng.00@bytedance.com> <20230707101057.29326-4-zhangpeng.00@bytedance.com> <20230707144550.eavqm7zcr6dofl73@revolver> From: Peng Zhang Cc: Peng Zhang , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org In-Reply-To: <20230707144550.eavqm7zcr6dofl73@revolver> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: C3DFCC0008 X-Stat-Signature: c4bt3a189ta9tz4xwbo8dqtz75xpmph1 X-HE-Tag: 1688982292-111006 X-HE-Meta: U2FsdGVkX19neikVAITPPhtkgw3gBTwARNM6EF3YRKcOu21dNWwxZ3RWYxn/bxyev8E3wW0t8aamzIyhTdhF0DlQlu0eY+Pm7Sn+UPqxSAG4TG41Cy51wPwLG4UWIZ81erl2tF0XHtLCztyh/n/VE+nd2fyPUp+ZrwG8hqzQeryoNWM7b4e8yeqRxiBuyevc0iDgoCVrqHD2o5fmqwMOVAtAxASs640wd+6WDWtfru1oIj4DkHJZeQ57pfAK0fqeNXLqs57Z2+n+/KN5+61twnL+XUgRpcSVb4aAosmiX+ffQ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mXRuIv0TaFjot/TKBdXPnGr54xijNKPHlvPJifMCC8/3lC+a3dEXtw11C+2ScGW7V0DLbymmtWkEfZB6eb6R8DblOEyvTSPbkQNQ/VyyFdGipe67pXYzEGDmukzIUb2tI3Jty6ghMs7KBYJ73eTA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 在 2023/7/7 22:45, Liam R. Howlett 写道: > * Peng Zhang [230707 06:11]: >> Make mas_validate_gaps() check whether the offset in the metadata points >> to the largest gap. By the way, simplify this function. >> >> Signed-off-by: Peng Zhang >> --- >> lib/maple_tree.c | 68 +++++++++++++++++++++++------------------------- >> 1 file changed, 33 insertions(+), 35 deletions(-) >> >> diff --git a/lib/maple_tree.c b/lib/maple_tree.c >> index 6a8982146338..1fe8b6a787dd 100644 >> --- a/lib/maple_tree.c >> +++ b/lib/maple_tree.c >> @@ -6983,15 +6983,16 @@ EXPORT_SYMBOL_GPL(mt_dump); >> static void mas_validate_gaps(struct ma_state *mas) >> { >> struct maple_enode *mte = mas->node; >> - struct maple_node *p_mn; >> + struct maple_node *p_mn, *node = mte_to_node(mte); >> + enum maple_type mt = mte_node_type(mas->node); >> unsigned long gap = 0, max_gap = 0; >> unsigned long p_end, p_start = mas->min; >> - unsigned char p_slot; >> + unsigned char p_slot, offset; >> unsigned long *gaps = NULL; >> - unsigned long *pivots = ma_pivots(mte_to_node(mte), mte_node_type(mte)); >> + unsigned long *pivots = ma_pivots(node, mt); >> int i; >> >> - if (ma_is_dense(mte_node_type(mte))) { >> + if (ma_is_dense(mt)) { >> for (i = 0; i < mt_slot_count(mte); i++) { >> if (mas_get_slot(mas, i)) { >> if (gap > max_gap) >> @@ -7004,52 +7005,51 @@ static void mas_validate_gaps(struct ma_state *mas) >> goto counted; >> } >> >> - gaps = ma_gaps(mte_to_node(mte), mte_node_type(mte)); >> + gaps = ma_gaps(node, mt); >> for (i = 0; i < mt_slot_count(mte); i++) { >> - p_end = mas_logical_pivot(mas, pivots, i, mte_node_type(mte)); >> + p_end = mas_logical_pivot(mas, pivots, i, mt); >> >> if (!gaps) { >> - if (mas_get_slot(mas, i)) { >> - gap = 0; >> - goto not_empty; >> - } >> - >> - gap += p_end - p_start + 1; >> + if (!mas_get_slot(mas, i)) >> + gap = p_end - p_start + 1; >> } else { >> void *entry = mas_get_slot(mas, i); >> >> gap = gaps[i]; >> - if (!entry) { >> - if (gap != p_end - p_start + 1) { >> - pr_err("%p[%u] -> %p %lu != %lu - %lu + 1\n", >> - mas_mn(mas), i, >> - mas_get_slot(mas, i), gap, >> - p_end, p_start); >> - mt_dump(mas->tree, mt_dump_hex); >> - >> - MT_BUG_ON(mas->tree, >> - gap != p_end - p_start + 1); >> - } >> - } else { >> - if (gap > p_end - p_start + 1) { >> - pr_err("%p[%u] %lu >= %lu - %lu + 1 (%lu)\n", >> - mas_mn(mas), i, gap, p_end, p_start, >> - p_end - p_start + 1); >> - MT_BUG_ON(mas->tree, >> - gap > p_end - p_start + 1); >> - } >> + MT_BUG_ON(mas->tree, !entry); >> + >> + if (gap > p_end - p_start + 1) { >> + pr_err("%p[%u] %lu >= %lu - %lu + 1 (%lu)\n", >> + mas_mn(mas), i, gap, p_end, p_start, >> + p_end - p_start + 1); >> + MT_BUG_ON(mas->tree, >> + gap > p_end - p_start + 1); > > Your change above points out that we are not verifying all gaps are zero > in non-leaf nodes after p_end >= mas->max. If we don't have a 'no gap' > indicator then this may be an issue, or maybe it already is an issue? If we don't have a 'no gap' indicator, why is there an issue? Are you worried that meta_gap is wrongly pointing to the gap after the node limit? If so we can verify that meta_gap points to a gap within the node limit. > >> } >> } >> >> if (gap > max_gap) >> max_gap = gap; >> -not_empty: >> + >> p_start = p_end + 1; >> if (p_end >= mas->max) >> break; >> } >> >> counted: >> + if (mt == maple_arange_64) { > > We could loop through the remainder of the gaps here pretty easily. In this way, it can be verified that the gaps after the node limit are 0. > >> + offset = ma_meta_gap(node, mt); >> + if (offset > mt_slots[mt]) { >> + pr_err("gap offset %p[%u] is invalid\n", node, offset); >> + MT_BUG_ON(mas->tree, 1); >> + } >> + >> + if (gaps[offset] != max_gap) { >> + pr_err("gap %p[%u] is not the largest gap %lu\n", >> + node, offset, max_gap); >> + MT_BUG_ON(mas->tree, 1); >> + } >> + } >> + >> if (mte_is_root(mte)) >> return; >> >> @@ -7059,10 +7059,8 @@ static void mas_validate_gaps(struct ma_state *mas) >> if (ma_gaps(p_mn, mas_parent_type(mas, mte))[p_slot] != max_gap) { >> pr_err("gap %p[%u] != %lu\n", p_mn, p_slot, max_gap); >> mt_dump(mas->tree, mt_dump_hex); >> + MT_BUG_ON(mas->tree, 1); >> } >> - >> - MT_BUG_ON(mas->tree, >> - ma_gaps(p_mn, mas_parent_type(mas, mte))[p_slot] != max_gap); >> } >> >> static void mas_validate_parent_slot(struct ma_state *mas) >> -- >> 2.20.1 >> >> >> -- >> maple-tree mailing list >> maple-tree@lists.infradead.org >> https://lists.infradead.org/mailman/listinfo/maple-tree