From: Lance Yang <lance.yang@linux.dev>
To: Wei Yang <richard.weiyang@gmail.com>
Cc: linux-mm@kvack.org, lorenzo.stoakes@oracle.com,
baohua@kernel.org, ryan.roberts@arm.com, Liam.Howlett@oracle.com,
dev.jain@arm.com, david@redhat.com, npache@redhat.com,
ziy@nvidia.com, akpm@linux-foundation.org,
baolin.wang@linux.alibaba.com
Subject: Re: [PATCH] mm/khugepaged: use [pmd|pte]_addr for better reading
Date: Sat, 20 Sep 2025 20:42:52 +0800 [thread overview]
Message-ID: <05363b2b-f6f2-4743-9620-7f906ec16138@linux.dev> (raw)
In-Reply-To: <20250920090023.52b4mupfa6dkhtnz@master>
On 2025/9/20 17:00, Wei Yang wrote:
> On Sat, Sep 20, 2025 at 12:30:52PM +0800, Lance Yang wrote:
>>
>> On 2025/9/20 08:54, Wei Yang wrote:
>>> When collapse a pmd, there are two address in use:
>>>
>>> * address points to the start of pmd
>>> * address points to each individual page
>>>
>>> Current naming is not easy to distinguish these two and error prone.
>>>
>>> Name the first one to pmd_addr and second one to pte_addr.
>>>
>>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>>> Suggested-by: David Hildenbrand <david@redhat.com>
>>
>> This renaming makes the code much easier to follow, but just
>> some minor style nits below :)
>>
>> Acked-by: Lance Yang <lance.yang@linux.dev>
>>
>>> ---
>>> mm/khugepaged.c | 43 ++++++++++++++++++++++---------------------
>>> 1 file changed, 22 insertions(+), 21 deletions(-)
>>>
>>> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
>>> index 4c957ce788d1..6d03072c1a92 100644
>>> --- a/mm/khugepaged.c
>>> +++ b/mm/khugepaged.c
>>> @@ -537,18 +537,19 @@ static void release_pte_pages(pte_t *pte, pte_t *_pte,
>>> }
>>> static int __collapse_huge_page_isolate(struct vm_area_struct *vma,
>>> - unsigned long address,
>>> + unsigned long pmd_addr,
>>> pte_t *pte,
>>> struct collapse_control *cc,
>>> struct list_head *compound_pagelist)
>>> {
>>> struct page *page = NULL;
>>> struct folio *folio = NULL;
>>> + unsigned long pte_addr = pmd_addr;
>>> pte_t *_pte;
>>> int none_or_zero = 0, shared = 0, result = SCAN_FAIL, referenced = 0;
>>
>> Nit: could we refactor this block into the "reverse christmas tree" style?
>>
>
> You mean sth like this?
>
> int none_or_zero = 0, shared = 0, result = SCAN_FAIL, referenced = 0;
> struct page *page = NULL;
> struct folio *folio = NULL;
> unsigned long pte_addr = pmd_addr;
> pte_t *_pte;
That's getting closer. The formatting would be something like this:
int none_or_zero = 0, shared = 0, result = SCAN_FAIL, referenced = 0;
unsigned long pte_addr = pmd_addr;
struct folio *folio = NULL;
struct page *page = NULL;
pte_t *_pte;
Feel free to change it :)
next prev parent reply other threads:[~2025-09-20 12:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-20 0:54 Wei Yang
2025-09-20 4:30 ` Lance Yang
2025-09-20 9:00 ` Wei Yang
2025-09-20 12:42 ` Lance Yang [this message]
2025-09-20 4:51 ` Dev Jain
2025-09-20 9:02 ` Wei Yang
2025-09-20 12:31 ` Dev Jain
2025-09-22 8:12 ` Wei Yang
2025-09-22 8:16 ` David Hildenbrand
2025-09-22 8:26 ` Dev Jain
2025-09-22 13:02 ` Wei Yang
2025-09-22 13:28 ` David Hildenbrand
2025-09-22 13:32 ` Wei Yang
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=05363b2b-f6f2-4743-9620-7f906ec16138@linux.dev \
--to=lance.yang@linux.dev \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@redhat.com \
--cc=dev.jain@arm.com \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=npache@redhat.com \
--cc=richard.weiyang@gmail.com \
--cc=ryan.roberts@arm.com \
--cc=ziy@nvidia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox