Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,stable@vger.kernel.org,sj@kernel.org,
	jm5905938@gmail.com,evanfengff@gmail.com,devnexen@gmail.com,
	akpm@linux-foundation.org
Subject: + mm-damon-stat-avoid-32-bit-overflow-in-idle-time-milliseconds.patch added to mm-hotfixes-unstable branch
Date: Mon, 23 Nov 2026 09:48:19 -0800	[thread overview]
Message-ID: <20261123174820.1E9B91F000D0@smtp.kernel.org> (raw)
In-Reply-To: <20261123150049.81317-2-sj@kernel.org>


The patch titled
     Subject: mm/damon/stat: avoid 32-bit overflow in idle time milliseconds
has been added to the -mm mm-hotfixes-unstable branch.  Its filename is
     mm-damon-stat-avoid-32-bit-overflow-in-idle-time-milliseconds.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-damon-stat-avoid-32-bit-overflow-in-idle-time-milliseconds.patch

This patch will later appear in the mm-hotfixes-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days

------------------------------------------------------
From: David Carlier <devnexen@gmail.com>
Subject: mm/damon/stat: avoid 32-bit overflow in idle time milliseconds
Date: Mon, 23 Nov 2026 07:00:46 -0800

Patch series "mm/damon: three fixes for idle_time overflow and damos_walk()
hang".

Avoid 32-bit overflow of idle time calculation in DAMON_STAT, via
patch 1 from David Carlier.  Fix a damos_walk() hang that can happen
under certain watermarks setup and a watermarks commit internal state
overwrite issue, via patches 2 and 3 from Yifan Feng.

This is a batched reposting of separately posted and reviewed patches
for being merged into the mm.git.  Refer to changelog on each patch for
changes that were made before this reposting.


This patch (of 3):

On 32-bit, the region idle time in microseconds is computed in a long
before the division to milliseconds. It wraps once a region has been
idle for about 36 minutes regardless of the intervals, so the cold end
of memory_idle_ms_percentiles reports wrong values with flipped signs.

Do the multiplication in 64 bits and divide with div_s64() so the sign
of recently accessed regions is kept.

Link: https://lore.kernel.org/20261123150049.81317-1-sj@kernel.org
Link: https://patch.msgid.link/20261123150049.81317-2-sj@kernel.org
Fixes: e5d2585d9e85 ("mm/damon/stat: calculate and expose idle time percentiles")
Signed-off-by: David Carlier <devnexen@gmail.com>
Signed-off-by: SJ Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: SJ Park <sj@kernel.org>
Cc: Aveline Noir <jm5905938@gmail.com>
Cc: Yifan Feng <evanfengff@gmail.com>
Cc: <stable@vger.kernel.org>

 mm/damon/stat.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/mm/damon/stat.c~mm-damon-stat-avoid-32-bit-overflow-in-idle-time-milliseconds
+++ a/mm/damon/stat.c
@@ -129,8 +129,8 @@ static void damon_stat_set_idletime_perc
 		accounted_bytes += region->ar.end - region->ar.start;
 		while (next_percentile <= accounted_bytes * 100 / total_sz)
 			memory_idle_ms_percentiles[next_percentile++] =
-				damon_stat_idletime(region) *
-				(long)c->attrs.aggr_interval / USEC_PER_MSEC;
+				div_s64((s64)damon_stat_idletime(region) *
+				c->attrs.aggr_interval, USEC_PER_MSEC);
 	}
 	kfree(sorted_regions);
 }
_

Patches currently in -mm which might be from devnexen@gmail.com are

mm-damon-stat-avoid-32-bit-overflow-in-idle-time-milliseconds.patch


  reply	other threads:[~2026-11-23 17:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 15:00 [PATCH mm-hotfixes-unstable 0/3] mm/damon: three fixes for idle_time overflow and damos_walk() hang SJ Park
2026-11-23 15:00 ` [PATCH mm-hotfixes-unstable 1/3] mm/damon/stat: avoid 32-bit overflow in idle time milliseconds SJ Park
2026-11-23 17:48   ` Andrew Morton [this message]
2026-11-23 15:00 ` [PATCH mm-hotfixes-unstable 2/3] mm/damon/core: fix damos_walk() hang with zero watermarks interval SJ Park
2026-11-23 17:48   ` + mm-damon-core-fix-damos_walk-hang-with-zero-watermarks-interval.patch added to mm-hotfixes-unstable branch Andrew Morton
2026-11-23 15:00 ` [PATCH mm-hotfixes-unstable 3/3] mm/damon/core: do not overwrite wmarks.activated in damos_commit() SJ Park
2026-11-23 17:48   ` + mm-damon-core-do-not-overwrite-wmarksactivated-in-damos_commit.patch added to mm-hotfixes-unstable branch Andrew Morton

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=20261123174820.1E9B91F000D0@smtp.kernel.org \
    --to=akpm@linux-foundation.org \
    --cc=devnexen@gmail.com \
    --cc=evanfengff@gmail.com \
    --cc=jm5905938@gmail.com \
    --cc=mm-commits@vger.kernel.org \
    --cc=sj@kernel.org \
    --cc=stable@vger.kernel.org \
    /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