Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3041913ybi; Mon, 10 Jun 2019 03:21:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqyVF4LmFXt3vflXHmb7WXt1+1+mLG5fr16ritKvBPIMn791Et/jUnYZuNHoFOImpdh9bzci X-Received: by 2002:a62:65c7:: with SMTP id z190mr73992380pfb.73.1560162064749; Mon, 10 Jun 2019 03:21:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560162064; cv=none; d=google.com; s=arc-20160816; b=Kaxc8DNQXoO3OGb5uQauZB7BEWf3LWIMXFw+GZsKM0fhGfvcffQn2ZKwXO0pQOyZG1 ufcYUIz8+VZBiKR9uzpa+3xhaGotFHyHKqTKFlFk9u3TJw4h41qOsGodthYnDDEQhhjZ CPe4m/LB6s+ZRC+R+xNdrMigOyUGxmSCxyvQ0Pvx5z9vMp+y7pdvV0nGL0QvLp1bXrVy U6Oi02I/aT1W4U5JaXQNPYPQk97fy6wCk1qKq2bOqo9qQnB3efDeoj/zgrzH7VFG4FaU PpP4G36hto9G8VmOLHcvsQnfBdVqqtCYJzZKgtKuD5pEWmVxNEyNB8xYYbU08k2t4RNa bA/w== 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=UpQZyxDAIZssxN7CCNuXeFikhiebMI4lHnTfzcrIiyQ=; b=stNKvONIlf46mbSJOgnKNcC5N17/1uxeYVcURLuopfL35ZGGRkU+wnsRn2ClrBIcQp 9oXSycLo7S9uDfOmU5n12pVW1GIAoNtgFhU3m4PfX+/TFSNxwATDSyBsOeQnpD9rYGgc 4rRru0P/ZfMaXh+Ru7ndUGUYO+7ezon4WwvPw+LRb1g9kHXQKRk0t91MzhWMwqA1AhjF F8k8V6v0T58C+YRYqGXKVjD0Sn5iXKTcakaFZjLdq6EZeDNzRrjyxJ/RicC8SC8EpXab N7G/eCc83+3RorK2GFLSYvCpqmkPZgEbU3nEWy9yQOusmeQWc3jEZBopIBhL/Hzmn8nV hwSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=oT3Tgck9; 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 p93si3683592pjp.66.2019.06.10.03.20.47; Mon, 10 Jun 2019 03:21:04 -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=oT3Tgck9; 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 S2388952AbfFJKM5 (ORCPT + 99 others); Mon, 10 Jun 2019 06:12:57 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:36205 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388489AbfFJKM5 (ORCPT ); Mon, 10 Jun 2019 06:12:57 -0400 Received: by mail-pg1-f196.google.com with SMTP id a3so4794530pgb.3; Mon, 10 Jun 2019 03:12:56 -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=UpQZyxDAIZssxN7CCNuXeFikhiebMI4lHnTfzcrIiyQ=; b=oT3Tgck9UOkWtTtrfEsTEc4PpMFYNC/1A+9ozR6V61Qzvmi8PU2PjmGz4nMCuGml3v H+nRmhJEBftdYa/jqjOOUDmFd3EIVk3K904sggw8sHSKT+izqm8D6xXryQtEqRIQwnYd kU6ue4gFnzw7c/7zfEq/nYUufkOUwE5mNFwKPN0SwyZ0Bbo4EwOKD09zGiKkw9lzRU0r 8oiPkxnTLIkCVg18tdGUfuEWKg8MvK4yGM9BSlB9tZo15gQMiOojbos6lEuAFQ2aqnVh 0TER9J8ovskikTwRLLABwQfJ8LIMQIbDXfzkiMaWGpOOhtsIYly64d/JTpyUpvwp9twe /YWQ== 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=UpQZyxDAIZssxN7CCNuXeFikhiebMI4lHnTfzcrIiyQ=; b=BB4nb2lS3T8WBIyotovYNh6IQSZSyekD63yC/MsYPovDEM/DsgAmlsn6KX0nRyJmEc rXFe8S8orQxNLzqTH5X5RHTfTHslTna6yREnJb6/vk2hZb7Ad3WC6JSCF+U4+Amtlcna MI+rYqbamCqMNAAqcuUTXpuuBX0l3JO57Yo24ikl/LuGFBTxVZi7MaaxmVou32B9egzj Fe+eT1XY7FDbypS86lv/N0bWrvvB42wZ7VaauZlDSe8SdOn9HuXcwfY791GN6E1lbC3f 3FNaigwglhJk1faJ6SayrmxG2MoSrL7J28u2VFzsEAgPmiD7QWxLrSVGJgISxVxyAmqO NCPQ== X-Gm-Message-State: APjAAAWYN+Ri+MNlz7V/qttOt5/9Q3uXbLvQcvibwP26CD/pBICKiGlx hM3I3ICf4qBj2ModOzEWiKs= X-Received: by 2002:a17:90a:3787:: with SMTP id v7mr10962360pjb.33.1560161576370; Mon, 10 Jun 2019 03:12:56 -0700 (PDT) Received: from google.com ([2401:fa00:d:0:98f1:8b3d:1f37:3e8]) by smtp.gmail.com with ESMTPSA id l38sm9533673pje.12.2019.06.10.03.12.50 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 10 Jun 2019 03:12:54 -0700 (PDT) Date: Mon, 10 Jun 2019 19:12:48 +0900 From: Minchan Kim To: Oleksandr Natalenko Cc: Andrew Morton , linux-mm , LKML , linux-api@vger.kernel.org, Michal Hocko , 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, hdanton@sina.com Subject: Re: [RFCv2 4/6] mm: factor out madvise's core functionality Message-ID: <20190610101248.GD55602@google.com> References: <20190531064313.193437-1-minchan@kernel.org> <20190531064313.193437-5-minchan@kernel.org> <20190531070420.m7sxybbzzayig44o@butterfly.localdomain> <20190531131226.GA195463@google.com> <20190531143545.jwmgzaigd4rbw2wy@butterfly.localdomain> <20190531232959.GC248371@google.com> <20190605132728.mihzzw7galqjf5uz@butterfly.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190605132728.mihzzw7galqjf5uz@butterfly.localdomain> 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 Hi Oleksandr, On Wed, Jun 05, 2019 at 03:27:28PM +0200, Oleksandr Natalenko wrote: < snip > > > > > > > write = madvise_need_mmap_write(behavior); > > > > > > if (write) { > > > > > > - if (down_write_killable(¤t->mm->mmap_sem)) > > > > > > + if (down_write_killable(&mm->mmap_sem)) > > > > > > return -EINTR; > > > > > > > > > > Do you still need that trick with mmget_still_valid() here? > > > > > Something like: > > > > > > > > Since MADV_COLD|PAGEOUT doesn't change address space layout or > > > > vma->vm_flags, technically, we don't need it if I understand > > > > correctly. Right? > > > > > > I'd expect so, yes. But. > > > > > > Since we want this interface to be universal and to be able to cover > > > various needs, and since my initial intention with working in this > > > direction involved KSM, I'd ask you to enable KSM hints too, and once > > > (and if) that happens, the work there is done under write lock, and > > > you'll need this trick to be applied. > > > > > > Of course, I can do that myself later in a subsequent patch series once > > > (and, again, if) your series is merged, but, maybe, we can cover this > > > already especially given the fact that KSM hinting is a relatively easy > > > task in this pile. I did some preliminary tests with it, and so far no > > > dragons have started to roar. > > > > Then, do you mind sending a patch based upon this series to expose > > MADV_MERGEABLE to process_madvise? It will have the right description > > why you want to have such feature which I couldn't provide since I don't > > have enough material to write the motivation. And the patch also could > > include the logic to prevent coredump race, which is more proper since > > finally we need to hold mmap_sem write-side lock, finally. > > I will pick it up and will rebase since then. > > Sure, I can. Would you really like to have it being based on this exact > revision, or I should wait till you deal with MADV_COLD & Co and re-iterate > this part again? I'm okay you to send your patch against this revision. I'm happy to include it when I start a new thread for process_madvise discussion after resolving MADV_COLD|PAGEOUT. Thanks.