Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp602636ybi; Fri, 31 May 2019 06:20:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqymJpfszKyMX59ut3Ah+i1hhuT/3mxtqAIdftU20O346p4L4zY6GbrY+WcuXGSKClJ09lFy X-Received: by 2002:a63:484d:: with SMTP id x13mr9161058pgk.275.1559308846317; Fri, 31 May 2019 06:20:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559308846; cv=none; d=google.com; s=arc-20160816; b=N9ToVmv8yvaoImaCwBhuwvJwztwteMe5ZXSzCZaY3ehXUzgp7VULBKj9KAbq7+r6zw hYVuMMLFc7wantqoL6cggtmTOfihqhKJJQNLDNhWXcD0Qbw6NM/GsjNjPR1k6aPUDREi 059TDVaH/mwIIJakLbwq/aH5qawplDNXm42N1rPXY197w9eMkf0it2C/RynkHH/ZBZOl O4kk11oROsxdSkEJ/Nsy67bj82nnmfMUfZgHMvcjFP9NACv9WwyBDiJQFUW1K+DrzW0k uJ5SK5yLb/ekcXsbgEGmTvVj4XaGynKYum03JA+nD3ro/HMcDNPvi59PU/ZSiH8rOPS+ ggRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=NGbXt3/IQA1b49aRJS6BBAi0DW9ybOJRqUfZBPY09dA=; b=BFdmpr05p/FujVLOqfqDFODrVfb1H53uBkl1PrE1wi4Ie81UOQhBTMhH3P+F1Jatmv KZ0NxnFFKmz2aqo6xFrnbfg5OkgJF1QaUk/xRsnu/qSF1QDpxMvJGWOGMetpeWXeTpGl fPlGPCyjXnXzZ/4b0VN4w4H7TMid3pinJ7Rr4PPq5Y7WsW55G8RUXAPst8iR69y15n/x crobCVvA7eIh1I8oTuf5KwVt2QLpcY43fxc5P2ABlfa5ZKu2srDaUNiQX4BWQysLZQGw 7RrxeAVuJoyQxF7N5ezSTS7dL+a90oq7eccORt0UM9QcIwbk9gKlD+7fKOpFS1CZtaeK SXEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=A3WPnRqn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g2si5921738pgs.215.2019.05.31.06.20.28; Fri, 31 May 2019 06:20:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=A3WPnRqn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726609AbfEaNTM (ORCPT + 99 others); Fri, 31 May 2019 09:19:12 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:38854 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726330AbfEaNTL (ORCPT ); Fri, 31 May 2019 09:19:11 -0400 Received: by mail-pf1-f196.google.com with SMTP id a186so5509979pfa.5; Fri, 31 May 2019 06:19:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=NGbXt3/IQA1b49aRJS6BBAi0DW9ybOJRqUfZBPY09dA=; b=A3WPnRqnTUdG3crEHGBb/NpBr+tWmhd8IyhewWKj1R4bjxJzKPyXLzw5G3U9Lnteyl S36wH0W0+2k1njFZy2Ds2f/9kFql5X0DZRwamUx250rLJpRwx19xr3wuHqAOJBBYxLq9 D5yvDqjjRPT9mniegqhTMI69xTfamzNzmqGuYDQC27qaWbbK2U1nrf6NWOVP/AQgAVed 27HAfAIiBEc/pMFVtc2MGWrATM8vpC7OKdA/xorvzdMTJRgsu4MAyOAQ07qRReLzaC1m vS3W5pSSEa4XJdth4E3PvyqmD9aT/s5qNUBsNMohsGUqNgFntqIxkqkXVq7VroDVR9nb xcZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=NGbXt3/IQA1b49aRJS6BBAi0DW9ybOJRqUfZBPY09dA=; b=Bf794g/fKtpcOFKaBaI/yDB3dac5tTlWFL3ZHSFogPoiv8uwpOEEY03gu7hIToEd9e WjxKA1QlEzavJoiZ8Wy6V/LBpvru82RbwVVl5i3jj+NaoAs2embXRTRdc09MgLpD/K+8 FYCzXpFuMQie9CpNi3fn+d/s5KBRvHKHhkt4yaIaGYzcRKknQhCyG0/SrMfRUz8bLcIG Kh3zY94gPdaLsP+zmPEH4NYLqWuSC9qE3L4Qlq9Mtedw7zOvunO9xuAPhau2wjpOjhSx J0zeNp+8idW3IWdUN9JQyLLwR8j9EJ4Vlmw/ygM8kyLOpDTUkIZNruTSxqiY24GI0/ZK Mpbg== X-Gm-Message-State: APjAAAUtqyDWQyAwfE+yw551v7ULeQM0KV2GulZJ7MytN/pKNCBZaCn6 jZYNyps3Ory4xxJtvFDPYq8= X-Received: by 2002:a63:6884:: with SMTP id d126mr9237347pgc.154.1559308750486; Fri, 31 May 2019 06:19:10 -0700 (PDT) Received: from google.com ([122.38.223.241]) by smtp.gmail.com with ESMTPSA id d186sm5485008pgc.58.2019.05.31.06.19.02 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 31 May 2019 06:19:09 -0700 (PDT) Date: Fri, 31 May 2019 22:19:00 +0900 From: Minchan Kim To: Michal Hocko Cc: Andrew Morton , linux-mm , LKML , linux-api@vger.kernel.org, Johannes Weiner , Tim Murray , Joel Fernandes , Suren Baghdasaryan , Daniel Colascione , Shakeel Butt , Sonny Rao , Brian Geffon , jannh@google.com, oleg@redhat.com, christian@brauner.io, oleksandr@redhat.com, hdanton@sina.com Subject: Re: [RFCv2 5/6] mm: introduce external memory hinting API Message-ID: <20190531131859.GB195463@google.com> References: <20190531064313.193437-1-minchan@kernel.org> <20190531064313.193437-6-minchan@kernel.org> <20190531083757.GH6896@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190531083757.GH6896@dhcp22.suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 31, 2019 at 10:37:57AM +0200, Michal Hocko wrote: > On Fri 31-05-19 15:43:12, Minchan Kim wrote: > > There is some usecase that centralized userspace daemon want to give > > a memory hint like MADV_[COLD|PAGEEOUT] to other process. Android's > > ActivityManagerService is one of them. > > > > It's similar in spirit to madvise(MADV_WONTNEED), but the information > > required to make the reclaim decision is not known to the app. Instead, > > it is known to the centralized userspace daemon(ActivityManagerService), > > and that daemon must be able to initiate reclaim on its own without > > any app involvement. > > > > To solve the issue, this patch introduces new syscall process_madvise(2). > > It could give a hint to the exeternal process of pidfd. > > > > int process_madvise(int pidfd, void *addr, size_t length, int advise, > > unsigned long cookie, unsigned long flag); > > > > Since it could affect other process's address range, only privileged > > process(CAP_SYS_PTRACE) or something else(e.g., being the same UID) > > gives it the right to ptrace the process could use it successfully. > > > > The syscall has a cookie argument to privode atomicity(i.e., detect > > target process's address space change since monitor process has parsed > > the address range of target process so the operaion could fail in case > > of happening race). Although there is no interface to get a cookie > > at this moment, it could be useful to consider it as argument to avoid > > introducing another new syscall in future. It could support *atomicity* > > for disruptive hint(e.g., MADV_DONTNEED|FREE). > > flag argument is reserved for future use if we need to extend the API. > > Providing an API that is incomplete will not fly. Really. As this really > begs for much more discussion and it would be good to move on with the > core idea of the pro active memory memory management from userspace > usecase. Could you split out the core change so that we can move on and > leave the external for a later discussion. I believe this would lead to > a smoother integration. No problem but I need to understand what you want a little bit more because I thought this patchset is already step by step so if we reach the agreement of part of them like [1-5/6], it could be merged first. Could you say how you want to split the patchset for forward progress? Thanks.