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=-11.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,URIBL_BLOCKED,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 3487DC63697 for ; Sat, 14 Nov 2020 00:06:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A70462224D for ; Sat, 14 Nov 2020 00:06:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="nrKE/pW+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A70462224D 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 D5A496B005C; Fri, 13 Nov 2020 19:06:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CE4586B005D; Fri, 13 Nov 2020 19:06:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B84786B0068; Fri, 13 Nov 2020 19:06:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0125.hostedemail.com [216.40.44.125]) by kanga.kvack.org (Postfix) with ESMTP id 86B6E6B005C for ; Fri, 13 Nov 2020 19:06:38 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 24572181AC9CC for ; Sat, 14 Nov 2020 00:06:38 +0000 (UTC) X-FDA: 77481082476.12.wine00_2b0936427313 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 03B771800912C for ; Sat, 14 Nov 2020 00:06:37 +0000 (UTC) X-HE-Tag: wine00_2b0936427313 X-Filterd-Recvd-Size: 4862 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Sat, 14 Nov 2020 00:06:37 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id 33so12042463wrl.7 for ; Fri, 13 Nov 2020 16:06:37 -0800 (PST) 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=YMwx6LSJmhzHC8ZwI/8VJ7EjLxTfqp/OPgMA3Bg83jQ=; b=nrKE/pW+KWhWL7CSJSxYp2bfQtrqaK67kOP6ChC/xDuQNJQPHtUu39mOKt5BQ/1Iyz cw/kthSZj4IYEDbey39LpdtlAmtJCw+iPxwM54LuojmucBh71oasiBOML7kI/Ik6bCZM wM5o5Xw4uqi7GB1JyXD6HXyZwYjpxMD3xmUmkez13aSUzi7snYzTXK6FGdciN6zVJuXe lXg2h7Q1qwiiVkxjoFnfGowHd1G1J+ASGEyOfkuDoGo26bwX+xAgRca3Dm/q8D0ph26L EoO3sgfQMnfcLn1kWx7OFTffF22K5ZrS/67y4dvmFqLSLBL4j1nXG1j5jZL93hiD5flD syKA== 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=YMwx6LSJmhzHC8ZwI/8VJ7EjLxTfqp/OPgMA3Bg83jQ=; b=is6qELll9q85Snn5h0fElOI3SDGOB2aEML86uj6RLX+bIDWo3yyewlWrEw3Ml6OZZl 7tvAuAbxepYTyIvCjTJYXVFFfgW0aT9F0djHbTFEdhW/l1l7GMBy+lxjA0GgdQOJ8HGx ynrpQ2KD8uEGKaZMcKV/d5+GEfmZ6KVigovgP7f+RAH8eR1zJXiNsQsuZeve43Em5nuL XsUeNEquVdO05yI9K+OEh8gQs4dIZlmGXwrB5HlVhcaMiPSGxepANIR58xRiYJNtGak2 77JwxY98hhKDFFxV0ieHVHvYWyU0VJwbg76YOYkcO7UyJsdRD7LONWU/RzDqi/zAi6Gf hktw== X-Gm-Message-State: AOAM532/2opmWVsBQIdPYZVCVQDyR3BWT6B0GsCEQPMn7448fOIpqZr8 x1Gm2jA7ovn3ar6RJw51KOnQt1DfUVDDcCs5d4M/Nw== X-Google-Smtp-Source: ABdhPJwWY4RJZxOCag2JXa57h3SCp1jATWMjlVteiWIgM6nKnyg8a1mu6hL4Duzswr0lpdXyinvH5OHjmlUhGdYZgU0= X-Received: by 2002:adf:9069:: with SMTP id h96mr6694004wrh.358.1605312396203; Fri, 13 Nov 2020 16:06:36 -0800 (PST) MIME-Version: 1.0 References: <20201113173448.1863419-1-surenb@google.com> <20201113155539.64e0af5b60ad3145b018ab0d@linux-foundation.org> In-Reply-To: <20201113155539.64e0af5b60ad3145b018ab0d@linux-foundation.org> From: Suren Baghdasaryan Date: Fri, 13 Nov 2020 16:06:25 -0800 Message-ID: Subject: Re: [PATCH 1/1] RFC: add pidfd_send_signal flag to reclaim mm while killing a process To: Andrew Morton Cc: Michal Hocko , David Rientjes , Matthew Wilcox , Johannes Weiner , Roman Gushchin , Rik van Riel , Christian Brauner , Oleg Nesterov , Tim Murray , linux-api@vger.kernel.org, linux-mm , LKML , kernel-team , Minchan Kim Content-Type: text/plain; charset="UTF-8" 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 Fri, Nov 13, 2020 at 3:55 PM Andrew Morton wrote: > > On Fri, 13 Nov 2020 09:34:48 -0800 Suren Baghdasaryan wrote: > > > When a process is being killed it might be in an uninterruptible sleep > > which leads to an unpredictable delay in its memory reclaim. In low memory > > situations, when it's important to free up memory quickly, such delay is > > problematic. Kernel solves this problem with oom-reaper thread which > > performs memory reclaim even when the victim process is not runnable. > > Userspace currently lacks such mechanisms and the need and potential > > solutions were discussed before (see links below). > > This patch provides a mechanism to perform memory reclaim in the context > > of the process that sends SIGKILL signal. New SYNC_REAP_MM flag for > > pidfd_send_signal syscall can be used only when sending SIGKILL signal > > and will lead to the caller synchronously reclaiming the memory that > > belongs to the victim and can be easily reclaimed. > > hm. > > Seems to me that the ability to reap another process's memory is a > generally useful one, and that it should not be tied to delivering a > signal in this fashion. > > And we do have the new process_madvise(MADV_PAGEOUT). It may need a > few changes and tweaks, but can't that be used to solve this problem? Thank you for the feedback, Andrew. process_madvise(MADV_DONTNEED) was one of the options recently discussed in https://lore.kernel.org/linux-api/CAJuCfpGz1kPM3G1gZH+09Z7aoWKg05QSAMMisJ7H5MdmRrRhNQ@mail.gmail.com . The thread describes some of the issues with that approach but if we limit it to processes with pending SIGKILL only then I think that would be doable.