From: "zhen.ni" <zhen.ni@easystack.cn>
To: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: akpm@linux-foundation.org, david@redhat.com,
Liam.Howlett@oracle.com, vbabka@suse.cz, rppt@kernel.org,
surenb@google.com, mhocko@suse.com, linux-mm@kvack.org
Subject: Re: [PATCH] mm: Refactor vm_mixed_ok() for more maintainable
Date: Tue, 21 Oct 2025 18:20:43 +0800 [thread overview]
Message-ID: <e370f185-de84-41ab-87b5-99f849b6e047@easystack.cn> (raw)
In-Reply-To: <abd79c61-8782-442e-b2e5-d3019a633ad3@lucifer.local>
在 2025/10/21 17:14, Lorenzo Stoakes 写道:
> On Tue, Oct 21, 2025 at 04:53:28PM +0800, Zhen Ni wrote:
>> Restructure the function without altering its logic:
>> - Check the VM_MIXEDMAP flag first as a fast path.
>> - Consolidate the zero page handling logic into a single, dedicated
>> block.
>>
>> These changes improve code organization and maintainability.
>>
>> Signed-off-by: Zhen Ni <zhen.ni@easystack.cn>
>
> The below is just incorrect and you're making the function _harder_ to read
> not easier.
>
>> ---
>> mm/memory.c | 11 +++++++----
>> 1 file changed, 7 insertions(+), 4 deletions(-)
>>
>
> You're changing the logic now? This is incorrect? If the conditions you removed
> are true but also vma->vm_flags & VM_MIXEDMAP is true you now return true rather
> than false?
>
>> - if (is_zero_pfn(pfn))
>> + if (unlikely(is_zero_pfn(pfn))) {
>> + /* Zero pages can only be mapped read-only and if VMA
>> + * allows them.
>> + */
>
> We don't start comments with /* xxxx, we do:
>
> /*
> * Zero pages ...
> */
>
>> + if (mkwrite || !vm_mixed_zeropage_allowed(vma))
>> + return false;
>
> Yeah this is just wrong. Plus you're now inserting an additional level of
> indentation?
>
>> return true;
>> + }
>> return false;
>> }
>>
>> --
>> 2.20.1
>>
>>
>
Hi,
Thank you for the thorough review and for pointing out the critical
logicerror I introduced.
You are absolutely right - my refactoring incorrectly changed the
function behavior when both VM_MIXEDMAP is set and we have a zero page
with mkwrite or mixed mapping restrictions. I apologize for this oversight.
I will drop this patch since:
1. The refactoring introduced a functional regression
2. As you noted, the original code is actually more readable
3. The change doesn't provide meaningful maintainability improvement
Best regards,
Zhen
prev parent reply other threads:[~2025-10-21 10:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-21 8:53 [PATCH] mm: Refactor vm_mixed_ok() for more maintainable Zhen Ni
2025-10-21 9:14 ` Lorenzo Stoakes
2025-10-21 10:20 ` zhen.ni [this message]
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=e370f185-de84-41ab-87b5-99f849b6e047@easystack.cn \
--to=zhen.ni@easystack.cn \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhocko@suse.com \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.