thank you Ying, it's a new record, i get a reviewed-by in 5 minutes ________________________________ From: Huang, Ying Sent: Tuesday, June 10, 2025 2:33:10 PM To: Li, Zhijian/Àî ÖǼá Cc: linux-mm@kvack.org ; akpm@linux-foundation.org ; linux-kernel@vger.kernel.org ; Ying Huang Subject: Re: [PATCH] mm/memory-tier: Fix abstract distance calculation overflow Li Zhijian writes: > In mt_perf_to_adistance(), the calculation of abstract distance (adist) > involves multiplying several int values including MEMTIER_ADISTANCE_DRAM. > ``` > *adist = MEMTIER_ADISTANCE_DRAM * > (perf->read_latency + perf->write_latency) / > (default_dram_perf.read_latency + default_dram_perf.write_latency) * > (default_dram_perf.read_bandwidth + default_dram_perf.write_bandwidth) / > (perf->read_bandwidth + perf->write_bandwidth); > ``` > Since these values can be large, the multiplication may exceed the maximum > value of an int (INT_MAX) and overflow (Our platform did), leading to an > incorrect adist. > > Change MEMTIER_ADISTANCE_DRAM to be a long constant by writing it with the > 'L' suffix. This prevents the overflow because the multiplication will then > be done in the long type which has a larger range. > > Fixes: 3718c02dbd4c ("acpi, hmat: calculate abstract distance with HMAT") > Cc: Ying Huang > Signed-off-by: Li Zhijian Good catch! Feel free to add Reviewed-by: Huang Ying in the future version. --- Best Regards, Huang, Ying [snip]