Skip to contentSkip to conversation

gfp_t

PATCH In review Rusty Russell 3 participants 7 messages Sep 26, 2002 – Oct 17, 2002

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gfp_t

This creates a mythical gfp_t for passing gfp states, and conversion macros __GFP() and __UNGFP(), to give warnings, It's 55k, so compressed and attached.

[Jens, bio_alloc() has the args reversed from normal (Grrr!)]

It's worse than I'd hoped, better than I feared. I didn't find any bugs (but then I didn't try compiling with "allyesconfig").

Notes:
o People use GFP_KERNEL instead of SLAB_KERNEL for kmem_cache_alloc, so I changed the slab types too.

o If we really want to do this, maybe introduce gfp_t as a typedef to int, and use it in all the interfaces first, then change the definition later.

BTW, I'm leaving in a couple of hours, so I'm leaving this here for someone else to get enthusiastic about 8)

Cheers,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#1 lore raw
Quoted 3 lines · Rusty Russell

This creates a mythical gfp_t for passing gfp states, and conversion macros __GFP() and __UNGFP(), to give warnings, It's 55k, so compressed and attached.

This breaks ntfs/malloc.h which is doing the following:
49: return __vmalloc(size, GFP_NOFS | __GFP_HIGHMEM, PAGE_KERNEL);

This turns into

          return __vmalloc(size, ((struct gfp_arg *)(0x10 | 0x40 |
		0x80)) | 0x02, ((pgprot_t) { (__PAGE_KERNEL) } ));

which '|' is not happy with.

Regards,
Rasmus

#2 lore raw
Quoted 7 lines · Rasmus Andersen
Quoted 3 lines · Rusty Russell

This creates a mythical gfp_t for passing gfp states, and conversion macros __GFP() and __UNGFP(), to give warnings, It's 55k, so compressed and attached.

This breaks ntfs/malloc.h which is doing the following:
49: return __vmalloc(size, GFP_NOFS | __GFP_HIGHMEM, PAGE_KERNEL);

[...]

After having had a bit more caffeine, I guess I would like to change my previous mail to: These two patches for mm/numa.c and ntfs/malloc.h needs to be in your patchset as well.

home/rasmus/transport/linux-2.5.38/mm/numa.c renamed from mm/numa.c +2 -2
@@ -42,10 +42,10 @@
 
 #endif /* !CONFIG_DISCONTIGMEM */
 
-struct page * alloc_pages_node(int nid, unsigned int gfp_mask, unsigned int order)
+struct page * alloc_pages_node(int nid, gfp_t gfp_mask, unsigned int order)
 {
 #ifdef CONFIG_NUMA
-	return __alloc_pages(gfp_mask, order, NODE_DATA(nid)->node_zonelists + (gfp_mask & GFP_ZONEMASK));
+	return __alloc_pages(gfp_mask, order, NODE_DATA(nid)->node_zonelists + (__UNGFP(gfp_mask) & GFP_ZONEMASK));
 #else
 	return alloc_pages(gfp_mask, order);
 #endif
home/rasmus/transport/linux-2.5.38/fs/ntfs/malloc.h renamed from fs/ntfs/malloc.h +1 -1
@@ -46,7 +46,7 @@
 		BUG();
 	}
 	if (likely(size >> PAGE_SHIFT < num_physpages))
-		return __vmalloc(size, GFP_NOFS | __GFP_HIGHMEM, PAGE_KERNEL);
+		return __vmalloc(size, gfp_sub(GFP_NOFS, __GFP_HIGHMEM), PAGE_KERNEL);
 	return NULL;
 }
 

Regards,
Rasmus

#3 lore raw
Quoted 6 lines · Rasmus Andersen
Quoted 5 lines · Rasmus Andersen
Quoted 3 lines · Rusty Russell

This creates a mythical gfp_t for passing gfp states, and conversion macros __GFP() and __UNGFP(), to give warnings, It's 55k, so compressed and attached.

Quoted 7 lines
Quoted 2 lines

This breaks ntfs/malloc.h which is doing the following:
49: return __vmalloc(size, GFP_NOFS | __GFP_HIGHMEM, PAGE_KERNEL);

[...]

After having had a bit more caffeine, I guess I would like to change my previous mail to: These two patches for mm/numa.c and ntfs/malloc.h needs to be in your patchset as well.

Another one:

drivers/char/synclink.c +3 -3
@@ -3975,7 +3975,7 @@
 		/* inspect portions of the buffer while other portions are being */
 		/* updated by the adapter using Bus Master DMA. */
 
-		info->buffer_list = kmalloc(BUFFERLISTSIZE, GFP_KERNEL | GFP_DMA);
+		info->buffer_list = kmalloc(BUFFERLISTSIZE, gfp_sub(GFP_KERNEL, __UNGFP(GFP_DMA)));
 		if ( info->buffer_list == NULL )
 			return -ENOMEM;
 			
@@ -4087,7 +4087,7 @@
 		} else {
 			/* ISA adapter uses system memory. */
 			BufferList[i].virt_addr = 
-				kmalloc(DMABUFFERSIZE, GFP_KERNEL | GFP_DMA);
+				kmalloc(DMABUFFERSIZE, gfp_sub(GFP_KERNEL, __UNGFP(GFP_DMA)));
 			if ( BufferList[i].virt_addr == NULL )
 				return -ENOMEM;
 			phys_addr = isa_virt_to_bus(BufferList[i].virt_addr);
@@ -4159,7 +4159,7 @@
  */
 int mgsl_alloc_intermediate_rxbuffer_memory(struct mgsl_struct *info)
 {
-	info->intermediate_rxbuffer = kmalloc(info->max_frame_size, GFP_KERNEL | GFP_DMA);
+	info->intermediate_rxbuffer = kmalloc(info->max_frame_size, gfp_sub(GFP_KERNEL, __UNGFP(GFP_DMA)));
 	if ( info->intermediate_rxbuffer == NULL )
 		return -ENOMEM;
 

Regards,
Rasmus

#4 lore raw

In message <[email protected]> you write:

Quoted 5 lines
Quoted 3 lines

After having had a bit more caffeine, I guess I would like to change my previous mail to: These two patches for mm/numa.c and ntfs/malloc.h needs to be in your patchset as well.

Another one:

Thanks, both added. The patch is unlikely to go anywhere unless someone champions it though.

Cheers,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#5 lore raw

From: Rusty Russell <[email protected]>
Date: Wed, 16 Oct 2002 09:10:17 +1000

Thanks, both added. The patch is unlikely to go anywhere unless someone champions it though.

Please post the current state of the patch so that this might be possible :-)

#6 lore raw

In message <[email protected]> you write:

Quoted 8 lines

From: Rusty Russell <[email protected]>
Date: Wed, 16 Oct 2002 09:10:17 +1000

Thanks, both added. The patch is unlikely to go anywhere unless someone champions it though.

Please post the current state of the patch so that this might be possible :-)

Oh, OK. It's on my kernel.org web page with all my other patches, of course, but updated and included here for wider audience.

Compiles...
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.