Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp409197ybx; Wed, 6 Nov 2019 02:36:45 -0800 (PST) X-Google-Smtp-Source: APXvYqw3FQV8gsIsPG3Qc6+FO5xTqoYys0r6JDpt/gB0Fi/yywH1xA5+JtDITSnYnrIo4s1mPX7Y X-Received: by 2002:a17:906:3019:: with SMTP id 25mr5912696ejz.280.1573036605627; Wed, 06 Nov 2019 02:36:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573036605; cv=none; d=google.com; s=arc-20160816; b=fwmf6sTquCbFSDXp8nFI8V0DzVco1SLe4f5iPh5jhgwc4c+cBf0Xd9w/gEVA/OYKdT np/b4xLNou9mv16aIJ090s+M0/aGNUjzCW5QaVb3mvRWlaatA+ExNzs6VouncgDTc7x4 0m0d+vpNz9ryuYVfY2h8ejsPdFBN1RtVtT0dDvDqQJe2mascJluRJw7RBophBymDu8Z8 SGm66OC99Kz9LsWjSvRwGwUVp4S7wtctR1Qo9CMEm1EZ2rTHAd186TUvrp++Bngbv+5s WDaT6JHuQvVx+zQDLCmMldTiHsauBtRrNlbvTKBipTydiAkuzRCVXu6sxF9elQAzdkNa mnQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:user-agent:in-reply-to:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=rVnePUZZwzprHYOXaNvUDvhLwt5XtmaSUL7fEAR5TpE=; b=brCW4indkk5bm3eJDtkC0fvozzD/uxfsIlloDaL82RHXCGdfmc3ZVaJf5aOQ1aY9Zj oAz5BUuCLBKjZymkggn3W+WJClMVjwqtI22Op7LbkhV3yVEakG4GGaKIQytuMpBAZc/S uYrHjjqLiA8MnpuEmXEPlQ3AGg2nnxpSjREpFsi1+f76yGKQuYRMyEW2NyIdkZSmhApp ncPldDI+w59/32GEpeSgkHdQWqpqMblqE7HBl0gFOsfigcfxXufSgwmtQAGX8rG/UVuq IOAWGDV9pMzTYKjVtZsit05CkbuCrX+8ytM3oZLfceVk37U3Lp+Zl4jvYpWZ06zgH/JU 3/NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=N0yl8oJa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r4si13041770edx.365.2019.11.06.02.36.20; Wed, 06 Nov 2019 02:36:45 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=N0yl8oJa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731322AbfKFKfV (ORCPT + 99 others); Wed, 6 Nov 2019 05:35:21 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:24920 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729059AbfKFKfU (ORCPT ); Wed, 6 Nov 2019 05:35:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573036519; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rVnePUZZwzprHYOXaNvUDvhLwt5XtmaSUL7fEAR5TpE=; b=N0yl8oJahNwq4gYm6PntQtECIk4AsmT+j7WIU6cwp+ldhU7Js3Oj7T5qmPFsvRGVfdMF2b QZdksEXeWDJX9VrKfq3hVXZ1l0Rcyy8TZPu54aHLM/sSwJ7XOuDe8GaVofBe+CEcgje6n3 7VcexgrT8EGqaA91GZdPGCRH7yAvAP0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-109-3WoS9rMNPKWwRDz_ANwNDw-1; Wed, 06 Nov 2019 05:35:15 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0967F1800D53; Wed, 6 Nov 2019 10:35:14 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.44]) by smtp.corp.redhat.com (Postfix) with SMTP id 50EE45D9CD; Wed, 6 Nov 2019 10:35:11 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Wed, 6 Nov 2019 11:35:13 +0100 (CET) Date: Wed, 6 Nov 2019 11:35:10 +0100 From: Oleg Nesterov To: Thomas Gleixner Cc: Florian Weimer , Shawn Landden , libc-alpha@sourceware.org, linux-api@vger.kernel.org, LKML , Arnd Bergmann , Deepa Dinamani , Andrew Morton , Catalin Marinas , Keith Packard , Peter Zijlstra Subject: Re: handle_exit_race && PF_EXITING Message-ID: <20191106103509.GB12575@redhat.com> References: <20191104002909.25783-1-shawn@git.icu> <87woceslfs.fsf@oldenburg2.str.redhat.com> <20191105152728.GA5666@redhat.com> <20191106085529.GA12575@redhat.com> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: 3WoS9rMNPKWwRDz_ANwNDw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/06, Thomas Gleixner wrote: > > > @@ -716,11 +716,13 @@ void exit_pi_state_list(struct task_struct *curr) > > > > =09if (!futex_cmpxchg_enabled) > > =09=09return; > > + > > =09/* > > -=09 * We are a ZOMBIE and nobody can enqueue itself on > > -=09 * pi_state_list anymore, but we have to be careful > > -=09 * versus waiters unqueueing themselves: > > +=09 * attach_to_pi_owner() can no longer add the new entry. But > > +=09 * we have to be careful versus waiters unqueueing themselves. > > =09 */ > > +=09curr->flags |=3D PF_EXITPIDONE; > > This obviously would need a barrier or would have to be moved inside of t= he > pi_lock region. probably yes, > > +=09if (unlikely(p->flags & PF_EXITPIDONE)) { > > +=09=09/* exit_pi_state_list() was already called */ > > =09=09raw_spin_unlock_irq(&p->pi_lock); > > =09=09put_task_struct(p); > > -=09=09return ret; > > +=09=09return -ESRCH; > > But, this is incorrect because we'd return -ESRCH to user space while the > futex value still has the TID of the exiting task set which will > subsequently cleanout the futex and set the owner died bit. Heh. Of course this is not correct. As I said, this patch should be adapted to the current code. See below. > See da791a667536 ("futex: Cure exit race") for example. Thomas, I simply can't resist ;) I reported this race when I sent this patch in 2015, https://lore.kernel.org/lkml/20150205181014.GA20244@redhat.com/ but somehow that discussion died with no result. > Guess why that code has more corner case handling than actual > functionality. :) I know why. To confuse me! Oleg.