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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36990C433EF for ; Fri, 17 Dec 2021 20:52:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237258AbhLQUwH (ORCPT ); Fri, 17 Dec 2021 15:52:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234597AbhLQUwG (ORCPT ); Fri, 17 Dec 2021 15:52:06 -0500 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED356C061574 for ; Fri, 17 Dec 2021 12:52:05 -0800 (PST) Received: by mail-ed1-x531.google.com with SMTP id o20so12413187eds.10 for ; Fri, 17 Dec 2021 12:52:05 -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=uaV95DFC7PNHVxvXFfSs7ijCY2LfKFES0+jxxVbmhEfzucm3CbK9uDYOC1P19q9tIL ivQo0ljR/kiRU1ALl8wFxT379GeooHxk182CNU3qt319dAlwNhO8cGUv5cNan/0RwYpv 9iwD7D+DtmjdCnqOen8t2xs/KIbhngGAwPqQxjJ7qPPpBjFA1sHMwrZCy0QfJVS2n4e6 iXJMeuNHlYz6Hz140hNPJmhT9anUAjj31xQFKqBwhSD8floKlwQSGMwewziAVJ38tY2k t9wQ4ItOct98UEjDuHLO69Z+QpLSmwbwtr+CPQDI+l7+Wfp/tdJQYP6TB/pyF7qrLTjy of3w== X-Gm-Message-State: AOAM531hs6PDXtwo65q3Si19ESNbLiXEuamAF94Kzahet1GW2h3ArnsI 5Za9ucTandZlL17WfxsvdPU8dD94M5q9rrlKAlQ= X-Google-Smtp-Source: ABdhPJxgM+uNnKX3xw0wwafHeTD2fvpnJCffvA8UCGZSz+5oWoDrgrnK+/s2juSCBlrWZMwS9+oVTw== X-Received: by 2002:aa7:cd12:: with SMTP id b18mr4398751edw.355.1639774324227; Fri, 17 Dec 2021 12:52:04 -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 he14sm3000993ejc.55.2021.12.17.12.52.04 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Dec 2021 12:52:04 -0800 (PST) Received: by mail-wm1-f54.google.com with SMTP id p27-20020a05600c1d9b00b0033bf8532855so2269729wms.3 for ; Fri, 17 Dec 2021 12:52:04 -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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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