From: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
To: Ira Weiny <ira.weiny@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Benjamin Philip <benjamin.philip495@gmail.com>,
Bart Van Assche <bvanassche@acm.org>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Charlie Sands <sandsch@northvilleschools.net>,
Mitali Borkar <mitaliborkar810@gmail.com>,
Colin Ian King <colin.king@intel.com>,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: rts5208: Convert kmap() to kmap_local_page()
Date: Mon, 28 Mar 2022 19:21:26 +0200 [thread overview]
Message-ID: <1816944.CQOukoFCf9@leap> (raw)
In-Reply-To: <YkHXQRmExRFioEBN@iweiny-desk3>
On luned? 28 marzo 2022 17:41:53 CEST Ira Weiny wrote:
> On Mon, Mar 28, 2022 at 01:24:40PM +0200, Fabio M. De Francesco wrote:
> > The use of kmap() is being deprecated and kmap_local_page() is faster.
> > Use kmap_local_page() in place of kmap().
>
> Thanks for the patch!
Thanks for your review!
> I have just a couple of comments.
>
> kmap_local_page() is not necessarily faster than kmap() but it is more correct
> in this case. You should mention why.
Sure, my mistake. Thomas G. was talking about kmap_atomic() when he wrote that
it is "faster". It does not apply to kmap_local_page().
What could justify the use of kmap_local_page() is that "The mapping is per
thread, CPU local and not globally visible.". Therefore this code is the right
context where to use kmap_local_page() in place of kmap().
At this moment I think that I might change my commit message and write something
like the above.
However, I'll research more information during the next days. In the meantime
I'm also going to take a look at the differences in implementation.
> Also to help with kmap_local_page() there are a number of helpers implemented
> in highmem.h for things like memcpy, memmove, etc.
>
> Check out memcpy_page() for this use case.
Aren't memcpy_to_page() and memcpy_from_page() better suited for the two
different branches of the "if" statement?
Thank you,
Fabio M. De Francesco
>
> Thank you!
> Ira
>
> >
> > Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
> > ---
> > drivers/staging/rts5208/rtsx_transport.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
> > index 805dc18fac0a..de690d7ee5e3 100644
> > --- a/drivers/staging/rts5208/rtsx_transport.c
> > +++ b/drivers/staging/rts5208/rtsx_transport.c
> > @@ -92,13 +92,13 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,
> > while (sglen > 0) {
> > unsigned int plen = min(sglen, (unsigned int)
> > PAGE_SIZE - poff);
> > - unsigned char *ptr = kmap(page);
> > + unsigned char *ptr = kmap_local_page(page);
> >
> > if (dir == TO_XFER_BUF)
> > memcpy(ptr + poff, buffer + cnt, plen);
> > else
> > memcpy(buffer + cnt, ptr + poff, plen);
> > - kunmap(page);
> > + kunmap_local(ptr);
> >
> > /* Start at the beginning of the next page */
> > poff = 0;
> > --
> > 2.34.1
> >
>
prev parent reply other threads:[~2022-03-28 17:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-28 11:24 [PATCH] staging: rts5208: Convert kmap() to kmap_local_page() Fabio M. De Francesco
2022-03-28 15:41 ` Ira Weiny
2022-03-28 16:11 ` Ira Weiny
2022-03-28 17:21 ` 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=1816944.CQOukoFCf9@leap \
--to=fmdefrancesco@gmail.com \
--cc=benjamin.philip495@gmail.com \
--cc=bvanassche@acm.org \
--cc=colin.king@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=ira.weiny@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=martin.petersen@oracle.com \
--cc=mitaliborkar810@gmail.com \
--cc=sandsch@northvilleschools.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.