linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Wei Yang <richard.weiyang@gmail.com>
To: Lance Yang <lance.yang@linux.dev>
Cc: Wei Yang <richard.weiyang@gmail.com>,
	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 09:00:23 +0000	[thread overview]
Message-ID: <20250920090023.52b4mupfa6dkhtnz@master> (raw)
In-Reply-To: <b1a8925b-8bb6-43b2-81e8-abb377905d48@linux.dev>

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;

-- 
Wei Yang
Help you, Help me


  reply	other threads:[~2025-09-20  9:00 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 [this message]
2025-09-20 12:42     ` Lance Yang
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=20250920090023.52b4mupfa6dkhtnz@master \
    --to=richard.weiyang@gmail.com \
    --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=lance.yang@linux.dev \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=npache@redhat.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