Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1385932pxj; Wed, 19 May 2021 05:05:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZX3FOLTG032r1ECSt7ibiFeKF1j1CrpViYe8BdfcNzKu41lVPrtOVcYWdig+5EhC7JVS5 X-Received: by 2002:a17:906:16d2:: with SMTP id t18mr11639278ejd.277.1621425957237; Wed, 19 May 2021 05:05:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621425957; cv=none; d=google.com; s=arc-20160816; b=wcit6pnp8dn4U2rleUoT47gIzBzMPphUgArfLGUoxcsPJdvkURrqyz4fIpZ+WHHkmj i23N9pQrv/4Zdo4TPdKagFOTUVp+ZVt5OydPgnHYArn8OSE//WIZhzVObAVpSUqUU8Bf X2J9rZ3Ov/zC6tI8SgfS7AuzmvTazr369cMtNp5Ji+p5emVuSiWyum1uWjoQcv5DGcJA V5wciN+o+qcfJ0Y6cbudVynhtSKAP4i3akATaFEGEQdgvmlKDBUxyZY5rH2NhYywzMkR Yxz+XkiQhAZPB4B35IlaMvjN9Jzx3p+wm/+eOpUhOb2hGiDQ8hYgNIcaBDrI7ZMYoaF0 j0tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=oGyoQZ4OUXeVA6v403FNp6TK38ni7y+Xi3ud+0Z9evc=; b=kl1+DgyyHo6gxznElQ45a1NtGYZFYyBAFPk2AOS0JfxTe09u3DRWiNtZAGmquwkig5 GLA6fAb+vGNmQ1GFBHXt5WhEYlVsX4qlBdPMyxJCxCjm7FjtWlTghxNtkIlCMI6sSJwK u64+plhQn65Iobl3ZVfpAtCRZ7q5n4Z0zctonS8fhnHdiuA6L0ckTyhdkpO5DRPeEhIh YaHCH8aNYDK4T5hIvihClzyxwnS7E2Yn/iPA8Yh4T+5RaUrtNpKPOR8haFtWeJgU8Zvf 97rlAp4Cns+zvAtGYuo4fXTmJtsI4vJnJaseNjbHe1myxAmReatc5Ozujef8lWTqYhhA rQGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a90si21313245edf.408.2021.05.19.05.05.32; Wed, 19 May 2021 05:05:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245638AbhEREtC (ORCPT + 99 others); Tue, 18 May 2021 00:49:02 -0400 Received: from foss.arm.com ([217.140.110.172]:41000 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241545AbhEREtC (ORCPT ); Tue, 18 May 2021 00:49:02 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AD9E231B; Mon, 17 May 2021 21:47:44 -0700 (PDT) Received: from p8cg001049571a15.arm.com (unknown [10.163.79.24]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C52503F73D; Mon, 17 May 2021 21:47:42 -0700 (PDT) From: Anshuman Khandual To: linux-mm@kvack.org, akpm@linux-foundation.org Cc: Anshuman Khandual , Zi Yan , linux-kernel@vger.kernel.org Subject: [PATCH] mm/thp: Update mm_struct's MM_ANONPAGES stat for huge zero pages Date: Tue, 18 May 2021 10:18:20 +0530 Message-Id: <1621313300-1118-1-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Although the zero huge page is being shared across various processes, each mapping needs to update its mm_struct's MM_ANONPAGES stat by HPAGE_PMD_NR to be consistent. This just updates the stats in set_huge_zero_page() after the mapping gets created and in zap_huge_pmd() when mapping gets destroyed. Cc: Andrew Morton Cc: Zi Yan Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- This applies on v5.13-rc2. Changes in V1: - Updated MM_ANONPAGES stat in zap_huge_pmd() - Updated the commit message Changes in RFC: https://lore.kernel.org/linux-mm/1620890438-9127-1-git-send-email-anshuman.khandual@arm.com/ mm/huge_memory.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 63ed6b25deaa..306d0a41bf75 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -706,6 +706,7 @@ static void set_huge_zero_page(pgtable_t pgtable, struct mm_struct *mm, if (pgtable) pgtable_trans_huge_deposit(mm, pmd, pgtable); set_pmd_at(mm, haddr, pmd, entry); + add_mm_counter(mm, MM_ANONPAGES, HPAGE_PMD_NR); mm_inc_nr_ptes(mm); } @@ -1678,6 +1679,7 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, tlb_remove_page_size(tlb, pmd_page(orig_pmd), HPAGE_PMD_SIZE); } else if (is_huge_zero_pmd(orig_pmd)) { zap_deposited_table(tlb->mm, pmd); + add_mm_counter(tlb->mm, MM_ANONPAGES, -HPAGE_PMD_NR); spin_unlock(ptl); tlb_remove_page_size(tlb, pmd_page(orig_pmd), HPAGE_PMD_SIZE); } else { -- 2.20.1