mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
mm/page_alloc.c: simplify pageblock bitmap access
Due to commit e58469bafd
("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>
This commit is contained in:
parent
399b795b7a
commit
d93d5ab9ca
2 changed files with 13 additions and 22 deletions
|
@ -66,25 +66,17 @@ void set_pfnblock_flags_mask(struct page *page,
|
|||
unsigned long mask);
|
||||
|
||||
/* Declarations for getting and setting flags. See mm/page_alloc.c */
|
||||
#define get_pageblock_flags_group(page, start_bitidx, end_bitidx) \
|
||||
get_pfnblock_flags_mask(page, page_to_pfn(page), \
|
||||
end_bitidx, \
|
||||
(1 << (end_bitidx - start_bitidx + 1)) - 1)
|
||||
#define set_pageblock_flags_group(page, flags, start_bitidx, end_bitidx) \
|
||||
set_pfnblock_flags_mask(page, flags, page_to_pfn(page), \
|
||||
end_bitidx, \
|
||||
(1 << (end_bitidx - start_bitidx + 1)) - 1)
|
||||
|
||||
#ifdef CONFIG_COMPACTION
|
||||
#define get_pageblock_skip(page) \
|
||||
get_pageblock_flags_group(page, PB_migrate_skip, \
|
||||
PB_migrate_skip)
|
||||
get_pfnblock_flags_mask(page, page_to_pfn(page), \
|
||||
PB_migrate_skip, (1 << (PB_migrate_skip)))
|
||||
#define clear_pageblock_skip(page) \
|
||||
set_pageblock_flags_group(page, 0, PB_migrate_skip, \
|
||||
PB_migrate_skip)
|
||||
set_pfnblock_flags_mask(page, 0, page_to_pfn(page), \
|
||||
PB_migrate_skip, (1 << PB_migrate_skip))
|
||||
#define set_pageblock_skip(page) \
|
||||
set_pageblock_flags_group(page, 1, PB_migrate_skip, \
|
||||
PB_migrate_skip)
|
||||
set_pfnblock_flags_mask(page, (1 << PB_migrate_skip), \
|
||||
page_to_pfn(page), \
|
||||
PB_migrate_skip, (1 << PB_migrate_skip))
|
||||
#else
|
||||
static inline bool get_pageblock_skip(struct page *page)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue