From: Quanmin Yan <yanquanmin1@huawei.com>
To: SeongJae Park <sj@kernel.org>
Cc: <akpm@linux-foundation.org>, <damon@lists.linux.dev>,
<linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>,
<wangkefeng.wang@huawei.com>, <zuoze1@huawei.com>,
<kernel-team@meta.com>, kernel test robot <lkp@intel.com>
Subject: Re: [PATCH v2 03/11] mm/damon/paddr: support addr_unit for DAMOS_PAGEOUT
Date: Thu, 28 Aug 2025 09:38:34 +0800 [thread overview]
Message-ID: <2c0477d5-217e-40fa-aa26-1dde19280779@huawei.com> (raw)
In-Reply-To: <20250827180743.47876-1-sj@kernel.org>
在 2025/8/28 2:07, SeongJae Park 写道:
> On Wed, 27 Aug 2025 19:37:38 +0800 Quanmin Yan <yanquanmin1@huawei.com> wrote:
>
>> Hi SJ,
>>
>> 在 2025/8/27 10:42, SeongJae Park 写道:
>>> On Wed, 27 Aug 2025 10:21:41 +0800 Quanmin Yan <yanquanmin1@huawei.com> wrote:
>>>
>>>> 在 2025/8/26 22:21, SeongJae Park 写道:
>>>>> On Tue, 26 Aug 2025 12:51:17 +0800 Quanmin Yan <yanquanmin1@huawei.com> wrote:
>>>>>
>>>>>> Hi SJ,
>>>>>>
>>>>>> 在 2025/8/26 11:21, SeongJae Park 写道:
> [...]
>>>> Please consider approving this fix.
>>> I'm yet in travel, and I'd like to take more time on thinking about the proper
>>> fix. Quanmin, could you share more details about your test setups, both for
>>> the compiling success case and failing case?
>> Apologies for disturbing you during your travels. Please allow me to explain:
> No worry, I'm the one who would like to apologize, for delayed response :)
> I'm back from the travel, btw.
>
>> When CONFIG_PHYS_ADDR_T_64BIT is enabled on "i386" [1], the phys_addr_t type
>> becomes 64-bit, requiring the use of the do_div function. We are in agreement
>> on this point.
>>
>> On arm32, if LPAE (which we intend to support in this series) is enabled,
>> CONFIG_PHYS_ADDR_T_64BIT will also be enabled. In this case, pa / addr_unit
>> will involve 64-bit division and similarly require the do_div function.
>> Obviously, such link errors should normally occur under these circumstances.
>> Unfortunately, the expected anomalies did not manifest in my previous tests.
>> This may be related to some incorrect adjustments I had made to my local build
>> environment quite some time ago — though I cannot be entirely certain. That
>> said, I have since cleaned up the old configurations and ensured the current
>> environment is clean and normal. For now, we have confirmed the actual problem
>> and its root cause, shall we focus on fixing it?
> Thank you for sharing the details. I wanted to better understand where the
> issue happens and not, to clearly understand the root cause and make a proper
> fix based on that. I think we can now focusing on fixing it.
>
>> In summary, after introducing addr_unit, we expect that any 32-bit architecture
>> should support monitoring of 64-bit phys_addr_t. Therefore, we can consider the
>> following adjustment:
>>
>> #if !defined(CONFIG_64BIT) && defined(CONFIG_PHYS_ADDR_T_64BIT)
>>
>> Or at least adjust it to:
>>
>> #if defined(__i386__) || (defined(__arm__) && defined(CONFIG_PHYS_ADDR_T_64BIT))
>>
>> I have thoroughly re-validated the feature functionality today and confirmed the
>> correctness of the aforementioned modifications. Therefore, could I kindly ask
>> you to consider the aforementioned modifications when you have some free time?
> Thank you for the suggestion and testing, Quanmin!
>
> I was thinking making the change for only i386 is right since I was mistakenly
> thinking the issue happens only on i386. Now it is clear I was wrong and we
> have at least two cases. And I agree your suggestion will fix both cases.
>
> But I'm bit concerned i386 and arm might not all the case, so wannt make the
> fix more generalized. My understanding of the problem, which is enlightened
> thanks to you, is that not every config supports dividing 64 bit with 32 bit.
> And div_u64() is suggested in general for dividing 64 bit with 32 bit. So,
> what about making the if condition more general but specific to the root cause,
> like below?
>
> static unsigned long damon_pa_core_addr(
> phys_addr_t pa, unsigned long addr_unit)
> {
> /*
> * Use div_u64() for avoiding linking errors related with __udivdi3,
> * __aeabi_uldivmod, or similar problems. This should also improve the
> * performance optimization (read div_u64() comment for the detail).
> */
> if (sizeof(pa) == 8 && sizeof(addr_unit) == 4)
> return div_u64(pa, addr_unit);
> return pa / addr_unit;
> }
>
> Because the sizeof() result can be known at compile time, I think it shouldn't
> cause the linking time error, and I confirmed that by passing the i386 test
> case that kernel test robot shared.
>
> Could I ask your opinion, Quanmin? If you think that works, I could post v3 of
> this patch series with the above fix.
Great! I believe this approach is better. This modification is more generic
and eliminates the need to deal with those messy configs.
I have also re-validated based on this change, and it is working correctly.
Thanks,
Quanmin Yan
next prev parent reply other threads:[~2025-08-28 1:38 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-22 9:34 [PATCH v2 00/11] mm/damon: support ARM32 with LPAE Quanmin Yan
2025-08-22 9:34 ` [PATCH v2 01/11] mm/damon/core: add damon_ctx->addr_unit Quanmin Yan
2025-08-22 9:34 ` [PATCH v2 02/11] mm/damon/paddr: support addr_unit for access monitoring Quanmin Yan
2025-08-22 9:34 ` [PATCH v2 03/11] mm/damon/paddr: support addr_unit for DAMOS_PAGEOUT Quanmin Yan
2025-08-25 15:12 ` SeongJae Park
2025-08-26 3:16 ` Quanmin Yan
2025-08-26 3:21 ` SeongJae Park
2025-08-26 4:51 ` Quanmin Yan
2025-08-26 14:21 ` SeongJae Park
2025-08-27 2:21 ` Quanmin Yan
2025-08-27 2:42 ` SeongJae Park
2025-08-27 3:38 ` Andrew Morton
2025-08-27 11:37 ` Quanmin Yan
2025-08-27 18:07 ` SeongJae Park
2025-08-28 1:38 ` Quanmin Yan [this message]
2025-08-28 3:22 ` SeongJae Park
2025-08-22 9:34 ` [PATCH v2 04/11] mm/damon/paddr: support addr_unit for DAMOS_LRU_[DE]PRIO Quanmin Yan
2025-08-25 15:13 ` SeongJae Park
2025-08-26 3:06 ` SeongJae Park
2025-08-22 9:34 ` [PATCH v2 05/11] mm/damon/paddr: support addr_unit for MIGRATE_{HOT,COLD} Quanmin Yan
2025-08-25 15:15 ` SeongJae Park
2025-08-22 9:34 ` [PATCH v2 06/11] mm/damon/paddr: support addr_unit for DAMOS_STAT Quanmin Yan
2025-08-22 9:34 ` [PATCH v2 07/11] mm/damon/sysfs: implement addr_unit file under context dir Quanmin Yan
2025-08-22 9:34 ` [PATCH v2 08/11] Docs/mm/damon/design: document 'address unit' parameter Quanmin Yan
2025-08-22 9:34 ` [PATCH v2 09/11] Docs/admin-guide/mm/damon/usage: document addr_unit file Quanmin Yan
2025-08-22 9:34 ` [PATCH v2 10/11] Docs/ABI/damon: " Quanmin Yan
2025-08-22 9:34 ` [PATCH v2 11/11] mm/damon: add damon_ctx->min_sz_region Quanmin Yan
2025-08-22 17:19 ` SeongJae Park
2025-08-22 17:21 ` [PATCH v2 00/11] mm/damon: support ARM32 with LPAE SeongJae Park
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=2c0477d5-217e-40fa-aa26-1dde19280779@huawei.com \
--to=yanquanmin1@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
--cc=sj@kernel.org \
--cc=wangkefeng.wang@huawei.com \
--cc=zuoze1@huawei.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;
as well as URLs for NNTP newsgroup(s).