lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ba4502f7-0c35-460e-a42c-d32dea9ab9eb@amd.com>
Date: Fri, 23 Jan 2026 15:03:58 +0530
From: "Garg, Shivank" <shivankg@....com>
To: Dev Jain <dev.jain@....com>, Andrew Morton <akpm@...ux-foundation.org>,
 David Hildenbrand <david@...nel.org>,
 Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
Cc: Zi Yan <ziy@...dia.com>, Baolin Wang <baolin.wang@...ux.alibaba.com>,
 "Liam R . Howlett" <Liam.Howlett@...cle.com>, Nico Pache
 <npache@...hat.com>, Ryan Roberts <ryan.roberts@....com>,
 Barry Song <baohua@...nel.org>, Lance Yang <lance.yang@...ux.dev>,
 linux-mm@...ck.org, linux-kernel@...r.kernel.org,
 Wei Yang <richard.weiyang@...il.com>,
 Anshuman Khandual <anshuman.khandual@....com>
Subject: Re: [PATCH V3 5/5] mm/khugepaged: make khugepaged_collapse_control
 static



On 1/23/2026 1:18 PM, Dev Jain wrote:
> 
> On 22/01/26 2:58 pm, Dev Jain wrote:
>> On 19/01/26 12:53 am, Shivank Garg wrote:
>>> The global variable 'khugepaged_collapse_control' is not used outside of
>>> mm/khugepaged.c. Make it static to limit its scope.
>>>
>>> Reviewed-by: Wei Yang <richard.weiyang@...il.com>
>>> Reviewed-by: Zi Yan <ziy@...dia.com>
>>> Acked-by: David Hildenbrand (Red Hat) <david@...nel.org>
>>> Reviewed-by: Anshuman Khandual <anshuman.khandual@....com>
>>> Signed-off-by: Shivank Garg <shivankg@....com>
>>> ---
>>>  mm/khugepaged.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
>>> index 1667abae6d8d..fba6aea5bea6 100644
>>> --- a/mm/khugepaged.c
>>> +++ b/mm/khugepaged.c
>>> @@ -827,7 +827,7 @@ static void khugepaged_alloc_sleep(void)
>>>  	remove_wait_queue(&khugepaged_wait, &wait);
>>>  }
>>>  
>>> -struct collapse_control khugepaged_collapse_control = {
>>> +static struct collapse_control khugepaged_collapse_control = {
>>>  	.is_khugepaged = true,
>>>  };
>>>  
>> Will it not be better to just remove this variable? In madvise_collapse,
>> we defined cc as a local variable and set .is_khugepaged = false. The
>> same can be done in int khugepaged() - define a local variable and set
>> .is_khugepaged = true.
> 
> Since this patch has been stabilized already by 4 R-bs, it may be a headache
> to now remove this, we can do my suggestion later.
> 
> Reviewed-by: Dev Jain <dev.jain@....com>
> 
>>
>>

Thank you Dev for the feedback and review.

I've attached the patch implementing your suggestion and sending this as a separate
follow-up to avoid disrupting the current series.

I’m happy to queue it for next cycle or if it’s acceptable now, please take it.

Thanks for the suggestion!

Regards,
Shivank

---
From: Shivank Garg <shivankg@....com>
Date: Thu, 22 Jan 2026 12:36:28 +0000
Subject: [PATCH] mm/khugepaged: convert khugepaged_collapse_control to local
 variable in khugepaged()

Make khugepaged_collapse_control a local variable in khugepaged() instead
of static global, consistent with how madvise_collapse() handles its
collapse_control. Static storage is unnecessary here as node_load and
alloc_nmask are reset per-VMA during scanning.

No functional change.

Suggested-by: Dev Jain <dev.jain@....com>
Signed-off-by: Shivank Garg <shivankg@....com>
---
 mm/khugepaged.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 9f790ec34400..c18d2ce639b1 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -829,10 +829,6 @@ static void khugepaged_alloc_sleep(void)
 	remove_wait_queue(&khugepaged_wait, &wait);
 }
 
-static struct collapse_control khugepaged_collapse_control = {
-	.is_khugepaged = true,
-};
-
 static bool hpage_collapse_scan_abort(int nid, struct collapse_control *cc)
 {
 	int i;
@@ -2629,13 +2625,16 @@ static void khugepaged_wait_work(void)
 
 static int khugepaged(void *none)
 {
+	struct collapse_control cc = {
+		.is_khugepaged = true,
+	};
 	struct mm_slot *slot;
 
 	set_freezable();
 	set_user_nice(current, MAX_NICE);
 
 	while (!kthread_should_stop()) {
-		khugepaged_do_scan(&khugepaged_collapse_control);
+		khugepaged_do_scan(&cc);
 		khugepaged_wait_work();
 	}
 
-- 
2.43.0





Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ