aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2005-10-21 02:55:38 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-10-28 11:16:46 -0400
commitaf4ca457eaf2d6682059c18463eb106e2ce58198 (patch)
tree399ca5ab3b15d723a6aefd04c764a2a06089ed06
parent434f1d10c1adb6c2e333d501ce1e42be610e0723 (diff)
[PATCH] gfp_t: infrastructure
Beginning of gfp_t annotations: - -Wbitwise added to CHECKFLAGS - old __bitwise renamed to __bitwise__ - __bitwise defined to either __bitwise__ or nothing, depending on __CHECK_ENDIAN__ being defined - gfp_t switched from __nocast to __bitwise__ - force cast to gfp_t added to __GFP_... constants - new helper - gfp_zone(); extracts zone bits out of gfp_t value and casts the result to int Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--Makefile2
-rw-r--r--fs/buffer.c2
-rw-r--r--include/linux/gfp.h39
-rw-r--r--include/linux/types.h9
-rw-r--r--mm/mempolicy.c6
-rw-r--r--mm/page_alloc.c4
6 files changed, 34 insertions, 28 deletions
diff --git a/Makefile b/Makefile
index 1fa7e5343464..f1d121f23025 100644
--- a/Makefile
+++ b/Makefile
@@ -334,7 +334,7 @@ KALLSYMS = scripts/kallsyms
334PERL = perl 334PERL = perl
335CHECK = sparse 335CHECK = sparse
336 336
337CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ $(CF) 337CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(CF)
338MODFLAGS = -DMODULE 338MODFLAGS = -DMODULE
339CFLAGS_MODULE = $(MODFLAGS) 339CFLAGS_MODULE = $(MODFLAGS)
340AFLAGS_MODULE = $(MODFLAGS) 340AFLAGS_MODULE = $(MODFLAGS)
diff --git a/fs/buffer.c b/fs/buffer.c
index 1216c0d3c8ce..9657696fd6d7 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -502,7 +502,7 @@ static void free_more_memory(void)
502 yield(); 502 yield();
503 503
504 for_each_pgdat(pgdat) { 504 for_each_pgdat(pgdat) {
505 zones = pgdat->node_zonelists[GFP_NOFS&GFP_ZONEMASK].zones; 505 zones = pgdat->node_zonelists[gfp_zone(GFP_NOFS)].zones;
506 if (*zones) 506 if (*zones)
507 try_to_free_pages(zones, GFP_NOFS); 507 try_to_free_pages(zones, GFP_NOFS);
508 } 508 }
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 3010e172394d..c3779432a723 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -12,8 +12,8 @@ struct vm_area_struct;
12 * GFP bitmasks.. 12 * GFP bitmasks..
13 */ 13 */
14/* Zone modifiers in GFP_ZONEMASK (see linux/mmzone.h - low two bits) */ 14/* Zone modifiers in GFP_ZONEMASK (see linux/mmzone.h - low two bits) */
15#define __GFP_DMA 0x01u 15#define __GFP_DMA ((__force gfp_t)0x01u)
16#define __GFP_HIGHMEM 0x02u 16#define __GFP_HIGHMEM ((__force gfp_t)0x02u)
17 17
18/* 18/*
19 * Action modifiers - doesn't change the zoning 19 * Action modifiers - doesn't change the zoning
@@ -26,24 +26,24 @@ struct vm_area_struct;
26 * 26 *
27 * __GFP_NORETRY: The VM implementation must not retry indefinitely. 27 * __GFP_NORETRY: The VM implementation must not retry indefinitely.
28 */ 28 */
29#define __GFP_WAIT 0x10u /* Can wait and reschedule? */ 29#define __GFP_WAIT ((__force gfp_t)0x10u) /* Can wait and reschedule? */
30#define __GFP_HIGH 0x20u /* Should access emergency pools? */ 30#define __GFP_HIGH ((__force gfp_t)0x20u) /* Should access emergency pools? */
31#define __GFP_IO 0x40u /* Can start physical IO? */ 31#define __GFP_IO ((__force gfp_t)0x40u) /* Can start physical IO? */
32#define __GFP_FS 0x80u /* Can call down to low-level FS? */ 32#define __GFP_FS ((__force gfp_t)0x80u) /* Can call down to low-level FS? */
33#define __GFP_COLD 0x100u /* Cache-cold page required */ 33#define __GFP_COLD ((__force gfp_t)0x100u) /* Cache-cold page required */
34#define __GFP_NOWARN 0x200u /* Suppress page allocation failure warning */ 34#define __GFP_NOWARN ((__force gfp_t)0x200u) /* Suppress page allocation failure warning */
35#define __GFP_REPEAT 0x400u /* Retry the allocation. Might fail */ 35#define __GFP_REPEAT ((__force gfp_t)0x400u) /* Retry the allocation. Might fail */
36#define __GFP_NOFAIL 0x800u /* Retry for ever. Cannot fail */ 36#define __GFP_NOFAIL ((__force gfp_t)0x800u) /* Retry for ever. Cannot fail */
37#define __GFP_NORETRY 0x1000u /* Do not retry. Might fail */ 37#define __GFP_NORETRY ((__force gfp_t)0x1000u)/* Do not retry. Might fail */
38#define __GFP_NO_GROW 0x2000u /* Slab internal usage */ 38#define __GFP_NO_GROW ((__force gfp_t)0x2000u)/* Slab internal usage */
39#define __GFP_COMP 0x4000u /* Add compound page metadata */ 39#define __GFP_COMP ((__force gfp_t)0x4000u)/* Add compound page metadata */
40#define __GFP_ZERO 0x8000u /* Return zeroed page on success */ 40#define __GFP_ZERO ((__force gfp_t)0x8000u)/* Return zeroed page on success */
41#define __GFP_NOMEMALLOC 0x10000u /* Don't use emergency reserves */ 41#define __GFP_NOMEMALLOC ((__force gfp_t)0x10000u) /* Don't use emergency reserves */
42#define __GFP_NORECLAIM 0x20000u /* No realy zone reclaim during allocation */ 42#define __GFP_NORECLAIM ((__force gfp_t)0x20000u) /* No realy zone reclaim during allocation */
43#define __GFP_HARDWALL 0x40000u /* Enforce hardwall cpuset memory allocs */ 43#define __GFP_HARDWALL ((__force gfp_t)0x40000u) /* Enforce hardwall cpuset memory allocs */
44 44
45#define __GFP_BITS_SHIFT 20 /* Room for 20 __GFP_FOO bits */ 45#define __GFP_BITS_SHIFT 20 /* Room for 20 __GFP_FOO bits */
46#define __GFP_BITS_MASK ((1 << __GFP_BITS_SHIFT) - 1) 46#define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
47 47
48/* if you forget to add the bitmask here kernel will crash, period */ 48/* if you forget to add the bitmask here kernel will crash, period */
49#define GFP_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS| \ 49#define GFP_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS| \
@@ -64,6 +64,7 @@ struct vm_area_struct;
64 64
65#define GFP_DMA __GFP_DMA 65#define GFP_DMA __GFP_DMA
66 66
67#define gfp_zone(mask) ((__force int)((mask) & (__force gfp_t)GFP_ZONEMASK))
67 68
68/* 69/*
69 * There is only one page-allocator function, and two main namespaces to 70 * There is only one page-allocator function, and two main namespaces to
@@ -94,7 +95,7 @@ static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask,
94 return NULL; 95 return NULL;
95 96
96 return __alloc_pages(gfp_mask, order, 97 return __alloc_pages(gfp_mask, order,
97 NODE_DATA(nid)->node_zonelists + (gfp_mask & GFP_ZONEMASK)); 98 NODE_DATA(nid)->node_zonelists + gfp_zone(gfp_mask));
98} 99}
99 100
100#ifdef CONFIG_NUMA 101#ifdef CONFIG_NUMA
diff --git a/include/linux/types.h b/include/linux/types.h
index 0aee34f9da9f..21b9ce803644 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -151,7 +151,12 @@ typedef unsigned long sector_t;
151 */ 151 */
152 152
153#ifdef __CHECKER__ 153#ifdef __CHECKER__
154#define __bitwise __attribute__((bitwise)) 154#define __bitwise__ __attribute__((bitwise))
155#else
156#define __bitwise__
157#endif
158#ifdef __CHECK_ENDIAN__
159#define __bitwise __bitwise__
155#else 160#else
156#define __bitwise 161#define __bitwise
157#endif 162#endif
@@ -166,7 +171,7 @@ typedef __u64 __bitwise __be64;
166#endif 171#endif
167 172
168#ifdef __KERNEL__ 173#ifdef __KERNEL__
169typedef unsigned __nocast gfp_t; 174typedef unsigned __bitwise__ gfp_t;
170#endif 175#endif
171 176
172struct ustat { 177struct ustat {
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 37af443eb094..1d5c64df1653 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -700,7 +700,7 @@ static struct zonelist *zonelist_policy(gfp_t gfp, struct mempolicy *policy)
700 case MPOL_BIND: 700 case MPOL_BIND:
701 /* Lower zones don't get a policy applied */ 701 /* Lower zones don't get a policy applied */
702 /* Careful: current->mems_allowed might have moved */ 702 /* Careful: current->mems_allowed might have moved */
703 if ((gfp & GFP_ZONEMASK) >= policy_zone) 703 if (gfp_zone(gfp) >= policy_zone)
704 if (cpuset_zonelist_valid_mems_allowed(policy->v.zonelist)) 704 if (cpuset_zonelist_valid_mems_allowed(policy->v.zonelist))
705 return policy->v.zonelist; 705 return policy->v.zonelist;
706 /*FALL THROUGH*/ 706 /*FALL THROUGH*/
@@ -712,7 +712,7 @@ static struct zonelist *zonelist_policy(gfp_t gfp, struct mempolicy *policy)
712 nd = 0; 712 nd = 0;
713 BUG(); 713 BUG();
714 } 714 }
715 return NODE_DATA(nd)->node_zonelists + (gfp & GFP_ZONEMASK); 715 return NODE_DATA(nd)->node_zonelists + gfp_zone(gfp);
716} 716}
717 717
718/* Do dynamic interleaving for a process */ 718/* Do dynamic interleaving for a process */
@@ -757,7 +757,7 @@ static struct page *alloc_page_interleave(gfp_t gfp, unsigned order, unsigned ni
757 struct page *page; 757 struct page *page;
758 758
759 BUG_ON(!node_online(nid)); 759 BUG_ON(!node_online(nid));
760 zl = NODE_DATA(nid)->node_zonelists + (gfp & GFP_ZONEMASK); 760 zl = NODE_DATA(nid)->node_zonelists + gfp_zone(gfp);
761 page = __alloc_pages(gfp, order, zl); 761 page = __alloc_pages(gfp, order, zl);
762 if (page && page_zone(page) == zl->zones[0]) { 762 if (page && page_zone(page) == zl->zones[0]) {
763 zone_pcp(zl->zones[0],get_cpu())->interleave_hit++; 763 zone_pcp(zl->zones[0],get_cpu())->interleave_hit++;
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index e1d3d77f4aee..aa43ae3ab8c9 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1089,7 +1089,7 @@ static unsigned int nr_free_zone_pages(int offset)
1089 */ 1089 */
1090unsigned int nr_free_buffer_pages(void) 1090unsigned int nr_free_buffer_pages(void)
1091{ 1091{
1092 return nr_free_zone_pages(GFP_USER & GFP_ZONEMASK); 1092 return nr_free_zone_pages(gfp_zone(GFP_USER));
1093} 1093}
1094 1094
1095/* 1095/*
@@ -1097,7 +1097,7 @@ unsigned int nr_free_buffer_pages(void)
1097 */ 1097 */
1098unsigned int nr_free_pagecache_pages(void) 1098unsigned int nr_free_pagecache_pages(void)
1099{ 1099{
1100 return nr_free_zone_pages(GFP_HIGHUSER & GFP_ZONEMASK); 1100 return nr_free_zone_pages(gfp_zone(GFP_HIGHUSER));
1101} 1101}
1102 1102
1103#ifdef CONFIG_HIGHMEM 1103#ifdef CONFIG_HIGHMEM