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 2EE30C433EF for ; Thu, 2 Dec 2021 22:34:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 52A4F6B0072; Thu, 2 Dec 2021 17:34:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DA916B0074; Thu, 2 Dec 2021 17:34:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 37A596B0075; Thu, 2 Dec 2021 17:34:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0063.hostedemail.com [216.40.44.63]) by kanga.kvack.org (Postfix) with ESMTP id 259E86B0072 for ; Thu, 2 Dec 2021 17:34:08 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id DC8548BECA for ; Thu, 2 Dec 2021 22:33:57 +0000 (UTC) X-FDA: 78874308114.19.299F1F8 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) by imf18.hostedemail.com (Postfix) with ESMTP id 82A074002087 for ; Thu, 2 Dec 2021 22:33:57 +0000 (UTC) Received: by mail-ed1-f50.google.com with SMTP id x6so3871774edr.5 for ; Thu, 02 Dec 2021 14:33:57 -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=LKwx+V2AktZno2fWolXVU26gwZuIYd93DrLMeKrtYvE=; b=X3l6T614nyuWfhM4V/g1+uAMSRhILIzxXddjQJP51l+3/Qpge1SyBWfsOy1VKonBRG /3cNKCLRs7WOLBoEs3znUxJqzdtieJXLSxYSp3RV456MeSwAXmiAQXF7+JwwipVf/wGG i9f2L+bmzzwcT81q0P3zBVKuzIcQBjMTNYkfY= 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=LKwx+V2AktZno2fWolXVU26gwZuIYd93DrLMeKrtYvE=; b=Jg+rP+Ay8xX+e99cp4n+1FHCqF857MYiPFLggk+i9lr0wE3sqCk/y0lgYoh6K7zxVW dobZRNOta6uXShyxjqSvkJpjQM8Xt+fvHUH7i9fsiiw3xC3dpoop+7sWZemvvjK3cGbG ChZShWIOtv2XoqPvpkOlH1W0MKkcdRHZqWHKpgNvzEFFOoK0xQBb/rQHqLzRPFUJZooF j1h11AnhCAbf9eWpkUZqD/q05i7+6hma+yRVbckKwN2ZHMMaYeJ3VHyoA0oXgHwsOzM9 C+7wiTNR31coVypo2iGex+HoR3O8QoEcH/+IJW7ffTawJrmcra1kIb5n38H4BRUFvXqh GT/w== X-Gm-Message-State: AOAM530D934K6w7he6iZjePZt2IX1vmv/VxGRJg6oV3w9CBkONjmEQr7 H6T08Zzt0+/Lje89TzCliSQJik/DKqv/Ll6v X-Google-Smtp-Source: ABdhPJxcD5PKj9VM1lpkE6ZvV232laYk1Slh2+Zx3xYP/YxJ21OY/MY7zFFZvIDLV40Rgj8WS89+Gw== X-Received: by 2002:a05:6402:b26:: with SMTP id bo6mr22079772edb.207.1638484435889; Thu, 02 Dec 2021 14:33:55 -0800 (PST) Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com. [209.85.128.45]) by smtp.gmail.com with ESMTPSA id e4sm684917ejs.13.2021.12.02.14.33.54 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Dec 2021 14:33:54 -0800 (PST) Received: by mail-wm1-f45.google.com with SMTP id n33-20020a05600c502100b0032fb900951eso3421532wmr.4 for ; Thu, 02 Dec 2021 14:33:54 -0800 (PST) X-Received: by 2002:a05:600c:4e4a:: with SMTP id e10mr9972584wmq.155.1638484433843; Thu, 02 Dec 2021 14:33:53 -0800 (PST) MIME-Version: 1.0 References: <20211201231757.332199-1-willy@infradead.org> In-Reply-To: From: Linus Torvalds Date: Thu, 2 Dec 2021 14:33:37 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [5.4 PATCH] mm/gup: Do not force a COW break on file-backed memory To: Matthew Wilcox Cc: Jann Horn , Jan Kara , Kirill Shutemov , Oleg Nesterov , Christoph Hellwig , Linux-MM , Linux Kernel Mailing List , Mike Kravetz Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 82A074002087 X-Stat-Signature: 4zo55qd7ur1ez656fq53gsna4ds4rogh Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=X3l6T614; dmarc=none; spf=pass (imf18.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.208.50 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org X-HE-Tag: 1638484437-798814 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 Thu, Dec 2, 2021 at 11:59 AM Matthew Wilcox wrote: > > Oh absolutely, it's semantically nonsense. The only reason it fixes the > problem is that VM_DENYWRITE VMAs are the only ones considered for the > RO_THP merging, so they're the only ones which we've seen causing a > problem. That would be a semantically meaningful argument, but I think the reverse isn't true: regular pages in VM_DENYWRITE vmas - that aren't using the RO_THP thing - are open to the same old "COW wrong way" issue. So it's not like VM_DENYWRITE is really meaningful for the conditional, even if it's perhaps a prerequisite for it being a problem. > > I suspect a real fix would be bigger and more invasive. > > Darn. I was hoping you were going to say something like "The real > problem is follow_trans_huge_pmd() is complete garbage and it should > just do X, Y and Z". Or "When we force on FOLL_WRITE, we should also > force on FOLL_SPLIT_PMD". Well, maybe that "FOLL_SPLIT_PMD" thing would indeed be a valid thing? But I _think_ that it shouldn't be too painful to do the should_force_cow_break() call later, when you actually have the exact page details, so while not exactly a one-liner, I hope that approach would end up working out. I only gave it a quick look, though, I might be missing something. Linus