summaryrefslogtreecommitdiffstats
path: root/include/linux/pagemap.h
diff options
context:
space:
mode:
authorMichal Hocko <mhocko@suse.com>2016-10-11 16:56:04 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-11 18:06:34 -0400
commit9c5d760b8d229b94c5030863a5edaee5f1a9d7b7 (patch)
tree2f8c87133c512712c23c9f79926c8f966953d64e /include/linux/pagemap.h
parent5114a97a8bce7f4ead29a32b67dee85438699b9e (diff)
mm: split gfp_mask and mapping flags into separate fields
mapping->flags currently encodes two different things into a single flag. It contains sticky gfp_mask for page cache allocations and AS_ codes used to report errors/enospace and other states which are mapping specific. Condensing the two semantically unrelated things saves few bytes but it also complicates other things. For one thing the gfp flags space is reduced and in fact we are already running out of available bits. It can be assumed that more gfp flags will be necessary later on. To not introduce the address_space grow (at least on x86_64) we can stick it right after private_lock because we have a hole there. struct address_space { struct inode * host; /* 0 8 */ struct radix_tree_root page_tree; /* 8 16 */ spinlock_t tree_lock; /* 24 4 */ atomic_t i_mmap_writable; /* 28 4 */ struct rb_root i_mmap; /* 32 8 */ struct rw_semaphore i_mmap_rwsem; /* 40 40 */ /* --- cacheline 1 boundary (64 bytes) was 16 bytes ago --- */ long unsigned int nrpages; /* 80 8 */ long unsigned int nrexceptional; /* 88 8 */ long unsigned int writeback_index; /* 96 8 */ const struct address_space_operations * a_ops; /* 104 8 */ long unsigned int flags; /* 112 8 */ spinlock_t private_lock; /* 120 4 */ /* XXX 4 bytes hole, try to pack */ /* --- cacheline 2 boundary (128 bytes) --- */ struct list_head private_list; /* 128 16 */ void * private_data; /* 144 8 */ /* size: 152, cachelines: 3, members: 14 */ /* sum members: 148, holes: 1, sum holes: 4 */ /* last cacheline: 24 bytes */ }; Link: http://lkml.kernel.org/r/20160912114852.GI14524@dhcp22.suse.cz Signed-off-by: Michal Hocko <mhocko@suse.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/pagemap.h')
-rw-r--r--include/linux/pagemap.h20
1 files changed, 9 insertions, 11 deletions
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 747f401cc312..dd15d39e1985 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -16,17 +16,16 @@
16#include <linux/hugetlb_inline.h> 16#include <linux/hugetlb_inline.h>
17 17
18/* 18/*
19 * Bits in mapping->flags. The lower __GFP_BITS_SHIFT bits are the page 19 * Bits in mapping->flags.
20 * allocation mode flags.
21 */ 20 */
22enum mapping_flags { 21enum mapping_flags {
23 AS_EIO = __GFP_BITS_SHIFT + 0, /* IO error on async write */ 22 AS_EIO = 0, /* IO error on async write */
24 AS_ENOSPC = __GFP_BITS_SHIFT + 1, /* ENOSPC on async write */ 23 AS_ENOSPC = 1, /* ENOSPC on async write */
25 AS_MM_ALL_LOCKS = __GFP_BITS_SHIFT + 2, /* under mm_take_all_locks() */ 24 AS_MM_ALL_LOCKS = 2, /* under mm_take_all_locks() */
26 AS_UNEVICTABLE = __GFP_BITS_SHIFT + 3, /* e.g., ramdisk, SHM_LOCK */ 25 AS_UNEVICTABLE = 3, /* e.g., ramdisk, SHM_LOCK */
27 AS_EXITING = __GFP_BITS_SHIFT + 4, /* final truncate in progress */ 26 AS_EXITING = 4, /* final truncate in progress */
28 /* writeback related tags are not used */ 27 /* writeback related tags are not used */
29 AS_NO_WRITEBACK_TAGS = __GFP_BITS_SHIFT + 5, 28 AS_NO_WRITEBACK_TAGS = 5,
30}; 29};
31 30
32static inline void mapping_set_error(struct address_space *mapping, int error) 31static inline void mapping_set_error(struct address_space *mapping, int error)
@@ -78,7 +77,7 @@ static inline int mapping_use_writeback_tags(struct address_space *mapping)
78 77
79static inline gfp_t mapping_gfp_mask(struct address_space * mapping) 78static inline gfp_t mapping_gfp_mask(struct address_space * mapping)
80{ 79{
81 return (__force gfp_t)mapping->flags & __GFP_BITS_MASK; 80 return mapping->gfp_mask;
82} 81}
83 82
84/* Restricts the given gfp_mask to what the mapping allows. */ 83/* Restricts the given gfp_mask to what the mapping allows. */
@@ -94,8 +93,7 @@ static inline gfp_t mapping_gfp_constraint(struct address_space *mapping,
94 */ 93 */
95static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask) 94static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask)
96{ 95{
97 m->flags = (m->flags & ~(__force unsigned long)__GFP_BITS_MASK) | 96 m->gfp_mask = mask;
98 (__force unsigned long)mask;
99} 97}
100 98
101void release_pages(struct page **pages, int nr, bool cold); 99void release_pages(struct page **pages, int nr, bool cold);