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 73A56C433EF for ; Fri, 17 Dec 2021 20:44:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D14296B0073; Fri, 17 Dec 2021 15:44:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CC2696B0074; Fri, 17 Dec 2021 15:44:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B8A6A6B0075; Fri, 17 Dec 2021 15:44:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0108.hostedemail.com [216.40.44.108]) by kanga.kvack.org (Postfix) with ESMTP id A7C5C6B0073 for ; Fri, 17 Dec 2021 15:44:22 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 6E7F1181AC9CC for ; Fri, 17 Dec 2021 20:44:12 +0000 (UTC) X-FDA: 78928463544.08.F4F19D9 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) by imf25.hostedemail.com (Postfix) with ESMTP id 0699BA0024 for ; Fri, 17 Dec 2021 20:44:05 +0000 (UTC) Received: by mail-ed1-f43.google.com with SMTP id t5so12630887edd.0 for ; Fri, 17 Dec 2021 12:44:11 -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=JJnsIIpunEWMbh/Qgzu/ClbtA+crRRC9ykjwMsxp4Xg=; b=Q7KfwzCp7ey3Od1yatE7bs9sLO+eQCx8S/bb7oiRSzyMiKD0DWQ2xXPhmdnChne7nw 86EM0hENEKAQr1TC1SKiTfMK5A+B3tCj9YW0qlShYCfu1WuGRaW1hfigEOBc39FylfMA K1VH5SRGwn742s/Dv9UxpopSjgjurI0JlTzfA= 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=JJnsIIpunEWMbh/Qgzu/ClbtA+crRRC9ykjwMsxp4Xg=; b=jZZq77ZvyE6+NNPJ1f1cCnpl7srOw+ioD3oDDqXYad44K86SAeJqp6q3DCb/P1grTe u5mjJBqKEZPjnkGhjm0sHFjE55G8hKGvuHyB+AfSjQYU+qh5tELZDndrOgmqEA4xjfgw hK46O1PxpWsOBkwm5k9mvoeAeGR0PTWXae5QGj7f/ahcBzb+ToeJ0dsppNrtsHIlnCS5 TH72Hi0/uv6NBrHS9YvJAfRewNBkZzD5wHAb2gMg7Wku+lZfHH69rH6ianMIklD9/QVp b/yhdQytCRdHwnfXrEy50PZ3fUK0sBSrFJAkZGQoKlIOCUMKPN6JoFGyDE1btTBZyWO3 thnw== X-Gm-Message-State: AOAM531cExnNEdY9WcyxJT+69SQirLGB++SLQZwLbgxiDNZpw6DGgQnv eaOGLEn+on9vz0L5N73WzjPLScQYsQYW9TPuiTY= X-Google-Smtp-Source: ABdhPJzefmtj8DMUzTASh3yDjwBBBxGVayKyxDnXjvUox6aGMBJMJeM5rZf7iCrPf7gypbM0j08bEw== X-Received: by 2002:a17:906:e0d0:: with SMTP id gl16mr3917951ejb.628.1639773850157; Fri, 17 Dec 2021 12:44:10 -0800 (PST) Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com. [209.85.128.48]) by smtp.gmail.com with ESMTPSA id m16sm3995177edd.61.2021.12.17.12.44.09 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Dec 2021 12:44:09 -0800 (PST) Received: by mail-wm1-f48.google.com with SMTP id z206so2412286wmc.1 for ; Fri, 17 Dec 2021 12:44:09 -0800 (PST) X-Received: by 2002:a7b:cb17:: with SMTP id u23mr11177984wmj.155.1639773838912; Fri, 17 Dec 2021 12:43:58 -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> In-Reply-To: From: Linus Torvalds Date: Fri, 17 Dec 2021 12:43:42 -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: David Hildenbrand Cc: Linux Kernel Mailing List , Andrew Morton , Hugh Dickins , David Rientjes , Shakeel Butt , John Hubbard , Jason Gunthorpe , Mike Kravetz , Mike Rapoport , Yang Shi , "Kirill A . Shutemov" , Matthew Wilcox , Vlastimil Babka , Jann Horn , Michal Hocko , Nadav Amit , 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: imf25.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=Q7KfwzCp; spf=pass (imf25.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.208.43 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org; dmarc=none X-Rspamd-Queue-Id: 0699BA0024 X-Stat-Signature: 3bucytp89denswm1eoixgkrxbn3atqtb X-Rspamd-Server: rspam04 X-HE-Tag: 1639773845-478234 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 12:39 PM Linus Torvalds wrote: > > At the time of such a shared pin, you can do what we already do: > re-use the page if it has a refcount of 1. Or do an early COW event > (feel free to avoid the "mark it writable and dirty"). Note that this also depends on fork() doing the right thing, marking things for "a fork() can not share this page any more". Which it does for regular pages, and is exactly what that page_needs_cow_for_dma() logic is all about (and the special write_protect_seq around gup/fork). I do believe that huge-pages don't do it right. But I think that as you try to fix hugepages, you are now breaking the normal case. If all your logic was only about hugepages, I wouldn't care so much. But you are playing questionable games with code that I think is correct. Please explain why. Linus