Changeset View
Standalone View
sys/vm/vm_page.h
Show First 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | |||||
#define VPB_SHARERS_WORD(x) ((x) << VPB_SHARERS_SHIFT | VPB_BIT_SHARED) | #define VPB_SHARERS_WORD(x) ((x) << VPB_SHARERS_SHIFT | VPB_BIT_SHARED) | ||||
#define VPB_ONE_SHARER (1 << VPB_SHARERS_SHIFT) | #define VPB_ONE_SHARER (1 << VPB_SHARERS_SHIFT) | ||||
#define VPB_SINGLE_EXCLUSIVER VPB_BIT_EXCLUSIVE | #define VPB_SINGLE_EXCLUSIVER VPB_BIT_EXCLUSIVE | ||||
#define VPB_UNBUSIED VPB_SHARERS_WORD(0) | #define VPB_UNBUSIED VPB_SHARERS_WORD(0) | ||||
#define PQ_NONE 255 | #define PQ_NONE 255 | ||||
#define PQ_INACTIVE 0 | #define PQ_UNSWAPPABLE 0 | ||||
dougm: Its not clear that this change is necessary. Why is it necessary? | |||||
Not Done Inline Actionsvm_page_in_laundry() would otherwise return true if m->queue == PQ_NONE. markj: vm_page_in_laundry() would otherwise return true if m->queue == PQ_NONE. | |||||
#define PQ_ACTIVE 1 | #define PQ_LAUNDRY 1 | ||||
#define PQ_LAUNDRY 2 | #define PQ_INACTIVE 2 | ||||
#define PQ_UNSWAPPABLE 3 | #define PQ_ACTIVE 3 | ||||
#define PQ_COUNT 4 | #define PQ_COUNT 4 | ||||
#ifndef VM_PAGE_HAVE_PGLIST | #ifndef VM_PAGE_HAVE_PGLIST | ||||
TAILQ_HEAD(pglist, vm_page); | TAILQ_HEAD(pglist, vm_page); | ||||
#define VM_PAGE_HAVE_PGLIST | #define VM_PAGE_HAVE_PGLIST | ||||
#endif | #endif | ||||
SLIST_HEAD(spglist, vm_page); | SLIST_HEAD(spglist, vm_page); | ||||
▲ Show 20 Lines • Show All 584 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
return (vm_page_queue(m) == PQ_INACTIVE); | return (vm_page_queue(m) == PQ_INACTIVE); | ||||
} | } | ||||
static inline bool | static inline bool | ||||
vm_page_in_laundry(vm_page_t m) | vm_page_in_laundry(vm_page_t m) | ||||
{ | { | ||||
uint8_t queue; | |||||
queue = vm_page_queue(m); | return (vm_page_queue(m) <= PQ_LAUNDRY); /* LAUNDRY or UNSWAPPABLE */ | ||||
Not Done Inline ActionsThis function should return true or false, not 0 or 2. Have you seen that this change causes some compiler to generate better assembly language for this function? Could you show us that? dougm: This function should return true or false, not 0 or 2.
Have you seen that this change causes… | |||||
Not Done Inline ActionsWe're testing queue == 2 || queue == 3, which can be optimized to (queue | 1) == 3. I don't think this kind of micro-optimization is really worth changing the definition of PQ_NONE. markj: We're testing queue == 2 || queue == 3, which can be optimized to (queue | 1) == 3. I don't… | |||||
Done Inline ActionsCopy the below adjusted code to https://godbolt.org/ and see the assembly code. #define PQ_NONE 255 struct vm_page { char queue; }; typedef struct vm_page *vm_page_t; static inline char static char queue = vm_page_queue(m); #undef PQ_NONE static char vm_page_in_laundry2(vm_page_t m) return (vm_page_queue(m) & PQ_LAUNDRY); ota_j.email.ne.jp: Copy the below adjusted code to https://godbolt.org/ and see the assembly code.
Unfortunately… | |||||
return (queue == PQ_LAUNDRY || queue == PQ_UNSWAPPABLE); | |||||
} | } | ||||
/* | /* | ||||
* vm_page_drop: | * vm_page_drop: | ||||
* | * | ||||
* Release a reference to a page and return the old reference count. | * Release a reference to a page and return the old reference count. | ||||
*/ | */ | ||||
static inline u_int | static inline u_int | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |
Its not clear that this change is necessary. Why is it necessary?