Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1165661ybh; Wed, 11 Mar 2020 19:05:19 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtHGM0zzGtXGpDpIodjFF5B3yTL9FYXLSgtFsGtivqe2dFf58/0Ogjz0Ogi/8DY+is00E+M X-Received: by 2002:a9d:1a4:: with SMTP id e33mr4471340ote.343.1583978719732; Wed, 11 Mar 2020 19:05:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583978719; cv=none; d=google.com; s=arc-20160816; b=sHNVlIASbZI28jaY40TRlyBOg7XQdXLi7EjYm4iVqJUc7LU/73o4QXRA75oGgjMObV ObdcwNuWePIGIDMLhq3Hx7LRuAlP1NSMvPnYF7sGrKTb6tqcGnLUGg6u/OYoejekvJoX LauRUOIUKU2CIHb5+2fUGvyM20EL1Xcits58nStK0v4t3JG6l+E81bfCaTPKW/jCf7JJ GxiOGEDXcvHk+2e1sA/47eEkkzsgVY1RNla+rNHbJk0AmGCjE3Yfxu4fMD5lksZUV1FF vvhGtTpf1KzkiT8nWuMiuUqIpHqsQ3W+v2C6QGfnLsDo76BPXqCNKcOIxEiEv+ttYEwX TfsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=s3hzFOv+ufMUG9fZYGvNPf1Rj5SadPChsc427Pq4MuU=; b=WnpJNZ33TvyiVWIdSMajVCF/hLrU3bxeCrbLNMpcXkp3uEuPmBNxL2S/dCfS/zJZMP qPEOnyMaxTpDspoJ+HIN0uibWiaoEaEEpudKE1vH0BtEMSrhA+JHgc71H6JznFC3Odjv uUi7n8X+/GrshE4kxqwV4aHN9kK9LkM5/TcJDznZs16ixZhUrphz8RMa8iOS28Tb5ane Yy/Ka3338f0k3gL5qBETs/pZSeTYbofxhZhnwSHfRfgRDGvqhnL33MtlOYO6CqY21uKs rAiDyAuIZkOCSrm6PT/rNyhc6cEsf3/Hq5/ObrRaGk8RdCzbCxL2tuBMHGsiiOO1XM8/ zQog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=vpgM4oEg; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z13si1983784oic.70.2020.03.11.19.05.07; Wed, 11 Mar 2020 19:05:19 -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=pass header.i=@google.com header.s=20161025 header.b=vpgM4oEg; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387630AbgCLCEL (ORCPT + 99 others); Wed, 11 Mar 2020 22:04:11 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:35229 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387501AbgCLCEL (ORCPT ); Wed, 11 Mar 2020 22:04:11 -0400 Received: by mail-lf1-f66.google.com with SMTP id v8so2492961lfe.2 for ; Wed, 11 Mar 2020 19:04:08 -0700 (PDT) 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=s3hzFOv+ufMUG9fZYGvNPf1Rj5SadPChsc427Pq4MuU=; b=vpgM4oEg5vQg7zF+tYEv7Vyyu3scK/a95qbpaEP7UrD/aYmlQ6SeWqFvun0hZ3k67e OtBqqS+3D0XjK7YxmxKEvnYIlia/p2feYBe18wkmL347YysBay5yMKLF2zJyOsjObWG3 nYyq2KALh1S+6KACoAWixnLjFD8geRrFQ9cYz7SmG6RCJZ+iqI6xa6zvxpHBHgUsME0D vakqiL/MWiRRrmMN7HzSSkWbBv+e326Y5hpVdwc7nGjb/kOxy6a6qCVWlUQ7JZHCV5IO 3eYWuWuLreDi+8F7hqmTuKnuQdGVfl+AlUIjqrrF4uhddIsSNDIokXjuJU3d3A+RNeXo xbEw== 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=s3hzFOv+ufMUG9fZYGvNPf1Rj5SadPChsc427Pq4MuU=; b=s9GfnvOwZkblgBZdc8nmw/p900j8T7QaJR4U2gago12lEKVvRL6muJI9iv+XQCilaz rLlSJEJDf3ugI5zRHnn/RNG9uLwD6+BZ9DYnrhsAbEl/HO8lH9cRyLcCa+1NuTKbkjvL 8GuaqtgsjfgV1VAVAATxZpxIoUMxssh0zbzmvRMmeuaAwwNv5j12Ax4at/11F9MsCiGL dzl6OoFl3lWMaUKbodbcLiH2zXnaEER9VmUV/PW/ZI12V+lqQ/98Uot05BRny54gi2th n5dRGMRAqgTtz2Cinj7Mdy3ZqyOicRATfWJo9XvFcGuv6E4O5+Ft1ETzsjjfqZyhogym Blmw== X-Gm-Message-State: ANhLgQ0iLpiJIzmUeaUH/b2WOZ/+xQ+4pDaxk7Yq/0Sm7xS6RbDUUSkm 8eGJ2ovOgbMfGuxyeg2Y+EVPqsmTQ7RYahnVe2ki1A== X-Received: by 2002:ac2:4c14:: with SMTP id t20mr3677256lfq.193.1583978646217; Wed, 11 Mar 2020 19:04:06 -0700 (PDT) MIME-Version: 1.0 References: <20200310184814.GA8447@dhcp22.suse.cz> <20200310210906.GD8447@dhcp22.suse.cz> <20200311084513.GD23944@dhcp22.suse.cz> <20200312001849.GA96953@google.com> In-Reply-To: <20200312001849.GA96953@google.com> From: Daniel Colascione Date: Wed, 11 Mar 2020 19:03:29 -0700 Message-ID: Subject: Re: interaction of MADV_PAGEOUT with CoW anonymous mappings? To: Minchan Kim Cc: Shakeel Butt , Michal Hocko , Dave Hansen , Jann Horn , Linux-MM , kernel list , "Joel Fernandes (Google)" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 11, 2020 at 5:18 PM Minchan Kim wrote: > > On Wed, Mar 11, 2020 at 04:53:17PM -0700, Shakeel Butt wrote: > > On Wed, Mar 11, 2020 at 1:45 AM Michal Hocko wrote: > > > > > > On Tue 10-03-20 15:48:31, Dave Hansen wrote: > > > > Maybe instead of just punting on MADV_PAGEOUT for map_count>1 we should > > > > only let it affect the *local* process. We could still put the page in > > > > the swap cache, we just wouldn't go do the rmap walk. > > > > > > Is it really worth medling with the reclaim code and special case > > > MADV_PAGEOUT there? I mean it is quite reasonable to have an initial > > > implementation that doesn't really touch shared pages because that can > > > lead to all sorts of hard to debug and unexpected problems. So I would > > > much rather go with a simple patch to check map count first and see > > > whether somebody actually cares about those shared pages and go from > > > there. > > > > > > Minchan, do you want to take my diff and turn it into the proper patch > > > or should I do it. > > > > > > > What about the remote_madvise(MADV_PAGEOUT)? Will your patch disable > > the pageout from that code path as well for pages with mapcount > 1? > > Maybe, not because process_madvise syscall needs more previliedge(ie, > PTRACE_MODE_ATTACH_FSCREDS) so I guess it would be more secure. > So in that case, I want to rely on the LRU chance for shared pages. I don't want the behavior of an madvise command to change depending on *how* the command is invoked. MADV_PAGEOUT should do the same thing regardless. If you want to allow purging of shared pages as well, please add a new MADV_PAGEOUT_ALL or something and require a privilege to use it. > With that, the manager process could give a hint to several processes > and finally makes them paging out. On many different occasions over the past few years, I've found myself wanting to ask the kernel to do bulk memory management operations. I'd much rather add *one* facility to allow for multiple-target mm operations than add one-off special cases for specific callers cases as they come up. If we had such a bulk operation, the kernel could inspect the bulk operation payload, see whether the number of MADV_PAGEOUT requests for a given page were equal to the share count for that page, and, if so, evict that page despite it being shared.