linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Zhijian Li (Fujitsu)" <lizhijian@fujitsu.com>
To: "Huang, Ying" <ying.huang@linux.alibaba.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Ying Huang <huang.ying.caritas@gmail.com>
Subject: Re: [PATCH] mm/memory-tier: Fix abstract distance calculation overflow
Date: Tue, 10 Jun 2025 06:39:47 +0000	[thread overview]
Message-ID: <TY1PR01MB1562CC57749CCB5FDEBB0B2FA56AA@TY1PR01MB1562.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <877c1kcdi1.fsf@DESKTOP-5N7EMDA>

[-- Attachment #1: Type: text/plain, Size: 1824 bytes --]


thank you Ying, it's a new record, i get a reviewed-by in 5 minutes


________________________________
From: Huang, Ying <ying.huang@linux.alibaba.com>
Sent: Tuesday, June 10, 2025 2:33:10 PM
To: Li, Zhijian/李 智坚 <lizhijian@fujitsu.com>
Cc: linux-mm@kvack.org <linux-mm@kvack.org>; akpm@linux-foundation.org <akpm@linux-foundation.org>; linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>; Ying Huang <huang.ying.caritas@gmail.com>
Subject: Re: [PATCH] mm/memory-tier: Fix abstract distance calculation overflow

Li Zhijian <lizhijian@fujitsu.com> 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 <huang.ying.caritas@gmail.com>
> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>

Good catch!  Feel free to add

Reviewed-by: Huang Ying <ying.huang@linux.alibaba.com>

in the future version.

---
Best Regards,
Huang, Ying

[snip]

[-- Attachment #2: Type: text/html, Size: 3201 bytes --]

  reply	other threads:[~2025-06-10  6:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-10  6:27 Li Zhijian
2025-06-10  6:33 ` Huang, Ying
2025-06-10  6:39   ` Zhijian Li (Fujitsu) [this message]
2025-06-10  6:40 ` Balbir Singh
2025-06-10  8:14 ` Donet Tom
2025-06-10 18:45 ` Oscar Salvador
2025-06-10 21:02 ` Andrew Morton
2025-06-11  2:34 ` [PATCH v2] " Li Zhijian

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=TY1PR01MB1562CC57749CCB5FDEBB0B2FA56AA@TY1PR01MB1562.jpnprd01.prod.outlook.com \
    --to=lizhijian@fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=huang.ying.caritas@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ying.huang@linux.alibaba.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