Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp669385ybi; Fri, 31 May 2019 07:15:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNU+X+mYrcphzo3FShTxC4ynwQBEnuNo5cmijY9nVFPIIwtVL4m4Eca3nE3wRF0imFLLpj X-Received: by 2002:a17:90a:4fa6:: with SMTP id q35mr10007672pjh.74.1559312128131; Fri, 31 May 2019 07:15:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559312128; cv=none; d=google.com; s=arc-20160816; b=FDP9hfqti+MitiFJ1TIq9iLc6D2aloyIb7lDlHMRGtW/Bp21BTfTE/Gih6G+B0t2Zy nH4AYbAsrwhVkp78ilkx+UiB20WmftH45+2p0pj+N9QyGUsNCgc5GW+g0yXcz/Jn0Ze/ EnShnxD4vJpjn2UVcOyoszBB6QXl162hgZNAVsPO8ESgl0pYLliFZWW9oCPomdEr5saw aiV0teDwm5fGRvS5OHnOey9+oMV5QjCe2pCpqc/g87SfP+nchByhCb9RLYb54TPyZcdu rLsvTcwLyVE+LdgwPH6JtWTfOjzpKSFUisGjwpejKXP7C982RfTqAbROuvZ4e7CvEpMO cCBw== 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=0xhb1pyImBa/JbJpYpXNh4R8mvOJIMPwfstX4vjxQNI=; b=IisxgNVHu8RDY0q03sF7hC9puxszhY3/vT6D0Nse0hpHNOS6L4mCsIuw9VnbJOkvUr GphY5YYPoo/grqUfC3u40izuTI81ApBoZNZp0lEWZW2yRG5ANgngP2gSICkrvhwimCNs Kryg2lInNeqpKE3zWpp4O3uryKV9VuCpDvRU6BlWT3eC3A2WSyvP2bGi2vUZ/lqtO/HI M+Hv0DsCcgN0xtoT3AS2OqenyWA+sD5g+tXErMChdHTPey+A/3VFIIF5TwNLaX5PS2U2 fl6p1wLdArLfTrJ8krS1mqZKcXL6ata6TaDSKvLtkj2qMl8vEEm2KxfoR2oBCSF1XjXW ppFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=QiARnrE8; 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 d34si6447678pgd.558.2019.05.31.07.15.07; Fri, 31 May 2019 07:15:28 -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=QiARnrE8; 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 S1726776AbfEaOLy (ORCPT + 99 others); Fri, 31 May 2019 10:11:54 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:46528 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726421AbfEaOLy (ORCPT ); Fri, 31 May 2019 10:11:54 -0400 Received: by mail-pl1-f193.google.com with SMTP id e5so2327859pls.13; Fri, 31 May 2019 07:11:53 -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=0xhb1pyImBa/JbJpYpXNh4R8mvOJIMPwfstX4vjxQNI=; b=QiARnrE80tnvvBre/mbPmuOKYNVVU8yYQMl/Ex2SrVLL+VfRNrYAD61HNOf0R3SPAb j44k0B09Ni2Ex/RblGlTkMnGKdwiyC9sqSZtLlKZX/BWZLzkFKSoJlgHv065+qA9jiTD 9MK2MRBipL+7zBbywzPB1bZaN4VP/WKmThTlnUztCsxMTnHjgQVhjJSkIaNaOYhBKK0c Q2A5ZFUiVoEzwLBqY2pO9Mgb4Bn8SAGzxoRx/cvzf9q58xcFW+bks2xKeh8iCk6BZL91 wDHdZ40z6OJh/aa9BdJXdimdyuf1zFwcCv82PyPaEiJmQYRq4vijRYwNx9iLgsCaQoeh JwYg== 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=0xhb1pyImBa/JbJpYpXNh4R8mvOJIMPwfstX4vjxQNI=; b=k+4sdMkGZlycRlEfSsWgjYI2y6cq6z9JS5DjN/pQ/59tivWnJ4KYdAcFtdbtxBHKbe KqEzPg20eesy/dfhK49a8PLIppmYUchh0XOne10dCutp2ZGdXnxs7zCUdCty5M780zrx b+vM0Bsj6iF6sFC4MUGvxSvg08o2Yxlsr7y7HqaK5rJvPZqcq0HwUXtKOKgdx0a/C10u bMvVcNNFKDXs1mb34DAm/4SRcFl/8tY5X0ijrYqb3dfSsxZme+Bt2sam3hP326ARKXma JXaeL9CL4Qz22F5bLSKcv08SIRi16AMFelENN+JIqCjwx7ejxfkk8Y+l8xiPdEmmTLqs YrbA== X-Gm-Message-State: APjAAAX5cp6jZot2klHlqwA+Apalo/uVf3bDuhgljWHG+vOUhix/XB1s /S/VQ/71/Fne7ABloi71nE0= X-Received: by 2002:a17:902:e311:: with SMTP id cg17mr9750155plb.202.1559311913113; Fri, 31 May 2019 07:11:53 -0700 (PDT) Received: from google.com ([122.38.223.241]) by smtp.gmail.com with ESMTPSA id m1sm5501839pjv.22.2019.05.31.07.11.45 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 31 May 2019 07:11:51 -0700 (PDT) Date: Fri, 31 May 2019 23:11:43 +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: <20190531141142.GA216592@google.com> References: <20190531064313.193437-1-minchan@kernel.org> <20190531064313.193437-6-minchan@kernel.org> <20190531083757.GH6896@dhcp22.suse.cz> <20190531131859.GB195463@google.com> <20190531140050.GS6896@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190531140050.GS6896@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 04:00:50PM +0200, Michal Hocko wrote: > On Fri 31-05-19 22:19:00, Minchan Kim wrote: > > 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? > > I would start with new madvise modes and once they are in a shape to be > merged then we can start the remote madvise API. I believe that even > local process reclaim modes are interesting and useful. I haven't heard > anybody objecting to them without having a remote API so far. Okay, let's focus on [1-3/6] at this moment. > -- > Michal Hocko > SUSE Labs