Re: [PATCH v1 3/5] mm, uaccess: trigger might_sleep() in might_fault() when pagefaults are disabled

David Hildenbrand
2014-12-05T11:46:36Z

> On Fri, Dec 05, 2014 at 12:18:07PM +0100, David Hildenbrand wrote:
> > -void might_fault(void)
> > +void __might_fault(const char *file, int line)
> > {
> > /*
> > * Some code (nfs/sunrpc) uses socket ops on kernel memory while
> > @@ -3710,21 +3710,16 @@ void might_fault(void)
> > */
> > if (segment_eq(get_fs(), KERNEL_DS))
> > return;
> > -
> > - /*
> > - * it would be nicer only to annotate paths which are not under
> > - * pagefault_disable, however that requires a larger audit and
> > - * providing helpers like get_user_atomic.
> > - */
> > - if (in_atomic())
> > + if (unlikely(!pagefault_disabled())) {
> > + __might_sleep(file, line, 0);
> > return;
> > -
> > - __might_sleep(__FILE__, __LINE__, 0);
> > -
> > + }
>
> This should be likely() instead of unlikely(), no?
> I'd rather write this
>
> if (pagefault_disabled())
> return;
> __might_sleep(file, line, 0);
>
> and leave the likely stuff completely away.

Makes perfect sense!

Thanks!

David