Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp4184756imd; Mon, 29 Oct 2018 20:07:55 -0700 (PDT) X-Google-Smtp-Source: AJdET5ds2/XixTu5biK8eqMv44I05+CYCHjAZHeGI5URyV68huUtoDiBNVNxlgeHvGkKCk7Ia36g X-Received: by 2002:a63:e07:: with SMTP id d7-v6mr16218762pgl.272.1540868875758; Mon, 29 Oct 2018 20:07:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540868875; cv=none; d=google.com; s=arc-20160816; b=AgxcTh2BW9Z+tTk0tsnE855+qJcb7CjCwWiz6MUGPMlaJOk/VGFZk9ksAycVzHesvp cq1mdWNFB3OCWG28hWKWkVc2f88Pd+fqtI5JasjgFfcp0tEbD9omK7sJrTEuDUqt9CcF 3fTXiiZpNjei3KxyFFH0z0JUgSWxnKFp2+AfEpG4VZwer28ZLgIRZ87gNuMxMhrnZ3sk TY67XFxY/Voz+Poyic8XeLEShdJJ49n8L9EPyKdYGZGlhe5pIq+Oj4PB/ZUk5HjL8dJI 19qy28ufYJM3nBHYi59KnvnE+NFX1KeETGKXsg2MShn9qeo+2pHxyVzfUr8OvKHhLGLN syEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=DEQiumCXGYw1j5BHNY/5b8CsffDg7qXIEi/GMSWLhnQ=; b=Gm4qfQ7ftSuL86LtVElvvbPntdNeMha4SngAy/0/xGpLDiCBNVvfyABIddONtNw8jl 8C5e3CAoqgGQqo3d67Ogg+r5/F53Brnh+eFlSXGPWcihlU7nRtcGZCa146/qHIpEKoUd HeXfhBiDZpXvMA5L9N91T5gGWvRrKK3B3Wmzf6kwydEWh37gGEsZzoT8JL5aBgmph+cz Ql2tS8l+Kl5vMgHF9pPB5sodyk6yVn1vbInRFOdYe4Hc0jOnDIkYd8uHe6YLdijNG6pt T5XGqCs36sSs0mTdK1hKbvYDJfBIAJoNzhr1C4MVEZwOS4sbdw0FLMukwfBSZNSLngHC JANA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=odzzFmRr; 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 u11-v6si21789176plr.122.2018.10.29.20.07.39; Mon, 29 Oct 2018 20:07:55 -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=odzzFmRr; 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 S1726596AbeJ3L6S (ORCPT + 99 others); Tue, 30 Oct 2018 07:58:18 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:45096 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726451AbeJ3L6S (ORCPT ); Tue, 30 Oct 2018 07:58:18 -0400 Received: by mail-qt1-f196.google.com with SMTP id l9-v6so11853821qtj.12 for ; Mon, 29 Oct 2018 20:06:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DEQiumCXGYw1j5BHNY/5b8CsffDg7qXIEi/GMSWLhnQ=; b=odzzFmRrr/oBDH5Jzm39yDmysXiLbx7cWvd/IiZa/yBW6IrWEEZaZDUws11lCeG/8M PQmPTixEK+tmWZ3dIzjhfTtzY/S4k3mXUEgNGTxy6V5DcBLKaZ5eTjzg/zofshyPgt/B I1PDgpovvI7PlxNBtIAB0rhY6jISx/NJGrqWK1eXo2c6jpwLeYTsRoL8MH9zoT9z7ifF 1puxPIrlk0RZLTScYVrZneKPRaC2d1yk4FWdg4AJHPsPZuxmqqmLseiMtdQ1AlP4uTko H7gqKaqgggp3OgBYjRIkeD86+8skRIQejkii35Uy8o70FWYSu43qKTm657Luc6Y/nBs9 liCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DEQiumCXGYw1j5BHNY/5b8CsffDg7qXIEi/GMSWLhnQ=; b=L7gApZYosn7wkH6s/fniLhThuLIMAokqyhKD8nzoRA6eTL0ndkMkQav+A5fp0+7g9K WdVAUdIeV4xRqOrr99zCtMLg0Y2XYEuMoLhJeG6vUoHcTuOpx79HvEYxBpP7FguIGiQE EWnuLg7wSwyU7ed6CB+Uc8zLeN2F/oXUAwebQNyHE9ycNVDYX4K4WcGUJYdudL4kynOP VvdS/wIDb+nc4k8BXOjPNoBBlHwKDkfkJKi7yqAvh/0qgZN3eFPF8dkSaR8cxx02xR4Z 1tbz+hr7p8xBU2OmIi7Uu6YDpJo1ZYGeukVao6hdeT+DpYfQRR1go1Om/0p5+d1rGWW/ BO5A== X-Gm-Message-State: AGRZ1gK0KI5x85S4TUrMVMtPIAzNZkYDswQz+vY6+67+vvdyxwPoDeTX mkgUhUB+KhRiSHvBl06EhkuKfggNAyZj716Jit03/Q== X-Received: by 2002:ad4:408f:: with SMTP id l15mr13097849qvp.165.1540868800177; Mon, 29 Oct 2018 20:06:40 -0700 (PDT) MIME-Version: 1.0 References: <20181029175322.189042-1-dancol@google.com> In-Reply-To: From: Joel Fernandes Date: Mon, 29 Oct 2018 20:06:28 -0700 Message-ID: Subject: Re: [RFC PATCH] Minimal non-child process exit notification support To: Daniel Colascione Cc: LKML , Tim Murray Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 29, 2018 at 1:01 PM Daniel Colascione wrote: > > Thanks for taking a look. > > On Mon, Oct 29, 2018 at 7:45 PM, Joel Fernandes wrote: > > > > On Mon, Oct 29, 2018 at 10:53 AM Daniel Colascione wrote: > > > > > > This patch adds a new file under /proc/pid, /proc/pid/exithand. > > > Attempting to read from an exithand file will block until the > > > corresponding process exits, at which point the read will successfully > > > complete with EOF. The file descriptor supports both blocking > > > operations and poll(2). It's intended to be a minimal interface for > > > allowing a program to wait for the exit of a process that is not one > > > of its children. > > > > > > Why might we want this interface? Android's lmkd kills processes in > > > order to free memory in response to various memory pressure > > > signals. It's desirable to wait until a killed process actually exits > > > before moving on (if needed) to killing the next process. Since the > > > processes that lmkd kills are not lmkd's children, lmkd currently > > > lacks a way to wait for a proces to actually die after being sent > > > SIGKILL; today, lmkd resorts to polling the proc filesystem pid > > > > Any idea why it needs to wait and then send SIGKILL? Why not do > > SIGKILL and look for errno == ESRCH in a loop with a delay. > > I want to get polling loops out of the system. Polling loops are bad > for wakeup attribution, bad for power, bad for priority inheritance, > and bad for latency. There's no right answer to the question "How long > should I wait before checking $CONDITION again?". If we can have an > explicit waitqueue interface to something, we should. Besides, PID > polling is vulnerable to PID reuse, whereas this mechanism (just like > anything based on struct pid) is immune to it. The argument sounds Ok to me. I would also more details in the commit message about the alternate methods to do this (such as kill polling or ptrace) and why they don't work well etc so no one asks any questions. Like maybe under a "other ways to do this" section. A bit of googling also showed a netlink way of doing it without polling (though I don't look into that much and wouldn't be surprised if its more complicated) Also I guess when you send a patch, it'd be good to pass "--cc-cmd='./scripts/get_maintainer.pl" to git-send-email so it automatically CCs the maintainers who maintain this. thanks, - Joel