diff options
author | Alexander Duyck <alexander.h.duyck@linux.intel.com> | 2019-02-15 17:44:12 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-02-17 18:48:43 -0500 |
commit | 8644772637deb121f7ac2df690cbf83fa63d3b70 (patch) | |
tree | ea32aa83dd30a3cb7491dc2d33c55971b00ce363 /mm/page_alloc.c | |
parent | e09c6a4ec1bb9ed73b4157b69c261e408d875b0f (diff) |
mm: Use fixed constant in page_frag_alloc instead of size + 1
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>
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r-- | mm/page_alloc.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 46285d28e43b..7f79b78bc829 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -4675,11 +4675,11 @@ refill: | |||
4675 | /* Even if we own the page, we do not use atomic_set(). | 4675 | /* Even if we own the page, we do not use atomic_set(). |
4676 | * This would break get_page_unless_zero() users. | 4676 | * This would break get_page_unless_zero() users. |
4677 | */ | 4677 | */ |
4678 | page_ref_add(page, size); | 4678 | page_ref_add(page, PAGE_FRAG_CACHE_MAX_SIZE); |
4679 | 4679 | ||
4680 | /* reset page count bias and offset to start of new frag */ | 4680 | /* reset page count bias and offset to start of new frag */ |
4681 | nc->pfmemalloc = page_is_pfmemalloc(page); | 4681 | nc->pfmemalloc = page_is_pfmemalloc(page); |
4682 | nc->pagecnt_bias = size + 1; | 4682 | nc->pagecnt_bias = PAGE_FRAG_CACHE_MAX_SIZE + 1; |
4683 | nc->offset = size; | 4683 | nc->offset = size; |
4684 | } | 4684 | } |
4685 | 4685 | ||
@@ -4695,10 +4695,10 @@ refill: | |||
4695 | size = nc->size; | 4695 | size = nc->size; |
4696 | #endif | 4696 | #endif |
4697 | /* OK, page count is 0, we can safely set it */ | 4697 | /* OK, page count is 0, we can safely set it */ |
4698 | set_page_count(page, size + 1); | 4698 | set_page_count(page, PAGE_FRAG_CACHE_MAX_SIZE + 1); |
4699 | 4699 | ||
4700 | /* reset page count bias and offset to start of new frag */ | 4700 | /* reset page count bias and offset to start of new frag */ |
4701 | nc->pagecnt_bias = size + 1; | 4701 | nc->pagecnt_bias = PAGE_FRAG_CACHE_MAX_SIZE + 1; |
4702 | offset = size - fragsz; | 4702 | offset = size - fragsz; |
4703 | } | 4703 | } |
4704 | 4704 | ||