Re: [RFC PATCH v4 3/9] mm: Hot page tracking and promotion
From: Bharata B Rao
Date: Thu Jan 01 2026 - 03:54:40 EST
On 22-Dec-25 3:47 PM, Alok Rathore wrote:
<snip>
>> +
>> +#define PGHOT_NID_WIDTH 10
>> +#define PGHOT_FREQ_WIDTH 3
>> +/* time is stored in 19 bits which can represent up to 8.73s with HZ=1000 */
>
> If we consider HZ = 1000 then using 19 bit time is coming 8.73 mins. I think by
> mistake you commented as 8.73 secs.
Yes you are right.
>
> Suggetion:
> If we are targeting to promote page in ~8 secs then 13 bits would be enough,
> that way we can handle hotness using 32 bits per pfn insead of 64 bits.
Right, we will have to figure out how many seconds would be ideal and it needn't
be in minutes and hence we should be able to fit everything within 32 bits.
Based on the discussions in Dec 18 Linux Memory Hotness and Promotion
call, I will check if I can reduce the overhead further and have a configurable
precision mode.
>
> #define PGHOT_MIGRATE_READY 31
> #define PGHOT_NID_WIDTH 10
> #define PGHOT_FREQ_WIDTH 3
> /* time is stored in 13 bits which can represent up to 8.19s with HZ=1000 */
> #define PGHOT_TIME_WIDTH 13
>
>> +#define PGHOT_TIME_WIDTH 19
>> +
>> +#define PGHOT_NID_SHIFT 0
>> +#define PGHOT_FREQ_SHIFT (PGHOT_NID_SHIFT + PGHOT_NID_WIDTH)
>> +#define PGHOT_TIME_SHIFT (PGHOT_FREQ_SHIFT + PGHOT_FREQ_WIDTH)
>> +
>> +#define PGHOT_NID_MASK ((1UL << PGHOT_NID_SHIFT) - 1)
>> +#define PGHOT_FREQ_MASK ((1UL << PGHOT_FREQ_SHIFT) - 1)
>> +#define PGHOT_TIME_MASK ((1UL << PGHOT_TIME_SHIFT) - 1)
>
> Mask generation of freq, nid and time seems not correct. It should be
>
> #define PGHOT_NID_MASK ((1UL << PGHOT_NID_WIDTH) - 1)
> #define PGHOT_FREQ_MASK ((1UL << PGHOT_FREQ_WIDTH) - 1)
> #define PGHOT_TIME_MASK ((1UL << PGHOT_TIME_WIDTH) - 1)
>
> Can you please have a look?
Thanks for catching this. Will fix.
Regards,
Bharata.