lkml.org 
[lkml]   [2018]   [Jan]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] arch/cris: use get_user_pages_fast()
Date
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(&current->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(&current->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(&current->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(&current->mm->mmap_sem);
}

/* Add 6 to nooutpages to make room for possibly inserted buffers for storing digest and
--
2.13.6
\
 
 \ /
  Last update: 2018-01-22 00:07    [W:0.033 / U:0.592 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site