linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Andrey Ryabinin <aryabinin@odin.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>,
	Dmitry Vyukov <dvyukov@google.com>,
	Sasha Levin <sasha.levin@oracle.com>
Subject: Re: undefined shift in wb_update_dirty_ratelimit()
Date: Mon, 7 Dec 2015 09:26:21 -0500	[thread overview]
Message-ID: <20151207142621.GA7012@mtj.duckdns.org> (raw)
In-Reply-To: <566594E2.3050306@odin.com>

Hello, Andrey.

On Mon, Dec 07, 2015 at 05:17:06PM +0300, Andrey Ryabinin wrote:
> I've hit undefined shift in wb_update_dirty_ratelimit() which does some
> mysterious 'step' calculations:
> 
> 	/*
> 	 * Don't pursue 100% rate matching. It's impossible since the balanced
> 	 * rate itself is constantly fluctuating. So decrease the track speed
> 	 * when it gets close to the target. Helps eliminate pointless tremors.
> 	 */
> 	step >>= dirty_ratelimit / (2 * step + 1);
> 
> 
> dirty_ratelimit = INIT_BW and step = 0 results in this:
> 
> [ 5006.957366] ================================================================================
> [ 5006.957798] UBSAN: Undefined behaviour in ../mm/page-writeback.c:1286:7
> [ 5006.958091] shift exponent 25600 is too large for 64-bit type 'long unsigned int'

We prolly should do sth like

	shift = dirty_ratelimit / (2 * step = 1);
	if (shift < BITS_PER_LONG) {
		step = (step >> shift) + 7 / 8;
	} else {
		step = 0;
	}

Thanks.

-- 
tejun

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2015-12-07 14:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-07 14:17 Andrey Ryabinin
2015-12-07 14:26 ` Tejun Heo [this message]
2015-12-12 23:17   ` Andy Shevchenko
2016-01-25 14:11 ` [PATCH] mm/page-writeback: fix dirty_ratelimit calculation Andrey Ryabinin

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=20151207142621.GA7012@mtj.duckdns.org \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=aryabinin@odin.com \
    --cc=dvyukov@google.com \
    --cc=fengguang.wu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sasha.levin@oracle.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