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 A4D34C61DD8 for ; Fri, 13 Nov 2020 17:37:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1CA0D20791 for ; Fri, 13 Nov 2020 17:37:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ghFs2rH1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1CA0D20791 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 805786B0089; Fri, 13 Nov 2020 12:37:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 78F026B0096; Fri, 13 Nov 2020 12:37:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5BBA36B0098; Fri, 13 Nov 2020 12:37:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0207.hostedemail.com [216.40.44.207]) by kanga.kvack.org (Postfix) with ESMTP id 2C0BC6B0089 for ; Fri, 13 Nov 2020 12:37:34 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id BFD8B181AC1E9 for ; Fri, 13 Nov 2020 17:37:33 +0000 (UTC) X-FDA: 77480101986.16.home67_2b0f6d427310 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 306EE100E6932 for ; Fri, 13 Nov 2020 17:37:32 +0000 (UTC) X-HE-Tag: home67_2b0f6d427310 X-Filterd-Recvd-Size: 7650 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Fri, 13 Nov 2020 17:37:31 +0000 (UTC) Received: by mail-wr1-f51.google.com with SMTP id 33so10797343wrl.7 for ; Fri, 13 Nov 2020 09:37:31 -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=hjhurK9P35kGnhWjbyimEvcQqerqsp2/lDGVzt9PJQE=; b=ghFs2rH1tOxUzusPZBY7hh+pYGf0lSRP1oZiBayW95v4HRIM53tzKkbLSh0pzuA5Co xfHhtLLdYKm2lD8HfJ/Q471eufx4MtA4EnYfIIUIZLQdzAjhwzJxqAJFLgi6DTGfCWXt VE51V6vz9UOot7j8ToGThJ5WRcoqDehfUZQ4IwLdu3FaFRGpkJevLb0EjnPfoBIeYXs5 MCPP0KqGyKiMu30O+byGDpFRzV9S2EgR48Dbz7oDYVsNl9VTs9ZRdfnNtN7+lxKFG0HP M4Ofux07F5YxHa6/vFLE9zZOz3mRQBWIzHOzWNFPSAZIG+1D4vFt2vyXHpUr4u1MAZhJ FjQg== 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=hjhurK9P35kGnhWjbyimEvcQqerqsp2/lDGVzt9PJQE=; b=qhxIxIEAXTpEkp/PC4++cRiGP2eIDBcrPklMXiWSldd1p1L5pVbKwzrHpglfWQFR0o EVbmoJfTFd/VnTk0KJre5m2bPZYnRoy+lRpbu05vpVkDHMRL66/w5+CaHeUTg+9UaCJg OZorWl0opVn24ubW1vW3lY0zHvuAd0d77UVABNSIRlS83Gi1+N8hMywEoDv85njR7u1Y Bq52NVX78jIffi0IDJbpIX3rCOVdDDXaAwp66z4gNB0QN1LoP5d/WWAhzfjT8MMQxL3F ZT+8XxwiLl0yZzwDLqoXJ73qEbpms2TlMW+6xZWKF2g7CjyB4FGILW0hZhncgXgI6Vqa gz9A== X-Gm-Message-State: AOAM5330/T3YKJq3Cc6cjwc2g1h1RoAaZX0MQYJdb8M48cOVQCmbgBIP 16ldwJpzSl3Pl3qs8hBr5oNKegOkpZno5bRAHX9o6g== X-Google-Smtp-Source: ABdhPJysGkR3uusoAbdMq81+hVOKWOIh9cN2NKfa5it3R7D7WPHOzI7MxNNO6qLC7Og9ApYXomjjySnltJCldDkJTG0= X-Received: by 2002:adf:db87:: with SMTP id u7mr4984321wri.334.1605289050149; Fri, 13 Nov 2020 09:37:30 -0800 (PST) MIME-Version: 1.0 References: <20201103093550.GE21990@dhcp22.suse.cz> <20201103213228.GB1631979@google.com> <20201104065844.GM21990@dhcp22.suse.cz> <20201104204051.GA3544305@google.com> <20201105122012.GD21348@dhcp22.suse.cz> <20201105171611.GO21348@dhcp22.suse.cz> <20201105174357.GR21348@dhcp22.suse.cz> In-Reply-To: From: Suren Baghdasaryan Date: Fri, 13 Nov 2020 09:37:18 -0800 Message-ID: Subject: Re: [RFC]: userspace memory reaping To: Michal Hocko Cc: Minchan Kim , linux-api@vger.kernel.org, linux-mm , Andrew Morton , David Rientjes , Matthew Wilcox , Johannes Weiner , Roman Gushchin , Rik van Riel , Christian Brauner , Oleg Nesterov , Tim Murray , kernel-team , LKML , Mel Gorman 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 Thu, Nov 5, 2020 at 10:02 AM Suren Baghdasaryan wrote: > > On Thu, Nov 5, 2020 at 9:44 AM Michal Hocko wrote: > > > > On Thu 05-11-20 09:21:13, Suren Baghdasaryan wrote: > > > On Thu, Nov 5, 2020 at 9:16 AM Michal Hocko wrote: > > > > > > > > On Thu 05-11-20 08:50:58, Suren Baghdasaryan wrote: > > > > > On Thu, Nov 5, 2020 at 4:20 AM Michal Hocko wrote: > > > > > > > > > > > > On Wed 04-11-20 12:40:51, Minchan Kim wrote: > > > > > > > On Wed, Nov 04, 2020 at 07:58:44AM +0100, Michal Hocko wrote: > > > > > > > > On Tue 03-11-20 13:32:28, Minchan Kim wrote: > > > > > > > > > On Tue, Nov 03, 2020 at 10:35:50AM +0100, Michal Hocko wrote: > > > > > > > > > > On Mon 02-11-20 12:29:24, Suren Baghdasaryan wrote: > > > > > > > > > > [...] > > > > > > > > > > > To follow up on this. Should I post an RFC implementing SIGKILL_SYNC > > > > > > > > > > > which in addition to sending a kill signal would also reap the > > > > > > > > > > > victim's mm in the context of the caller? Maybe having some code will > > > > > > > > > > > get the discussion moving forward? > > > > > > > > > > > > > > > > > > > > Yeah, having a code, even preliminary, might help here. This definitely > > > > > > > > > > needs a good to go from process management people as that proper is land > > > > > > > > > > full of surprises... > > > > > > > > > > > > > > > > > > Just to remind a idea I suggested to reuse existing concept > > > > > > > > > > > > > > > > > > fd = pidfd_open(victim process) > > > > > > > > > fdatasync(fd); > > > > > > > > > close(fd); > > > > > > > > > > > > > > > > I must have missed this proposal. Anyway, are you suggesting fdatasync > > > > > > > > to act as a destructive operation? > > > > > > > > > > > > > > write(fd) && fdatasync(fd) are already destructive operation if the file > > > > > > > is shared. > > > > > > > > > > > > I am likely missing something because fdatasync will not destroy any > > > > > > underlying data. It will sync > > > > > > > > > > > > > You don't need to reaping as destruptive operation. Rather than, just > > > > > > > commit on the asynchrnous status "write file into page cache and commit > > > > > > > with fsync" and "killing process and commit with fsync". > > > > > > > > > > > > I am sorry but I do not follow. The result of the memory reaping is a > > > > > > data loss. Any private mapping will simply lose it's content. The caller > > > > > > will get EFAULT when trying to access it but there is no way to > > > > > > reconstruct the data. This is everything but not resembling what I see > > > > > > f{data}sync is used for. > > > > > > > > > > I think Minchan considers f{data}sync as a "commit" operation. > > > > > > > > But there is nothing like commit in that operation. It is simply a > > > > destroy operation. ftruncate as Minchan mentions in another reply would > > > > be a closer fit but how do you interpret the length argument? What about > > > > memory regions which cannot be reaped? > > > > > > > > I do understand that reusing an existing mechanism is usually preferable > > > > but the semantic should be reasonable and easy to reason about. > > > > > > Maybe then we can consider a flag for pidfd_send_signal() to indicate > > > that we want a synchronous mm cleanup when SIGKILL is being sent? > > > Similar to my original RFC but cleanup would happen in the context of > > > the caller. That seems to me like the simplest and most obvious way of > > > expressing what we want to accomplish. WDYT? > > > > Yes that would make sense. Althought it would have to be SIGKILL > > specific flag IMO. But let's see what process management people think > > about that. > > Very well, I'll brush up the implementation and will post a new RFC. Thanks! > Sorry for the delay. The new RFC is posted at https://lkml.org/lkml/2020/11/13/849 > > > > -- > > Michal Hocko > > SUSE Labs