]> git.ipfire.org Git - thirdparty/grub.git/commit
mm: Avoid complex heap growth math in hot path
authorZhang Boyang <zhangboyang.id@gmail.com>
Sun, 29 Jan 2023 11:49:33 +0000 (19:49 +0800)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 2 Feb 2023 18:44:56 +0000 (19:44 +0100)
commit65bc45963014773e2062ccc63ff34a089d2e352e
tree7bb60b56c11f88559be09c7f2ffcf57a81ee9711
parent21869baec15239b6d99122b32b14a778af4c754f
mm: Avoid complex heap growth math in hot path

We do a lot of math about heap growth in hot path of grub_memalign().
However, the result is only used if out of memory is encountered, which
is seldom.

This patch moves these calculations away from hot path. These
calculations are now only done if out of memory is encountered. This
change can also help compiler to optimize integer overflow checks away.

Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/kern/mm.c