Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3640344imu; Tue, 18 Dec 2018 01:32:31 -0800 (PST) X-Google-Smtp-Source: AFSGD/V/gBf8A5SZgTiayedtkEVr0wvgByWdQC5WZxyLU19V5rxIqi+La5aP2Jj6A6UDPFrYR6kT X-Received: by 2002:a17:902:b118:: with SMTP id q24mr16038262plr.209.1545125551474; Tue, 18 Dec 2018 01:32:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545125551; cv=none; d=google.com; s=arc-20160816; b=NlppHPdyyoOoL/ZM9/jhwscuPMqTv/fwYo4CLEEoSGbdkN4Y4y3zOtCJFDa4hGtWow 0JsFSXXimlunjArnqD8ljhoxq/3Q7T9yXM1edVLYmEP5Z15xmFJ9a7a2YLGT8g3LKjmK OEpUqnnOYRBNI/CtSQMNeXqlGaAAhQ9b+P3sS7VeXr+aHCg3X/ZpdTcaG4pHBGBrZkSC 3XPXX8/Xvkyukx26YMzz5JHvdw/C57OI4ZKMJj2zVIGJVM+2dfivYe7xgt1AJx5IXPqw yGhQ2q/LkDZvqrkPo5j5Y03guOHtXOaZ7jICFsvNk8m4PwBBoGG95QFfIaYSS4Ai2BiQ sYZw== 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=/QPljyG/YBhEBNl5S6N43lhi9N42+WMseFQ8wFadRLU=; b=Pbr/pFZX3Ge/RqGqljFBPWC+pVsstlM4IpScQmoSrWOPd/Z2Yex3l1tgFK5Iim9kJS g2+rV70Rm35JvZReWddCe5YsKxtjhiKtD2ArHa4m2KqihQucvnpQlhRt7nGA6K5qXWoP C9sgMV/KMaFyI2BexBSHFv96sPPeT72BckGnFa8c87KufK83rBF0PaNF9g8Egk6fVQ7P ZxMK2x5fy139pY6F879BgQs36wbHgD71STlW2yG1Jvfy8BqgNFPm6TSmQP+Yn1YK2iPS ulPatFvr//yZOq7d4vQc32t+qFZQ5yFmtXqmQua0seesIGL+ACqXikK5POeapHT+ENpV aPAA== 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 k30si12845249pgb.113.2018.12.18.01.32.15; Tue, 18 Dec 2018 01:32:31 -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 S1726416AbeLRJbK (ORCPT + 99 others); Tue, 18 Dec 2018 04:31:10 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:55229 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726358AbeLRJbJ (ORCPT ); Tue, 18 Dec 2018 04:31:09 -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 1gZBiV-00052d-FL; Tue, 18 Dec 2018 10:31:07 +0100 Date: Tue, 18 Dec 2018 10:31:06 +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: <20181212090418.GT5289@hirez.programming.kicks-ass.net> Message-ID: References: <20181210152311.986181245@linutronix.de> <20181210160205.GQ5289@hirez.programming.kicks-ass.net> <20181212090418.GT5289@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 Wed, 12 Dec 2018, Peter Zijlstra wrote: > On Mon, Dec 10, 2018 at 06:43:51PM +0100, Thomas Gleixner wrote: > @@ -806,6 +806,8 @@ void __noreturn do_exit(long code) > * task into the wait for ever nirwana as well. > */ > tsk->flags |= PF_EXITPIDONE; > + smp_mb(); > + wake_up_bit(&tsk->flags, 3 /* PF_EXITPIDONE */); Using ilog2(PF_EXITPIDONE) spares that horrible inline comment and more importantly selects the right bit. 0x04 is bit 2 .... > @@ -1187,10 +1236,15 @@ static int attach_to_pi_owner(u32 uval, union futex_key *key, > * set, we know that the task has finished the > * cleanup: > */ > int ret = handle_exit_race(uaddr, uval, p); > > raw_spin_unlock_irq(&p->pi_lock); > - put_task_struct(p); > + > + if (ret == -EAGAIN) > + *pe = p; Hmm, no. We really want to split the return value for that. EAGAIN is also returned for other reasons. Plus requeue_pi() needs the same treatment. I'm staring into it, but all I came up with so far is horribly ugly. Thanks, tglx