All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bharata B Rao <bharata@amd.com>
To: <linux-mm@kvack.org>
Cc: <linux-kernel@vger.kernel.org>, <akpm@linux-foundation.org>,
	<mingo@redhat.com>, <peterz@infradead.org>,
	<mgorman@techsingularity.net>, <raghavendra.kt@amd.com>,
	<ying.huang@intel.com>, <dave.hansen@linux.intel.com>,
	<hannes@cmpxchg.org>, Bharata B Rao <bharata@amd.com>
Subject: [RFC PATCH 2/2] mm: Update hint fault count for pages that are skipped during scanning
Date: Wed, 27 Mar 2024 21:32:37 +0530	[thread overview]
Message-ID: <20240327160237.2355-3-bharata@amd.com> (raw)
In-Reply-To: <20240327160237.2355-1-bharata@amd.com>

During scanning, PTE updates are skipped for those pages which
are already marked as PROT_NONE. This is required but update the
scan time fault count so that the fault count which is used to
calculate the latency is kept uptodate based on the recent
scanning iteration.

Signed-off-by: Bharata B Rao <bharata@amd.com>
---
 mm/huge_memory.c | 7 ++++---
 mm/mprotect.c    | 9 +++++----
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 7e62c3c2bbcb..24a4f976323e 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2086,9 +2086,6 @@ int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
 		if (is_huge_zero_pmd(*pmd))
 			goto unlock;
 
-		if (pmd_protnone(*pmd))
-			goto unlock;
-
 		folio = page_folio(pmd_page(*pmd));
 		toptier = node_is_toptier(folio_nid(folio));
 		/*
@@ -2102,6 +2099,10 @@ int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
 		if (sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING &&
 		    !toptier)
 			folio_xchg_fault_count(folio, atomic_read(&mm->hint_faults));
+
+		if (pmd_protnone(*pmd))
+			goto unlock;
+
 	}
 	/*
 	 * In case prot_numa, we are under mmap_read_lock(mm). It's critical
diff --git a/mm/mprotect.c b/mm/mprotect.c
index 30118fd492f4..cfd3812302be 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -118,10 +118,6 @@ static long change_pte_range(struct mmu_gather *tlb,
 				int nid;
 				bool toptier;
 
-				/* Avoid TLB flush if possible */
-				if (pte_protnone(oldpte))
-					continue;
-
 				folio = vm_normal_folio(vma, addr, oldpte);
 				if (!folio || folio_is_zone_device(folio) ||
 				    folio_test_ksm(folio))
@@ -162,6 +158,11 @@ static long change_pte_range(struct mmu_gather *tlb,
 					folio_xchg_fault_count(folio,
 							atomic_read(&vma->vm_mm->hint_faults));
 
+				/* Avoid TLB flush if possible */
+				if (pte_protnone(oldpte))
+					continue;
+
+
 			}
 
 			oldpte = ptep_modify_prot_start(vma, addr, pte);
-- 
2.25.1


  parent reply	other threads:[~2024-03-27 16:03 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-27 16:02 [RFC PATCH 0/2] Hot page promotion optimization for large address space Bharata B Rao
2024-03-27 16:02 ` [RFC PATCH 1/2] sched/numa: Fault count based NUMA hint fault latency Bharata B Rao
2024-03-28  1:56   ` Huang, Ying
2024-03-28  4:39     ` Bharata B Rao
2024-03-28  5:21       ` Huang, Ying
2024-03-30  1:11   ` kernel test robot
2024-03-30  3:47   ` kernel test robot
2024-03-27 16:02 ` Bharata B Rao [this message]
2024-03-28  5:35 ` [RFC PATCH 0/2] Hot page promotion optimization for large address space Huang, Ying
2024-03-28  5:49   ` Bharata B Rao
2024-03-28  6:03     ` Huang, Ying
2024-03-28  6:29       ` Bharata B Rao
2024-03-29  1:14         ` Huang, Ying
2024-04-01 12:20           ` Bharata B Rao
2024-04-02  2:03             ` Huang, Ying
2024-04-02  9:26               ` Bharata B Rao
2024-04-03  8:40                 ` Huang, Ying
2024-04-12  4:00                   ` Bharata B Rao
2024-04-12  7:28                     ` Huang, Ying
2024-04-12  8:16                       ` Bharata B Rao
2024-04-12  8:48                         ` Huang, Ying

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240327160237.2355-3-bharata@amd.com \
    --to=bharata@amd.com \
    --cc=akpm@linux-foundation.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=raghavendra.kt@amd.com \
    --cc=ying.huang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.