Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp3814767imd; Mon, 29 Oct 2018 12:49:02 -0700 (PDT) X-Google-Smtp-Source: AJdET5cfQOYH/5M3YMUh1DZ/134KS6PR9cVhyFjOzIQhusRrtypBRmbHtw12sGUgOkHkhmaUTHos X-Received: by 2002:a17:902:59d6:: with SMTP id d22-v6mr15637800plj.116.1540842542125; Mon, 29 Oct 2018 12:49:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540842542; cv=none; d=google.com; s=arc-20160816; b=eRmIl8zpgE1i9mtHt37oacYI0O8MF8YoTtn6Rxa4rfTlRJ6kKDkHRdrAM47aG696j3 jMK7P2+kuk7oqqp9sV9VA/wDwVuauj6UIFAfEqCeGr5bpE7vhkoDUvohc4na+zatMJy2 Mtp4o1xnbiGJVmsaFZ28HqeX6zwZZIsZLWIVCTpY24vMUVZdpsDtuuxInB35Dst31e/f Ou7QRFlFdoNTY0/09FJgyZUinnEr42DQdiKz845U5ApZPBM/jnn1WCxvKLjrsB4b9KkT IG8rgYBhc5qMpgQikO61F3mQ9Ez25PK6uROycPOzw6poip41+42Dht4Qy3UEyRtz0fsk zJJQ== 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=jAAOcWZXrc9pNA9zgpJnUaBbYEUNJCtGEP2DciOoHTw=; b=HlAubZDZzY5vihIsjLuIvQdLFfVAbYXSBpA0jMm9G60lmwFZdXnTil8mVQjpzUGBJk V5li4LDRfLk3699GoY7Y9DY9ALmND1uUXmMFbxOpF2+3EUVsrzz4dfxzuznHK1o8iPsA MGwiJQ5ljmWlhbw2hJgZtuD3SQG23GrTHYNdgGCynOD9KFzPUJmDZWISChy3IperwqGI zoFEm/Wr+P0Ih0SqZ+yiouytVwijTWGZNrk/wXjtcP4JMf15yAPR9PGAzQEEgGhi2TdM 62s0gWjm4F1CjLaF+jBllXXttPXPHjdRHik5JRmUmqSrHrWP1GuSBj2Ydz+XWF9MTEKV hniA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=SOhodhg+; 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 x2-v6si20852223plo.259.2018.10.29.12.48.46; Mon, 29 Oct 2018 12:49:02 -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=SOhodhg+; 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 S1727387AbeJ3EiU (ORCPT + 99 others); Tue, 30 Oct 2018 00:38:20 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:40220 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725781AbeJ3EiU (ORCPT ); Tue, 30 Oct 2018 00:38:20 -0400 Received: by mail-qk1-f193.google.com with SMTP id f18-v6so5744184qkm.7 for ; Mon, 29 Oct 2018 12:48:11 -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=jAAOcWZXrc9pNA9zgpJnUaBbYEUNJCtGEP2DciOoHTw=; b=SOhodhg+8z2QLVwE9sh5BDJGHrPZqrA7xpbiRKqqJL5+rAuwySOcDmXAkdtG1BN2IG uRTaAW/8+h/HHrpwF+CaVUoLk9sRSfTI4s0WHuE3WVQC/yasuChDpUci9KGGlyFJyiuH i/eIfZkDM5o5LgI/Yoht6sTtCvr2E26wjq3pSZhCKUJ02ICSIrm9Dq29OFVjXIqguZUP lS6WvVS+6tyx8H90lm2fnjM51doePmWHYNRu3I7QoZ8Rmajlud18L6IZP8hw+oXdJwbJ bu8rPbov6HDTRiEmmCMkx1coRh/OJYMFpYKmdno6B8jZ8PZAKn/OGk0C2QCp/OnPRu03 wzDQ== 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=jAAOcWZXrc9pNA9zgpJnUaBbYEUNJCtGEP2DciOoHTw=; b=TIEsnxDfqvG+p8AhV2A9nTQzT54JwMCos1juS1vrQwZTdTa+BzzOPoBzgJaCWYiSAg 5pO6GDbuG6HM+5JerVOGmIm55Hb6Qov7/Gt+4i5qUxQybQ63YAKB044MNJ8WDdw2/dmn pKpf9p8cYudnTAmnLD3RJMbmXM83+eTwfA0JjkP84CD5BzBYgktDzWWVjGTny1Ht4Vyj wVnOmZaMtUOo5CPJ88SXITLTfWhuH+KZPFt1P2NUaRAZUlLhzJq+hUOEqmm3Rn+XSkrB tOI+rALVeArT7THQE1g90MyALiGr4I9I9jUf8tJaXx3tlI+xGWX0bY9UNNb4AscVs1hm 1Zuw== X-Gm-Message-State: AGRZ1gJSEtM18lt60YwzzuD80eTZPKuCMD7kQqXVFzqyAFWArDqkR+Rx m93mSXFvEJs6MmaSxtvurGyaDEfQCOnRccInCstqBQ== X-Received: by 2002:a37:12a1:: with SMTP id 33mr12822845qks.189.1540842491115; Mon, 29 Oct 2018 12:48:11 -0700 (PDT) MIME-Version: 1.0 References: <20181029175322.189042-1-dancol@google.com> In-Reply-To: From: Joel Fernandes Date: Mon, 29 Oct 2018 12:47:57 -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 12: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. > Sorry I take that back, I see it needs to wait after sending the kill, not before (duh). Anyway if the polling is ever rewritten, another way could be to do kill(pid, 0) and then check for return of -1 and errno == ESRCH; instead of looking at /proc/