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

From: Heiko Carstens
Date: Fri Dec 05 2014 - 06:45:43 EST


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.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/