diff options
author | Wei Yang <richard.weiyang@linux.alibaba.com> | 2020-08-06 23:25:48 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2020-08-07 11:33:29 -0700 |
commit | d93d5ab9ca01e24efc6add60371b0d5684b5c146 (patch) | |
tree | a7a5200b015b9da4e84b03e6d51cfe006abbb88f /include/asm-generic/spinlock.h | |
parent | 399b795b7a80bf703aae56fa0b66fd1949ca1fd9 (diff) | |
download | linux-d93d5ab9ca01e24efc6add60371b0d5684b5c146.tar.gz linux-d93d5ab9ca01e24efc6add60371b0d5684b5c146.tar.bz2 linux-d93d5ab9ca01e24efc6add60371b0d5684b5c146.zip |
mm/page_alloc.c: simplify pageblock bitmap access
Due to commit e58469bafd05 ("mm: page_alloc: use word-based accesses for
get/set pageblock bitmaps"), pageblock bitmap is accessed with word-based
access. This operation could be simplified a little.
Intuitively, if we want to get a bit range [start_idx, end_idx] in a word,
we can do like this:
mask = (1 << (end_bitidx - start_bitidx + 1)) - 1;
ret = (word >> start_idx) & mask;
And also if we want to set a bit range [start_idx, end_idx] with flags, we
can do the same by just shift start_bitidx.
By doing so we reduce some instructions for these two helper functions:
Before Patched
set_pfnblock_flags_mask 209 198(-5%)
get_pfnblock_flags_mask 101 87(-13%)
Since the syntax is changed a little, we need to check the whole 4-bit
migrate_type instead of part of it.
Signed-off-by: Wei Yang <richard.weiyang@linux.alibaba.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Mel Gorman <mgorman@suse.de>
Link: http://lkml.kernel.org/r/20200623124201.8199-3-richard.weiyang@linux.alibaba.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/asm-generic/spinlock.h')
0 files changed, 0 insertions, 0 deletions