Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3118314pxu; Sat, 19 Dec 2020 12:46:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJxCpm1vUYHM/mCITThGpTmVGOj/e3E5Dv4sTJd2YJ530eJfgB4X5j0VtnPrfK8H+M9vRk8l X-Received: by 2002:a17:906:b0c2:: with SMTP id bk2mr9823778ejb.223.1608410759963; Sat, 19 Dec 2020 12:45:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608410759; cv=none; d=google.com; s=arc-20160816; b=WRAg/UTLVzVjs2rTSErXLv1CNEnuLc46oBTK5p85CXZAKydb/68x12nvhr423oIAwl PxIIMZTXaCzt6qp26eVBiGMfXwv67qolNJ3X0oE8rXQTVRRJRg6bx+Yp+5lO7b8FEIAN +TopoSJAQLKyHfOlse7eXX3Ogs+gtw2sJDdAVznEP3ol4A0R1/uxuWpcyCAzSKwNGUsW 4IaNrqqxnF6GMGYxKOKzZXlpn5j2vcCIZjIwWIzPHINOoeafvIqMD28N7HCsEciDJtib zdmWZTzWCX+PQu7jvN76NHOIBbmdZc3/f487RoLJcIQYZMXpS98rPG5y1zl4tN4TzA2V rkCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=i6WEkkm6ItmYR5Nc7WLcGl8iPUHvmHopSYUb1uCJQT0=; b=Z/obtnlQ59XleCEbuvH9P7Jpg9yPjfPZAeDd0+5U+hNxeiZdxm64nuL6NLcViFvUVR J713OaFzmZzhQ+i8hHUtJUR7miy/NSCLAShDBHRr7cblGWJ7mWHkvVzziNEX+sv2lpjy 4k8GIqJBmhy6yKShHFKN98XC+OcRbKPCrSdQ0TCzhC20K3b1JHlfw4sih9RgDY8gqkJh 6Ci/99MVCQ0jryfO3p8VIWSTpB9HOtvlWLrp4k8yzeKMDj1HXOauap+TBrCDeFd3Me3C znZQN7pBabKFK0+yHnM+EsUcYnWZ//arYCvx+H9uZlY/dR0RA58xPw74zUuN0U9B7NcY j9IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=OyMepeYR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i8si8062966edq.125.2020.12.19.12.45.37; Sat, 19 Dec 2020 12:45:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=OyMepeYR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727680AbgLSUkr (ORCPT + 99 others); Sat, 19 Dec 2020 15:40:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726238AbgLSUkr (ORCPT ); Sat, 19 Dec 2020 15:40:47 -0500 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FDDEC0613CF for ; Sat, 19 Dec 2020 12:39:55 -0800 (PST) Received: by mail-lf1-x135.google.com with SMTP id o17so14426674lfg.4 for ; Sat, 19 Dec 2020 12:39:55 -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=fYGMCFdIdjxFp4fQfW2Pl4aRE4p8VpJMTOvaXB+JR9QBa3yfPs7meAkf7661M4B2un NIQZfdb2LV10J3mgIUiNi1QwiR4A0D6zdHdbTurvsonRKJ/j6PSsy5clswSh0BDPX0aM w08pvJlKjUcs2a3JEugG2gsq5J69eHPHr9SHS1W8UCD6ACe+njziALLc4Dn4W08CnPqJ l0LUjvz+t6MeTq6Xb2+8JXhd5MGudy9uTkPnUseN2qY9BbAsjLocMZ7yXK0oMj5c0+nN YjNyV5rw6tXmpmObXafNHegw7eVUnWHKBiMxWUsS5cxCJNSdMMT+CJX3UxyWOpQveLEN 1Usw== X-Gm-Message-State: AOAM533eiGa2e27iZMkVA4DJs/CH1BVJ2xNevJXHdQ6wZQ+kQjEXHTWP 5FWffN0f2g2sTkI+JtZpcToHR/1cBsr4Dg== X-Received: by 2002:a19:42c2:: with SMTP id p185mr1832061lfa.423.1608410393568; Sat, 19 Dec 2020 12:39:53 -0800 (PST) Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com. [209.85.167.43]) by smtp.gmail.com with ESMTPSA id j7sm1407537lfg.114.2020.12.19.12.39.53 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 19 Dec 2020 12:39:53 -0800 (PST) Received: by mail-lf1-f43.google.com with SMTP id l11so14475468lfg.0 for ; Sat, 19 Dec 2020 12:39:53 -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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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