mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Hungyu Lin <dennylin0707@gmail.com>
Cc: willy@infradead.org, jack@suse.cz, shr@devkernel.io,
	linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] mm/page-writeback: avoid 32-bit overflow in dirty threshold shares
Date: Tue, 20 Oct 2026 18:57:18 -0700	[thread overview]
Message-ID: <20261020185718.1d17aa486a19c4ba88a005fe@linux-foundation.org> (raw)
In-Reply-To: <20261021013046.23997-1-dennylin0707@gmail.com>

On Wed, 21 Oct 2026 01:30:46 +0000 Hungyu Lin <dennylin0707@gmail.com> wrote:

> The ratios used by __wb_calc_thresh() are scaled to parts per million,
> but the threshold and ratio operands are unsigned long. On 32-bit
> kernels, their multiplication can wrap before the result is assigned
> to u64.
> 
> For example, with a threshold of 25600 pages and the default maximum
> ratio of 1000000, wb_max_thresh becomes 4125 pages instead of 25600.
> The shared threshold and minimum share calculations can overflow in
> the same way, producing incorrect per-writeback dirty limits.
> 
> Promote the threshold before each ratio multiplication and use
> div_u64() to retain the existing division order and rounding.

Checks out, thanks.

As usual, the need for typecasting is a signal that we're using the
wrong types.  It's better to reexamine those typing choices, rather
than casting away previous mistakes.

I think that if you add a new

	u64 threshold = thresh;

then use that, things will turn out more cleanly?


      reply	other threads:[~2026-10-21  1:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21  1:30 Hungyu Lin
2026-10-21  1:57 ` Andrew Morton [this message]

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=20261020185718.1d17aa486a19c4ba88a005fe@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=dennylin0707@gmail.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=shr@devkernel.io \
    --cc=stable@vger.kernel.org \
    --cc=willy@infradead.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

all inboxes | Powered by JetHome®