Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp166570pxv; Wed, 30 Jun 2021 17:48:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcPydeSkw0QLceZXTC88TcEa7gC77TYP6pmrP03lxpLBIj3CQVH6WMW4WcbLAZzW/K/gce X-Received: by 2002:a17:907:7b9b:: with SMTP id ne27mr7441933ejc.266.1625100526643; Wed, 30 Jun 2021 17:48:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625100526; cv=none; d=google.com; s=arc-20160816; b=cnYrcwCI3Ta3Ks2QQeoZTlSry18g/uL8PvmmL+lYVDE8xgNY3sYiAoBiSUDTDDvvJ3 Iy476IYgRa+ad4/ryEoWv7OHUQRgW5KG1voTuEZhPCgtX1FH4UDyRPfr8+GSaOfpxprD ET5+uRY4h/x5Ff0sTK+Yb8K9DGuH2o+pETY9GFfzAostQIQzzMzfRky/zxL1c92jpLwr FLxs03JMRLZRzOKmTvDXXg8/o1Ul9N4EkiGUSbazmycxa35NOLfDY78aKbv6nwaEDmtV RUn+vdNCec5VR5Fr5WsYYoIQoeNofEjZkeCbvksVSkT6y9G7DhNStOK1itbcwVvva6eC BWNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=rd2xninRAZkGGWRj0kANLttoJcXOidJJZAu9d4Mg8CU=; b=O3cSjql+JF6N/mhzpjLF4wd6JlKwDYYxYlhbtyNLPrLFSrLR9Wafhj93IqkBzeW+r/ 9fSBI+DUWjFT+u1qGEWN6C/y9KsdLf/2cMBrdBDAJAQlxtdsTqWGtj9LYRPCZXovziP9 I6VAi2ev6gTsDB06prPjgucedCUXq46bXCbyPX6tj3np5mOMKcofHdg1eXGXqlWTOud9 JbDuJiGU94AoWm8kXu5YLx+O8c1FqyXM6H7u+aFR4uSajtlKC9SZD9hy2hPshIsa8Mkb gn6O5e9fYESqIjN6PLHQxZE9oK6Pdpu2vTgSqGrXanjZcj9BxVdcLCs2ybih1qjks2+f tM5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YQvrmmvR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hv7si17321520ejc.15.2021.06.30.17.48.23; Wed, 30 Jun 2021 17:48:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YQvrmmvR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238267AbhGAAsm (ORCPT + 99 others); Wed, 30 Jun 2021 20:48:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:56980 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238259AbhGAAsl (ORCPT ); Wed, 30 Jun 2021 20:48:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 638F661424 for ; Thu, 1 Jul 2021 00:46:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625100372; bh=0OplSnVaoxKOPAKIj0YXj4H1e8gkOZHWvzcV1/ElgJA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=YQvrmmvRQztIwU6L7vDKUtlM29SnA6smSKQNMHpw0MNk8ZYFltQE1kTnxXMr/JhMC WwW19dhj2NRSDywPQY6odxYiRb3lBx56D2oOw+vDJ33meaxFx3bflxogQMunJM7j5u Uf4s47mQN/T2mW0QFotYo1hSWwhTv/jgZfmvwQgYFJ20hvI2RzezdnwRwSqJIMDt+t qa0kgtvxyKMKtEXQCwqHHT68PZb43z/QGtJhM5qCD5IzucN6TfH4K/8J3FX5mkS8rC BWKgKVCjNrDy6I6wOF3Qj1P4tb0/3zLVxc6Kvh0+q9GcsW8cqbLV+P6t2x1UVdDEzh x7Cq/8QD7mDEA== Received: by mail-lf1-f50.google.com with SMTP id q18so8520149lfc.7 for ; Wed, 30 Jun 2021 17:46:12 -0700 (PDT) X-Gm-Message-State: AOAM530IUGEQm1vQ53Tn+Fgm8aj+F0uy3LK5KHrQGHHlb6ol6bDn/y7a 0Eq26lEz6pGKdvfzBBepKuqmLiVBXajhUstdSujVuQ== X-Received: by 2002:a05:6402:4393:: with SMTP id o19mr49699733edc.263.1625100360517; Wed, 30 Jun 2021 17:46:00 -0700 (PDT) MIME-Version: 1.0 References: <20210623192822.3072029-1-surenb@google.com> In-Reply-To: From: Andy Lutomirski Date: Wed, 30 Jun 2021 17:45:49 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/1] mm: introduce process_reap system call To: Suren Baghdasaryan Cc: Andy Lutomirski , Andrew Morton , Michal Hocko , Michal Hocko , David Rientjes , Matthew Wilcox , Johannes Weiner , Roman Gushchin , Rik van Riel , Minchan Kim , Christian Brauner , Christoph Hellwig , Oleg Nesterov , David Hildenbrand , Jann Horn , Shakeel Butt , Tim Murray , Linux API , Linux-MM , LKML , Android Kernel Team Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 30, 2021 at 11:51 AM Suren Baghdasaryan wrote: > > On Wed, Jun 30, 2021 at 11:26 AM Andy Lutomirski wrote: > > > > On Wed, Jun 23, 2021 at 12:28 PM Suren Baghdasaryan wrote: > > > > > > In modern systems it's not unusual to have a system component monitoring > > > memory conditions of the system and tasked with keeping system memory > > > pressure under control. One way to accomplish that is to kill > > > non-essential processes to free up memory for more important ones. > > > Examples of this are Facebook's OOM killer daemon called oomd and > > > Android's low memory killer daemon called lmkd. > > > For such system component it's important to be able to free memory > > > quickly and efficiently. Unfortunately the time process takes to free > > > up its memory after receiving a SIGKILL might vary based on the state > > > of the process (uninterruptible sleep), size and OPP level of the core > > > the process is running. A mechanism to free resources of the target > > > process in a more predictable way would improve system's ability to > > > control its memory pressure. > > > Introduce process_reap system call that reclaims memory of a dying process > > > from the context of the caller. This way the memory in freed in a more > > > controllable way with CPU affinity and priority of the caller. The workload > > > of freeing the memory will also be charged to the caller. > > > The operation is allowed only on a dying process. > > > > At the risk of asking a potentially silly question, should this just > > be a file in procfs? > > Hmm. I guess it's doable if procfs will not disappear too soon before > memory is released... syscall also supports parameters, in this case > flags can be used in the future to support PIDs in addition to PIDFDs > for example. > Before looking more in that direction, a silly question from my side: > why procfs interface would be preferable to a syscall? It avoids using a syscall nr. (Admittedly a syscall nr is not *that* precious of a resource.) It also makes it possible to use a shell script to do this, which is maybe useful. --Andy