mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] kmalloc(HIGHUSER) crashes
@ 2000-12-28 14:58 Matthew Wilcox
  0 siblings, 0 replies; only message in thread
From: Matthew Wilcox @ 2000-12-28 14:58 UTC (permalink / raw)
  To: linux-kernel


doh, i'm a moron.

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

Date: Thu, 28 Dec 2000 14:51:25 +0000
From: Matthew Wilcox <matthew@wil.cx>
To: linux-kernel@vger.rutgers.edu
Cc: torvalds@transmeta.com
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
diff -u -p -r1.1.1.1 include/linux/slab.h
--- include/linux/slab.h	2000/10/31 19:18:05	1.1.1.1
+++ include/linux/slab.h	2000/12/28 11:06:49
@@ -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().

-- 
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 majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-12-28 15:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-12-28 14:58 [PATCH] kmalloc(HIGHUSER) crashes Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®