Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp24021rdb; Mon, 4 Dec 2023 18:48:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IHpQhmW8OcajAJx6GXuXWDrlP+VpcUoNelzdYUwU06yBG7wd0sqzbC/Xhzll+xdbxUfJWbh X-Received: by 2002:a17:90a:2a0e:b0:286:a93f:bdb9 with SMTP id i14-20020a17090a2a0e00b00286a93fbdb9mr489160pjd.33.1701744481698; Mon, 04 Dec 2023 18:48:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701744481; cv=none; d=google.com; s=arc-20160816; b=yeSrlojQJLeyaztoTUDLobXPvJgExasDL7v+DfnsAzjEMcW2/sRNZhrhP2C1gvAhia R+NeO1idCZ7vpgqnRTxu0FN9S5LUZfgYLQB18KVtQt2jjC5k10MYhVraQnFB2bhSc5b5 pwG5HZiU1tSTtGmdrQ/dBgXT6rElN0SMdwC23Ea0S2zzCE09CmxZZ/xMYMr96K6KZvp+ DnIEhyQBWUKjsYNdbEhu7jxzA11unlf/feAoyhp5dOpbqMLi8LhGq2qH9mO2bqRqZRxX PAulNkh5guy+/CueiWxyqPXekK1b9sRwAKpUgYLBXdHl7ug5HNnR2vTUbpHWOp086wnf GT6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=L+gZubsRH31odcoqRD7fvFFSzO5DYYZUYFSAk62Ge2s=; fh=2iHlf3letx4QWKH81n+7aNB/Yi5Z+1XTewouSb7FUCc=; b=qF0FO+7GDO/gJCvJNLkysB08cn28JjaZzLYUJpJmDpJH5e//93HSimzyO6WSx6FVRf 5M45tBuvNkVgsCBk8RRJfjbKh4bz9b8umbNqNIh54uO26IPIt2aIQy5+Ajy7k4sTBUGu sEFhZjuJap7x7pzMoscvqk8KdWm8Uknj8i/WF8+M648nBMzNlGgN1MGpj/cYUB/piWX9 IQwmnkWueZSD4rctVM1TV9fI2ESsZjesUYXGbB3oZydQZZB19IHNGngD8opuXGV/uDdl 4nxKTPiZvF97S1z3BP+RMOnjc3dbGTmgeCNgP4VoQ1+u2uDxHEGdbi48Nh+dPs3Doxn1 K+tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=M41vbbN2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id z17-20020a17090ab11100b002850d5f8ab3si11223021pjq.174.2023.12.04.18.48.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 18:48:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=M41vbbN2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 28555804AF69; Mon, 4 Dec 2023 18:47:58 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346321AbjLECr2 (ORCPT + 99 others); Mon, 4 Dec 2023 21:47:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231536AbjLECrZ (ORCPT ); Mon, 4 Dec 2023 21:47:25 -0500 Received: from out-188.mta0.migadu.com (out-188.mta0.migadu.com [IPv6:2001:41d0:1004:224b::bc]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88285CD for ; Mon, 4 Dec 2023 18:47:31 -0800 (PST) Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1701744450; h=from:from: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; bh=L+gZubsRH31odcoqRD7fvFFSzO5DYYZUYFSAk62Ge2s=; b=M41vbbN2M2qKox8gqmA+RhYSM3dMqetsHI+A/5QB16j4LcxCVBSrYBvGGHlktMG3qVWr2a fgVQja15ijmTOAb0+Cilr0TNpyX7gpaZqTjBpiZHylCvAMrdpr37YFRm/jHy9BlUqXVlek 54JW757MdnpuGfGacTd+2/2/PMlGt94= Mime-Version: 1.0 Subject: Re: [PATCH 3/4] mm: hugetlb_vmemmap: move PageVmemmapSelfHosted() check to split_vmemmap_huge_pmd() X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: <20231204232728.GD4129@monkey> Date: Tue, 5 Dec 2023 10:46:52 +0800 Cc: Muchun Song , Andrew Morton , Linux-MM , linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20231127084645.27017-1-songmuchun@bytedance.com> <20231127084645.27017-4-songmuchun@bytedance.com> <20231204232728.GD4129@monkey> To: Mike Kravetz X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 04 Dec 2023 18:47:58 -0800 (PST) > On Dec 5, 2023, at 07:27, Mike Kravetz = wrote: >=20 > On 11/27/23 16:46, Muchun Song wrote: >> To check a page whether it is self-hosted needs to traverse the page = table (e.g. >> pmd_off_k()), however, we already have done this in the next calling = of >> vmemmap_remap_range(). Moving PageVmemmapSelfHosted() check to = vmemmap_pmd_entry() >> could simplify the code a bit. >>=20 >> Signed-off-by: Muchun Song >> --- >> mm/hugetlb_vmemmap.c | 70 = +++++++++++++++----------------------------- >> 1 file changed, 24 insertions(+), 46 deletions(-) >>=20 >> diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c >> index ef14356855d13..ce920ca6c90ee 100644 >> --- a/mm/hugetlb_vmemmap.c >> +++ b/mm/hugetlb_vmemmap.c >> @@ -95,6 +95,7 @@ static int vmemmap_split_pmd(pmd_t *pmd, struct = page *head, unsigned long start, >> static int vmemmap_pmd_entry(pmd_t *pmd, unsigned long addr, >> unsigned long next, struct mm_walk *walk) >> { >> + int ret =3D 0; >> struct page *head; >> struct vmemmap_remap_walk *vmemmap_walk =3D walk->private; >>=20 >> @@ -104,9 +105,30 @@ static int vmemmap_pmd_entry(pmd_t *pmd, = unsigned long addr, >>=20 >> spin_lock(&init_mm.page_table_lock); >> head =3D pmd_leaf(*pmd) ? pmd_page(*pmd) : NULL; >=20 > I was going to ask why you dropped the: > if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) > However, without the extra page table reads it really is not = necessary. I thought the compiler is smart enough to find out this code is unnecessary so that it will be dropped. But I am wrong, I did a test showing the compiler does optimize the code when CONFIG_MEMORY_HOTPLUG is disabled, but it is not enough compared with adding the check of = "IS_ENABLED(CONFIG_MEMORY_HOTPLUG)". I will add the check back in a separate patch (I suspect it is easy for Andrew to merge). >=20 > Reviewed-by: Mike Kravetz Thanks. > --=20 > Mike Kravetz