Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp307226ybi; Fri, 31 May 2019 01:39:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqyIXDym06XSDONEOsHmDeiWz4bxgoXynCbxoiE0Ywp4HbiPge+4CdRnqcbA/thFv+cMR+qY X-Received: by 2002:a17:90a:af8a:: with SMTP id w10mr8018234pjq.132.1559291999670; Fri, 31 May 2019 01:39:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559291999; cv=none; d=google.com; s=arc-20160816; b=y+XtbqUO10tGXkPeahY4RIyf7Dh22K3ZbOK1kDrPyZ3qGVVpqhQc83x/bNZlI7nrFl kmB/Fp2ibP05BNGSqZ702SK/R2tj/ZMOBbJGRAwOlwQo3AWRZPtLhqDve5Q0TBYSRXk+ cfhYef8PUBo9/08U4I4/JIirDZtA09+WqaTrpdoN71aZ6tanS4UBXx2N6iGftccA6dnZ 1taeupc2WBHETmRdvqV3hjmUGX4Ij1L6Hemv2MIXjUcrSQPKN1Vb7N00fHClr1OfCjMf ZWw8JMmbph0z6g72BURFHThheOkV00S0b9R23SlMXjA80siD29gmfF/FoT85IiWp6lpe c05g== 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; bh=WV/Bt78Zvh3IqdfHz4dmUPlTd+8NY/6tHhR2h8zWlYk=; b=tnZiasS0iNAV1VXxO41xXxOfKOv8NM76W/NQyX09P6ToSAJmLtnXG2Anb+KKVP1dR0 5kRYQUOC6aooXtUu+eG7OrXZpOS/bPhQvz2itxTr/i+KzISPZJbzpAR2dFqodqwdBbQu c0ACGFmA0stJRrnGm01yxEuibF+a0U8vY5RohqGvque38922SX9FULJ+v5j0glYXfdxW n6rqm8jkrpu1YCsPGFqD1GDfOogo8Bp38Xif1sy7q2VUMWzGRUvsoxb+GnzADwNxRGTM 3BG+amYoA2QZOY5ldkAyPWKaLo8I2keCd39UnR1yocB7itCCHNJl3EvthfXj9KvmOPdf CTNg== ARC-Authentication-Results: i=1; mx.google.com; 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 t3si1710622pjv.1.2019.05.31.01.39.42; Fri, 31 May 2019 01:39:59 -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; 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 S1727008AbfEaIiA (ORCPT + 99 others); Fri, 31 May 2019 04:38:00 -0400 Received: from mx2.suse.de ([195.135.220.15]:53698 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726002AbfEaIiA (ORCPT ); Fri, 31 May 2019 04:38:00 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id AD507AC2E; Fri, 31 May 2019 08:37:58 +0000 (UTC) Date: Fri, 31 May 2019 10:37:57 +0200 From: Michal Hocko To: Minchan Kim 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: <20190531083757.GH6896@dhcp22.suse.cz> References: <20190531064313.193437-1-minchan@kernel.org> <20190531064313.193437-6-minchan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190531064313.193437-6-minchan@kernel.org> 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 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. -- Michal Hocko SUSE Labs