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 84987C433EF for ; Fri, 17 Dec 2021 19:05:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D0D236B0074; Fri, 17 Dec 2021 14:05:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C96616B0075; Fri, 17 Dec 2021 14:05:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B35CA6B0078; Fri, 17 Dec 2021 14:05:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0004.hostedemail.com [216.40.44.4]) by kanga.kvack.org (Postfix) with ESMTP id A1C7E6B0074 for ; Fri, 17 Dec 2021 14:05:26 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 62A298088C for ; Fri, 17 Dec 2021 19:05:16 +0000 (UTC) X-FDA: 78928214232.27.6E91427 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) by imf29.hostedemail.com (Postfix) with ESMTP id 31D5C12001B for ; Fri, 17 Dec 2021 19:05:13 +0000 (UTC) Received: by mail-ed1-f42.google.com with SMTP id z9so11599036edb.5 for ; Fri, 17 Dec 2021 11:05: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=7F2aHCSe8IzO12Nz4RyfBAXoLOfk6p6JbZVcFiKHrQg=; b=ZjQ4/n3jpC4K+CjIh7Q22vd534RgwvYHtS9nR1P4Lv9P3PuipIG4Ky5i+x88FHfNU+ COO7Q+1L2Wl2VME7dDHc3akKiuLmeIvlviUDhdeTrCBSljMxVDX7hZf2YhkozKnphVFk YaiCt3VRfbmQic5ajEaNqa5Otx58kYxFTYkgk= 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=7F2aHCSe8IzO12Nz4RyfBAXoLOfk6p6JbZVcFiKHrQg=; b=eWRK4y7aR8g4h/YYWKF9hY5KnbCxwIBb2UXT55u8nBiGVPFa0FpHaIgIJf7wGNWyiu u4qmv0mp9mufXpZvQ8J0f80iup2G9L9mBQAvPSf6VnQska+leF1LFHkJ1GDcmczV1yYp f7wV1peAPMA4F4ytOY5pW0320Woe59Y3IN1Hd7QeFKL2kSoSHANTL1B12n4ihfuft5gk HtqlGKrjv9HMHApIQMat3PLvJO0Lj2p3FWmBnc4uwkxcjQ8/OA9ZhnDTGqmO4tcRPauO OdlB1GPzWqNFhAJ6B9qIUV+NbOmV/5i/tH5f60l5nuSSSJDdpVQkpJ2MqjViYRlF8ubI x5vw== X-Gm-Message-State: AOAM532fku5UVIWJzJ74EABxIwNSM52zJpADdY298TNpnH+Jp8e0ei8i In/ziwYeWWvjWdPAz6LZfPYnLokVI6SREB6Fvc4= X-Google-Smtp-Source: ABdhPJwKHixra7mOSVjO3u2JX1eM711gau1bSYg93ECXG79cP8ze5tk1DZVht4ja3iG8qQZx5YJulA== X-Received: by 2002:a17:906:9f10:: with SMTP id fy16mr3609470ejc.637.1639767914305; Fri, 17 Dec 2021 11:05:14 -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 j4sm3946758edk.64.2021.12.17.11.05.14 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Dec 2021 11:05:14 -0800 (PST) Received: by mail-wm1-f48.google.com with SMTP id g191-20020a1c9dc8000000b0032fbf912885so2121603wme.4 for ; Fri, 17 Dec 2021 11:05:14 -0800 (PST) X-Received: by 2002:a05:600c:1e01:: with SMTP id ay1mr1762683wmb.152.1639767903770; Fri, 17 Dec 2021 11:05:03 -0800 (PST) MIME-Version: 1.0 References: <20211217113049.23850-1-david@redhat.com> <20211217113049.23850-7-david@redhat.com> In-Reply-To: <20211217113049.23850-7-david@redhat.com> From: Linus Torvalds Date: Fri, 17 Dec 2021 11:04: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: 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" X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 31D5C12001B X-Stat-Signature: 19oaz3iie4jhopw56f998r5xucfxuu4y Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b="ZjQ4/n3j"; dmarc=none; spf=pass (imf29.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.208.42 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org X-HE-Tag: 1639767913-634409 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 3:34 AM David Hildenbrand wrote: > > + * If the child takes a read-only pin on such a page (i.e., FOLL_WRITE is not > + * set) and then unmaps the target page, we have: > + * > + * * page has mapcount == 1 and refcount > 1 All these games with mapcount makes me think this is still broken. mapcount has been a horribly broken thing in the past, and I'm not convinced it's not a broken thing now. > + vmf->page = vm_normal_page(vmf->vma, vmf->address, vmf->orig_pte); > + if (vmf->page && PageAnon(vmf->page) && !PageKsm(vmf->page) && > + page_mapcount(vmf->page) > 1) { What keeps the mapcount stable in here? And I still believe that the whole notion that "COW should use mapcount" is pure and utter garbage. If we are doing a COW, we need an *exclusive* access to the page. That is not mapcount, that is the page ref. mapcount is insane, and I think this is making this worse again. Linus