Q: put_user_try & co (Was: [PATCH 1/5] Split wait_noreap_copyout())

From: Oleg Nesterov
Date: Wed May 20 2009 - 15:08:36 EST


On 05/11, Ingo Molnar wrote:
>
> See the (new) put_user_try / put_user_ex() / put_user_catch()
> abstraction in arch/x86/include/asm/uaccess.h, and how all the x86
> signal code makes use of that to optimize such patterns of per field
> user copies.

Just curious, can't we simplify put_user_{try,ex,catch} ?

Pseudo-code:

#define put_user_try \
do { \
__label__ __efault_label; \


#define put_user_catch(err) \
err = 0; \
if (0) { \
__efault_label: \
err = -EFAULT; \
} \
while (0)


#define __put_user_asm_ex(...) \
asm volatile( \
"1: mov ..." \
_ASM_EXTABLE(1b, &__efault_label) \
: : ...)


Now, we don't need thread_info->uaccess_err, and we don't need the
special "if (fixup->fixup < 16)" hack in fixup_exception(). Once
any put_user_ex() fails, we jump to the __efault_label and set
err = -EFAULT.

This also means that we skip other put_user_ex's after the faulted
one. Not very important, this is unlikely case, but imho nice anyway.

Can this work? (warning: my asm skills is almost zero ;)

Oleg.

--
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/