Whamcloud - gitweb
b=4336
[fs/lustre-release.git] / lustre / kernel_patches / patches / gfp_memalloc-2.4.21-chaos.patch
1 Index: linux-2.4.21-chaos/include/linux/mm.h
2 ===================================================================
3 --- linux-2.4.21-chaos.orig/include/linux/mm.h  2003-12-12 13:36:59.000000000 +0300
4 +++ linux-2.4.21-chaos/include/linux/mm.h       2003-12-12 16:15:57.000000000 +0300
5 @@ -843,6 +843,7 @@
6  #define __GFP_HIGHIO   0x80    /* Can start high mem physical IO? */
7  #define __GFP_FS       0x100   /* Can call down to low-level FS? */
8  #define __GFP_WIRED    0x200   /* Highmem bias and wired */
9 +#define __GFP_MEMALLOC 0x400   /* like PF_MEMALLOC: see __alloc_pages */
10  
11  #define GFP_NOHIGHIO   (__GFP_HIGH | __GFP_WAIT | __GFP_IO)
12  #define GFP_NOIO       (__GFP_HIGH | __GFP_WAIT)
13 @@ -853,6 +854,7 @@
14  #define GFP_KERNEL     (__GFP_HIGH | __GFP_WAIT | __GFP_IO | __GFP_HIGHIO | __GFP_FS)
15  #define GFP_NFS                (__GFP_HIGH | __GFP_WAIT | __GFP_IO | __GFP_HIGHIO | __GFP_FS)
16  #define GFP_KSWAPD     (             __GFP_WAIT | __GFP_IO | __GFP_HIGHIO | __GFP_FS)
17 +#define GFP_MEMALLOC   __GFP_MEMALLOC
18  
19  /* Flag - indicates that the buffer will be suitable for DMA.  Ignored on some
20     platforms, used as appropriate on others */
21 Index: linux-2.4.21-chaos/include/linux/slab.h
22 ===================================================================
23 --- linux-2.4.21-chaos.orig/include/linux/slab.h        2003-12-05 16:54:33.000000000 +0300
24 +++ linux-2.4.21-chaos/include/linux/slab.h     2003-12-12 16:15:57.000000000 +0300
25 @@ -23,6 +23,7 @@
26  #define        SLAB_KERNEL             GFP_KERNEL
27  #define        SLAB_NFS                GFP_NFS
28  #define        SLAB_DMA                GFP_DMA
29 +#define        SLAB_MEMALLOC           GFP_MEMALLOC
30  
31  #define SLAB_LEVEL_MASK                (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_HIGHIO|__GFP_FS)
32  #define        SLAB_NO_GROW            0x00001000UL    /* don't grow a cache */
33 Index: linux-2.4.21-chaos/mm/page_alloc.c
34 ===================================================================
35 --- linux-2.4.21-chaos.orig/mm/page_alloc.c     2003-12-12 11:31:08.000000000 +0300
36 +++ linux-2.4.21-chaos/mm/page_alloc.c  2003-12-12 16:15:57.000000000 +0300
37 @@ -595,7 +595,8 @@
38         /*
39          * Oh well, we didn't succeed.
40          */
41 -       if (!(current->flags & (PF_MEMALLOC|PF_MEMDIE))) {
42 +       if (!(current->flags & (PF_MEMALLOC|PF_MEMDIE)) &&
43 +               !(gfp_mask & __GFP_MEMALLOC)) {
44                 /*
45                  * Are we dealing with a higher order allocation?
46                  *
47 @@ -670,7 +671,9 @@
48  
49                 /* XXX: is pages_min/4 a good amount to reserve for this? */
50                 min += z->pages_min / 4;
51 -               if (z->free_pages > min || ((current->flags & PF_MEMALLOC) && !in_interrupt())) {
52 +               if (z->free_pages > min ||
53 +                   (((current->flags & PF_MEMALLOC) || (gfp_mask & __GFP_MEMALLOC))
54 +                    && !in_interrupt())) {
55                         page = rmqueue(z, order);
56                         if (page)
57                                 return page;
58 Index: linux-2.4.21-chaos/mm/slab.c
59 ===================================================================
60 --- linux-2.4.21-chaos.orig/mm/slab.c   2003-12-05 07:55:51.000000000 +0300
61 +++ linux-2.4.21-chaos/mm/slab.c        2003-12-12 16:15:57.000000000 +0300
62 @@ -1125,7 +1125,7 @@
63         /* Be lazy and only check for valid flags here,
64          * keeping it out of the critical path in kmem_cache_alloc().
65          */
66 -       if (flags & ~(SLAB_DMA|SLAB_LEVEL_MASK|SLAB_NO_GROW))
67 +       if (flags & ~(SLAB_DMA|SLAB_LEVEL_MASK|SLAB_NO_GROW|SLAB_MEMALLOC))
68                 BUG();
69         if (flags & SLAB_NO_GROW)
70                 return 0;