* [PATCH] mm/khugepaged: use list_xxx() helper to improve readability
@ 2025-08-22 2:57 Wei Yang
2025-08-22 4:42 ` Lorenzo Stoakes
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Wei Yang @ 2025-08-22 2:57 UTC (permalink / raw)
To: akpm, david, lorenzo.stoakes, ziy, baolin.wang, npache,
ryan.roberts, dev.jain, baohua
Cc: linux-mm, Wei Yang
In general, khugepaged_scan_mm_slot() iterates khugepaged_scan.mm_head list
to get a mm_struct for collapse memory.
Use list_xxx() helper would be more obvious to the list iteration
operation.
No functional change.
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
mm/khugepaged.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index d3d4f116e14b..24e18a7f8a93 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -2402,7 +2402,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, int *result,
mm_slot = khugepaged_scan.mm_slot;
slot = &mm_slot->slot;
} else {
- slot = list_entry(khugepaged_scan.mm_head.next,
+ slot = list_first_entry(&khugepaged_scan.mm_head,
struct mm_slot, mm_node);
mm_slot = mm_slot_entry(slot, struct khugepaged_mm_slot, slot);
khugepaged_scan.address = 0;
@@ -2515,9 +2515,8 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, int *result,
* khugepaged runs here, khugepaged_exit will find
* mm_slot not pointing to the exiting mm.
*/
- if (slot->mm_node.next != &khugepaged_scan.mm_head) {
- slot = list_entry(slot->mm_node.next,
- struct mm_slot, mm_node);
+ if (!list_is_last(&slot->mm_node, &khugepaged_scan.mm_head)) {
+ slot = list_next_entry(slot, mm_node);
khugepaged_scan.mm_slot =
mm_slot_entry(slot, struct khugepaged_mm_slot, slot);
khugepaged_scan.address = 0;
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/khugepaged: use list_xxx() helper to improve readability
2025-08-22 2:57 [PATCH] mm/khugepaged: use list_xxx() helper to improve readability Wei Yang
@ 2025-08-22 4:42 ` Lorenzo Stoakes
2025-08-22 5:49 ` Dev Jain
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Lorenzo Stoakes @ 2025-08-22 4:42 UTC (permalink / raw)
To: Wei Yang
Cc: akpm, david, ziy, baolin.wang, npache, ryan.roberts, dev.jain,
baohua, linux-mm
On Fri, Aug 22, 2025 at 02:57:32AM +0000, Wei Yang wrote:
> In general, khugepaged_scan_mm_slot() iterates khugepaged_scan.mm_head list
> to get a mm_struct for collapse memory.
>
> Use list_xxx() helper would be more obvious to the list iteration
> operation.
>
> No functional change.
>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
LGTM so,
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> ---
> mm/khugepaged.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index d3d4f116e14b..24e18a7f8a93 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -2402,7 +2402,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, int *result,
> mm_slot = khugepaged_scan.mm_slot;
> slot = &mm_slot->slot;
> } else {
> - slot = list_entry(khugepaged_scan.mm_head.next,
> + slot = list_first_entry(&khugepaged_scan.mm_head,
> struct mm_slot, mm_node);
> mm_slot = mm_slot_entry(slot, struct khugepaged_mm_slot, slot);
> khugepaged_scan.address = 0;
> @@ -2515,9 +2515,8 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, int *result,
> * khugepaged runs here, khugepaged_exit will find
> * mm_slot not pointing to the exiting mm.
> */
> - if (slot->mm_node.next != &khugepaged_scan.mm_head) {
> - slot = list_entry(slot->mm_node.next,
> - struct mm_slot, mm_node);
> + if (!list_is_last(&slot->mm_node, &khugepaged_scan.mm_head)) {
> + slot = list_next_entry(slot, mm_node);
> khugepaged_scan.mm_slot =
> mm_slot_entry(slot, struct khugepaged_mm_slot, slot);
> khugepaged_scan.address = 0;
> --
> 2.34.1
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/khugepaged: use list_xxx() helper to improve readability
2025-08-22 2:57 [PATCH] mm/khugepaged: use list_xxx() helper to improve readability Wei Yang
2025-08-22 4:42 ` Lorenzo Stoakes
@ 2025-08-22 5:49 ` Dev Jain
2025-08-22 8:56 ` Baolin Wang
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Dev Jain @ 2025-08-22 5:49 UTC (permalink / raw)
To: Wei Yang, akpm, david, lorenzo.stoakes, ziy, baolin.wang, npache,
ryan.roberts, baohua
Cc: linux-mm
On 22/08/25 8:27 am, Wei Yang wrote:
> In general, khugepaged_scan_mm_slot() iterates khugepaged_scan.mm_head list
> to get a mm_struct for collapse memory.
>
> Use list_xxx() helper would be more obvious to the list iteration
> operation.
>
> No functional change.
>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> ---
>
LGTM
Reviewed-by: Dev Jain <dev.jain@arm.com>
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/khugepaged: use list_xxx() helper to improve readability
2025-08-22 2:57 [PATCH] mm/khugepaged: use list_xxx() helper to improve readability Wei Yang
2025-08-22 4:42 ` Lorenzo Stoakes
2025-08-22 5:49 ` Dev Jain
@ 2025-08-22 8:56 ` Baolin Wang
2025-08-22 9:46 ` David Hildenbrand
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Baolin Wang @ 2025-08-22 8:56 UTC (permalink / raw)
To: Wei Yang, akpm, david, lorenzo.stoakes, ziy, npache, ryan.roberts,
dev.jain, baohua
Cc: linux-mm
On 2025/8/22 10:57, Wei Yang wrote:
> In general, khugepaged_scan_mm_slot() iterates khugepaged_scan.mm_head list
> to get a mm_struct for collapse memory.
>
> Use list_xxx() helper would be more obvious to the list iteration
> operation.
>
> No functional change.
>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> ---
LGTM.
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> mm/khugepaged.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index d3d4f116e14b..24e18a7f8a93 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -2402,7 +2402,7 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, int *result,
> mm_slot = khugepaged_scan.mm_slot;
> slot = &mm_slot->slot;
> } else {
> - slot = list_entry(khugepaged_scan.mm_head.next,
> + slot = list_first_entry(&khugepaged_scan.mm_head,
> struct mm_slot, mm_node);
> mm_slot = mm_slot_entry(slot, struct khugepaged_mm_slot, slot);
> khugepaged_scan.address = 0;
> @@ -2515,9 +2515,8 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, int *result,
> * khugepaged runs here, khugepaged_exit will find
> * mm_slot not pointing to the exiting mm.
> */
> - if (slot->mm_node.next != &khugepaged_scan.mm_head) {
> - slot = list_entry(slot->mm_node.next,
> - struct mm_slot, mm_node);
> + if (!list_is_last(&slot->mm_node, &khugepaged_scan.mm_head)) {
> + slot = list_next_entry(slot, mm_node);
> khugepaged_scan.mm_slot =
> mm_slot_entry(slot, struct khugepaged_mm_slot, slot);
> khugepaged_scan.address = 0;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/khugepaged: use list_xxx() helper to improve readability
2025-08-22 2:57 [PATCH] mm/khugepaged: use list_xxx() helper to improve readability Wei Yang
` (2 preceding siblings ...)
2025-08-22 8:56 ` Baolin Wang
@ 2025-08-22 9:46 ` David Hildenbrand
2025-08-22 17:03 ` Zi Yan
2025-08-22 17:15 ` SeongJae Park
5 siblings, 0 replies; 7+ messages in thread
From: David Hildenbrand @ 2025-08-22 9:46 UTC (permalink / raw)
To: Wei Yang, akpm, lorenzo.stoakes, ziy, baolin.wang, npache,
ryan.roberts, dev.jain, baohua
Cc: linux-mm
On 22.08.25 04:57, Wei Yang wrote:
> In general, khugepaged_scan_mm_slot() iterates khugepaged_scan.mm_head list
> to get a mm_struct for collapse memory.
>
> Use list_xxx() helper would be more obvious to the list iteration
> operation.
>
> No functional change.
>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> ---
Acked-by: David Hildenbrand <david@redhat.com>
--
Cheers
David / dhildenb
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/khugepaged: use list_xxx() helper to improve readability
2025-08-22 2:57 [PATCH] mm/khugepaged: use list_xxx() helper to improve readability Wei Yang
` (3 preceding siblings ...)
2025-08-22 9:46 ` David Hildenbrand
@ 2025-08-22 17:03 ` Zi Yan
2025-08-22 17:15 ` SeongJae Park
5 siblings, 0 replies; 7+ messages in thread
From: Zi Yan @ 2025-08-22 17:03 UTC (permalink / raw)
To: Wei Yang
Cc: akpm, david, lorenzo.stoakes, baolin.wang, npache, ryan.roberts,
dev.jain, baohua, linux-mm
On 21 Aug 2025, at 22:57, Wei Yang wrote:
> In general, khugepaged_scan_mm_slot() iterates khugepaged_scan.mm_head list
> to get a mm_struct for collapse memory.
>
> Use list_xxx() helper would be more obvious to the list iteration
> operation.
>
> No functional change.
>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> ---
> mm/khugepaged.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
LGTM. Reviewed-by: Zi Yan <ziy@nvidia.com>
--
Best Regards,
Yan, Zi
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mm/khugepaged: use list_xxx() helper to improve readability
2025-08-22 2:57 [PATCH] mm/khugepaged: use list_xxx() helper to improve readability Wei Yang
` (4 preceding siblings ...)
2025-08-22 17:03 ` Zi Yan
@ 2025-08-22 17:15 ` SeongJae Park
5 siblings, 0 replies; 7+ messages in thread
From: SeongJae Park @ 2025-08-22 17:15 UTC (permalink / raw)
To: Wei Yang
Cc: SeongJae Park, akpm, david, lorenzo.stoakes, ziy, baolin.wang,
npache, ryan.roberts, dev.jain, baohua, linux-mm
On Fri, 22 Aug 2025 02:57:32 +0000 Wei Yang <richard.weiyang@gmail.com> wrote:
> In general, khugepaged_scan_mm_slot() iterates khugepaged_scan.mm_head list
> to get a mm_struct for collapse memory.
>
> Use list_xxx() helper would be more obvious to the list iteration
> operation.
Nice cleanup!
>
> No functional change.
>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Acked-by: SeongJae Park <sj@kernel.org>
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-08-22 17:15 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-22 2:57 [PATCH] mm/khugepaged: use list_xxx() helper to improve readability Wei Yang
2025-08-22 4:42 ` Lorenzo Stoakes
2025-08-22 5:49 ` Dev Jain
2025-08-22 8:56 ` Baolin Wang
2025-08-22 9:46 ` David Hildenbrand
2025-08-22 17:03 ` Zi Yan
2025-08-22 17:15 ` SeongJae Park
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).