On Tue 28-11-17 18:33:02, Yafang Shao wrote: > 2017-11-28 18:25 GMT+08:00 Jan Kara <jack@xxxxxxx>: > > Hi Yafang, > > > > On Tue 28-11-17 11:11:40, Yafang Shao wrote: > >> What about bellow change ? > >> It makes the function domain_dirty_limits() more clear. > >> And the result will have a higher precision. > > > > Frankly, I don't find this any better and you've just lost the additional > > precision of ratios computed in the "if (gdtc)" branch the multiplication by > > PAGE_SIZE got us. > > > > What about bellow change? It won't be lost any more, becasue > bytes and bg_bytes are both PAGE_SIZE aligned. > > - if (bytes) > - ratio = min(DIV_ROUND_UP(bytes, global_avail), > - PAGE_SIZE); > - if (bg_bytes) > - bg_ratio = min(DIV_ROUND_UP(bg_bytes, global_avail), > - PAGE_SIZE); > + if (bytes) { > + pages = DIV_ROUND_UP(bytes, PAGE_SIZE); > + ratio = DIV_ROUND_UP(pages * 100, global_avail); > + > + } > + > + if (bg_bytes) { > + pages = DIV_ROUND_UP(bg_bytes, PAGE_SIZE); > + bg_ratio = DIV_ROUND_UP(pages * 100, global_avail); > + } Not better... Look, in the original code the 'ratio' and 'bg_ratio' variables contain a number between 0 and 1 as fractions of 1/PAGE_SIZE. In your code you have in these variables fractions of 1/100. That's certainly less precise no matter how you get to those numbers. Honza -- Jan Kara <jack@xxxxxxxx> SUSE Labs, CR -- 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>