The patch titled Subject: math64: prevent double calculation of DIV64_U64_ROUND_UP() arguments has been added to the -mm tree. Its filename is mm-dont-miss-the-last-page-because-of-round-off-error-fix.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-dont-miss-the-last-page-because-of-round-off-error-fix.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-dont-miss-the-last-page-because-of-round-off-error-fix.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Roman Gushchin <guro@xxxxxx> Subject: math64: prevent double calculation of DIV64_U64_ROUND_UP() arguments Cause the DIV64_U64_ROUND_UP(ll, d) macro to cache the result of (d) expression in a local variable to avoid double calculation, which might bring unexpected side effects. Link: http://lkml.kernel.org/r/20180829213311.GA13501@castle Signed-off-by: Roman Gushchin <guro@xxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxxxx> Cc: Tejun Heo <tj@xxxxxxxxxx> Cc: Rik van Riel <riel@xxxxxxxxxxx> Cc: Konstantin Khlebnikov <koct9i@xxxxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/math64.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/include/linux/math64.h~mm-dont-miss-the-last-page-because-of-round-off-error-fix +++ a/include/linux/math64.h @@ -281,6 +281,7 @@ static inline u64 mul_u64_u32_div(u64 a, } #endif /* mul_u64_u32_div */ -#define DIV64_U64_ROUND_UP(ll, d) div64_u64((ll) + (d) - 1, (d)) +#define DIV64_U64_ROUND_UP(ll, d) \ + ({ u64 _tmp = (d); div64_u64((ll) + _tmp - 1, _tmp); }) #endif /* _LINUX_MATH64_H */ _ Patches currently in -mm which might be from guro@xxxxxx are mm-rework-memcg-kernel-stack-accounting.patch mm-drain-memcg-stocks-on-css-offlining.patch mm-dont-miss-the-last-page-because-of-round-off-error.patch mm-dont-miss-the-last-page-because-of-round-off-error-fix.patch