diff options
-rw-r--r-- | include/linux/idr.h | 3 | ||||
-rw-r--r-- | include/linux/radix-tree.h | 7 | ||||
-rw-r--r-- | lib/radix-tree.c | 3 | ||||
-rw-r--r-- | tools/testing/radix-tree/linux/gfp.h | 1 |
4 files changed, 9 insertions, 5 deletions
diff --git a/include/linux/idr.h b/include/linux/idr.h index 7d6a6313f0ab..913c335054f0 100644 --- a/include/linux/idr.h +++ b/include/linux/idr.h | |||
@@ -29,7 +29,8 @@ struct idr { | |||
29 | #define IDR_FREE 0 | 29 | #define IDR_FREE 0 |
30 | 30 | ||
31 | /* Set the IDR flag and the IDR_FREE tag */ | 31 | /* Set the IDR flag and the IDR_FREE tag */ |
32 | #define IDR_RT_MARKER ((__force gfp_t)(3 << __GFP_BITS_SHIFT)) | 32 | #define IDR_RT_MARKER (ROOT_IS_IDR | (__force gfp_t) \ |
33 | (1 << (ROOT_TAG_SHIFT + IDR_FREE))) | ||
33 | 34 | ||
34 | #define IDR_INIT_BASE(base) { \ | 35 | #define IDR_INIT_BASE(base) { \ |
35 | .idr_rt = RADIX_TREE_INIT(IDR_RT_MARKER), \ | 36 | .idr_rt = RADIX_TREE_INIT(IDR_RT_MARKER), \ |
diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h index fc55ff31eca7..6c4e2e716dac 100644 --- a/include/linux/radix-tree.h +++ b/include/linux/radix-tree.h | |||
@@ -104,9 +104,10 @@ struct radix_tree_node { | |||
104 | unsigned long tags[RADIX_TREE_MAX_TAGS][RADIX_TREE_TAG_LONGS]; | 104 | unsigned long tags[RADIX_TREE_MAX_TAGS][RADIX_TREE_TAG_LONGS]; |
105 | }; | 105 | }; |
106 | 106 | ||
107 | /* The top bits of gfp_mask are used to store the root tags and the IDR flag */ | 107 | /* The IDR tag is stored in the low bits of the GFP flags */ |
108 | #define ROOT_IS_IDR ((__force gfp_t)(1 << __GFP_BITS_SHIFT)) | 108 | #define ROOT_IS_IDR ((__force gfp_t)4) |
109 | #define ROOT_TAG_SHIFT (__GFP_BITS_SHIFT + 1) | 109 | /* The top bits of gfp_mask are used to store the root tags */ |
110 | #define ROOT_TAG_SHIFT (__GFP_BITS_SHIFT) | ||
110 | 111 | ||
111 | struct radix_tree_root { | 112 | struct radix_tree_root { |
112 | gfp_t gfp_mask; | 113 | gfp_t gfp_mask; |
diff --git a/lib/radix-tree.c b/lib/radix-tree.c index 8e00138d593f..da9e10c827df 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c | |||
@@ -146,7 +146,7 @@ static unsigned int radix_tree_descend(const struct radix_tree_node *parent, | |||
146 | 146 | ||
147 | static inline gfp_t root_gfp_mask(const struct radix_tree_root *root) | 147 | static inline gfp_t root_gfp_mask(const struct radix_tree_root *root) |
148 | { | 148 | { |
149 | return root->gfp_mask & __GFP_BITS_MASK; | 149 | return root->gfp_mask & (__GFP_BITS_MASK & ~GFP_ZONEMASK); |
150 | } | 150 | } |
151 | 151 | ||
152 | static inline void tag_set(struct radix_tree_node *node, unsigned int tag, | 152 | static inline void tag_set(struct radix_tree_node *node, unsigned int tag, |
@@ -2285,6 +2285,7 @@ void __init radix_tree_init(void) | |||
2285 | int ret; | 2285 | int ret; |
2286 | 2286 | ||
2287 | BUILD_BUG_ON(RADIX_TREE_MAX_TAGS + __GFP_BITS_SHIFT > 32); | 2287 | BUILD_BUG_ON(RADIX_TREE_MAX_TAGS + __GFP_BITS_SHIFT > 32); |
2288 | BUILD_BUG_ON(ROOT_IS_IDR & ~GFP_ZONEMASK); | ||
2288 | radix_tree_node_cachep = kmem_cache_create("radix_tree_node", | 2289 | radix_tree_node_cachep = kmem_cache_create("radix_tree_node", |
2289 | sizeof(struct radix_tree_node), 0, | 2290 | sizeof(struct radix_tree_node), 0, |
2290 | SLAB_PANIC | SLAB_RECLAIM_ACCOUNT, | 2291 | SLAB_PANIC | SLAB_RECLAIM_ACCOUNT, |
diff --git a/tools/testing/radix-tree/linux/gfp.h b/tools/testing/radix-tree/linux/gfp.h index e3201ccf54c3..32159c08a52e 100644 --- a/tools/testing/radix-tree/linux/gfp.h +++ b/tools/testing/radix-tree/linux/gfp.h | |||
@@ -19,6 +19,7 @@ | |||
19 | 19 | ||
20 | #define __GFP_RECLAIM (__GFP_DIRECT_RECLAIM|__GFP_KSWAPD_RECLAIM) | 20 | #define __GFP_RECLAIM (__GFP_DIRECT_RECLAIM|__GFP_KSWAPD_RECLAIM) |
21 | 21 | ||
22 | #define GFP_ZONEMASK 0x0fu | ||
22 | #define GFP_ATOMIC (__GFP_HIGH|__GFP_ATOMIC|__GFP_KSWAPD_RECLAIM) | 23 | #define GFP_ATOMIC (__GFP_HIGH|__GFP_ATOMIC|__GFP_KSWAPD_RECLAIM) |
23 | #define GFP_KERNEL (__GFP_RECLAIM | __GFP_IO | __GFP_FS) | 24 | #define GFP_KERNEL (__GFP_RECLAIM | __GFP_IO | __GFP_FS) |
24 | #define GFP_NOWAIT (__GFP_KSWAPD_RECLAIM) | 25 | #define GFP_NOWAIT (__GFP_KSWAPD_RECLAIM) |