Re: undefined shift in wb_update_dirty_ratelimit()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]