Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp4446497imd; Tue, 30 Oct 2018 02:00:09 -0700 (PDT) X-Google-Smtp-Source: AJdET5eUyEp4QaE8PlCoWJPgQmLNHvIOrEtpty7t6japfJm4vI/S0FwX4N/rDqIc/cqAlueZQlGT X-Received: by 2002:a63:181c:: with SMTP id y28mr16657939pgl.75.1540890009875; Tue, 30 Oct 2018 02:00:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540890009; cv=none; d=google.com; s=arc-20160816; b=ue42LzlUeNdGWNc0g9fr7BrXybU5L6sMYfrNVRvrzC7Z+Vyey3czvouThA7TFF1Lzj cg2btCCjTgFCXReEB9AML3FYhp81s1+bZf63bYKZBujzolwZ2gxlHY3mZUQufgtamWaj bjWZx9veQ5/F41RXcwIvgxVMgWCd8sOHaAoLSdpnSN++LWsinqmn5tYZkx7wNL97cjeY qvlQI0JsQOCSuidd/cs+E6BoRcylyrjvn79RyNFefZzo5TyQ4KrR5/Di3WiD5Tm/EJPG bVUjM5Qu5DqDPxS6NxuA9Hvo+8SRbVfgFcwetffjRVYhKT2opDHHJOBUhxWPNSFJBq+U X49g== 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 :references:in-reply-to:mime-version:dkim-signature; bh=I56xSu4RY4TGKO99XbtGs2nK5ZhjNUH4Tr9D+ZItFAM=; b=OMY66Yfuytg7Pj6/D/CcjTQlo1YpgKHphAV2CfOxUL5Jb6DJafD1vYkwu9QTlaQLg9 TBN5XIBEevKGI8sspkE49qJeof+xHZS0KKa0KF9XcNrMisHHd/4uqTojko8x3gCTuYyv /0jI4ibCkTvb7WRwLVz1LWBP6OEDkWZ9CPvwJDVrZ81KOBiWCpYtEVwkCF3WfAXTBQzL VDpeyDbtoGmtH3uGKJEz4osYts8BJjlvdfbupGAVg+6htt43xTSo3OAZp+Sp565o8T1u vWDgqTHBKMkmAKurM+tKXyN5SUZlB8dURlqfcn8Z09Tj5alGt5NV81TSzTSwxPs7okrx 0PZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=l+GRQWTf; 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 e184-v6si24531121pfa.206.2018.10.30.01.59.53; Tue, 30 Oct 2018 02:00:09 -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=l+GRQWTf; 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 S1727265AbeJ3RwB (ORCPT + 99 others); Tue, 30 Oct 2018 13:52:01 -0400 Received: from mail-vs1-f65.google.com ([209.85.217.65]:46172 "EHLO mail-vs1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726225AbeJ3RwA (ORCPT ); Tue, 30 Oct 2018 13:52:00 -0400 Received: by mail-vs1-f65.google.com with SMTP id l6so7131924vsj.13 for ; Tue, 30 Oct 2018 01:59:27 -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; bh=I56xSu4RY4TGKO99XbtGs2nK5ZhjNUH4Tr9D+ZItFAM=; b=l+GRQWTfX3biGvqREt9Ceo9/28nN9YRxtd6uBuxhQQjZ7L9JTazd9ZOY8iGdJhJ3QS vlj3BjfUE46zgCgZq1WD4H8krQTMqgfq5vaP2EobOW1gpq2885XZKY1mmfEryIML/PNp c+BNlPXIH8PXctOiSKh/Uw8h/JPNShfXOXrTYhOIMvbJO5hP1LlMKxw1gk3nJVXfALXk kZQHAN8+GuNLv/AmIAExI6HYhey8nT52c1dc6uhAS4ggnwoLYfQZemSDJdTdU+NAKmge utwsRoRIeH8IoeOw9ROnhZ4F9t8zkWBSpK5oGnhjQOEX+plW7IfzGq3yZC1k/rNi97o1 V47Q== 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; bh=I56xSu4RY4TGKO99XbtGs2nK5ZhjNUH4Tr9D+ZItFAM=; b=cGHDyvJFqloa7RO5QpgZP2LGqxHsx6zQo5pwfcaAT7KJ5wpAWVjrL5r3eMnlTKV13c PIXmpJpR1qeHDrUCMKLocCljdwWvnBpd536mHxLPCrbXlbWkXPFpcAJriTWcLYpl9SgS XgY+vYcLcKvS1jsS7OpGOyaCgFq4ZzTvdo9CSuGPilarcM8SEzAJgdHlTXda50iVA7hP aERlh42cLms7fJKXnVPUbor6z+bBq83DIwokDl/nBprMVGW5nJGNiaqVTv43UPDAMjD3 6+J7TkCRAi1RylsfQmOzEQ7VofSIR6tG2WLFaSQXMe4e5IlnqjixUPqOfidgfLHJwlxt sJZQ== X-Gm-Message-State: AGRZ1gLKds7EfMgmJnlrdWXzIz6QSmdNwWcJhU0p7rao4kcSiwOkZ/lC zN+vof3RwHuZgTs0pdj9peR995Vx3Jyt92D7q0iCFt8TEgU= X-Received: by 2002:a67:6cc1:: with SMTP id h184mr2746911vsc.149.1540889966495; Tue, 30 Oct 2018 01:59:26 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a67:f492:0:0:0:0:0 with HTTP; Tue, 30 Oct 2018 01:59:25 -0700 (PDT) In-Reply-To: References: <20181029175322.189042-1-dancol@google.com> From: Daniel Colascione Date: Tue, 30 Oct 2018 08:59:25 +0000 Message-ID: Subject: Re: [RFC PATCH] Minimal non-child process exit notification support To: Joel Fernandes 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 Tue, Oct 30, 2018 at 3:06 AM, Joel Fernandes wrote: > 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) Thanks for taking a look. I'll add to the commit message. Re: netlink isn't enabled everywhere and is subject to lossy buffy overruns, AIUI. You could also monitor process exit by setting up ftrace and watching events, or by installing BPF that watched for process exit and sent a perf event. :-) All of these interfaces feel like abusing a "monitoring" API for controlling system operations, and this kind of abuse tends to have ugly failure modes. I'm looking for something a bit more explicit and robust. > > 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 for the tip!