Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp483623imd; Thu, 1 Nov 2018 00:02:01 -0700 (PDT) X-Google-Smtp-Source: AJdET5ce4Vvkr/sBQ2kfwcPVDmU7V8W+rHdnsdE5tsc5jrAUG9Zft/MaF7rnrIZ67x99Q3OP59d1 X-Received: by 2002:a63:ef47:: with SMTP id c7mr6184409pgk.386.1541055721922; Thu, 01 Nov 2018 00:02:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541055721; cv=none; d=google.com; s=arc-20160816; b=1JzqRQmBKMxkqpRce68JO7UCzS8kP8h5DosH96bhMKIRlbzsdbFmRd4FhJKNceplp8 GP2NXizLZZUbhhNvn6Yt0Mpgxa2KYmBmjnOwoREeW4RoPCEC7uclzCp2sZ5Y6KtKZFN8 Q1sc+1M9dQ8YsHtaWXhqpixhOw9NgkUfTkxmkOesog2mBLKUGn88eUB4izdcVqNlk/r/ 3/d4IW9Oxw81x0uqgjVNa3X7KFqx7gJGUsdc9+zzm1JrHdSiAixUDIb7nD2PkmivUEsj 9euHo+lGcSKSU+bQ899Ug+7TK5rL052bke3VE50eVzKrmWTxcwaZoeja7qZWakzEPvXF yIYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=0MPVgj3x9J02o8a/XrICz4ZyC5SE+4p7icIIYL3S2Qg=; b=yqdCxTvwKfho364VLynelKjnwGuvXrL6f5XjLsWYdqlYjmv9lwWKSZiMFGC5b8YU6C 3PwaOqU2Z3XoWU6mnxBG7OEaeO2zaOno0u+hGRInzZl2JipKAOPTr7/LEd3MxTAXw7XL OUJ9d9BHOXUMK1qmgnTHa1MFAZxU8/KFheQtgzfqO0aDg4M0pjKY1z6RcM4VPg3VVnp0 8YXl4KDkD0vOaGuL3jrvEPzilikKjWbWAAnQBU3ljt6ECGuRFC3Jq+WfaEOhDtbZn3iM fEaWQktDl9P1jI6mYuExWMtPgFXLlxFOPJzE1HS4S7/xA2q2rTYx+p4UwTkedDSAt0I8 A8YQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v5-v6si11955945pfe.237.2018.11.01.00.01.47; Thu, 01 Nov 2018 00:02:01 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728076AbeKAQC2 (ORCPT + 99 others); Thu, 1 Nov 2018 12:02:28 -0400 Received: from mx2.mailbox.org ([80.241.60.215]:59226 "EHLO mx2.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727716AbeKAQC1 (ORCPT ); Thu, 1 Nov 2018 12:02:27 -0400 Received: from smtp2.mailbox.org (unknown [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 04FA6A10D7; Thu, 1 Nov 2018 08:00:44 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter02.heinlein-hosting.de (spamfilter02.heinlein-hosting.de [80.241.56.116]) (amavisd-new, port 10030) with ESMTP id 1ZI5LgM89CdB; Thu, 1 Nov 2018 08:00:42 +0100 (CET) Date: Thu, 1 Nov 2018 18:00:36 +1100 From: Aleksa Sarai To: Daniel Colascione Cc: linux-kernel@vger.kernel.org, timmurray@google.com, joelaf@google.com Subject: Re: [RFC PATCH v2] Minimal non-child process exit notification support Message-ID: <20181101070036.l24c2p432ohuwmqf@yavin> References: <20181029175322.189042-1-dancol@google.com> <20181029192250.130551-1-dancol@google.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="uai654nwee5vog4c" Content-Disposition: inline In-Reply-To: <20181029192250.130551-1-dancol@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --uai654nwee5vog4c Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2018-10-29, 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. >=20 > 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 process to actually die after being sent > SIGKILL; today, lmkd resorts to polling the proc filesystem pid > entry. This interface allow lmkd to give up polling and instead block > and wait for process death. I agree with the need for this interface (with a few caveats), but there are a few points I'd like to make: * I don't think that making a new procfile is necessary. When you open /proc/$pid you already have a handle for the underlying process, and you can already poll to check whether the process has died (fstatat fails for instance). What if we just used an inotify event to tell userspace that the process has died -- to avoid userspace doing a poll loop? * There is a fairly old interface called the proc_connector which gives you global fork+exec+exit events (similar to kevents from FreeBSD though much less full-featured). I was working on some patches to extend proc_connector so that it could be used inside containers as well as unprivileged users. This would be another way we could implement this. I'm really not a huge fan of the "blocking read" semantic (though if we have to have it, can we at least provide as much information as you get =66rom proc_connector -- such as the exit status?). Also maybe we should integrate this into the exit machinery instead of this loop... --=20 Aleksa Sarai Senior Software Engineer (Containers) SUSE Linux GmbH --uai654nwee5vog4c Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEb6Gz4/mhjNy+aiz1Snvnv3Dem58FAlvapJEACgkQSnvnv3De m5/TmQ/9GtWsv8b6N4kHuqHB7WfMnXm9Kqq3nR4W1WcDGWK86NpjcvzyVKPJSMlV B6gdnTWMfc9bqChvTqT5Q0/qgcbNqzzyDzWKG4JkMt0nDJBJ07tdvp32HXegWJlo JMMulHkErG5fsKX7nf1OH6lGIz80WLKZnqm7/6Qic7l/nPpcW7oN6W9MZcHxMXl9 j5jFv/EPeTnQ9YFn+BkQStKCMdXl/7eIw46VRD62RfDykwH5qg4/zgpIOMEGsQts OLNdNocCj6AB8vd2C0TJEJlfwczvjlFnEnDYwkMzPudmyp6Rl2If6YcWtjNet6ul DXgM8zsHZ0Dd+EeUGJWe8Y2Lt2oWOi7LQtzcw99Oy//EmjX13IOcKWxgPJBihRK+ V/an7p0QiM060PW0u8RRFFYt0gWnkpb83nv+6x91aOcbdj+kdDMwRCMPsGZfq5yn 9WbqFxraygoZfsctSq2U6kQF6OpVoUzx01tqk9DT8mdGY/RxSb88DkTSvHdG3E7j OPqJGZ+wKlof2/It6ca3ojGcuLC0T7uUa5VZrFp5lmK6w7+eoZwn2cWnxu7CvGM9 VdSizrpc50+2SwfSsKXs5cuIhWZrgB9yGruywDIz+1HAxnATKYtpYiTqEWc1rs29 /XOgzmCWLmhPqa53PoPv2ySMl1TcPn/iAygdT2+LjJ8xuFW+OR4= =urye -----END PGP SIGNATURE----- --uai654nwee5vog4c--