Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp6379831imd; Wed, 31 Oct 2018 10:46:28 -0700 (PDT) X-Google-Smtp-Source: AJdET5fCMMKxfbjMVIvw8zfnXRm/VQbwfzWpzGnk4s26oeC4b2hcIuvSkWrCLtfdHcfSYC5G8Mio X-Received: by 2002:a17:902:a418:: with SMTP id p24-v6mr4188039plq.29.1541007988225; Wed, 31 Oct 2018 10:46:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541007988; cv=none; d=google.com; s=arc-20160816; b=Uq0dqS3i93G7jAYkoXRYfl26YFiP/EVwyy4K9aAFC17lwdmU8crFG63OgU5eVdv7pr 74DAXciWYoYh3qxwCwH0R/cZMRk+wNMDRtcytKAFlm7pa23stnrvQDYMrtZuNHVV9WnO QUd9PBx9ryFNx7YX0QpMonCeFbwebNW8T9Mlg8ejRRnprpFIUo5jQn1xzwTC0IL06aam E/xigEjFIeCioqf3IkmEO0DcYcMCuRns9As9RxY7byBu4yKJjF5ef99Cw4Qc6hzt6Vt8 1JYdjH89HY9teHnwlaiQDe0wzqwpyZbZ66sbiCIpcaUBDSLu85Fju94fMltG2tErNgn0 ft1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature; bh=4vcOD6E25VumNhaqeNzWwPkzPZMJ/b+SNHRZfcLSucc=; b=hdIA13aBLDLTLQseCjuAf8zLLibdxuZ2FGp4mgzLs/Mr7jwYXOWbxv/mPmX3nO9Q/b 2Bo6a43BDoBZi6v7SIg/FB/HrBVhlQOQMD/CfOH5OPLnCpPt3oLbSBSK9DsG7ieL9jz3 MfDbWxyCGN1YM2/rNiixY0+coyHHEQo9XPeo6VWqv9BDOpH9Ge5cy+3PeMZn30hxI1nd 6kvpuHJLYC+JFm7ylAK64ED6oklETm/dFhB9JuGW5J2TGK94HEAAWGUMxjdQDF3pCpWv kS2DiG+jjAQAOVHBCBUXZHv1Q/HZtcHci+k0hUkDarfrkosdjnsWzHKIikI8NPDpo7+t TeUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=eMNUZEE6; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b34-v6si27721962plc.428.2018.10.31.10.46.12; Wed, 31 Oct 2018 10:46:28 -0700 (PDT) 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=@google.com header.s=20161025 header.b=eMNUZEE6; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729986AbeKACn3 (ORCPT + 99 others); Wed, 31 Oct 2018 22:43:29 -0400 Received: from mail-ua1-f68.google.com ([209.85.222.68]:35475 "EHLO mail-ua1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729315AbeKACn2 (ORCPT ); Wed, 31 Oct 2018 22:43:28 -0400 Received: by mail-ua1-f68.google.com with SMTP id d8so5245890ual.2 for ; Wed, 31 Oct 2018 10:44:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=4vcOD6E25VumNhaqeNzWwPkzPZMJ/b+SNHRZfcLSucc=; b=eMNUZEE6SapBZfp2ttNijdIrk7ZDP0eekCrv00i6SpEDZ+kQlTv78eOMLL0DNs0nl4 BOjqwz6JTy2AABOVXFXMDEOvz1OkJjHmhZopMP67TIpx2vNhGy0k/aotuaHAiNjolaTu 0aklovUNOk2mmAzIoxQAx2wNan7EA0XVBDwJcHR0GSB3+uHjTERKUyzgYZy7tOv1JlU5 zApt+g7DPB/l6EnRcLfN8yr/PdmLBg6Jzr82XigOiPzLu8cOBHmZdzr+MIATtRM5b9qh 0xKTif2osoLIwnaMV8/Cr+BAJ9ytMcPDcZj23U39NT+AhGxA49UJtlBqoqqsEgJYVW2x 4d+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=4vcOD6E25VumNhaqeNzWwPkzPZMJ/b+SNHRZfcLSucc=; b=SupTLcxnBKml0+G/5OMUjqiB9zBBMgeEEZm9Y3s6txi7lqCxSiPSJoVYl7LjJOCMIH 0YobtrCWPgganNoPgmbY/R43H9lFsW9x9rBbek4JANer6hOvIIQHLpJxjUjgCl2wEtRk jw9gGf4KNDslOODjTCMi/Jn6m04wRSChl2I76gQCHX1ARFjPWg23B47+bW2yxQQMi5bq mT6DV6IhpPpnLS52afJKz7By34SGDbRuZu+HEPOgywWAiviYr53+BCXnFgCwkipoR5Tv WDKt5HwHFU6+xmH1RecYZKFFKTduwFUUowLPDR06YRZD0TBS5syKo8PR3bhNL2tV0fJR QR2Q== X-Gm-Message-State: AGRZ1gL50qS6jbs9VpQgEEPgTd0CwtOaCcr5pqSyfWOoYFvKARM0d4rf hTAWfJVJi8aJ0CEzwtG8onqQiEizBVmCXUZ+WLYIjA== X-Received: by 2002:ab0:15a1:: with SMTP id i30mr1889024uae.11.1541007867134; Wed, 31 Oct 2018 10:44:27 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a67:f48d:0:0:0:0:0 with HTTP; Wed, 31 Oct 2018 10:44:24 -0700 (PDT) In-Reply-To: <175DDE5D-E738-4C35-B664-6AD8B9CF446D@amacapital.net> References: <20181029175322.189042-1-dancol@google.com> <175DDE5D-E738-4C35-B664-6AD8B9CF446D@amacapital.net> From: Daniel Colascione Date: Wed, 31 Oct 2018 17:44:24 +0000 Message-ID: Subject: Re: [RFC PATCH] Minimal non-child process exit notification support To: Andy Lutomirski Cc: linux-kernel , linux-api@vger.kernel.org, Tim Murray , Joel Fernandes Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 31, 2018 at 5:25 PM, Andy Lutomirski wrot= e: > I had an old patch to do much the same thing: It's a perennial idea. :-) > https://lore.kernel.org/patchwork/patch/345098/ > > Can you comment as to how your API compares to my old patch? Sure. Basically, my approach is sort-of eventfd-esque, whereas your approach involves adding a very unusual operation (poll support) to a type of file (a directory) that normally doesn't support it. My approach feels a bit more "conventional" than poll on a dfd. Additionally, my approach is usable from the shell. In your model, poll(2) returning *is* the notification, whereas in my approach, the canonical notification is read() yielding EOF, with poll(2) acting like a wakeup hint, just like for eventfd. (You can set O_NONBLOCK on the exithand FD just like you would any other FD.) The use of read() for notification of exit also allows for a simple extension in which we return a siginfo_t with exit information to the waiter, without changing the API model. My initial patch doesn't include this feature because I wanted to keep the initial version as simple as possible. > You=E2=80=99re using > some fairly gnarly global synchronization The global synchronization only kicks for a particular process exit if somebody has used an exithand FD to wait on that process. (Or more precisely, that process's struct signal.) Since most process exits don't require global synchronization, I don't think the global waitqueue for exithand is a big problem, but if it is, there are options for fixing it. > , and that seems unnecessary It is necessary, and I don't see how your patch is correct. In your proc_task_base_poll, you call poll_wait() with &task->detach_wqh. What prevents that waitqueue disappearing (and the poll table waitqueue pointer dangling) immediately after proc_task_base_poll returns? The proc_inode maintains a reference to a struct pid, not a task_struct, but your waitqueue lives in task_struct. The waitqueue living in task_struct is also wrong in the case that a multithreaded program execs from a non-main thread; in this case (if I'm reading the code in exec.c right) we destroy the old main thread task_struct and have the caller-of-exec's task_struct adopt the old main thread's struct pid. That is, identity-continuity of struct task is not the same as identity-continuity of the logical thread group.