Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6043400yba; Thu, 11 Apr 2019 10:49:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxahv+ORTH1CNlZ2GOrUvrCESLnZpwDfw+z0O9hHn/CCFuLcwGwIUe0hhFABiGuUgIPlH/E X-Received: by 2002:a17:902:b48c:: with SMTP id y12mr50326788plr.280.1555004941022; Thu, 11 Apr 2019 10:49:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555004941; cv=none; d=google.com; s=arc-20160816; b=J9s62iqhXleWrzYOLGrpZfCW/Y8TdK7hPd9RIVNU/8mt+ute/eVvDljcucrBgEmIQi 0Q++DAUVXMxFO6D8x9bMWm5hcq+gecQY0YTVDBNtTiajxtvT5YiTJZmid1yM8DqDJpte 80yHffwpaiZb3BmI8kKHhMbhyE+2KkAIuhA7QL3OX0+mErPFyYrEeU5zrwyCQhrgE0Rl HzU8u+1eUD0q51UVv5zCmJ5s6nBISr7S9yTvgQEg1LXnxkm6VS9ZCOPotly6BysJvxJz QCIEZfYS0HyjFrzxU4NuG4i3pCDnU2hYZQsD2DWynnhSLyEzJthrwT0ZnLe+tpytXC6i mHuQ== 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=EdmEfhETvX5sRZ2i3AN4xgxKTisr0Ltj90Tc5NPzL+I=; b=kyawA+lBmoD5YgleYZTpOcePpwqZ7pUzsQq3kKjuuIVK9l7pKEozyR6P23hv+5zWvz BcmuJZ8nELjhOxmncO0jkrvxRNqygJnreDRKCXPXLK+R4PngQQLYTX3iCEiQbb8NueDa 4H1eAnivmkir/XXC/RMF3tWQfhUv01KOC9o89jO7zQ9QTa4vv/zdy273i5vatyaFgqQ9 8OR0q7j6mwYJEfX/pxEaBKZ85pVm/MFZFpHhKSd8HRIQdsim4y62C3CG6h9c4fzMOQ8V R0DEr1/2P+5J/Q4zIiBIXGQFj9SB4wh2WdTjYDZ519xbjYJdQ3b8Dm9j4PTdeJ6qGyfk L4lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="jz89wF/P"; 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 ay8si29075737plb.202.2019.04.11.10.48.44; Thu, 11 Apr 2019 10:49: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; dkim=pass header.i=@google.com header.s=20161025 header.b="jz89wF/P"; 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 S1726664AbfDKRsD (ORCPT + 99 others); Thu, 11 Apr 2019 13:48:03 -0400 Received: from mail-vs1-f67.google.com ([209.85.217.67]:47014 "EHLO mail-vs1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726603AbfDKRsD (ORCPT ); Thu, 11 Apr 2019 13:48:03 -0400 Received: by mail-vs1-f67.google.com with SMTP id e2so3969688vsc.13 for ; Thu, 11 Apr 2019 10:48:02 -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=EdmEfhETvX5sRZ2i3AN4xgxKTisr0Ltj90Tc5NPzL+I=; b=jz89wF/PI7xg90sbXXootb01OYHrWVY1nyKpnYun8KA/55ifTn0poh8w9zFwRH252Z Dw+IysDpcGaJw6W5CznS2kYl/jSmZrStx7LG6OgW7ihxHEasnyj+5cNjp8m1rxozoENV vMjq/0/brXM7n2UaYUjItZAJjRAXYz1OmAao8Sd69dilMIvL2IJT3oDvDBgrSAejGbbH Zkfmdw/a3nVbVz2iTiFBR2bFuKyW6eJU5N2v2KaFR6vXkF5HJzyxVz9TqJVHMm1aLN/9 EFNznjoGr1qh/+0NrHLQrLhfHjTFVDwPn5uDgrh7B5/JwMRo4NtPiZ0lSShhe+MBfz37 1zCA== 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=EdmEfhETvX5sRZ2i3AN4xgxKTisr0Ltj90Tc5NPzL+I=; b=BcqqUIYTHpvyb7PKXdwXocuH621UvGsP86STtjwOqj3C/sTjoFupuPYneMP7C+SCTQ UxGM1dmvIJWaRViyrgzqfVkF8pRbE3ssKqDeDdxu328Vco0cpL0UFjPmdXoW/T0bwaAC Ym74bbx/mrnJYmymSFL5GGoYkKFoGTqEANNMKGoDEXbHiNrY+ZoUtN6L0dvQyV3aWTzr tKhWG3BTi0zlBCptJFVhpyFNH9oHADpCyN2thu7uA7SyqieER/Cas4yiBfe2S48yr10Q lS5s457EDaNFf7MPd8OKPNR2oJRgi3dMRqVo2CcRYSzUnR1BaZ0vnT41FZSKLgT94Uun CuNg== X-Gm-Message-State: APjAAAVy9ZBhRMkbRFl5rXPM+zcUMg5BlYAxTSDeUiDzob6HkL+wjcgy Hai1U/wcZjzPuO8Ea5nk/nZH89tGdBpdoQxgC6atqA== X-Received: by 2002:a05:6102:212:: with SMTP id z18mr29458490vsp.218.1555004881611; Thu, 11 Apr 2019 10:48:01 -0700 (PDT) MIME-Version: 1.0 References: <20190411014353.113252-1-surenb@google.com> <20190411014353.113252-3-surenb@google.com> <20190411153313.GE22763@bombadil.infradead.org> <20190411173649.GF22763@bombadil.infradead.org> In-Reply-To: <20190411173649.GF22763@bombadil.infradead.org> From: Daniel Colascione Date: Thu, 11 Apr 2019 10:47:50 -0700 Message-ID: Subject: Re: [RFC 2/2] signal: extend pidfd_send_signal() to allow expedited process killing To: Matthew Wilcox Cc: Suren Baghdasaryan , Andrew Morton , Michal Hocko , David Rientjes , yuzhoujian@didichuxing.com, Souptick Joarder , Roman Gushchin , Johannes Weiner , Tetsuo Handa , "Eric W. Biederman" , Shakeel Butt , Christian Brauner , Minchan Kim , Tim Murray , Joel Fernandes , Jann Horn , linux-mm , lsf-pc@lists.linux-foundation.org, LKML , kernel-team 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 Thu, Apr 11, 2019 at 10:36 AM Matthew Wilcox wrote: > > On Thu, Apr 11, 2019 at 10:33:32AM -0700, Daniel Colascione wrote: > > On Thu, Apr 11, 2019 at 10:09 AM Suren Baghdasaryan wrote: > > > On Thu, Apr 11, 2019 at 8:33 AM Matthew Wilcox wrote: > > > > > > > > On Wed, Apr 10, 2019 at 06:43:53PM -0700, Suren Baghdasaryan wrote: > > > > > Add new SS_EXPEDITE flag to be used when sending SIGKILL via > > > > > pidfd_send_signal() syscall to allow expedited memory reclaim of the > > > > > victim process. The usage of this flag is currently limited to SIGKILL > > > > > signal and only to privileged users. > > > > > > > > What is the downside of doing expedited memory reclaim? ie why not do it > > > > every time a process is going to die? > > > > > > I think with an implementation that does not use/abuse oom-reaper > > > thread this could be done for any kill. As I mentioned oom-reaper is a > > > limited resource which has access to memory reserves and should not be > > > abused in the way I do in this reference implementation. > > > While there might be downsides that I don't know of, I'm not sure it's > > > required to hurry every kill's memory reclaim. I think there are cases > > > when resource deallocation is critical, for example when we kill to > > > relieve resource shortage and there are kills when reclaim speed is > > > not essential. It would be great if we can identify urgent cases > > > without userspace hints, so I'm open to suggestions that do not > > > involve additional flags. > > > > I was imagining a PI-ish approach where we'd reap in case an RT > > process was waiting on the death of some other process. I'd still > > prefer the API I proposed in the other message because it gets the > > kernel out of the business of deciding what the right signal is. I'm a > > huge believer in "mechanism, not policy". > > It's not a question of the kernel deciding what the right signal is. > The kernel knows whether a signal is fatal to a particular process or not. > The question is whether the killing process should do the work of reaping > the dying process's resources sometimes, always or never. Currently, > that is never (the process reaps its own resources); Suren is suggesting > sometimes, and I'm asking "Why not always?" FWIW, Suren's initial proposal is that the oom_reaper kthread do the reaping, not the process sending the kill. Are you suggesting that sending SIGKILL should spend a while in signal delivery reaping pages before returning? I thought about just doing it this way, but I didn't like the idea: it'd slow down mass-killing programs like killall(1). Programs expect sending SIGKILL to be a fast operation that returns immediately.