xfs
[Top] [All Lists]

New allocation flag for non critical allocations

To: linux-xfs@xxxxxxxxxxx
Subject: New allocation flag for non critical allocations
From: Marcelo Tosatti <marcelo@xxxxxxxxxxxxxxxx>
Date: Tue, 6 Mar 2001 19:09:29 -0300 (BRT)
Cc: Steve Lord <lord@xxxxxxx>, Rajagopal Ananthanarayanan <ananth@xxxxxxx>
Sender: owner-linux-xfs@xxxxxxxxxxx
Hi, 

I'm attaching a patch to add a new allocation flag which can be used by
non critical allocations.

The kernel memory allocator will fail relatively easy if this flag is set
for the current allocation. 

This is very useful for allocators which are trying to optimize things by
allocating memory, but want to fail in case memory is short. (e.g. IO
clustering)

The patch also changes pagebuf's writepage() code to use this new flag
when trying to allocate page pointers to do IO clustering. 

Comments are welcome. 



Index: mm/page_alloc.c
===================================================================
RCS file: /cvs/linux-2.4-xfs/linux/mm/page_alloc.c,v
retrieving revision 1.38
diff -u -r1.38 page_alloc.c
--- mm/page_alloc.c     2001/02/27 00:36:49     1.38
+++ mm/page_alloc.c     2001/03/06 23:29:05
@@ -398,6 +398,10 @@
        if (page)
                return page;
 
+        /* For non critical allocations we fail previously. */
+       if (gfp_mask & __GFP_FAIL)
+               return NULL;
+
        /*
         * Damn, we didn't succeed.
         *
Index: include/linux/mm.h
===================================================================
RCS file: /cvs/linux-2.4-xfs/linux/include/linux/mm.h,v
retrieving revision 1.50
diff -u -r1.50 mm.h
--- include/linux/mm.h  2001/02/27 00:36:49     1.50
+++ include/linux/mm.h  2001/03/06 23:29:33
@@ -468,7 +468,9 @@
 #endif
 #define __GFP_VM       0x20
 #define __GFP_PAGE_IO  0x40
+#define __GFP_FAIL     0x80
 
+#define GFP_FAIL       (__GFP_HIGH | __GFP_WAIT | __GFP_FAIL)
 #define GFP_PAGE_IO    (__GFP_HIGH | __GFP_WAIT | __GFP_PAGE_IO)
 #define GFP_BUFFER     (__GFP_HIGH | __GFP_WAIT)
 #define GFP_ATOMIC     (__GFP_HIGH)
Index: fs/pagebuf/page_buf_io.c
===================================================================
RCS file: /cvs/linux-2.4-xfs/linux/fs/pagebuf/page_buf_io.c,v
retrieving revision 1.64
diff -u -r1.64 page_buf_io.c
--- fs/pagebuf/page_buf_io.c    2001/03/05 20:58:46     1.64
+++ fs/pagebuf/page_buf_io.c    2001/03/06 23:29:51
@@ -989,7 +989,7 @@
        current->flags |= PF_MEMALLOC;
 #if defined(KIOCLUSTER)
        cpages = kmalloc(CLUSTER_PAGE_LIST_SIZE * sizeof(struct page *),
-                       GFP_PAGE_IO);
+                       GFP_FAIL);
 #endif
        do_write_full_page++;
 
Index: include/linux/slab.h
===================================================================
RCS file: /cvs/linux-2.4-xfs/linux/include/linux/slab.h,v
retrieving revision 1.13
diff -u -r1.13 slab.h
--- include/linux/slab.h        2001/02/22 21:29:07     1.13
+++ include/linux/slab.h        2001/03/06 23:30:34
@@ -22,8 +22,10 @@
 #define        SLAB_NFS                GFP_NFS
 #define        SLAB_DMA                GFP_DMA
 #define SLAB_PAGE_IO           GFP_PAGE_IO
+#define SLAB_FAIL              GFP_FAIL
 
-#define SLAB_LEVEL_MASK                
(__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_PAGE_IO)
+#define SLAB_LEVEL_MASK                
(__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_PAGE_IO|__GFP_FAIL)
+
 #define        SLAB_NO_GROW            0x00001000UL    /* don't grow a cache */
 
 /* flags to pass to kmem_cache_create().



<Prev in Thread] Current Thread [Next in Thread>
  • New allocation flag for non critical allocations, Marcelo Tosatti <=