Files
linux-apfs/include/linux/page_cgroup.h
T

146 lines
3.4 KiB
C
Raw Normal View History

2008-10-18 20:28:16 -07:00
#ifndef __LINUX_PAGE_CGROUP_H
#define __LINUX_PAGE_CGROUP_H
enum {
/* flags for mem_cgroup */
PCG_LOCK, /* Lock for pc->mem_cgroup and following bits. */
PCG_USED, /* this object is in use. */
PCG_MIGRATION, /* under page migration */
__NR_PCG_FLAGS,
};
#ifndef __GENERATING_BOUNDS_H
#include <generated/bounds.h>
2012-07-31 16:43:02 -07:00
#ifdef CONFIG_MEMCG
2008-10-18 20:28:16 -07:00
#include <linux/bit_spinlock.h>
2008-10-18 20:28:16 -07:00
/*
* Page Cgroup can be considered as an extended mem_map.
* A page_cgroup page is associated with every page descriptor. The
* page_cgroup helps us identify information about the cgroup
* All page cgroups are allocated at boot or memory hotplug event,
* then the page cgroup for pfn always exists.
*/
struct page_cgroup {
unsigned long flags;
struct mem_cgroup *mem_cgroup;
};
2008-11-22 17:33:24 +00:00
void __meminit pgdat_page_cgroup_init(struct pglist_data *pgdat);
#ifdef CONFIG_SPARSEMEM
static inline void __init page_cgroup_init_flatmem(void)
{
}
extern void __init page_cgroup_init(void);
#else
void __init page_cgroup_init_flatmem(void);
static inline void __init page_cgroup_init(void)
{
}
#endif
2008-10-18 20:28:16 -07:00
struct page_cgroup *lookup_page_cgroup(struct page *page);
struct page *lookup_cgroup_page(struct page_cgroup *pc);
2008-10-18 20:28:16 -07:00
#define TESTPCGFLAG(uname, lname) \
static inline int PageCgroup##uname(struct page_cgroup *pc) \
{ return test_bit(PCG_##lname, &pc->flags); }
#define SETPCGFLAG(uname, lname) \
static inline void SetPageCgroup##uname(struct page_cgroup *pc)\
{ set_bit(PCG_##lname, &pc->flags); }
#define CLEARPCGFLAG(uname, lname) \
static inline void ClearPageCgroup##uname(struct page_cgroup *pc) \
{ clear_bit(PCG_##lname, &pc->flags); }
#define TESTCLEARPCGFLAG(uname, lname) \
static inline int TestClearPageCgroup##uname(struct page_cgroup *pc) \
{ return test_and_clear_bit(PCG_##lname, &pc->flags); }
2008-10-18 20:28:16 -07:00
TESTPCGFLAG(Used, USED)
CLEARPCGFLAG(Used, USED)
SETPCGFLAG(Used, USED)
SETPCGFLAG(Migration, MIGRATION)
CLEARPCGFLAG(Migration, MIGRATION)
TESTPCGFLAG(Migration, MIGRATION)
2008-10-18 20:28:16 -07:00
static inline void lock_page_cgroup(struct page_cgroup *pc)
{
/*
* Don't take this lock in IRQ context.
2012-03-21 16:34:22 -07:00
* This lock is for pc->mem_cgroup, USED, MIGRATION
*/
2008-10-18 20:28:16 -07:00
bit_spin_lock(PCG_LOCK, &pc->flags);
}
static inline void unlock_page_cgroup(struct page_cgroup *pc)
{
bit_spin_unlock(PCG_LOCK, &pc->flags);
}
2012-07-31 16:43:02 -07:00
#else /* CONFIG_MEMCG */
2008-10-18 20:28:16 -07:00
struct page_cgroup;
2008-11-22 17:33:24 +00:00
static inline void __meminit pgdat_page_cgroup_init(struct pglist_data *pgdat)
2008-10-18 20:28:16 -07:00
{
}
static inline struct page_cgroup *lookup_page_cgroup(struct page *page)
{
return NULL;
}
2008-10-22 14:15:05 -07:00
static inline void page_cgroup_init(void)
{
}
static inline void __init page_cgroup_init_flatmem(void)
{
}
2012-07-31 16:43:02 -07:00
#endif /* CONFIG_MEMCG */
2009-01-07 18:07:58 -08:00
#include <linux/swap.h>
2012-07-31 16:43:02 -07:00
#ifdef CONFIG_MEMCG_SWAP
2010-03-10 15:22:17 -08:00
extern unsigned short swap_cgroup_cmpxchg(swp_entry_t ent,
unsigned short old, unsigned short new);
extern unsigned short swap_cgroup_record(swp_entry_t ent, unsigned short id);
extern unsigned short lookup_swap_cgroup_id(swp_entry_t ent);
2009-01-07 18:07:58 -08:00
extern int swap_cgroup_swapon(int type, unsigned long max_pages);
extern void swap_cgroup_swapoff(int type);
#else
static inline
unsigned short swap_cgroup_record(swp_entry_t ent, unsigned short id)
2009-01-07 18:07:58 -08:00
{
return 0;
2009-01-07 18:07:58 -08:00
}
static inline
unsigned short lookup_swap_cgroup_id(swp_entry_t ent)
2009-01-07 18:07:58 -08:00
{
return 0;
2009-01-07 18:07:58 -08:00
}
static inline int
swap_cgroup_swapon(int type, unsigned long max_pages)
{
return 0;
}
static inline void swap_cgroup_swapoff(int type)
{
return;
}
2012-07-31 16:43:02 -07:00
#endif /* CONFIG_MEMCG_SWAP */
#endif /* !__GENERATING_BOUNDS_H */
#endif /* __LINUX_PAGE_CGROUP_H */