Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9030735pxu; Mon, 28 Dec 2020 04:56:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJzUncuNhJslLFYwPxWqVcnUkfNNdjoDo9raiCpNPlyfsT4CkVtvBs8DyZVtl4t6h6MBCJfX X-Received: by 2002:a05:6402:1d15:: with SMTP id dg21mr41416427edb.280.1609160203280; Mon, 28 Dec 2020 04:56:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609160203; cv=none; d=google.com; s=arc-20160816; b=cE5nYi9wb0snvuX0vggHSZUV46Zo2cRFu5S/7E/YxpmGUI0ijn5QdLQPh8HomZ/Gnk oldgOmaex8O2F+TYmzIqwNoDpw70J60Kd24wrKBqc+jlfn20wmKq0I4gYGuB7eXdL7SG 1EYJVszB0FO3F9d6sJgmHmDrlHWJ4m/rvLt8+b2/zjO1q0eCZlU+KGr6LG/UREWSu8Po MDkVLgcjYYZ45a8GblTJePppnwULyHMZLJYAeu8krTKF4AeVpaNsdTsp0N+hAdSAWJ2U 6bqgo7NwajD0+i5RvzkZvLg3kO8bZjrrLooZd4Muaeidh9H07jJ6e/UD98DLfvcqEBnA Uuaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=e/ofUiCRRpB4u/ncszNNbx4yVQ41aGMLvWQFS35RvZk=; b=KE9fSJ6rzEw7XOJmMLBNtGh4sfkwDYMfFHYKOdKreDUiM5TPmPIY0TtYOcDKPJInTg AZFUv2TH/7HkGNwB47RPhErcUe2+3k0eN2x7OOsDQkhV3TaiNo7fJz6yno/WQe6B0y1t 5Kma9KDylag1NZnG2++ldXbbSel5TyDaS/vP/Uz0t+E4o/xECS5+K9fDj/Bf1LhqbQTO rP2akv7Mpso+ppk+HY2Y/HXAzX7SzPVr5EsIgni9A113dHZW3XUT4nyeHJiSRWILkAsi vXy9S8K4dzHH5RSzwdP4k3y2TjxC/g/F0N7rsYD/VPIhVBa0XFoH25QMOVRWA0Hjq6su lcCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=LtOrTYXJ; 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 e14si18823867ejr.169.2020.12.28.04.56.19; Mon, 28 Dec 2020 04:56:43 -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=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=LtOrTYXJ; 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 S1728392AbgL1Myn (ORCPT + 99 others); Mon, 28 Dec 2020 07:54:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728372AbgL1Myg (ORCPT ); Mon, 28 Dec 2020 07:54:36 -0500 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF4D2C061794 for ; Mon, 28 Dec 2020 04:53:54 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id b26so23631891lff.9 for ; Mon, 28 Dec 2020 04:53:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=e/ofUiCRRpB4u/ncszNNbx4yVQ41aGMLvWQFS35RvZk=; b=LtOrTYXJm5GCAEJmyygo6av6ilVjte7nrHfuv67gXDpKd+J+pPdTCcxYoIGp1dX2w5 Ihd5Qc2FtGU3gkA9UCXFeBOVXtmF3FnWevd7p76cvCLgY3D+rXxSsU67PTKPx5J3a9zf uElwOP/OCHcUtHiAe6BZzxxUfgrYLg2Z7S38iArnEgsXBm7Vdj8wuG58GjfYodS8aTsq t0CWf/hY4H5bnuF+Baqp67r1D0d25zzn6kMkxzTUWCUgm15TmoKXiO8s6vvrzcjs5BmL 56zSFKosBDPZB9Q+jEXFPoy/z3+8D1EQY1QWh/kndY66e3IQB0KG8w+ANVgwfrdXZJAC 5ZeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=e/ofUiCRRpB4u/ncszNNbx4yVQ41aGMLvWQFS35RvZk=; b=fK/EvP64NirrPlF1sZihUHmjJgohGubk2pD9uaqZdSCIq/l8mpH/hCJRTJZaySpC8X 855vBmDaN/0gw5jyZ7ZAttHdCr4WR3h+Z47+nOo+mE9Tb2JBfZQxdAc9/qOTBb7Xq8TK Cf/jvSkUlVfdTHu3IeTQDKzMByHFBv8dDK8xwI/5GUui9oCpAWdHtWAFOl5bIEwxF25t VsrirYmYUCL+KUoSJRdIW3A4NYSC7l6pwUYUVDWTvNVK4HETlCzoDkHBy4F0Ycijcmp+ UXUG1fyIlIl/qdxSp1bEdMBs9fgQoS/g8IPll3GhJ1opSRZoI3brx5m/jcGMT80p7IqU K74A== X-Gm-Message-State: AOAM5331fjUCdkGwUnvxinq8L7i/OHRhGPaa3+Lz5FGFMjatccVRZJ8o vt6iUMO+6K1VhjMexMMItKAdhw== X-Received: by 2002:a05:651c:205b:: with SMTP id t27mr22712768ljo.368.1609160033448; Mon, 28 Dec 2020 04:53:53 -0800 (PST) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id j26sm200426lfh.251.2020.12.28.04.53.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Dec 2020 04:53:52 -0800 (PST) Received: by box.localdomain (Postfix, from userid 1000) id 89D9A100F3B; Mon, 28 Dec 2020 15:53:52 +0300 (+03) Date: Mon, 28 Dec 2020 15:53:52 +0300 From: "Kirill A. Shutemov" To: Hugh Dickins Cc: Linus Torvalds , 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 Subject: Re: [PATCH 1/2] mm: Allow architectures to request 'old' entries when prefaulting Message-ID: <20201228125352.phnj2x2ci3kwfld5@box> References: <20201226204335.dikqkrkezqet6oqf@box> <20201226224016.dxjmordcfj75xgte@box> <20201227234853.5mjyxcybucts3kbq@box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Dec 27, 2020 at 10:43:44PM -0800, Hugh Dickins wrote: > On Sun, 27 Dec 2020, Linus Torvalds wrote: > > On Sun, Dec 27, 2020 at 3:48 PM Kirill A. Shutemov wrote: > > > > > > I did what Hugh proposed and it got clear to my eyes. It gets somewhat > > > large, but take a look. > > > > Ok, it's not that much bigger, and the end result is certainly much > > clearer wrt locking. > > > > So that last version of yours with the fix for the uninitialized 'ret' > > variable looks good to me. > > > > Of course, I've said that before, and have been wrong. So ... > > And guess what... it's broken. > > I folded it into testing rc1: segfault on cc1, systemd > "Journal file corrupted, rotating", seen on more than one machine. > > I've backed it out, rc1 itself seems fine, I'll leave rc1 under > load overnight, then come back to the faultaround patch tomorrow; > won't glance at it tonight, but maybe Kirill will guess what's wrong. So far I only found one more pin leak and always-true check. I don't see how can it lead to crash or corruption. Keep looking. diff --git a/mm/filemap.c b/mm/filemap.c index c5da09f3f363..87671284de62 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2966,8 +2966,7 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf, unsigned long address, mmap_miss--; vmf->address += (xas.xa_index - last_pgoff) << PAGE_SHIFT; - if (vmf->pte) - vmf->pte += xas.xa_index - last_pgoff; + vmf->pte += xas.xa_index - last_pgoff; last_pgoff = xas.xa_index; if (!pte_none(*vmf->pte)) diff --git a/mm/memory.c b/mm/memory.c index e51638b92e7c..829f5056dd1c 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3785,13 +3785,16 @@ vm_fault_t finish_fault(struct vm_fault *vmf) vmf->pte = pte_offset_map_lock(vma->vm_mm, vmf->pmd, vmf->address, &vmf->ptl); + ret = 0; /* Re-check under ptl */ if (likely(pte_none(*vmf->pte))) do_set_pte(vmf, page); + else + ret = VM_FAULT_NOPAGE; update_mmu_tlb(vma, vmf->address, vmf->pte); pte_unmap_unlock(vmf->pte, vmf->ptl); - return 0; + return ret; } static unsigned long fault_around_bytes __read_mostly = -- Kirill A. Shutemov