[OpenAFS-devel] [PATCH] linux kernel memory allocation and __GFP_HIGHMEM

Joe Buehler jbuehler@spirentcom.com
Fri, 02 Jun 2006 11:18:42 -0400


In looking at the way the 1.4.1 linux client code allocates memory,
I notice that it does not use __GFP_HIGHMEM.  I see that
at least one of my main machines appears to have a high
memory zone, as witnessed by the boot up messages:

Jun  2 04:13:20 brain kernel: Linux version 2.4.20-35.9smp (bachbuilder@n27) (gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) #1
SMP Thu Jun 24 06:51:49 EDT 2004
Jun  2 04:13:20 brain kernel: BIOS-provided physical RAM map:
Jun  2 04:13:20 brain kernel:  BIOS-e820: 0000000000000000 - 000000000009fc00 (usable)
Jun  2 04:13:20 brain kernel:  BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved)
Jun  2 04:13:20 brain kernel:  BIOS-e820: 00000000000e0000 - 0000000000100000 (reserved)
Jun  2 04:13:20 brain kernel:  BIOS-e820: 0000000000100000 - 0000000080000000 (usable)
Jun  2 04:13:20 brain kernel:  BIOS-e820: 00000000fec00000 - 00000000fed00000 (reserved)
Jun  2 04:13:20 brain kernel:  BIOS-e820: 00000000fee00000 - 00000000fee01000 (reserved)
Jun  2 04:13:20 brain kernel:  BIOS-e820: 00000000ffb80000 - 0000000100000000 (reserved)
Jun  2 04:13:20 brain kernel: 1152MB HIGHMEM available.
Jun  2 04:13:20 brain kernel: 896MB LOWMEM available.
Jun  2 04:13:20 brain kernel: found SMP MP-table at 000ff780
Jun  2 04:13:20 brain kernel: hm, page 000ff000 reserved twice.
Jun  2 04:13:20 brain syslog: klogd startup succeeded
Jun  2 04:13:20 brain kernel: hm, page 00100000 reserved twice.
Jun  2 04:13:20 brain kernel: hm, page 000f9000 reserved twice.
Jun  2 04:13:20 brain kernel: hm, page 000fa000 reserved twice.
Jun  2 04:13:20 brain kernel: On node 0 totalpages: 524288
Jun  2 04:13:20 brain kernel: zone(0): 4096 pages.
Jun  2 04:13:20 brain kernel: zone(1): 225280 pages.
Jun  2 04:13:20 brain kernel: zone(2): 294912 pages.

If I understand the kernel allocator correctly, the following patch
seems appropriate to enable kmalloc calls to use high memory:

--- src/afs/LINUX/osi_alloc.c.~1~	2004-12-07 01:12:12.000000000 -0500
+++ src/afs/LINUX/osi_alloc.c	2006-06-02 11:14:46.000000000 -0400
@@ -90,9 +90,9 @@
 	if (asize <= MAX_KMALLOC_SIZE) {
 	    new = (void *)(unsigned long)kmalloc(asize,
 #ifdef GFP_NOFS
-						 GFP_NOFS
+						 GFP_NOFS | __GFP_HIGHMEM
 #else
-						 GFP_KERNEL
+						 GFP_KERNEL | __GFP_HIGHMEM
 #endif
 		);
 	    if (new)		/* piggy back alloc type */
-- 
Joe Buehler