Where’s PageSlab() macro???

If you are having hard time to find the definition of PageSlab() in linux kernel, here’s the answer.

In include/linux/page-flags.h:

#define __PAGEFLAG(uname, lname) TESTPAGEFLAG(uname, lname)     \
__SETPAGEFLAG(uname, lname)  __CLEARPAGEFLAG(uname, lname)

#define TESTPAGEFLAG(uname, lname)                  \
static inline int Page##uname(const struct page *page)          \
{ return test_bit(PG_##lname, &page->flags); }

#define __SETPAGEFLAG(uname, lname)                 \
static inline void __SetPage##uname(struct page *page)          \
{ __set_bit(PG_##lname, &page->flags); }

#define __CLEARPAGEFLAG(uname, lname)                   \
static inline void __ClearPage##uname(struct page *page)        \
{ __clear_bit(PG_##lname, &page->flags); }

__PAGEFLAG(Slab, slab)

Above becomes like below during compile time.

static inline int PageSlab(const struct page *page) {
return test_bit(PG_slab, &page->flags);

static inline void __SetPageSlab(struct page *page) {
__set_bit(PG_slab, &page->flags);

static inline void __ClearPageSlab(struct page *page) {
__clear_bit(PG_slab, &page->flags);

2 responses to “Where’s PageSlab() macro???”

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: