2002-09-26 04:38:49

by Rusty Russell

[permalink] [raw]
Subject: [PATCH] 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.


Attachments:
gfp_t.patch.gz (13.67 kB)
gfp_t safety patch

2002-09-26 18:54:17

by Rasmus Andersen

[permalink] [raw]
Subject: Re: [PATCH] gfp_t

On Thu, Sep 26, 2002 at 02:35:30PM +1000, Rusty Russell wrote:
> 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


Attachments:
(No filename) (545.00 B)
(No filename) (232.00 B)
Download all attachments

2002-09-26 19:24:23

by Rasmus Andersen

[permalink] [raw]
Subject: Re: [PATCH] gfp_t

On Thu, Sep 26, 2002 at 08:59:24PM +0200, Rasmus Andersen wrote:
> On Thu, Sep 26, 2002 at 02:35:30PM +1000, Rusty Russell wrote:
> > 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.

--- linux-2.5.38/mm/numa.c Sun Sep 22 06:25:17 2002
+++ /home/rasmus/transport/linux-2.5.38/mm/numa.c Thu Sep 26 21:18:59 2002
@@ -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


--- linux-2.5.38/fs/ntfs/malloc.h Sun Sep 22 06:25:01 2002
+++ /home/rasmus/transport/linux-2.5.38/fs/ntfs/malloc.h Thu Sep 26 21:15:55 2002
@@ -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


Attachments:
(No filename) (1.62 kB)
(No filename) (232.00 B)
Download all attachments

2002-09-26 21:09:56

by Rasmus Andersen

[permalink] [raw]
Subject: Re: [PATCH] gfp_t

On Thu, Sep 26, 2002 at 09:29:32PM +0200, Rasmus Andersen wrote:
> On Thu, Sep 26, 2002 at 08:59:24PM +0200, Rasmus Andersen wrote:
> > On Thu, Sep 26, 2002 at 02:35:30PM +1000, Rusty Russell wrote:
> > > 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.

Another one:


--- linux-2.5.38/drivers/char/synclink.c Sun Sep 22 06:25:06 2002
+++ linux-2.5.38-gfp/drivers/char/synclink.c Thu Sep 26 23:01:57 2002
@@ -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


Attachments:
(No filename) (1.90 kB)
(No filename) (232.00 B)
Download all attachments

2002-10-16 02:13:56

by Rusty Russell

[permalink] [raw]
Subject: Re: [PATCH] gfp_t

In message <[email protected]> you write:
> > 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.

2002-10-16 02:16:03

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] gfp_t

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 :-)

2002-10-17 07:49:46

by Rusty Russell

[permalink] [raw]
Subject: Re: [PATCH] gfp_t

In message <[email protected]> you write:
> 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.


Attachments:
gfp_t.patch.gz (15.59 kB)
gfp_t patch for 2.5.43