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=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 D4CD4C11F67 for ; Thu, 1 Jul 2021 23:08:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5C8BD6140E for ; Thu, 1 Jul 2021 23:08:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5C8BD6140E Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DBE908D02B9; Thu, 1 Jul 2021 19:08:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D6EB58D0001; Thu, 1 Jul 2021 19:08:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C0F308D02B9; Thu, 1 Jul 2021 19:08:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0137.hostedemail.com [216.40.44.137]) by kanga.kvack.org (Postfix) with ESMTP id 9A8018D0001 for ; Thu, 1 Jul 2021 19:08:13 -0400 (EDT) Received: from smtpin34.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 535738087BE8 for ; Thu, 1 Jul 2021 23:08:13 +0000 (UTC) X-FDA: 78315559266.34.C32EC62 Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) by imf07.hostedemail.com (Postfix) with ESMTP id 0FE8B10004E3 for ; Thu, 1 Jul 2021 23:08:12 +0000 (UTC) Received: by mail-yb1-f171.google.com with SMTP id s129so13546348ybf.3 for ; Thu, 01 Jul 2021 16:08:12 -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=JVFwhu0Nl1U9FivJTXYgbITws6r7aJBlzJ81RHuWBSo=; b=lYp1QR+VzXen7d2xJF2fbcLqhi1ay1+vCQpxCfKI+F1Y7rAEbyh89MNhAJooFga14A 2CH/m1K/T8X3/uyuzQjJDfWZHqlboXl4tsagwV7koZJU7jeAfOYCnWCgWa/O4R5fwY3k yYnfPUXeE/8aSQXjZhSXs6EvokPk/NMTM5PpcQaBWdcNl0Dl55TWRBjo3DMictyRffxP FNevKNKq8Ym1jcjlF+kQrzoOANVGeNb9pQxesajua1x+gbaUcYlzLUHWX9Mz/Ee+5Yf1 2ZFBoRILOFE+9MK5DbKOXMVrix+YZBY/am2DjjhmAb4abHoU+TtwSZ7pcjhIfuwthRJm tOjg== 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=JVFwhu0Nl1U9FivJTXYgbITws6r7aJBlzJ81RHuWBSo=; b=mWKGiiOrOHqJ98REdoXWxhHl2mObqbcI8DEQb25mP2Ro+uorK2I36x1zsbQKPPRMmS k5GoPegL1flVM+DVmpQZcztN8wfabxdyaC47Hyp9J15+mxINe8QQJSO4UOm/X1fOuCEd F/IMWMwlDU7zvfXfodS2vBhsk87mOU82lfsVp2Y/ksNi0BbEdfqHnqEX/Yoj/Htmbaw3 8Mr84zlg/Bdn4E8LGeVkfghf/es3yWx+dSOzjpl28FMWbKC+xR/0qqoT+Pm2+xPDovrO yR1kGbIYGd7tgHQN/t2jN+8El9o/Y2PhqnTnsEYxrN3EjhhdgHTKfmDiqx+UbCcAL6K1 5ZCA== X-Gm-Message-State: AOAM533VB8e2ULRmxL3Th9NTRC7Z0XKj/JFgs76dhQVEi7doig50hbUJ Q3LhJE8sxB6VcKvYJgvTSr3k9S/db4eo3UtCQxOIsg== X-Google-Smtp-Source: ABdhPJzlD1Rwyg4aaTXscYYkLEEMfARA5rwHrPGJiwB0C5EZgf9sRsRKGD9SS7+cgRsYyt0WzPidD7cw4j9F8JmjJMM= X-Received: by 2002:a25:2341:: with SMTP id j62mr3050343ybj.190.1625180892125; Thu, 01 Jul 2021 16:08:12 -0700 (PDT) MIME-Version: 1.0 References: <20210623192822.3072029-1-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Thu, 1 Jul 2021 16:08:01 -0700 Message-ID: Subject: Re: [PATCH 1/1] mm: introduce process_reap system call To: Andy Lutomirski Cc: 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: rspam05 X-Rspamd-Queue-Id: 0FE8B10004E3 X-Stat-Signature: at84h3b7p6mhoagbxud1a5hkq6mof9m5 Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=lYp1QR+V; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf07.hostedemail.com: domain of surenb@google.com designates 209.85.219.171 as permitted sender) smtp.mailfrom=surenb@google.com X-HE-Tag: 1625180892-888956 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 5:46 PM Andy Lutomirski wrote: > > 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. I see. Not really sure if the shell usage is a big usecase for this operation but let's see if more people like that approach. For my specific usecase one syscall (process_reap) is better than three syscalls (open, write, close) and the possibility to extend the functionality using flags might be of value for the future. > > --Andy