linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [v4] mm: khugepaged: avoid overriding min_free_kbytes set by user
@ 2020-09-17  6:39 Vijay Balakrishna
  2020-09-17  9:28 ` Michal Hocko
  0 siblings, 1 reply; 11+ messages in thread
From: Vijay Balakrishna @ 2020-09-17  6:39 UTC (permalink / raw)
  To: Andrew Morton, Kirill A. Shutemov, Oleg Nesterov, Song Liu,
	Andrea Arcangeli, Pavel Tatashin, Vijay Balakrishna,
	Michal Hocko, Allen Pais
  Cc: linux-kernel, linux-mm

set_recommended_min_free_kbytes need to honor min_free_kbytes set by the
user.  Post start-of-day THP enable or memory hotplug operations can
lose user specified min_free_kbytes, in particular when it is higher than
calculated recommended value.

Signed-off-by: Vijay Balakrishna <vijayb@linux.microsoft.com>
Cc: stable@vger.kernel.org
Reviewed-by: Pavel Tatashin <pasha.tatashin@soleen.com>
---
 mm/khugepaged.c | 3 ++-
 mm/page_alloc.c | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 4f7107476a6f..888802e85162 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -2283,7 +2283,8 @@ static void set_recommended_min_free_kbytes(void)
 			      (unsigned long) nr_free_buffer_pages() / 20);
 	recommended_min <<= (PAGE_SHIFT-10);
 
-	if (recommended_min > min_free_kbytes) {
+	if (recommended_min > min_free_kbytes ||
+	    recommended_min > user_min_free_kbytes) {
 		if (user_min_free_kbytes >= 0)
 			pr_info("raising min_free_kbytes from %d to %lu to help transparent hugepage allocations\n",
 				min_free_kbytes, recommended_min);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index fab5e97dc9ca..472646aef477 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -315,7 +315,7 @@ compound_page_dtor * const compound_page_dtors[NR_COMPOUND_DTORS] = {
 };
 
 int min_free_kbytes = 1024;
-int user_min_free_kbytes = -1;
+int user_min_free_kbytes;
 #ifdef CONFIG_DISCONTIGMEM
 /*
  * DiscontigMem defines memory ranges as separate pg_data_t even if the ranges
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-09-22 16:10 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17  6:39 [v4] mm: khugepaged: avoid overriding min_free_kbytes set by user Vijay Balakrishna
2020-09-17  9:28 ` Michal Hocko
2020-09-17  9:34   ` Michal Hocko
2020-09-17 17:27   ` Vijay Balakrishna
2020-09-17 17:52     ` Michal Hocko
2020-09-17 18:16       ` Vijay Balakrishna
2020-09-18  5:56         ` Michal Hocko
2020-09-21 19:07           ` Vijay Balakrishna
2020-09-22  7:07             ` Kirill A. Shutemov
2020-09-22 10:07               ` Michal Hocko
2020-09-22 16:10                 ` Vijay Balakrishna

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).