Skip to contentSkip to conversation

kmalloc(HIGHUSER) crashes

PATCH New Matthew Wilcox 1 participant 1 message Dec 28, 2000

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kmalloc(HIGHUSER) crashes

doh, i'm a moron.

------ This is a copy of the message ------

Date: Thu, 28 Dec 2000 14:51:25 +0000
From: Matthew Wilcox <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [PATCH] kmalloc(HIGHUSER) crashes

The slab cache accepts the __GFP_HIGHMEM flag, but it will then die horribly, tracing it through:

<linux/slab.h>
#define SLAB_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_HIGHMEM)

slab.c:kmem_cache_grow()
if (flags & ~(SLAB_DMA|SLAB_LEVEL_MASK|SLAB_NO_GROW))
BUG();
(...)
slab.c:kmem_getpages()

        addr = (void*) __get_free_pages(flags, cachep->gfporder);

__get_free_pages calls page_address() on the allocated pages, but:

/*
* Permanent address of a page. Obviously must never be
* called on a highmem page.
*/
#define page_address(page) ((page)->virtual)

so I think we should apply the patch at the bottom of this email.

Ideally, I think slab.c should call alloc_pages and manage them directly -- it calls virt_to_page often enough that it should become more intimate with the linux struct page *. But I don't think we should allow HIGHMEM kmallocs anyway; we'd run out of kmap space too readily.

Index: include/linux/slab.h
===================================================================
RCS file: /var/cvs/linux/include/linux/slab.h,v
retrieving revision 1.1.1.1

linux/slab.h +1 -1
diff -u -p -r1.1.1.1 include/linux/slab.h
@@ -22,7 +22,7 @@ typedef struct kmem_cache_s kmem_cache_t
 #define	SLAB_NFS		GFP_NFS
 #define	SLAB_DMA		GFP_DMA
 
-#define SLAB_LEVEL_MASK		(__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_HIGHMEM)
+#define SLAB_LEVEL_MASK		(__GFP_WAIT|__GFP_HIGH|__GFP_IO)
 #define	SLAB_NO_GROW		0x00001000UL	/* don't grow a cache */
 
 /* flags to pass to kmem_cache_create().
Signature · 10 lines
Revolutions do not require corporate support.

----- End forwarded message -----

-- 
Revolutions do not require corporate support.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/