thp: compound_trans_order

Read compound_trans_order safe. Noop for CONFIG_TRANSPARENT_HUGEPAGE=n.

Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Andrea Arcangeli 2011-01-13 15:47:16 -08:00 committed by Linus Torvalds
parent 91600e9e59
commit 37c2ac7872
3 changed files with 26 additions and 12 deletions

View file

@ -450,6 +450,20 @@ static inline int compound_order(struct page *page)
return (unsigned long)page[1].lru.prev;
}
static inline int compound_trans_order(struct page *page)
{
int order;
unsigned long flags;
if (!PageHead(page))
return 0;
flags = compound_lock_irqsave(page);
order = compound_order(page);
compound_unlock_irqrestore(page, flags);
return order;
}
static inline void set_compound_order(struct page *page, unsigned long order)
{
page[1].lru.prev = (void *)order;