From patchwork Mon Dec 9 09:42:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhenhua Huang X-Patchwork-Id: 13899147 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 05C07E7717D for ; Mon, 9 Dec 2024 09:43:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9342A6B03EC; Mon, 9 Dec 2024 04:43:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E3276B03ED; Mon, 9 Dec 2024 04:43:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 783D16B03EE; Mon, 9 Dec 2024 04:43:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 591A36B03EC for ; Mon, 9 Dec 2024 04:43:06 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id DC908C0307 for ; Mon, 9 Dec 2024 09:43:05 +0000 (UTC) X-FDA: 82874930460.20.8392BCA Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by imf21.hostedemail.com (Postfix) with ESMTP id 936941C0005 for ; Mon, 9 Dec 2024 09:42:24 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=immPB09I; spf=pass (imf21.hostedemail.com: domain of quic_zhenhuah@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_zhenhuah@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733737369; 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=Tqbr13cTVpmFqpleZm78ZDOWuVR4wFo0Qdc8LscuVcA=; b=Yn+cE+jTXUKhflXqiwBylwSlU5cnr+43QAEVb7zbBv3iMyBowbY81DOYurj4Hiqjo9nCJc Zga8L2QlVP5vFjCZYlcUmgkaNqp4N/K9xHDr342GnJcvsIFWY0DbVcSGm329UKmJpPvk/O 7O+vwix/Nxymv4dQdIc/0559YU34Gdw= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=immPB09I; spf=pass (imf21.hostedemail.com: domain of quic_zhenhuah@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_zhenhuah@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733737369; a=rsa-sha256; cv=none; b=fRTPcwJx95ZFwiVmdHBQ8KFNJ9DuqxpO/ExtJGTplgerdT24jRpGngaozs4wboB2QKK2hm 7f9lOEKoYrWLM0vPqm7SZiRcORARnwUJ2N3FunjoJaEck8RN7xsEX3NlSXn2UtUExV9S6o t6kfKuHTFWsswZpECELemSu3ierWmcQ= Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4B8NkrgO019407; Mon, 9 Dec 2024 09:42:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= Tqbr13cTVpmFqpleZm78ZDOWuVR4wFo0Qdc8LscuVcA=; b=immPB09IHqdJ86ly Wt5sEZWvGhCy3KNGq40HOAuAcKo+CFcCg5agk6CeGJBseyHXs18IpTs2Yw96+HRJ /qNIyAry9Vj00yiPO+78nct5dI40owyBOnwYmERKtSEk9M0IHjMnqyNbQfViiIpk frhftXVoSs44Gw8MA+NWdBeOQoFiodZuZPq1ifoMkbbeXoj6Z+InNfDb7ETI8xj1 qvsCfPwaiTQWcEi+qVfoqnS1mPUkJ11/OYkLtWTUvG9EacsEmRZrQVC7K0SuyUn9 Ia6tGuR/LErbV3YG1Y4zALTxh1XG/7vjliIThRRpthLWbZLmRXSomB7lq5RUg4Q9 wosV2g== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 43cc2ecb4a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 09:42:57 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 4B99guef019069 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 9 Dec 2024 09:42:56 GMT Received: from ap-kernel-sh01-lnx.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 9 Dec 2024 01:42:53 -0800 From: Zhenhua Huang To: , , , , , , , , , CC: , , , Zhenhua Huang Subject: [PATCH v2 1/2] arm64: mm: vmemmap populate to page level if not section aligned Date: Mon, 9 Dec 2024 17:42:26 +0800 Message-ID: <20241209094227.1529977-2-quic_zhenhuah@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241209094227.1529977-1-quic_zhenhuah@quicinc.com> References: <20241209094227.1529977-1-quic_zhenhuah@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 4-q_SRzBcq3Y4hdw5tH8DRWs14OCq0fu X-Proofpoint-GUID: 4-q_SRzBcq3Y4hdw5tH8DRWs14OCq0fu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxscore=0 mlxlogscore=822 priorityscore=1501 impostorscore=0 lowpriorityscore=0 adultscore=0 malwarescore=0 clxscore=1011 suspectscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412090075 X-Rspamd-Server: rspam05 X-Stat-Signature: 18hjjhkqya8uy5uc5p7fps88cwqoptag X-Rspamd-Queue-Id: 936941C0005 X-Rspam-User: X-HE-Tag: 1733737344-357791 X-HE-Meta: U2FsdGVkX1+K5Igzeh/qcVxsYNy2uwpxneF+IIUtxhFWCWE9NJ0jAHjCINo4CH4XXtz7Wo5ZTc3msGqBVqcmXhlDa8+2DQbrle7RPjHi4QYU/BQEyr3hYoQW77vcS8noDk535evWy4vpIU5hRx/YfPZfSMMNoq8Lt99CZFC8Qvm+rE41zZ3HUhc9zUq9w94smezCOVCb2lZ12zuwggJjTvtsujvDo0OEVZkf4ULc90BLTicqf6xGTxjfHe9YoboRtg8Eh3iCEnCn9O3GRZfAdPbEn/MoBACV/dgRAhdEmKWfDHgbxQo/XoinQCB9J+q/3faNFSRj6VEBR8JkVdD3MEC5hehmIp3MN6Kqo0JYyhciO2t9MBx91cjnO4q8H+0MT9+RvPRDSIo7D2SwRFfUSu+mEN2vOO1rns62fBKJesTToH25svsvt9q7dncBV4HN5e8/dgvbwtP3dhmL/L5wYcruVsb2RGSrUNAyXNW8POmQrSdNoX0v9Taue+CxZm1YxCyMpUBv62Q8W6JqWxjlste4XM3X3Q5gsS25zw/eMeSiPn94QzSnUu1IsICae10Yir38HuW8wkX71TF9dTjVo66bt4FaYB+2AeLHjFBf8QY7S6N7qFDH9dzx0BwzCv+MyBiwO7cfQC0ww2mgwm8rezz2KiLgfJEQ9fdAd83B6hVcS3gqhwACGlHl6gUDHcIEx1paO0IYViocCxPaKcRr6ahCi2tcbXz7kq0OdO5Aph7ktvU/HMAjmVxwjHe03qESmR9eWMpT6YnR+lHgI/c2n+afe68bZTUYiOf5hwA3v0P736MiNTtHim+9N9lfDOv8K8KLRCmSFwsmCpPrbt3ckftucBSzrPLvLvGG0rhUdlM+LP7XuXvL4d8xze9dOLHGYmP8ri7MQxG2FDBpxQdwRHahYkNrWf5SGcmTQsK2RCdZyRFQ4MSoW4lnvffyeu2TR6crI8lh+fYZQJA7hfZ Xsp28AQx hnGB980lRmSHdog6uAMU+5jVTpQ1kfni+32WPettCpIQlCA5Y7cGdgRDul9E5VsE1Q8cGHPSXI3jSM9jI+K/VDMucEjogrzK8Q9S2/BSwHTH+CtjS73+C661eyUW68sKSwZaO40szFTDaGHAeMw/ZTTca0WLXmGuqpEzAvZfQsecdh7qc6w9Nvo2SWcfLb/RbuurighQGBX/OGfPANdJxy1LdEUvQ47ZhaUnVbDo7aks3GqFhvhvP39XDJXPprO03SV8MYkedofMzSxNmRGseli2U8TK+FgzhcRfn/gT6e6hfuc6wdBd/3Gd8uBYZOQ7O8zn/ 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: List-Subscribe: List-Unsubscribe: Commit c1cc1552616d ("arm64: MMU initialisation") optimizes the vmemmap to populate at the PMD section level. However, if start or end is not aligned to a section boundary, such as when a subsection is hot added, populating the entire section is wasteful. For instance, if only one subsection hot-added, the entire section's struct page metadata will still be populated.In such cases, it is more effective to populate at page granularity. This change also addresses mismatch issues during vmemmap_free(): When pmd_sect() is true, the entire PMD section is cleared, even if there is other effective subsection. For example, pagemap1 and pagemap2 are part of a single PMD entry and they are hot-added sequentially. Then pagemap1 is removed, vmemmap_free() will clear the entire PMD entry, freeing the struct page metadata for the whole section, even though pagemap2 is still active. Fixes: c1cc1552616d ("arm64: MMU initialisation") Signed-off-by: Zhenhua Huang --- arch/arm64/mm/mmu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index e2739b69e11b..fd59ee44960e 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -1177,7 +1177,9 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node, { WARN_ON((start < VMEMMAP_START) || (end > VMEMMAP_END)); - if (!IS_ENABLED(CONFIG_ARM64_4K_PAGES)) + if (!IS_ENABLED(CONFIG_ARM64_4K_PAGES) || + !IS_ALIGNED(page_to_pfn((struct page *)start), PAGES_PER_SECTION) || + !IS_ALIGNED(page_to_pfn((struct page *)end), PAGES_PER_SECTION)) return vmemmap_populate_basepages(start, end, node, altmap); else return vmemmap_populate_hugepages(start, end, node, altmap);