Re: [PATCH v2] fs/aio: Replace kmap{,_atomic}() with kmap_local_page()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 11, 2023 at 04:02:26PM +0000, Al Viro wrote:
> On Wed, Jan 11, 2023 at 09:13:40AM -0500, Jeff Moyer wrote:
> > Hi, Al,
> > 
> > Al Viro <viro@xxxxxxxxxxxxxxxxxx> writes:
> > 
> > > On Mon, Jan 09, 2023 at 06:56:29PM +0100, Fabio M. De Francesco wrote:
> > >
> > >> -	ring = kmap_atomic(ctx->ring_pages[0]);
> > >> +	ring = kmap_local_page(ctx->ring_pages[0]);
> > >>  	ring->nr = nr_events;	/* user copy */
> > >>  	ring->id = ~0U;
> > >>  	ring->head = ring->tail = 0;
> > >> @@ -575,7 +575,7 @@ static int aio_setup_ring(struct kioctx *ctx, unsigned int nr_events)
> > >>  	ring->compat_features = AIO_RING_COMPAT_FEATURES;
> > >>  	ring->incompat_features = AIO_RING_INCOMPAT_FEATURES;
> > >>  	ring->header_length = sizeof(struct aio_ring);
> > >> -	kunmap_atomic(ring);
> > >> +	kunmap_local(ring);
> > >>  	flush_dcache_page(ctx->ring_pages[0]);
> > >
> > > I wonder if it would be more readable as memcpy_to_page(), actually...
> > 
> > I'm not sure I understand what you're suggesting.
> 
> 	memcpy_to_page(ctx->ring_pages[0], 0, &(struct aio_ring){
> 			.nr = nr_events, .id = ~0U, .magic = AIO_RING_MAGIC,
> 			.compat_features = AIO_RING_COMPAT_FEATURES,
> 			.in_compat_features = AIO_RING_INCOMPAT_FEATURES,
> 			.header_length = sizeof(struct aio_ring)},
> 			sizeof(struct aio_ring));
> 
> instead of the lines from kmap_atomic to flush_dcache_page...

For us mere mortals I think this may parse easier as:

	struct aio_ring r;

...
	r = (struct aio_ring) {
		.nr = nr_events,
		.id = ~0U,
		.magic = AIO_RING_MAGIC,
		.compat_features = AIO_RING_COMPAT_FEATURES,
		.incompat_features = AIO_RING_INCOMPAT_FEATURES,
		.header_length = sizeof(struct aio_ring),
	};

	memcpy_to_page(ctx->ring_pages[0], 0, &r, sizeof(r));
...

Is there any concern with the extra assignments to the stack only to copy into
the page?  I guess this is not a critical path?

Ira

> > 
> > >>  
> > >>  	return 0;
> > >> @@ -678,9 +678,9 @@ static int ioctx_add_table(struct kioctx *ctx, struct mm_struct *mm)
> > >>  					 * we are protected from page migration
> > >>  					 * changes ring_pages by ->ring_lock.
> > >>  					 */
> > >> -					ring = kmap_atomic(ctx->ring_pages[0]);
> > >> +					ring = kmap_local_page(ctx->ring_pages[0]);
> > >>  					ring->id = ctx->id;
> > >> -					kunmap_atomic(ring);
> > >> +					kunmap_local(ring);
> > >
> > > Incidentally, does it need flush_dcache_page()?
> > 
> > Yes, good catch.



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux