public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
To: Jeff Moyer <jmoyer@redhat.com>, Al Viro <viro@zeniv.linux.org.uk>
Cc: Benjamin LaHaise <bcrl@kvack.org>,
	linux-aio@kvack.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, "Venkataramanan,
	Anirudh" <anirudh.venkataramanan@intel.com>,
	Ira Weiny <ira.weiny@intel.com>
Subject: Re: [PATCH v2] fs/aio: Replace kmap{,_atomic}() with kmap_local_page()
Date: Thu, 12 Jan 2023 21:42:33 +0100	[thread overview]
Message-ID: <3477941.iIbC2pHGDl@suse> (raw)
In-Reply-To: <Y77dkghufF6GVq1Y@ZenIV>

On mercoledì 11 gennaio 2023 17:02:26 CET Al Viro wrote:
> On Wed, Jan 11, 2023 at 09:13:40AM -0500, Jeff Moyer wrote:
> > Hi, Al,
> > 
> > Al Viro <viro@zeniv.linux.org.uk> 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...

Actually, I'd prefer Ira's solution for readability, but I have nothing 
against yours. I will send you the code in the way you rewrote it.

> > >>  	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.

Yes, I missed it :-(

However, with the use of memcpy_to_page() we no longer need that explicit call 
to flush_dcache_page().

Thank you,

Fabio



      parent reply	other threads:[~2023-01-12 21:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-09 17:56 [PATCH v2] fs/aio: Replace kmap{,_atomic}() with kmap_local_page() Fabio M. De Francesco
2023-01-11  0:11 ` Al Viro
2023-01-11 14:13   ` Jeff Moyer
2023-01-11 16:02     ` Al Viro
2023-01-11 16:20       ` Jeff Moyer
2023-01-11 16:29       ` Ira Weiny
2023-01-12 20:42       ` Fabio M. De Francesco [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3477941.iIbC2pHGDl@suse \
    --to=fmdefrancesco@gmail.com \
    --cc=anirudh.venkataramanan@intel.com \
    --cc=bcrl@kvack.org \
    --cc=ira.weiny@intel.com \
    --cc=jmoyer@redhat.com \
    --cc=linux-aio@kvack.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox