From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39E57C433E1 for ; Fri, 21 Aug 2020 17:01:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E85CD20656 for ; Fri, 21 Aug 2020 17:01:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="LMGya38u" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E85CD20656 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 61EFE8D0006; Fri, 21 Aug 2020 13:01:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D0E58D0002; Fri, 21 Aug 2020 13:01:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C0B58D0006; Fri, 21 Aug 2020 13:01:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0236.hostedemail.com [216.40.44.236]) by kanga.kvack.org (Postfix) with ESMTP id 35C808D0002 for ; Fri, 21 Aug 2020 13:01:22 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id DB4A0181AEF0B for ; Fri, 21 Aug 2020 17:01:21 +0000 (UTC) X-FDA: 77175191562.02.plate42_52100072703a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id 590B910097AB3 for ; Fri, 21 Aug 2020 17:01:20 +0000 (UTC) X-HE-Tag: plate42_52100072703a X-Filterd-Recvd-Size: 5521 Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Fri, 21 Aug 2020 17:01:19 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id i10so2623098ljn.2 for ; Fri, 21 Aug 2020 10:01:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tXLHMGIPdVkIhXLps0eqzqu9gb1jBU6At3Q0gRIPsOk=; b=LMGya38u0UebERx+VyXuhbTqigAW+BkbMraZO7VYNU3FF0kycK7jAzZp4BxMZz5Uz2 thnDr1lHDGLOodacgbMVJmrAnyS0ZHbXx2B3OOxYizKhXGCKPsMWq8drS/k40VRShgCI aS6oIf4a8yskW0YdgV0wOIiwSXwNHHS4WcRNE= 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=tXLHMGIPdVkIhXLps0eqzqu9gb1jBU6At3Q0gRIPsOk=; b=Zn/Aaa61vL2CfU2QMgipl7wqTc83+bsazxWKgU0ron31beF7KqAd9K5ey/V/MuwShQ 67hM4EFma24HjOc7VjMYqHJZtwZezqWvYF80fjNZyFPk6v6vEYy6x/7LXbF3KxYrmBRW +Gd/EA1c0niFX/UUg2cmqsYJuwc4IUfilg/vkkjG443jVc0Ws9WRK90qKsP1QV5XjdeG IrmbsXd1dHl7tVXecg18u3mCbtjFXMIc4D/AjUFCxIfTit8cIzJpfy0wt9syaUa84ygx tgG4f8fd+LYAZKx4GbLj4fdcGV5Rc1tNTbjai8e8bmZw0ArgY9JGpG18C128URFJTkfE LYcQ== X-Gm-Message-State: AOAM5324+kbJYxKA7WVgZmqxdmpI4MV6XGRNRw1XeBoBIjzsDL7IyXFE P8N+0R9tD04GcAXhGbwsG3iSOVUAl3C90g== X-Google-Smtp-Source: ABdhPJxmumGGOJwggptD4JXtsW7tIDSpLBLwT1KjlWZLlklOzY2inHL1KeFT9/094g+AD3E13/ynUg== X-Received: by 2002:a2e:8e70:: with SMTP id t16mr2050314ljk.81.1598029277626; Fri, 21 Aug 2020 10:01:17 -0700 (PDT) Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com. [209.85.208.179]) by smtp.gmail.com with ESMTPSA id r19sm487015ljc.59.2020.08.21.10.01.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Aug 2020 10:01:16 -0700 (PDT) Received: by mail-lj1-f179.google.com with SMTP id v9so2610922ljk.6 for ; Fri, 21 Aug 2020 10:01:15 -0700 (PDT) X-Received: by 2002:a2e:92d0:: with SMTP id k16mr1825308ljh.70.1598029275225; Fri, 21 Aug 2020 10:01:15 -0700 (PDT) MIME-Version: 1.0 References: <20200811183950.10603-1-peterx@redhat.com> <20200811214255.GE6353@xz-x1> <20200820215449.GB358043@xz-x1> <20200821101333.GA3432@quack2.suse.cz> <20200821154756.GC3432@quack2.suse.cz> In-Reply-To: <20200821154756.GC3432@quack2.suse.cz> From: Linus Torvalds Date: Fri, 21 Aug 2020 10:00:59 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3] mm/gup: Allow real explicit breaking of COW To: Jan Kara Cc: Peter Xu , Andrea Arcangeli , Linux-MM , Linux Kernel Mailing List , Andrew Morton , Marty Mcfadden , "Maya B . Gokhale" , Jann Horn , Christoph Hellwig , Oleg Nesterov , Kirill Shutemov Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 590B910097AB3 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Aug 21, 2020 at 8:48 AM Jan Kara wrote: > > I was more concerned about the case where you decide to writeably map (i.e. > wp_page_reuse() path) a PageKsm() page. Yeah, so I think what I do is stricter than what we used to do - any KSM page will never be re-used, simply because the KSM part will have incremented the page count. So as far as I can tell, with that patch we will never ever share except for the "I really am the _only_ user of the page, there are no KSM or swap cache pages" case. That's the whole point of the patch. Get rid of all the games. If there is *any* possible other use - be it KSM or swap cache or *anything*, we don't try to re-use it. > And also here I was more concerned that page_mapcount != 1 || page_count != > 1 check could be actually a weaker check than what reuse_swap_page() does. If that is the case, then yes, that would be a problem. But really, if page_count() == 1, then we're the only possible thing that holds that page. Nothing else can have a reference to it - by definition. And if page_count() != 1, we will not share. Ever. We'll just do what zap_paghe_range() does - unmap the old page and do the page_remove_rmap(). The only small worry would be the race between releasing the page table lock - when we allocate a new page - and somebody coming in and doing something magical to that page. But that's where holding the page lock comes in. Plus that part isn't anything my patch changes. Linus