mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch] aio: make aio_ring_info->nr_pages an unsigned int
@ 2006-12-30  3:15 Chen, Kenneth W
  2007-01-03  1:14 ` Zach Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Chen, Kenneth W @ 2006-12-30  3:15 UTC (permalink / raw)
  To: 'Andrew Morton', zach.brown
  Cc: linux-aio, linux-kernel, 'Benjamin LaHaise', suparna

The number of io_event in AIO event queue allowed currently is no more
than 2^32-1, because the syscall defines:

	asmlinkage long sys_io_setup(unsigned nr_events, aio_context_t __user *ctxp)

We internally allocate a ring buffer for nr_events and keeps tracks of
page descriptors for each of these ring buffer pages.  Since page size
is significantly larger than AIO event size (4096 versus 32), I don't
think it is ever possible to overflow nr_pages in 32-bit quantity.

This patch changes nr_pages to unsigned int. on 64-bit arch, changing
it to unsigned int also allows better packing of aio_ring_info structure.


Signed-off-by: Ken Chen <kenneth.w.chen@intel.com>

--- ./include/linux/aio.h.orig	2006-12-24 22:31:55.000000000 -0800
+++ ./include/linux/aio.h	2006-12-24 22:41:28.000000000 -0800
@@ -165,7 +165,7 @@ struct aio_ring_info {
 
 	struct page		**ring_pages;
 	spinlock_t		ring_lock;
-	long			nr_pages;
+	unsigned		nr_pages;
 
 	unsigned		nr, tail;
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] aio: make aio_ring_info->nr_pages an unsigned int
  2006-12-30  3:15 [patch] aio: make aio_ring_info->nr_pages an unsigned int Chen, Kenneth W
@ 2007-01-03  1:14 ` Zach Brown
  2007-01-03  1:23   ` Chen, Kenneth W
  0 siblings, 1 reply; 4+ messages in thread
From: Zach Brown @ 2007-01-03  1:14 UTC (permalink / raw)
  To: Chen, Kenneth W
  Cc: 'Andrew Morton',
	linux-aio, linux-kernel, 'Benjamin LaHaise',
	suparna

> --- ./include/linux/aio.h.orig	2006-12-24 22:31:55.000000000 -0800
> +++ ./include/linux/aio.h	2006-12-24 22:41:28.000000000 -0800
> @@ -165,7 +165,7 @@ struct aio_ring_info {
>
>  	struct page		**ring_pages;
>  	spinlock_t		ring_lock;
> -	long			nr_pages;
> +	unsigned		nr_pages;
>
>  	unsigned		nr, tail;
>
>

Hmm.

This seems so trivial as to not be worth it.  It'd be more compelling  
if it was more thorough -- doing things like updating the 'long i'  
iterators that a feww have over ->nr_pages.  That kind of thing.   
Giving some confidence that the references of ->nr_pages were audited.

- z

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [patch] aio: make aio_ring_info->nr_pages an unsigned int
  2007-01-03  1:14 ` Zach Brown
@ 2007-01-03  1:23   ` Chen, Kenneth W
  2007-01-03  1:25     ` Zach Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Chen, Kenneth W @ 2007-01-03  1:23 UTC (permalink / raw)
  To: 'Zach Brown'
  Cc: 'Andrew Morton',
	linux-aio, linux-kernel, 'Benjamin LaHaise',
	suparna

Zach Brown wrote on Tuesday, January 02, 2007 5:14 PM
> To: Chen, Kenneth W
> > --- ./include/linux/aio.h.orig	2006-12-24 22:31:55.000000000 -0800
> > +++ ./include/linux/aio.h	2006-12-24 22:41:28.000000000 -0800
> > @@ -165,7 +165,7 @@ struct aio_ring_info {
> >
> >  	struct page		**ring_pages;
> >  	spinlock_t		ring_lock;
> > -	long			nr_pages;
> > +	unsigned		nr_pages;
> >
> >  	unsigned		nr, tail;
> 
> Hmm.
> 
> This seems so trivial as to not be worth it.  It'd be more compelling  
> if it was more thorough -- doing things like updating the 'long i'  
> iterators that a feww have over ->nr_pages.  That kind of thing.   
> Giving some confidence that the references of ->nr_pages were audited.


I had that changes earlier, but dropped it to make the patch smaller. It
all started with head and tail index, which is defined as unsigned int in
structure, but in aio.c, all local variables that does temporary head and
tail calculation are unsigned long. While cleaning that, it got expanded
into nr_pages etc.  Oh well.

- Ken


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] aio: make aio_ring_info->nr_pages an unsigned int
  2007-01-03  1:23   ` Chen, Kenneth W
@ 2007-01-03  1:25     ` Zach Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Zach Brown @ 2007-01-03  1:25 UTC (permalink / raw)
  To: Chen, Kenneth W
  Cc: 'Andrew Morton',
	linux-aio, linux-kernel, 'Benjamin LaHaise',
	suparna

>
> I had that changes earlier, but dropped it to make the patch smaller.

Still have it kicking around?

Making this stuff more consistent would be nice, I agree, I'm just  
not sure it's worth the risk of running into some subtle bugs.

- z

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-01-03  1:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-30  3:15 [patch] aio: make aio_ring_info->nr_pages an unsigned int Chen, Kenneth W
2007-01-03  1:14 ` Zach Brown
2007-01-03  1:23   ` Chen, Kenneth W
2007-01-03  1:25     ` Zach Brown

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

Powered by JetHome