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 X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90E00C4361B for ; Sat, 19 Dec 2020 20:34:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 151AA2388E for ; Sat, 19 Dec 2020 20:34:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 151AA2388E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2F4346B005C; Sat, 19 Dec 2020 15:34:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A5DE6B005D; Sat, 19 Dec 2020 15:34:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F11A6B0068; Sat, 19 Dec 2020 15:34:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0019.hostedemail.com [216.40.44.19]) by kanga.kvack.org (Postfix) with ESMTP id 05E216B005C for ; Sat, 19 Dec 2020 15:34:38 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id BEC0F8249980 for ; Sat, 19 Dec 2020 20:34:37 +0000 (UTC) X-FDA: 77611184994.07.road48_22025f127449 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id A75111803F900 for ; Sat, 19 Dec 2020 20:34:37 +0000 (UTC) X-HE-Tag: road48_22025f127449 X-Filterd-Recvd-Size: 5323 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Sat, 19 Dec 2020 20:34:37 +0000 (UTC) Received: by mail-lf1-f47.google.com with SMTP id x20so14295218lfe.12 for ; Sat, 19 Dec 2020 12:34:36 -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=i6WEkkm6ItmYR5Nc7WLcGl8iPUHvmHopSYUb1uCJQT0=; b=OyMepeYRv3SqqZn1639l0dapTnd3++utPvIHPn/lAKEKQz8ez3nMhl3LxHjUrjCAch bIwOnC79LDNLzECuWXDHNLtLFoZNVW9RT1K4iYWHcjnyQjwDShXfShciNOARkm4QAzWd rztJriJMwLJToBCHJ5xgY++4IZUL1rg5qu4qE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=i6WEkkm6ItmYR5Nc7WLcGl8iPUHvmHopSYUb1uCJQT0=; b=T0VtDYtngUdCQoAK2cwyzlIVb/hzUNipOa75TOH8wk6fKS+DPKjxaBbQKmBCamu8f6 5yNo50A4KNauHkiF3qTCDFzTR7VBzttZLd8WZiUL4H1VhDJVNwMX9ajXO9XbOmRLI6EZ ErNR9z87vPo/wcOSyrZGAu21rKNNgO8h49EO2CmMgR89oJ/estODfyEuIVCD30qo/z5S Q9+PUon7+beWveJGQqsVsRjkHns4t2I2Zc9/v0egux9ype7F0avARVshN8IA9S3sH0yg Vd0liEgzHwrncn5SAF63TGNNatGfKGFATiEujpbjyim7Fln0TyS0b9kfHNVntVo0On47 xtIw== X-Gm-Message-State: AOAM533ZugepkB8HBGm9QlSgvXH/y1lw5P9+l4dnYqqD7OML8JJCKXX8 Z/70GP1fdrakjtjgy/R75PVvKEhI8UuRzg== X-Google-Smtp-Source: ABdhPJzigu2CbtAmiyFXsEzGJEYYFzQv7yQBbNPYneCnl3GX68SdfbvdzduRJUD0G7IPurPOnDUg7g== X-Received: by 2002:a2e:81cb:: with SMTP id s11mr4314227ljg.377.1608410074988; Sat, 19 Dec 2020 12:34:34 -0800 (PST) Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com. [209.85.167.50]) by smtp.gmail.com with ESMTPSA id y9sm1541544ljy.37.2020.12.19.12.34.33 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 19 Dec 2020 12:34:34 -0800 (PST) Received: by mail-lf1-f50.google.com with SMTP id o13so14408692lfr.3 for ; Sat, 19 Dec 2020 12:34:33 -0800 (PST) X-Received: by 2002:a2e:6f17:: with SMTP id k23mr4369075ljc.411.1608410073306; Sat, 19 Dec 2020 12:34:33 -0800 (PST) MIME-Version: 1.0 References: <20201210150828.4b7pg5lx666r7l2u@black.fi.intel.com> <20201214160724.ewhjqoi32chheone@box> <20201216170703.o5lpsnjfmoj7f3ml@box> <20201217105409.2gacwgg7rco2ft3m@box> <20201218110400.yve45r3zsv7qgfa3@box> <20201219124103.w6isern3ywc7xbur@box> In-Reply-To: <20201219124103.w6isern3ywc7xbur@box> From: Linus Torvalds Date: Sat, 19 Dec 2020 12:34:17 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] mm: Allow architectures to request 'old' entries when prefaulting To: "Kirill A. Shutemov" Cc: Matthew Wilcox , "Kirill A. Shutemov" , Will Deacon , Linux Kernel Mailing List , Linux-MM , Linux ARM , Catalin Marinas , Jan Kara , Minchan Kim , Andrew Morton , Vinayak Menon , Android Kernel Team Content-Type: text/plain; charset="UTF-8" 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 Sat, Dec 19, 2020 at 4:41 AM Kirill A. Shutemov wrote: > > @@ -2884,19 +2966,18 @@ void filemap_map_pages(struct vm_fault *vmf, > if (vmf->pte) > vmf->pte += xas.xa_index - last_pgoff; > last_pgoff = xas.xa_index; > - if (alloc_set_pte(vmf, page)) > - goto unlock; > + if (pte_none(*vmf->pte)) > + do_set_pte(vmf, page); > + /* no need to invalidate: a not-present page won't be cached */ > + update_mmu_cache(vma, vmf->address, vmf->pte); > unlock_page(head); > - goto next; > + continue; This can't be right. Look at what happens if "pte_none()" is not true.. It won't install the new pte, but it also won't drop the ref to the page. So I think it needs to be - if (alloc_set_pte(vmf, page)) + if (!pte_none(*vmf->pte)) goto unlock; + do_set_pte(vmf, page); instead, so that the "if somebody else already filled the page table" case gets handled right. Hmm? Linus