Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3944382imu; Mon, 10 Dec 2018 10:17:32 -0800 (PST) X-Google-Smtp-Source: AFSGD/WdslDzvwetcM0kE2SiiFdNi1oHAVEMN5YcQtKMuXJWvc+EL2G4lSDO0zJj3DsS5oQfaM15 X-Received: by 2002:a17:902:34a:: with SMTP id 68mr13331240pld.268.1544465852891; Mon, 10 Dec 2018 10:17:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544465852; cv=none; d=google.com; s=arc-20160816; b=SfuVVKYVNcpqG66lE+hNvSI0QgWql1uC4hIFMJUPKaZQFnTm59N59LqFQoFmHwoNVg 6Wf4sGQAowArM2r4HOr866EzVzdJ+JwHEqelUqMpH9TWkTonouayCoYq9N4t21wL6hYr BQvKnwIOYb2FbVabllpCgo6e2vlmyvfnsDQgoP8XmuqQYZyYpLYFMAOU5mfFmZ6tTDUQ 2w7ryT1jOBoLxMasiMpEH3bUXBwgnxhF+f26/LJkFBLjtiHVJws9mlFGBvhEtDiEy1XX Tj4mhi8mxp8+zNDlPTHmq3Zc9+nJlipvJy0sol6L94r1953cMC2L/0lXigpnFod8xwdU 9dVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=nmjpfm3JlpjU1e5wbgC1dIZc7Yr+ej2g1j7SfW2VLvc=; b=JF0SkPIc4cr+74aH0vxVJLYGq4x+y0tPOCbJhyM5d2ssIkXpZjYndgZL0rKdOEMo2i IGLII2Fr8Yi4epwg6LPUQ5uUy91QddfaiCVTibhX1l0LAa1sUfj21RAF0WsV1D8li/fh Op8qjGZIaoRg7GfYni1WjzbIAk8jE9UW/Oth+BDi7ThlyjAMLX6EzhyE29wjhjFk0r4+ kuT27VbRt3eF1puOTLfdzzgEecozcMIM0MhDQculL30nMsWpMnMBiPaNJqZ7ToY7pmff Duz1cIsmK9xWfTBgfq5vjgTdDc+qg8ZyuAdg/THIEJTfmVfHfjRS/Sj3xg1gKrb755us JSNA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d195si11048809pfd.93.2018.12.10.10.17.15; Mon, 10 Dec 2018 10:17:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728933AbeLJRoA (ORCPT + 99 others); Mon, 10 Dec 2018 12:44:00 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:34038 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727071AbeLJRn7 (ORCPT ); Mon, 10 Dec 2018 12:43:59 -0500 Received: from p4fea4820.dip0.t-ipconnect.de ([79.234.72.32] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1gWPb2-0000sA-Us; Mon, 10 Dec 2018 18:43:57 +0100 Date: Mon, 10 Dec 2018 18:43:51 +0100 (CET) From: Thomas Gleixner To: Peter Zijlstra cc: LKML , Stefan Liebler , Heiko Carstens , Darren Hart , Ingo Molnar Subject: Re: [patch] futex: Cure exit race In-Reply-To: <20181210160205.GQ5289@hirez.programming.kicks-ass.net> Message-ID: References: <20181210152311.986181245@linutronix.de> <20181210160205.GQ5289@hirez.programming.kicks-ass.net> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 10 Dec 2018, Peter Zijlstra wrote: > On Mon, Dec 10, 2018 at 04:23:06PM +0100, Thomas Gleixner wrote: > There is another callers of futex_lock_pi_atomic(), > futex_proxy_trylock_atomic(), which is part of futex_requeue(), that too > does a retry loop on -EAGAIN. > > And there is another caller of attach_to_pi_owner(): lookup_pi_state(), > and that too is in futex_requeue() and handles the retry case properly. > > Yes, this all looks good. > > Acked-by: Peter Zijlstra (Intel) Bah. The little devil in the unconcious part of my brain insisted on thinking further about that EAGAIN loop even despite my attempt to page that futex horrors out again immediately after sending that patch. There is another related issue which is even worse than just mildly confusing user space: task1(SCHED_OTHER) sys_exit() do_exit() exit_mm() task1->flags |= PF_EXITING; ---> preemption task2(SCHED_FIFO) sys_futex(LOCK_PI) .... attach_to_pi_owner() { ... if (!task1->flags & PF_EXITING) { attach(); } else { if (!(tsk->flags & PF_EXITPIDONE)) return -EAGAIN; Now assume UP or both tasks pinned on the same CPU. That results in a livelock because task2 is going to loop forever. No immediate idea how to cure that one w/o creating a mess. Thanks, tglx