From: Davidlohr Bueso <dave@stgolabs.net>
To: starvik@axis.com, jesper.nilsson@axis.com, akpm@linux-foundation.org
Cc: viro@zeniv.linux.org.uk, linux-cris-kernel@axis.com,
linux-kernel@vger.kernel.org, Davidlohr Bueso <dave@stgolabs.net>,
Davidlohr Bueso <dbueso@suse.de>
Subject: [PATCH] arch/cris: use get_user_pages_fast()
Date: Sun, 21 Jan 2018 14:59:29 -0800 [thread overview]
Message-ID: <20180121225929.11782-1-dave@stgolabs.net> (raw)
Since we currently hold mmap_sem across both gup calls (and
nothing more), we can substitute it with two _fast()
alternatives and possibly avoid grabbing the lock.
This was found while adding mmap_sem wrappers, and was also
previously reported by Al: https://lkml.org/lkml/2017/11/17/777
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
arch/cris/arch-v32/drivers/cryptocop.c | 29 ++++++++++-------------------
1 file changed, 10 insertions(+), 19 deletions(-)
diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c
index d688fe117dca..76f8d3b1d39e 100644
--- a/arch/cris/arch-v32/drivers/cryptocop.c
+++ b/arch/cris/arch-v32/drivers/cryptocop.c
@@ -2717,37 +2717,28 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
}
}
- /* Acquire the mm page semaphore. */
- down_read(¤t->mm->mmap_sem);
-
- err = get_user_pages((unsigned long int)(oper.indata + prev_ix),
- noinpages,
- 0, /* read access only for in data */
- inpages,
- NULL);
+ err = get_user_pages_fast((unsigned long int)(oper.indata + prev_ix),
+ noinpages,
+ 0, /* read access only for in data */
+ inpages);
if (err < 0) {
- up_read(¤t->mm->mmap_sem);
nooutpages = noinpages = 0;
- DEBUG_API(printk("cryptocop_ioctl_process: get_user_pages indata\n"));
+ DEBUG_API(printk("cryptocop_ioctl_process: get_user_pages_fast indata\n"));
goto error_cleanup;
}
noinpages = err;
if (oper.do_cipher){
- err = get_user_pages((unsigned long int)oper.cipher_outdata,
- nooutpages,
- FOLL_WRITE, /* write access for out data */
- outpages,
- NULL);
- up_read(¤t->mm->mmap_sem);
+ err = get_user_pages_fast((unsigned long int)oper.cipher_outdata,
+ nooutpages,
+ FOLL_WRITE, /* write access for out data */
+ outpages);
if (err < 0) {
nooutpages = 0;
- DEBUG_API(printk("cryptocop_ioctl_process: get_user_pages outdata\n"));
+ DEBUG_API(printk("cryptocop_ioctl_process: get_user_pages_fast outdata\n"));
goto error_cleanup;
}
nooutpages = err;
- } else {
- up_read(¤t->mm->mmap_sem);
}
/* Add 6 to nooutpages to make room for possibly inserted buffers for storing digest and
--
2.13.6
next reply other threads:[~2018-01-21 23:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-21 22:59 Davidlohr Bueso [this message]
2018-01-21 23:39 ` [PATCH] arch/cris: use get_user_pages_fast() Al Viro
2018-01-21 23:48 ` Davidlohr Bueso
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=20180121225929.11782-1-dave@stgolabs.net \
--to=dave@stgolabs.net \
--cc=akpm@linux-foundation.org \
--cc=dbueso@suse.de \
--cc=jesper.nilsson@axis.com \
--cc=linux-cris-kernel@axis.com \
--cc=linux-kernel@vger.kernel.org \
--cc=starvik@axis.com \
--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