public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] fs: don't randomized kiocb fields
@ 2022-08-12 22:56 Keith Busch
  2022-08-12 23:00 ` Jens Axboe
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Keith Busch @ 2022-08-12 22:56 UTC (permalink / raw)
  To: axboe, io-uring; +Cc: linux-fsdevel, Keith Busch, Linus Torvalds

From: Keith Busch <[email protected]>

This is a size sensitive structure and randomizing can introduce extra
padding that breaks io_uring's fixed size expectations. There are few
fields here as it is, half of which need a fixed order to optimally
pack, so the randomization isn't providing much.

Suggested-by: Linus Torvalds <[email protected]>
Signed-off-by: Keith Busch <[email protected]>
---
 include/linux/fs.h | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 5113f65c786f..9eced4cc286e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -340,17 +340,12 @@ enum rw_hint {
 
 struct kiocb {
 	struct file		*ki_filp;
-
-	/* The 'ki_filp' pointer is shared in a union for aio */
-	randomized_struct_fields_start
-
 	loff_t			ki_pos;
 	void (*ki_complete)(struct kiocb *iocb, long ret);
 	void			*private;
 	int			ki_flags;
 	u16			ki_ioprio; /* See linux/ioprio.h */
 	struct wait_page_queue	*ki_waitq; /* for async buffered IO */
-	randomized_struct_fields_end
 };
 
 static inline bool is_sync_kiocb(struct kiocb *kiocb)
-- 
2.30.2


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

* Re: [PATCH] fs: don't randomized kiocb fields
  2022-08-12 22:56 [PATCH] fs: don't randomized kiocb fields Keith Busch
@ 2022-08-12 23:00 ` Jens Axboe
  2022-08-13  7:59 ` Christoph Hellwig
  2022-08-14 10:35 ` Matthew Wilcox
  2 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2022-08-12 23:00 UTC (permalink / raw)
  To: Keith Busch, io-uring; +Cc: linux-fsdevel, Keith Busch, Linus Torvalds

On 8/12/22 4:56 PM, Keith Busch wrote:
> From: Keith Busch <[email protected]>
> 
> This is a size sensitive structure and randomizing can introduce extra
> padding that breaks io_uring's fixed size expectations. There are few
> fields here as it is, half of which need a fixed order to optimally
> pack, so the randomization isn't providing much.

I'll add the link to the previous discussion as well in the commit:

Link: https://lore.kernel.org/io-uring/[email protected]/

as it's pretty useful for context.

-- 
Jens Axboe


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

* Re: [PATCH] fs: don't randomized kiocb fields
  2022-08-12 22:56 [PATCH] fs: don't randomized kiocb fields Keith Busch
  2022-08-12 23:00 ` Jens Axboe
@ 2022-08-13  7:59 ` Christoph Hellwig
  2022-08-13 14:33   ` Jens Axboe
  2022-08-14 10:35 ` Matthew Wilcox
  2 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2022-08-13  7:59 UTC (permalink / raw)
  To: Keith Busch; +Cc: axboe, io-uring, linux-fsdevel, Keith Busch, Linus Torvalds

s/randomized/randomize/

in the subject?

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

* Re: [PATCH] fs: don't randomized kiocb fields
  2022-08-13  7:59 ` Christoph Hellwig
@ 2022-08-13 14:33   ` Jens Axboe
  0 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2022-08-13 14:33 UTC (permalink / raw)
  To: Christoph Hellwig, Keith Busch
  Cc: io-uring, linux-fsdevel, Keith Busch, Linus Torvalds

On 8/13/22 1:59 AM, Christoph Hellwig wrote:
> s/randomized/randomize/
> 
> in the subject?

I did notice that one and made the edit yesterday.

-- 
Jens Axboe


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

* Re: [PATCH] fs: don't randomized kiocb fields
  2022-08-12 22:56 [PATCH] fs: don't randomized kiocb fields Keith Busch
  2022-08-12 23:00 ` Jens Axboe
  2022-08-13  7:59 ` Christoph Hellwig
@ 2022-08-14 10:35 ` Matthew Wilcox
  2022-08-15 14:49   ` Keith Busch
  2 siblings, 1 reply; 6+ messages in thread
From: Matthew Wilcox @ 2022-08-14 10:35 UTC (permalink / raw)
  To: Keith Busch; +Cc: axboe, io-uring, linux-fsdevel, Keith Busch, Linus Torvalds

On Fri, Aug 12, 2022 at 03:56:33PM -0700, Keith Busch wrote:
>  struct kiocb {
>  	struct file		*ki_filp;
> -
> -	/* The 'ki_filp' pointer is shared in a union for aio */
> -	randomized_struct_fields_start
> -
>  	loff_t			ki_pos;
>  	void (*ki_complete)(struct kiocb *iocb, long ret);
>  	void			*private;
>  	int			ki_flags;
>  	u16			ki_ioprio; /* See linux/ioprio.h */
>  	struct wait_page_queue	*ki_waitq; /* for async buffered IO */
> -	randomized_struct_fields_end
>  };

Now that I've read the thread ...

If we care about struct size on 32-bit, we should fit something into
the 32-bit hole before the 64-bit loff_t (assuming at least some 32-bit
arches want loff_t to be 64-bit aligned; I thik x86 doesn't?)
Easiest seems to be to put ki_complete before ki_pos?

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

* Re: [PATCH] fs: don't randomized kiocb fields
  2022-08-14 10:35 ` Matthew Wilcox
@ 2022-08-15 14:49   ` Keith Busch
  0 siblings, 0 replies; 6+ messages in thread
From: Keith Busch @ 2022-08-15 14:49 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Keith Busch, axboe, io-uring, linux-fsdevel, Linus Torvalds

On Sun, Aug 14, 2022 at 11:35:35AM +0100, Matthew Wilcox wrote:
> On Fri, Aug 12, 2022 at 03:56:33PM -0700, Keith Busch wrote:
> >  struct kiocb {
> >  	struct file		*ki_filp;
> > -
> > -	/* The 'ki_filp' pointer is shared in a union for aio */
> > -	randomized_struct_fields_start
> > -
> >  	loff_t			ki_pos;
> >  	void (*ki_complete)(struct kiocb *iocb, long ret);
> >  	void			*private;
> >  	int			ki_flags;
> >  	u16			ki_ioprio; /* See linux/ioprio.h */
> >  	struct wait_page_queue	*ki_waitq; /* for async buffered IO */
> > -	randomized_struct_fields_end
> >  };
> 
> Now that I've read the thread ...
> 
> If we care about struct size on 32-bit, we should fit something into
> the 32-bit hole before the 64-bit loff_t (assuming at least some 32-bit
> arches want loff_t to be 64-bit aligned; I thik x86 doesn't?)
> Easiest seems to be to put ki_complete before ki_pos?

Yes, that would be a better compact arrangment. The immediate need was just to
correct io_uring's max command struct size. The 32-bit verison isn't near the
limit, so no additional optimizations were done in this patch. 

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

end of thread, other threads:[~2022-08-15 14:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-12 22:56 [PATCH] fs: don't randomized kiocb fields Keith Busch
2022-08-12 23:00 ` Jens Axboe
2022-08-13  7:59 ` Christoph Hellwig
2022-08-13 14:33   ` Jens Axboe
2022-08-14 10:35 ` Matthew Wilcox
2022-08-15 14:49   ` Keith Busch

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