diff options
Diffstat (limited to 'include/linux/hugetlb.h')
| -rw-r--r-- | include/linux/hugetlb.h | 88 | 
1 files changed, 75 insertions, 13 deletions
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 1e897e4168ac..43a1cef8f0f1 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -46,7 +46,52 @@ struct resv_map {  	long adds_in_progress;  	struct list_head region_cache;  	long region_cache_count; +#ifdef CONFIG_CGROUP_HUGETLB +	/* +	 * On private mappings, the counter to uncharge reservations is stored +	 * here. If these fields are 0, then either the mapping is shared, or +	 * cgroup accounting is disabled for this resv_map. +	 */ +	struct page_counter *reservation_counter; +	unsigned long pages_per_hpage; +	struct cgroup_subsys_state *css; +#endif +}; + +/* + * Region tracking -- allows tracking of reservations and instantiated pages + *                    across the pages in a mapping. + * + * The region data structures are embedded into a resv_map and protected + * by a resv_map's lock.  The set of regions within the resv_map represent + * reservations for huge pages, or huge pages that have already been + * instantiated within the map.  The from and to elements are huge page + * indicies into the associated mapping.  from indicates the starting index + * of the region.  to represents the first index past the end of  the region. + * + * For example, a file region structure with from == 0 and to == 4 represents + * four huge pages in a mapping.  It is important to note that the to element + * represents the first element past the end of the region. This is used in + * arithmetic as 4(to) - 0(from) = 4 huge pages in the region. + * + * Interval notation of the form [from, to) will be used to indicate that + * the endpoint from is inclusive and to is exclusive. + */ +struct file_region { +	struct list_head link; +	long from; +	long to; +#ifdef CONFIG_CGROUP_HUGETLB +	/* +	 * On shared mappings, each reserved region appears as a struct +	 * file_region in resv_map. These fields hold the info needed to +	 * uncharge each reservation. +	 */ +	struct page_counter *reservation_counter; +	struct cgroup_subsys_state *css; +#endif  }; +  extern struct resv_map *resv_map_alloc(void);  void resv_map_release(struct kref *ref); @@ -109,6 +154,8 @@ u32 hugetlb_fault_mutex_hash(struct address_space *mapping, pgoff_t idx);  pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud); +struct address_space *hugetlb_page_mapping_lock_write(struct page *hpage); +  extern int sysctl_hugetlb_shm_group;  extern struct list_head huge_boot_pages; @@ -151,6 +198,12 @@ static inline unsigned long hugetlb_total_pages(void)  	return 0;  } +static inline struct address_space *hugetlb_page_mapping_lock_write( +							struct page *hpage) +{ +	return NULL; +} +  static inline int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr,  					pte_t *ptep)  { @@ -390,7 +443,10 @@ static inline bool is_file_hugepages(struct file *file)  	return is_file_shm_hugepages(file);  } - +static inline struct hstate *hstate_inode(struct inode *i) +{ +	return HUGETLBFS_SB(i->i_sb)->hstate; +}  #else /* !CONFIG_HUGETLBFS */  #define is_file_hugepages(file)			false @@ -402,6 +458,10 @@ hugetlb_file_setup(const char *name, size_t size, vm_flags_t acctflag,  	return ERR_PTR(-ENOSYS);  } +static inline struct hstate *hstate_inode(struct inode *i) +{ +	return NULL; +}  #endif /* !CONFIG_HUGETLBFS */  #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA @@ -432,8 +492,8 @@ struct hstate {  	unsigned int surplus_huge_pages_node[MAX_NUMNODES];  #ifdef CONFIG_CGROUP_HUGETLB  	/* cgroup control files */ -	struct cftype cgroup_files_dfl[5]; -	struct cftype cgroup_files_legacy[5]; +	struct cftype cgroup_files_dfl[7]; +	struct cftype cgroup_files_legacy[9];  #endif  	char name[HSTATE_NAME_LEN];  }; @@ -472,11 +532,6 @@ extern unsigned int default_hstate_idx;  #define default_hstate (hstates[default_hstate_idx]) -static inline struct hstate *hstate_inode(struct inode *i) -{ -	return HUGETLBFS_SB(i->i_sb)->hstate; -} -  static inline struct hstate *hstate_file(struct file *f)  {  	return hstate_inode(file_inode(f)); @@ -729,11 +784,6 @@ static inline struct hstate *hstate_vma(struct vm_area_struct *vma)  	return NULL;  } -static inline struct hstate *hstate_inode(struct inode *i) -{ -	return NULL; -} -  static inline struct hstate *page_hstate(struct page *page)  {  	return NULL; @@ -845,4 +895,16 @@ static inline spinlock_t *huge_pte_lock(struct hstate *h,  	return ptl;  } +#if defined(CONFIG_HUGETLB_PAGE) && defined(CONFIG_CMA) +extern void __init hugetlb_cma_reserve(int order); +extern void __init hugetlb_cma_check(void); +#else +static inline __init void hugetlb_cma_reserve(int order) +{ +} +static inline __init void hugetlb_cma_check(void) +{ +} +#endif +  #endif /* _LINUX_HUGETLB_H */  |