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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C652C433F5 for ; Sat, 18 Dec 2021 03:37:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA4276B0072; Fri, 17 Dec 2021 22:37:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C53806B0073; Fri, 17 Dec 2021 22:37:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF3966B0074; Fri, 17 Dec 2021 22:37:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0119.hostedemail.com [216.40.44.119]) by kanga.kvack.org (Postfix) with ESMTP id A15686B0072 for ; Fri, 17 Dec 2021 22:37:26 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 69FEE8BEEF for ; Sat, 18 Dec 2021 03:37:16 +0000 (UTC) X-FDA: 78929504472.28.ADDDCEA Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) by imf08.hostedemail.com (Postfix) with ESMTP id 33B83160039 for ; Sat, 18 Dec 2021 03:37:11 +0000 (UTC) Received: by mail-ed1-f46.google.com with SMTP id y12so14919912eda.12 for ; Fri, 17 Dec 2021 19:37:15 -0800 (PST) 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=83Xcfaye/oCagrVxR06HPkUeHOAm9jlfZc3XXOxBSxE=; b=UdhXhGrxIVVjBAhE1tG5QDFxd3MjLEl7IW9JiZFv7x4Sm08/pVCTGJCS5oxsGwTVhs J+q/QYg7ZosglyichPV1OkhqfIehNaxoT9AxjmfFlWg7zRETdmafmJ2RG4JR7WmHxLRm 3SWT3EfiBhyiEtHJlFUtafpYS3HvFcUAb6VXY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=83Xcfaye/oCagrVxR06HPkUeHOAm9jlfZc3XXOxBSxE=; b=s6cdcX+G4TDrcQGRWd4VcbL0RKgQtc4sh4/5TddZdxnJUM2MRNwsOmcnrD/1uWskbC y6TH8G+qN+bNiDtildPVzZtLYLXPxxZIwiuYmMF2WUtiPgwG5SCI9/6qomX0+21k+y3T C/dNGuZiJfSrHcCK5wjkjuFIrLQyQ4HrDCpZ24zqPOhhzEQ5lB3D5aUiPYwsyfxr+1Kn l17iS6PfhEBHhP44c1JXimcl+Vc7GYd/f4KwFmciBLTyVp9nQJxn2Vq9Q+pNmPo8kHOd oGp61kN3P+L86EaH0vaingD9ZOMzvBq5vuaNe5kFglLCoqgXRFUoMsGxLc0L/CyxqMeG xIjA== X-Gm-Message-State: AOAM533iO5QXmxd9svW1RVxgJg+yxDw26yzpFnMnxi76yK5CkMOyEONf eOtbXf/Qqdxev4hstmjHUlTV3fz5jh9CWRvMcoo= X-Google-Smtp-Source: ABdhPJwT+H5a+pA4b/zTn+/epk9QJlNFZPASpsrwzegDhEaTMa/A0C8hAzpPsbrm3NCx69MRmJBACQ== X-Received: by 2002:a17:906:69c5:: with SMTP id g5mr4775894ejs.41.1639798634567; Fri, 17 Dec 2021 19:37:14 -0800 (PST) Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com. [209.85.128.54]) by smtp.gmail.com with ESMTPSA id y15sm4462256eda.13.2021.12.17.19.37.14 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Dec 2021 19:37:14 -0800 (PST) Received: by mail-wm1-f54.google.com with SMTP id d198-20020a1c1dcf000000b0034569cdd2a2so2689475wmd.5 for ; Fri, 17 Dec 2021 19:37:14 -0800 (PST) X-Received: by 2002:a05:600c:1914:: with SMTP id j20mr12004454wmq.26.1639798623645; Fri, 17 Dec 2021 19:37:03 -0800 (PST) MIME-Version: 1.0 References: <20211217113049.23850-1-david@redhat.com> <20211217113049.23850-7-david@redhat.com> <54c492d7-ddcd-dcd0-7209-efb2847adf7c@redhat.com> <20211217204705.GF6385@nvidia.com> <2E28C79D-F79C-45BE-A16C-43678AD165E9@vmware.com> In-Reply-To: From: Linus Torvalds Date: Fri, 17 Dec 2021 19:36:47 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1 06/11] mm: support GUP-triggered unsharing via FAULT_FLAG_UNSHARE (!hugetlb) To: Nadav Amit Cc: Jason Gunthorpe , David Hildenbrand , Linux Kernel Mailing List , Andrew Morton , Hugh Dickins , David Rientjes , Shakeel Butt , John Hubbard , Mike Kravetz , Mike Rapoport , Yang Shi , "Kirill A . Shutemov" , Matthew Wilcox , Vlastimil Babka , Jann Horn , Michal Hocko , Rik van Riel , Roman Gushchin , Andrea Arcangeli , Peter Xu , Donald Dutile , Christoph Hellwig , Oleg Nesterov , Jan Kara , Linux-MM , "open list:KERNEL SELFTEST FRAMEWORK" , "open list:DOCUMENTATION" Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=UdhXhGrx; spf=pass (imf08.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.208.46 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org; dmarc=none X-Rspamd-Queue-Id: 33B83160039 X-Stat-Signature: 5m3pfids7e3nx94djoir5imwehx3s878 X-Rspamd-Server: rspam04 X-HE-Tag: 1639798631-330977 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, Dec 17, 2021 at 6:42 PM Linus Torvalds wrote: > > IOW, I think that this stupid (AND UNTESTED) patch should likely just > fix David's test-case with the hugepage and splice thing.. Looking at that patch, the page lock is entirely pointless. It existed because of that broken reuse_swap_page() that tried to count page mappings etc, but once you get rid of that - like we got rid of it for the regular pages - it's not even needed. So as we hold the page table lock, and see a page_count() of 1, we could be done without any page lock at all. So that whole trylock/unlock is actually unnecessary. That said, it's possibly woth re-using any swap cache pages at this point, and that would want the page lock. So some complexity in this area is likely worth it. Similar to how we did it in commit f4c4a3f48480 ("mm: free idle swap cache page after COW") for regular pages. So that patch is not great, but I think it works as a guiding one. And notice how *simple* it is. It doesn't require careful counting of swap entries that depend on page locking. Linus