Date: Sun, 19 Apr 2009 13:48:43 +0000 (UTC) From: Dmitry Chagin <dchagin@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r191269 - head/sys/compat/linux Message-ID: <200904191348.n3JDmhVH010871@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dchagin Date: Sun Apr 19 13:48:42 2009 New Revision: 191269 URL: http://svn.freebsd.org/changeset/base/191269 Log: Remove support for FUTEX_REQUEUE operation. Glibc does not use this operation since 2.3.3 version (Jun 2004), as it is racy and replaced by FUTEX_CMP_REQUEUE operation. Glibc versions prior to 2.3.3 fall back to FUTEX_WAKE when FUTEX_REQUEUE returned EINVAL. Any application directly using FUTEX_REQUEUE without return value checking are definitely broken. Limit quantity of messages per process about unsupported operation. Approved by: kib (mentor) MFC after: 1 month Modified: head/sys/compat/linux/linux_emul.c head/sys/compat/linux/linux_emul.h head/sys/compat/linux/linux_futex.c Modified: head/sys/compat/linux/linux_emul.c ============================================================================== --- head/sys/compat/linux/linux_emul.c Sun Apr 19 12:41:37 2009 (r191268) +++ head/sys/compat/linux/linux_emul.c Sun Apr 19 13:48:42 2009 (r191269) @@ -86,6 +86,7 @@ linux_proc_init(struct thread *td, pid_t em = malloc(sizeof *em, M_LINUX, M_WAITOK | M_ZERO); em->pid = child; em->pdeath_signal = 0; + em->used_requeue = 0; em->robust_futexes = NULL; if (flags & LINUX_CLONE_THREAD) { /* handled later in the code */ Modified: head/sys/compat/linux/linux_emul.h ============================================================================== --- head/sys/compat/linux/linux_emul.h Sun Apr 19 12:41:37 2009 (r191268) +++ head/sys/compat/linux/linux_emul.h Sun Apr 19 13:48:42 2009 (r191269) @@ -51,6 +51,7 @@ struct linux_emuldata { struct linux_emuldata_shared *shared; int pdeath_signal; /* parent death signal */ + int used_requeue; /* uses deprecated futex op */ struct linux_robust_list_head *robust_futexes; Modified: head/sys/compat/linux/linux_futex.c ============================================================================== --- head/sys/compat/linux/linux_futex.c Sun Apr 19 12:41:37 2009 (r191268) +++ head/sys/compat/linux/linux_futex.c Sun Apr 19 13:48:42 2009 (r191269) @@ -114,6 +114,7 @@ linux_sys_futex(struct thread *td, struc struct timeval tv = {0, 0}; struct futex *f2; int op_ret; + struct linux_emuldata *em; #ifdef DEBUG if (ldebug(sys_futex)) @@ -262,19 +263,6 @@ linux_sys_futex(struct thread *td, struc FUTEX_SYSTEM_UNLOCK; break; - case LINUX_FUTEX_REQUEUE: - FUTEX_SYSTEM_LOCK; - - f = futex_get(args->uaddr, FUTEX_UNLOCKED); - newf = futex_get(args->uaddr2, FUTEX_UNLOCKED); - td->td_retval[0] = futex_wake(f, args->val, newf, - (int)(unsigned long)args->timeout); - futex_put(f); - futex_put(newf); - - FUTEX_SYSTEM_UNLOCK; - break; - case LINUX_FUTEX_WAKE_OP: FUTEX_SYSTEM_LOCK; #ifdef DEBUG @@ -342,6 +330,23 @@ linux_sys_futex(struct thread *td, struc /* not yet implemented */ return (ENOSYS); + case LINUX_FUTEX_REQUEUE: + + /* + * Glibc does not use this operation since Jun 2004 (2.3.3), + * as it is racy and replaced by FUTEX_CMP_REQUEUE operation. + * Glibc versions prior to 2.3.3 fall back to FUTEX_WAKE when + * FUTEX_REQUEUE returned EINVAL. + */ + em = em_find(td->td_proc, EMUL_DONTLOCK); + if (em->used_requeue == 0) { + printf("linux(%s (%d)) sys_futex: " + "unsupported futex_requeue op\n", + td->td_proc->p_comm, td->td_proc->p_pid); + em->used_requeue = 1; + } + return (EINVAL); + default: printf("linux_sys_futex: unknown op %d\n", args->op);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200904191348.n3JDmhVH010871>