mm: Use fixed constant in page_frag_alloc instead of size + 1
authorAlexander Duyck <alexander.h.duyck@linux.intel.com>
Fri, 15 Feb 2019 22:44:12 +0000 (14:44 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 24 Apr 2020 05:58:57 +0000 (07:58 +0200)
commitb59a2e0a56515df9439b0974d6af92323865e4e5
tree8cacfec454c0b0290b9ea4a74fe6097c073c1b94
parentbd075802b09f5062744ddfde7ecf5cde826e5377
mm: Use fixed constant in page_frag_alloc instead of size + 1

commit 8644772637deb121f7ac2df690cbf83fa63d3b70 upstream.

This patch replaces the size + 1 value introduced with the recent fix for 1
byte allocs with a constant value.

The idea here is to reduce code overhead as the previous logic would have
to read size into a register, then increment it, and write it back to
whatever field was being used. By using a constant we can avoid those
memory reads and arithmetic operations in favor of just encoding the
maximum value into the operation itself.

Fixes: 2c2ade81741c ("mm: page_alloc: fix ref bias in page_frag_alloc() for 1-byte allocs")
Signed-off-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
mm/page_alloc.c