Re: [PATCH v2 10/10] kernel: might_fault does not imply might_sleep

2013-05-22 Thread Michael S. Tsirkin
On Tue, May 21, 2013 at 01:57:34PM +0200, Peter Zijlstra wrote: > On Sun, May 19, 2013 at 12:35:26PM +0300, Michael S. Tsirkin wrote: > > > > --- a/include/linux/kernel.h > > > > +++ b/include/linux/kernel.h > > > > @@ -198,7 +198,6 @@ void might_fault(void); > > > > #else > > > > static inline v

Re: [PATCH v2 10/10] kernel: might_fault does not imply might_sleep

2013-05-22 Thread Michael S. Tsirkin
On Thu, May 16, 2013 at 08:40:41PM +0200, Peter Zijlstra wrote: > On Thu, May 16, 2013 at 02:16:10PM +0300, Michael S. Tsirkin wrote: > > There are several ways to make sure might_fault > > calling function does not sleep. > > One is to use it on kernel or otherwise locked memory - apparently > > n

Re: [PATCH v2 10/10] kernel: might_fault does not imply might_sleep

2013-05-22 Thread Peter Zijlstra
On Wed, May 22, 2013 at 12:47:09PM +0300, Michael S. Tsirkin wrote: > > > > +static inline bool __can_fault(void) > > +{ > > + /* > > +* Some code (nfs/sunrpc) uses socket ops on kernel memory while > > +* holding the mmap_sem, this is safe because kernel memory doesn't > > +* get p

Re: [PATCH v2 10/10] kernel: might_fault does not imply might_sleep

2013-05-22 Thread Michael S. Tsirkin
On Tue, May 21, 2013 at 01:57:34PM +0200, Peter Zijlstra wrote: > On Sun, May 19, 2013 at 12:35:26PM +0300, Michael S. Tsirkin wrote: > > > > --- a/include/linux/kernel.h > > > > +++ b/include/linux/kernel.h > > > > @@ -198,7 +198,6 @@ void might_fault(void); > > > > #else > > > > static inline v

Re: [PATCH v2 10/10] kernel: might_fault does not imply might_sleep

2013-05-21 Thread Peter Zijlstra
On Sun, May 19, 2013 at 12:35:26PM +0300, Michael S. Tsirkin wrote: > On Thu, May 16, 2013 at 08:40:41PM +0200, Peter Zijlstra wrote: > > On Thu, May 16, 2013 at 02:16:10PM +0300, Michael S. Tsirkin wrote: > > > There are several ways to make sure might_fault > > > calling function does not sleep.

Re: [PATCH v2 10/10] kernel: might_fault does not imply might_sleep

2013-05-21 Thread Peter Zijlstra
On Sun, May 19, 2013 at 12:35:26PM +0300, Michael S. Tsirkin wrote: > > > --- a/include/linux/kernel.h > > > +++ b/include/linux/kernel.h > > > @@ -198,7 +198,6 @@ void might_fault(void); > > > #else > > > static inline void might_fault(void) > > > { > > > - might_sleep(); > > > > This removes

Re: [PATCH v2 10/10] kernel: might_fault does not imply might_sleep

2013-05-21 Thread Peter Zijlstra
On Sun, May 19, 2013 at 07:40:09PM +0300, Michael S. Tsirkin wrote: > OK I get it. So let me correct myself. The simple code > that does something like this under a spinlock: > > preempt_disable > > pagefault_disable > > error = copy_to_user > > pagefault_enable > > pr

Re: [PATCH v2 10/10] kernel: might_fault does not imply might_sleep

2013-05-19 Thread Michael S. Tsirkin
On Sun, May 19, 2013 at 04:23:22PM -0400, Steven Rostedt wrote: > On Sun, 2013-05-19 at 19:40 +0300, Michael S. Tsirkin wrote: > > > OK I get it. So let me correct myself. The simple code > > that does something like this under a spinlock: > > > preempt_disable > > > pagefault_disable

Re: [PATCH v2 10/10] kernel: might_fault does not imply might_sleep

2013-05-19 Thread Steven Rostedt
On Sun, 2013-05-19 at 19:40 +0300, Michael S. Tsirkin wrote: > OK I get it. So let me correct myself. The simple code > that does something like this under a spinlock: > > preempt_disable > > pagefault_disable > > error = copy_to_user > > pagefault_enable > > preempt_

Re: [PATCH v2 10/10] kernel: might_fault does not imply might_sleep

2013-05-19 Thread Michael S. Tsirkin
On Sun, May 19, 2013 at 12:06:19PM -0400, Steven Rostedt wrote: > On Sun, 2013-05-19 at 16:34 +0300, Michael S. Tsirkin wrote: > > > Right but we need to keep it working on upstream as well. > > If I do preempt_enable under a spinlock upstream won't it > > try to sleep under spinlock? > > No it w

Re: [PATCH v2 10/10] kernel: might_fault does not imply might_sleep

2013-05-19 Thread Steven Rostedt
On Sun, 2013-05-19 at 16:34 +0300, Michael S. Tsirkin wrote: > Right but we need to keep it working on upstream as well. > If I do preempt_enable under a spinlock upstream won't it > try to sleep under spinlock? No it wont. A spinlock calls preempt_disable implicitly, and a preempt_enable() will

Re: [PATCH v2 10/10] kernel: might_fault does not imply might_sleep

2013-05-19 Thread Michael S. Tsirkin
On Sun, May 19, 2013 at 08:34:04AM -0400, Steven Rostedt wrote: > On Sun, 2013-05-19 at 12:35 +0300, Michael S. Tsirkin wrote: > > > No, I was not assuming that. What I'm trying to say is that a caller > > that does something like this under a spinlock: > > preempt_disable > > pagefault_di

Re: [PATCH v2 10/10] kernel: might_fault does not imply might_sleep

2013-05-19 Thread Steven Rostedt
On Sun, 2013-05-19 at 12:35 +0300, Michael S. Tsirkin wrote: > No, I was not assuming that. What I'm trying to say is that a caller > that does something like this under a spinlock: > preempt_disable > pagefault_disable > error = copy_to_user > pagefault_enable > pree

Re: [PATCH v2 10/10] kernel: might_fault does not imply might_sleep

2013-05-19 Thread Michael S. Tsirkin
On Thu, May 16, 2013 at 08:40:41PM +0200, Peter Zijlstra wrote: > On Thu, May 16, 2013 at 02:16:10PM +0300, Michael S. Tsirkin wrote: > > There are several ways to make sure might_fault > > calling function does not sleep. > > One is to use it on kernel or otherwise locked memory - apparently > > n

Re: [PATCH v2 10/10] kernel: might_fault does not imply might_sleep

2013-05-16 Thread Peter Zijlstra
On Thu, May 16, 2013 at 02:16:10PM +0300, Michael S. Tsirkin wrote: > There are several ways to make sure might_fault > calling function does not sleep. > One is to use it on kernel or otherwise locked memory - apparently > nfs/sunrpc does this. As noted by Ingo, this is handled by the > migh_fault

[PATCH v2 10/10] kernel: might_fault does not imply might_sleep

2013-05-16 Thread Michael S. Tsirkin
There are several ways to make sure might_fault calling function does not sleep. One is to use it on kernel or otherwise locked memory - apparently nfs/sunrpc does this. As noted by Ingo, this is handled by the migh_fault() implementation in mm/memory.c but not the one in linux/kernel.h so in the c