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,DKIMWL_WL_HIGH, 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 CD775C433E1 for ; Fri, 21 Aug 2020 19:31:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5F24420714 for ; Fri, 21 Aug 2020 19:31:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fiUhRTvN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F24420714 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CC6C38D0077; Fri, 21 Aug 2020 15:31:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C77AD8D0002; Fri, 21 Aug 2020 15:31:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B64498D0077; Fri, 21 Aug 2020 15:31:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0179.hostedemail.com [216.40.44.179]) by kanga.kvack.org (Postfix) with ESMTP id 9A8838D0002 for ; Fri, 21 Aug 2020 15:31:08 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 57403824556B for ; Fri, 21 Aug 2020 19:31:08 +0000 (UTC) X-FDA: 77175569016.07.prose90_31055312703b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id C210A180424D2 for ; Fri, 21 Aug 2020 19:31:07 +0000 (UTC) X-HE-Tag: prose90_31055312703b X-Filterd-Recvd-Size: 6057 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Fri, 21 Aug 2020 19:31:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598038265; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=MHf1EBkT1Dy1Sxom78LRrOH5QXXkCxI+ZwxWCHSIPnM=; b=fiUhRTvNFfs+4Nd6RTyd1PBQwwA7cKfgzQ1DiavOcOdyMTjUfbVqdkTPGg/rXJJ00YOejx ULwW1p3bmh+25DuoR9dg0v55X+CzH24jJzgyniE2f4x6usM0hmaQ8CAnwA+z4zo6y3DGYn MkpO7hFAAH2zzErIxHhk7C4SDTDnlrA= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-50-qrpAF37eMsSoweW7AcP9Xw-1; Fri, 21 Aug 2020 15:31:03 -0400 X-MC-Unique: qrpAF37eMsSoweW7AcP9Xw-1 Received: by mail-qk1-f198.google.com with SMTP id a130so2099364qkg.9 for ; Fri, 21 Aug 2020 12:31:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MHf1EBkT1Dy1Sxom78LRrOH5QXXkCxI+ZwxWCHSIPnM=; b=EC6NQt0f8AkxGM+fPmTnK1BtC3VxWuN7gHdznb2boHGcSZ7t7bKP2zLV7MHdzdVLZg HFtzFA4ePByvpzvBtrUhiQuOaAMG+pCMBn0duh4bj3QXHLlcRNkbnK3bB9vGa27xEsCR RolTdvnJCzHBosGtcUcNmGZkhXJJdnjckqkF6toVaN0/boaxoJrOV0Q+h9gL1D18TlSs imiHNElnzPXI1uylUM5NmsKBxWiYJ1soHKq2t4Ya/cmjDpjajIOI1zv7RnPoXmCdIz5S 0379uMSpPP9YidUEUXz6Pp4YrxBSYeLiG1n8uEGjmdpi4vakg6omRkpwSJnLlIlSrYeg sPwg== X-Gm-Message-State: AOAM531Uj0MDy009QxLnmfR2j3tMhaHanlUq+soHLNqTcRGykd3bzZ31 69h5qTk0HQX+9Jm/uxjBNzkYHrtH3ELERYHFNFPEfaEaFhtQ+DnVEKblzn2OblNxNvjbJyLDEDD Cq9JRyr/BDPU= X-Received: by 2002:a37:9a97:: with SMTP id c145mr4112685qke.385.1598038263096; Fri, 21 Aug 2020 12:31:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIDT+dfkV6MshPTrHOcz6MO3y6HAU3upZRyOOq+yPyHjO60OLZanIZiouXFJFyoqVR7pfbaw== X-Received: by 2002:a37:9a97:: with SMTP id c145mr4112646qke.385.1598038262741; Fri, 21 Aug 2020 12:31:02 -0700 (PDT) Received: from xz-x1 (bras-vprn-toroon474qw-lp130-11-70-53-122-15.dsl.bell.ca. [70.53.122.15]) by smtp.gmail.com with ESMTPSA id o21sm2487226qkk.94.2020.08.21.12.31.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 12:31:01 -0700 (PDT) Date: Fri, 21 Aug 2020 15:31:00 -0400 From: Peter Xu To: Linus Torvalds 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 Subject: Re: [PATCH v3] mm/gup: Allow real explicit breaking of COW Message-ID: <20200821193100.GA38249@xz-x1> References: <20200811214255.GE6353@xz-x1> <20200820215449.GB358043@xz-x1> <20200821101333.GA3432@quack2.suse.cz> <20200821154756.GC3432@quack2.suse.cz> <20200821180848.GA11376@xz-x1> MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspamd-Queue-Id: C210A180424D2 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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:23:31AM -0700, Linus Torvalds wrote: > 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. That's definitely tricky.. Though IMHO that's another KSM topic that we might want to look into later besides the current effort to fix up the COW breaking issue for gup. For now, it shouldn't be hard for us as long as we do cow always for KSM pages. However, do we really want to revert the whole logic of 52d1e606ee73? Asking because it still seems to be an improvement to me (after all we'll need to look after KSM pages here). So it seems still good to keep. Thanks, -- Peter Xu