From patchwork Fri Jun 16 11:08:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 13282624 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 AA2A4EB64D8 for ; Fri, 16 Jun 2023 11:09:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3B8E96B007B; Fri, 16 Jun 2023 07:09:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 368D26B007E; Fri, 16 Jun 2023 07:09:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E49E6B0080; Fri, 16 Jun 2023 07:09:20 -0400 (EDT) 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 0C05F6B007B for ; Fri, 16 Jun 2023 07:09:20 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D4EEBA0BEA for ; Fri, 16 Jun 2023 11:09:19 +0000 (UTC) X-FDA: 80908339638.02.4CD8430 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf04.hostedemail.com (Postfix) with ESMTP id 641CD4001E for ; Fri, 16 Jun 2023 11:09:17 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="Fq/G4oOB"; spf=pass (imf04.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686913757; a=rsa-sha256; cv=none; b=0FOvAL0xR0vcoAQl3+WiHhB0xkuXMYVIAb+NyflUXcDsm208OSQX2xCUDY596x1XdaFr5u 95fTSqYbbiUPwY19DH6qS3iI/YbU4PJ6BQS9L5MQXTzqvpUgaL9A77Khh4IhBmjfmhS14J RAkQaA0PojPCgU6gI9so9SPk49apTw8= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="Fq/G4oOB"; spf=pass (imf04.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686913757; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=77K1R1/kGwWHCcLG2tEIMVoGfZHm1aKBUIsLmqWw1So=; b=8WUe7l52PpZQfQsZP7DT/l5kIMcoyNhqv2Lqco75g1wDOfirJqbsymoU7dXnM/EccEWBHN VZtupZSY1imu1JbUV8iv8B8eig/V8Wmf+uSCXuD1ssUo0XnIQvsSzUghT8lKReELT4/nBI 4pkeKNGq7sq/Ibq7YC3oWdxxqGrP3iw= Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35GB8KDq015816; Fri, 16 Jun 2023 11:09:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=77K1R1/kGwWHCcLG2tEIMVoGfZHm1aKBUIsLmqWw1So=; b=Fq/G4oOBRR/X6XqBnIrEAbYzlbI1Kqg96GPFuSK+QRwR1aZcN4K2zgh+XJyFBLhn2+EA fxPsq0usRYCH1z68mxZwiP519e1HvcLDcqwBbYorXUAHdP7czvY9UK90SlpkbHUODQoL e1lPrfKPSuWdhiOeBSuzP+eNv1t8+hqFvYEAT68A+qND5cPwZjKQMVmA8Ma9lD5Ai8ho nZYhgqLJC49KgzGSR0/PAdq98PkMiOSGZX/faGOHL5tqjp0jQHxVO2WFC2/sQMxobDLW mGdGyMstgOntnhRJ5vRiMsykqm5nBf64N/BJCU3HKP5SsTj7M5T8JPOB5vnNZdE7vOYP PQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3r8p9m8a4s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Jun 2023 11:09:06 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 35GB8Q0x016011; Fri, 16 Jun 2023 11:09:06 GMT Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3r8p9m8a4e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Jun 2023 11:09:05 +0000 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 35GAMR7J003274; Fri, 16 Jun 2023 11:09:04 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([9.208.130.100]) by ppma01wdc.us.ibm.com (PPS) with ESMTPS id 3r4gt5qhqx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Jun 2023 11:09:04 +0000 Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 35GB93NN983798 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 16 Jun 2023 11:09:03 GMT Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6E1B75805B; Fri, 16 Jun 2023 11:09:03 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3097A5805C; Fri, 16 Jun 2023 11:08:57 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.43.52.24]) by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP; Fri, 16 Jun 2023 11:08:56 +0000 (GMT) From: "Aneesh Kumar K.V" To: linux-mm@kvack.org, akpm@linux-foundation.org, mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org, npiggin@gmail.com, christophe.leroy@csgroup.eu Cc: Oscar Salvador , Mike Kravetz , Dan Williams , Joao Martins , Catalin Marinas , Muchun Song , Will Deacon , "Aneesh Kumar K.V" Subject: [PATCH v2 03/16] powerpc/book3s64/mm: Fix DirectMap stats in /proc/meminfo Date: Fri, 16 Jun 2023 16:38:13 +0530 Message-Id: <20230616110826.344417-4-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230616110826.344417-1-aneesh.kumar@linux.ibm.com> References: <20230616110826.344417-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Odp8cUWp3s0d4YuSsCiOdERwl9xp95pY X-Proofpoint-ORIG-GUID: s4EXAUrBlFL4zFELS2xfARnVFE1sJDJ8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-16_07,2023-06-16_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 mlxlogscore=999 bulkscore=0 impostorscore=0 priorityscore=1501 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306160099 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 641CD4001E X-Stat-Signature: inzwpkty6ncmwbursmshpfpm7nwbygsd X-Rspam-User: X-HE-Tag: 1686913757-786462 X-HE-Meta: U2FsdGVkX18Nc36ugRd8ms6Is1rLQ0C+8wZqGuczMw3RKODFNdRxDbHPdwwgUrV5TP0p7kGbvTC/dLetAYtpVv15zTB/atwShJYfooavWo+N5MXvYfKrPs+pyDf09qytzVlZKyfiT4qHz9z1B6somG27Xy6eSBKkVwJhAwiTUnXpfP2pMjejKChpuP5+vNgXYW5+rctaUtUQSOx6YbJ8xjtNrz2T0F6NJH6uZh6v85ps887qeRf7yzlzTt+GX01xRR58ufKLdYecKcHpvs92lGuqogUHTpxO0beI/nX8n/+C08IpJVfZanbVT1dyojL9cwxAI7f+E7d8bek20dwQEd/ujiHgsEy1liH4rl2BDqkoeRMcVRSg6xU9O3izbO/NCU+iHQfJ6t60Y2i4tRCy1b8x1/pSjXaHUoYg1PWlEHS9ftaMUZYBggqXF+i8H1giXaZRvaegoLgvPjkjW59V0cDYfhd/Q5GhMCtnd0TZUDoZntduJjZ7tHD5tjugzNESwc2NGJA5mijHFSw/k45wv2I3nNK/S+W2g2uDmFNsn5I+tLf/WIC98PKh1V9pHY+LA0OoJxKwLHlgZO9lxPSlH67sb7LlDFmVkhYl9RsIwgtPTtFAwYUyppUf50Uq9tjhS0aAK/j1vVNgjwpkBImWrAyZe/6ZqEHKmSugHYbyneo3Feu+fP2OP2HCUZl+MlICBfxJ2cAnF+LPbmDdql+3xBUJP0cuc+9tcUmpZ38epOtf5pkEteekBoK66Q1mjOgy/jjLpCLpmK4HoJdx9YqOcw4p+xGyIVf6mMhmya0czfoyrwYsMH1zxwoDLS7weMBukiEESIMg7Y4AG8+KtLv8BXU2Mj8NK4IqajXyRpCCQS8wkRvzT7ZzwxwCJ6wLt3chR9DM+kGxL8Hp1oP40xSqpclW5uKxyHGxrCiJWz6VPVgdIee3VIacz4xrWpYj1InnwvQ3OUek8n3/Vub/2Ha 2rT5B37E CBi7i2kgcoZtubGnRlQW2iNvfZcsuewBKlKd+tjWfjwWNQjE29/gWcfioWLh9S3tyBkHMBJyWxCvI4zofOIGMdogEQMJNJwwhnYswGm+KtXy5JpyKZYsMmZP57eAFdpG6xrfNkMouxcrZ6s4= 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: On memory unplug reduce DirectMap page count correctly. root@ubuntu-guest:# grep Direct /proc/meminfo DirectMap4k: 0 kB DirectMap64k: 0 kB DirectMap2M: 115343360 kB DirectMap1G: 0 kB Before fix: root@ubuntu-guest:# ndctl disable-namespace all disabled 1 namespace root@ubuntu-guest:# grep Direct /proc/meminfo DirectMap4k: 0 kB DirectMap64k: 0 kB DirectMap2M: 115343360 kB DirectMap1G: 0 kB After fix: root@ubuntu-guest:# ndctl disable-namespace all disabled 1 namespace root@ubuntu-guest:# grep Direct /proc/meminfo DirectMap4k: 0 kB DirectMap64k: 0 kB DirectMap2M: 104857600 kB DirectMap1G: 0 kB Fixes: a2dc009afa9a ("powerpc/mm/book3s/radix: Add mapping statistics") Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/mm/book3s64/radix_pgtable.c | 34 +++++++++++++++--------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c index 570add33c02d..15a099e53cde 100644 --- a/arch/powerpc/mm/book3s64/radix_pgtable.c +++ b/arch/powerpc/mm/book3s64/radix_pgtable.c @@ -743,9 +743,9 @@ static void free_pud_table(pud_t *pud_start, p4d_t *p4d) } static void remove_pte_table(pte_t *pte_start, unsigned long addr, - unsigned long end) + unsigned long end, bool direct) { - unsigned long next; + unsigned long next, pages = 0; pte_t *pte; pte = pte_start + pte_index(addr); @@ -767,13 +767,16 @@ static void remove_pte_table(pte_t *pte_start, unsigned long addr, } pte_clear(&init_mm, addr, pte); + pages++; } + if (direct) + update_page_count(mmu_virtual_psize, -pages); } static void __meminit remove_pmd_table(pmd_t *pmd_start, unsigned long addr, - unsigned long end) + unsigned long end, bool direct) { - unsigned long next; + unsigned long next, pages = 0; pte_t *pte_base; pmd_t *pmd; @@ -791,19 +794,22 @@ static void __meminit remove_pmd_table(pmd_t *pmd_start, unsigned long addr, continue; } pte_clear(&init_mm, addr, (pte_t *)pmd); + pages++; continue; } pte_base = (pte_t *)pmd_page_vaddr(*pmd); - remove_pte_table(pte_base, addr, next); + remove_pte_table(pte_base, addr, next, direct); free_pte_table(pte_base, pmd); } + if (direct) + update_page_count(MMU_PAGE_2M, -pages); } static void __meminit remove_pud_table(pud_t *pud_start, unsigned long addr, - unsigned long end) + unsigned long end, bool direct) { - unsigned long next; + unsigned long next, pages = 0; pmd_t *pmd_base; pud_t *pud; @@ -821,16 +827,20 @@ static void __meminit remove_pud_table(pud_t *pud_start, unsigned long addr, continue; } pte_clear(&init_mm, addr, (pte_t *)pud); + pages++; continue; } pmd_base = pud_pgtable(*pud); - remove_pmd_table(pmd_base, addr, next); + remove_pmd_table(pmd_base, addr, next, direct); free_pmd_table(pmd_base, pud); } + if (direct) + update_page_count(MMU_PAGE_1G, -pages); } -static void __meminit remove_pagetable(unsigned long start, unsigned long end) +static void __meminit remove_pagetable(unsigned long start, unsigned long end, + bool direct) { unsigned long addr, next; pud_t *pud_base; @@ -859,7 +869,7 @@ static void __meminit remove_pagetable(unsigned long start, unsigned long end) } pud_base = p4d_pgtable(*p4d); - remove_pud_table(pud_base, addr, next); + remove_pud_table(pud_base, addr, next, direct); free_pud_table(pud_base, p4d); } @@ -882,7 +892,7 @@ int __meminit radix__create_section_mapping(unsigned long start, int __meminit radix__remove_section_mapping(unsigned long start, unsigned long end) { - remove_pagetable(start, end); + remove_pagetable(start, end, true); return 0; } #endif /* CONFIG_MEMORY_HOTPLUG */ @@ -918,7 +928,7 @@ int __meminit radix__vmemmap_create_mapping(unsigned long start, #ifdef CONFIG_MEMORY_HOTPLUG void __meminit radix__vmemmap_remove_mapping(unsigned long start, unsigned long page_size) { - remove_pagetable(start, start + page_size); + remove_pagetable(start, start + page_size, false); } #endif #endif