From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3BE8C11F68 for ; Thu, 1 Jul 2021 00:46:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4056B6146B for ; Thu, 1 Jul 2021 00:46:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4056B6146B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A8BE78D01D1; Wed, 30 Jun 2021 20:46:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A63278D01D0; Wed, 30 Jun 2021 20:46:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9043D8D01D1; Wed, 30 Jun 2021 20:46:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0069.hostedemail.com [216.40.44.69]) by kanga.kvack.org (Postfix) with ESMTP id 6DE718D01D0 for ; Wed, 30 Jun 2021 20:46:03 -0400 (EDT) Received: from smtpin36.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 33D82181AF5C7 for ; Thu, 1 Jul 2021 00:46:03 +0000 (UTC) X-FDA: 78312177006.36.ACFCF2C Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf17.hostedemail.com (Postfix) with ESMTP id BDF69F000123 for ; Thu, 1 Jul 2021 00:46:02 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id E5A1A6147E for ; Thu, 1 Jul 2021 00:46:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625100361; bh=0OplSnVaoxKOPAKIj0YXj4H1e8gkOZHWvzcV1/ElgJA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Qoumys6/wpVgX1FlAasWZbeYGG8rO8LeyLNoQC7i4gFfApoLo9vm+7L/QUR0YV5Pz HX1j7Agj3arfrF9Wu/Y2wwptNMgluhnATBjO4x+YRTl25RdVPignqI8b2ZtLjGpL5i Z+e4yvFDF7sva3OSd9f+xzebr/DU1J2YdUu+SlXg+rjUTwNeGj4r6MRpAOLLbznOOc ms6ta5hkPl7z8gos1YjTmYBlVpJTRFdWKBMFAn6EeGkeEG8gcU46IHIHgGTLXIAD9f Q3C+Zb0Oq5n5AJKiIDqQrcCrq2iTgpOMOSfLGB+UwLKtIMjje9zGssQabdeb9NKLez VhvI1B4xXjBKA== Received: by mail-ed1-f52.google.com with SMTP id w13so5907118edc.0 for ; Wed, 30 Jun 2021 17:46:01 -0700 (PDT) X-Gm-Message-State: AOAM532uZnjrdfqm1uoi0PpmrMghBv1sNQJA00+mrBilD91GYhUHKuiv bwAtD6i+2KqwmsroXDZzwBWKipRyXvxcps5IftegBA== X-Google-Smtp-Source: ABdhPJxUMSsYleMar6Ny4OBozaHRTablcTTgOJypvmdOI2KwxsSVPgnD113vOEQRqSPVn4WCmT84R/kKOTjaT4scv4A= 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" X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: BDF69F000123 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Qoumys6/"; spf=pass (imf17.hostedemail.com: domain of luto@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=luto@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Stat-Signature: 8yq3fj885q8d1rm97ougkqwzsozdmjcu X-HE-Tag: 1625100362-782352 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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