linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Shakeel Butt <shakeel.butt@linux.dev>
To: Kuniyuki Iwashima <kuniyu@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	 Johannes Weiner <hannes@cmpxchg.org>,
	"David S. Miller" <davem@davemloft.net>,
	 Vladimir Davydov <vdavydov.dev@gmail.com>,
	Kuniyuki Iwashima <kuni1840@gmail.com>,
	linux-mm@kvack.org,  Neal Cardwell <ncardwell@google.com>
Subject: Re: [PATCH v2] memcg: Convert memcg->socket_pressure to u64.
Date: Thu, 17 Jul 2025 13:01:22 -0700	[thread overview]
Message-ID: <kce2ox4fofu4ismtzgkrdzoqurze5h7cemrvseqot623qi2hz2@q6jrqdsipzns> (raw)
In-Reply-To: <20250717194645.1096500-1-kuniyu@google.com>

On Thu, Jul 17, 2025 at 07:46:43PM +0000, Kuniyuki Iwashima wrote:
> memcg->socket_pressure is initialised with jiffies when the memcg
> is created.
> 
> Once vmpressure detects that the cgroup is under memory pressure,
> the field is updated with jiffies + HZ to signal the fact to the
> socket layer and suppress memory allocation for one second.
> 
> Otherwise, the field is not updated.
> 
> mem_cgroup_under_socket_pressure() uses time_before() to check if
> jiffies is less than memcg->socket_pressure, and this has a bug on
> 32-bit kernel.
> 
>   if (time_before(jiffies, memcg->socket_pressure))
>           return true;
> 
> As time_before() casts the final result to long, the acceptable delta
> between two timestamps is 2 ^ (BITS_PER_LONG - 1).
> 
> On 32-bit kernel with CONFIG_HZ=1000, this is about 24 days.
> 
>   >>> (2 ** 31) / 1000 / 60 / 60 / 24
>   24.855134814814818
> 
> Once 24 days have passed since the last update of socket_pressure,
> mem_cgroup_under_socket_pressure() starts to lie until the next
> 24 days pass.
> 
> We don't need to worry about this on 64-bit machines unless they
> serve for 300 million years.
> 
>   >>> (2 ** 63) / 1000 / 60 / 60 / 24 / 365
>   292471208.6775361
> 
> Let's convert memcg->socket_pressure to u64.
> 
> Fixes: 8e8ae645249b8 ("mm: memcontrol: hook up vmpressure to socket pressure")
> Reported-by: Neal Cardwell <ncardwell@google.com>
> Suggested-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>

Acked-by: Shakeel Butt <shakeel.butt@linux.dev>


  reply	other threads:[~2025-07-17 20:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-17 19:46 Kuniyuki Iwashima
2025-07-17 20:01 ` Shakeel Butt [this message]
2025-07-18 15:38 ` Johannes Weiner

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=kce2ox4fofu4ismtzgkrdzoqurze5h7cemrvseqot623qi2hz2@q6jrqdsipzns \
    --to=shakeel.butt@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=hannes@cmpxchg.org \
    --cc=kuni1840@gmail.com \
    --cc=kuniyu@google.com \
    --cc=linux-mm@kvack.org \
    --cc=ncardwell@google.com \
    --cc=vdavydov.dev@gmail.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