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 BC1ABC433DF for ; Fri, 21 Aug 2020 18:23:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7D84220720 for ; Fri, 21 Aug 2020 18:23:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="MbyUwYZQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D84220720 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 257438D0070; Fri, 21 Aug 2020 14:23:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 206DF8D0002; Fri, 21 Aug 2020 14:23:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F6388D0070; Fri, 21 Aug 2020 14:23:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0059.hostedemail.com [216.40.44.59]) by kanga.kvack.org (Postfix) with ESMTP id EAC4C8D0002 for ; Fri, 21 Aug 2020 14:23:52 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id AC62D824556B for ; Fri, 21 Aug 2020 18:23:52 +0000 (UTC) X-FDA: 77175399504.11.team51_5011e652703b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 7D4A4180F9855 for ; Fri, 21 Aug 2020 18:23:52 +0000 (UTC) X-HE-Tag: team51_5011e652703b X-Filterd-Recvd-Size: 5165 Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Fri, 21 Aug 2020 18:23:51 +0000 (UTC) Received: by mail-lf1-f66.google.com with SMTP id i19so1367784lfj.8 for ; Fri, 21 Aug 2020 11:23:51 -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=vVM0nc5//lK1v8wxZ87XZqkf3LFcyTaix5QpBjQniwc=; b=MbyUwYZQh6bG3SmDnG7jthrAn7nv2nYdSg47RogmQ2pe5tOsy937deWQCL4eR1nwVQ mAVZLGkYereQlthbnwcftr/bl76j4K8MvSUrrPBfJRjTl+GOZM6lqmXlREHoDsF6aN+z 4bGtHdAQ3oyu3EN2Nb8pGKFZOCaDXpXo0a7Gg= 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=vVM0nc5//lK1v8wxZ87XZqkf3LFcyTaix5QpBjQniwc=; b=RiYnoaS9J134Fq/LwU0D5GGADbrjDzTyjs52jKhaTtX4IIMDlih8IUXRs/3O88eYvt jIPngp4t+THG6Uho5K7VDsTAF0xleYbpo9+a6zcfAhUVaYLoYQb1nr357C0uOj6ubOCY xRSd/Azca4QIiWb1L0wcleIlQzw3QmQ+2sWm12082E8W5I1v9ZN3CX91tbznFiNPeon8 Sj5sCrX8iSqDdiN027+MKJq+OFwF6HmRcdNrPtUNRXWmZX3kh7P6UK4lZp/pvQ+GCTpw XBLN7NycBn5qeM50dnP4G01feLB3VqKgfFs15C2RHvsm4ZPduAPF8gg0UGN8QE1SGygB 5q0Q== X-Gm-Message-State: AOAM531PechgN1sEVF7H5Zhr3lEpgfRAoAaU7MFytdLK0jHnEJDuWbvg Z/E1+QEs81R8v3n/vBs4E+3azJXHQcF81g== X-Google-Smtp-Source: ABdhPJy2UOBF544wYWDnl7DuUHQqtN/dz1OguQaiuPOFouaPsDLrJN7l3Wr5QGEhxtjvNX6bmh2bxA== X-Received: by 2002:a19:e07:: with SMTP id 7mr814238lfo.6.1598034229200; Fri, 21 Aug 2020 11:23:49 -0700 (PDT) Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com. [209.85.208.176]) by smtp.gmail.com with ESMTPSA id a23sm521432ljp.121.2020.08.21.11.23.47 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Aug 2020 11:23:48 -0700 (PDT) Received: by mail-lj1-f176.google.com with SMTP id y2so2896908ljc.1 for ; Fri, 21 Aug 2020 11:23:47 -0700 (PDT) X-Received: by 2002:a2e:92d0:: with SMTP id k16mr1956690ljh.70.1598034227550; Fri, 21 Aug 2020 11:23:47 -0700 (PDT) MIME-Version: 1.0 References: <20200811214255.GE6353@xz-x1> <20200820215449.GB358043@xz-x1> <20200821101333.GA3432@quack2.suse.cz> <20200821154756.GC3432@quack2.suse.cz> <20200821180848.GA11376@xz-x1> In-Reply-To: <20200821180848.GA11376@xz-x1> From: Linus Torvalds Date: Fri, 21 Aug 2020 11:23:31 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3] mm/gup: Allow real explicit breaking of COW To: Peter Xu Cc: Jan Kara , 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: 7D4A4180F9855 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 11:08 AM Peter Xu wrote: > > IIUC, Jan wanted to point out the fact that KSM didn't increase page count for > stable pages (reasons are above get_ksm_page()). Ouch. > Do we still at least need to check the swap count if PageSwapCache(page)? No. Because a PageSwapCache() page should be a perfectly normal page cache thing. It will increment the page count if it's active. That PageKsm() thing that *doesn't* increment the page could does look worrisome, but > So we check page_count() (which covers KSM or normal pages) after we've got the > page lock, while we keep all the rest. Why would we keep the rest? I The actual thing I would really want to get rid of is the page lock, in fact. We shouldn't need it in this path, and it's the most expensive part of it all. But that's also why I did the page count test optimistically unlocked - because if page_count is 1, then we really shouldn't contend with anything else, so hopefully the (currently quite expensive) page locking is actually a non-issue once you get there. But the PageKsm() page_count() issue I didn't even realize. That worries me. Linus