Received: by 2002:ac0:a874:0:0:0:0:0 with SMTP id c49csp602026ima; Fri, 15 Mar 2019 09:44:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqyomRCvVqPeES1INP4CUm2aUI9LvNbIGYEArX8fs1sm9CDVE44wu924mya8I8Jq9I9F04fK X-Received: by 2002:a63:c511:: with SMTP id f17mr4334063pgd.202.1552668290530; Fri, 15 Mar 2019 09:44:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552668290; cv=none; d=google.com; s=arc-20160816; b=xbWw1OynklpMvmQZEilyBX3X1oXNHTpBJm/lTR88VlgD+8PqCfPJ02px9GCR606S0G lUnwYCwq7g1E3M3lqRVD4sWWkpjbaf887KQPY80g0V/B8Ujdlj+wSJp30h7+AqqwyPUT NXZOvxUNTT26n6/7oP7u6r211IL+NNco+k1EHAQGCkHtugMO06RdDVtXWd955Uygw5Dg OEMTBEUuZpAtFvtjSkYZ3DNbShXAWIYcgMTzmVgVjkWpcy60apPmeSA9LKV9qKqkK3NX pBj6uEeDVM/Y7apjW7iDuYlHBxLtSfMRl/CVVxumMZulj+v0MV37KfTIJgOeWBNzJP/p Ib6Q== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=1xgekOBVffSTeVbtQD1XDRPdkSDm9vBxhenoNR6GhYo=; b=YswemjAt2q7O94kbxFOWbGkfFhw90C8pixUS7HxL5e8eCf1hRxcsthyeHvESuZgl6G v9yynwiTlDF+T5rSH5cPNcA0AmxM/iU7Iw3YCeb28mVEIGzvc5lHPNgUuhWUELLlyhQ9 NYMpMdrzj6ZEHKRHzbpOCMwdTV87YEDSq0bxQXXytFkXz8nWakGdrp0urZ0N20LWLs/v gX6kkfKNeZ7vwLhQPCrODywmT3sNipRYsyv3j+o2JIUFIT2TQIe7+46NzB2Fzb21PnJw G8ujAQ2OMhGdt5bnrPcn2+0Wu8k7Jy2QdW3ZoCXUMUPOPVvVwEYwKYH6uOxcW4OqEdb7 4h4w== 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 65si2204407plf.288.2019.03.15.09.44.35; Fri, 15 Mar 2019 09:44:50 -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 S1729626AbfCOQnw (ORCPT + 99 others); Fri, 15 Mar 2019 12:43:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:34952 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728182AbfCOQnw (ORCPT ); Fri, 15 Mar 2019 12:43:52 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 09713218AC; Fri, 15 Mar 2019 16:43:49 +0000 (UTC) Date: Fri, 15 Mar 2019 12:43:48 -0400 From: Steven Rostedt To: Daniel Colascione Cc: Sultan Alsawaf , Joel Fernandes , Tim Murray , Michal Hocko , Suren Baghdasaryan , Greg Kroah-Hartman , Arve =?UTF-8?B?SGrDuG5uZXY=?= =?UTF-8?B?w6Vn?= , Todd Kjos , Martijn Coenen , Christian Brauner , Ingo Molnar , Peter Zijlstra , LKML , "open list:ANDROID DRIVERS" , linux-mm , kernel-team Subject: Re: [RFC] simple_lmk: Introduce Simple Low Memory Killer for Android Message-ID: <20190315124348.528ecd87@gandalf.local.home> In-Reply-To: References: <20190310203403.27915-1-sultan@kerneltoast.com> <20190311174320.GC5721@dhcp22.suse.cz> <20190311175800.GA5522@sultan-box.localdomain> <20190311204626.GA3119@sultan-box.localdomain> <20190312080532.GE5721@dhcp22.suse.cz> <20190312163741.GA2762@sultan-box.localdomain> <20190314204911.GA875@sultan-box.localdomain> <20190314231641.5a37932b@oasis.local.home> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 14 Mar 2019 21:36:43 -0700 Daniel Colascione wrote: > On Thu, Mar 14, 2019 at 8:16 PM Steven Rostedt wrote: > > > > On Thu, 14 Mar 2019 13:49:11 -0700 > > Sultan Alsawaf wrote: > > > > > Perhaps I'm missing something, but if you want to know when a process has died > > > after sending a SIGKILL to it, then why not just make the SIGKILL optionally > > > block until the process has died completely? It'd be rather trivial to just > > > store a pointer to an onstack completion inside the victim process' task_struct, > > > and then complete it in free_task(). > > > > How would you implement such a method in userspace? kill() doesn't take > > any parameters but the pid of the process you want to send a signal to, > > and the signal to send. This would require a new system call, and be > > quite a bit of work. > > That's what the pidfd work is for. Please read the original threads > about the motivation and design of that facility. I wasn't Cc'd on the original work, so I haven't read them. > > > If you can solve this with an ebpf program, I > > strongly suggest you do that instead. > > We do want killed processes to die promptly. That's why I support > boosting a process's priority somehow when lmkd is about to kill it. > The precise way in which we do that --- involving not only actual > priority, but scheduler knobs, cgroup assignment, core affinity, and > so on --- is a complex topic best left to userspace. lmkd already has > all the knobs it needs to implement whatever priority boosting policy > it wants. > > Hell, once we add a pidfd_wait --- which I plan to work on, assuming > nobody beats me to it, after pidfd_send_signal lands --- you can > imagine a general-purpose priority inheritance mechanism expediting > process death when a high-priority process waits on a pidfd_wait > handle for a condemned process. You know you're on the right track > design-wise when you start seeing this kind of elegant constructive > interference between seemingly-unrelated features. What we don't need > is some kind of blocking SIGKILL alternative or backdoor event > delivery system. > > We definitely don't want to have to wait for a process's parent to > reap it. Instead, we want to wait for it to become a zombie. That's > why I designed my original exithand patch to fire death notification > upon transition to the zombie state, not upon process table removal, > and I expect pidfd_wait (or whatever we call it) to act the same way. > > In any case, there's a clear path forward here --- general-purpose, > cheap, and elegant --- and we should just focus on doing that instead > of more complex proposals with few advantages. If you add new pidfd systemcalls then making a new way to send a signal and block till it does die or whatever is more acceptable than adding a new signal that changes the semantics of sending signals, which is what I was against. I do agree with Joel about bloating task_struct too. If anything, have a wait queue you add, where you can allocate a descriptor with the task dieing and task killing, and just search this queue on dying. We could add a TIF flag to the task as well to let the exiting of this task know it should do such an operation. -- Steve