Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1627597pxa; Sun, 2 Aug 2020 14:47:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJws0yjUv0BkhYnBnELxRA83uMzv+geuakeVQqpm+wO3erDutc8T02wshJQUh8eg6MI4w1iG X-Received: by 2002:a50:e1c5:: with SMTP id m5mr13524258edl.138.1596404854808; Sun, 02 Aug 2020 14:47:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596404854; cv=none; d=google.com; s=arc-20160816; b=Y9IVUtzv0iEYPLU/vaeL19xI0blULsqfJPEdm4/p3sgLJ683Ub5wytknEiXuYUY5MI anQ7vtIZFDMilbnPEMJ6x96gnUWyl6A7/ck/6I/GkaZtywnulHvs5gxp7ezLJ7h+FU7Z m0yc42MVZi6N3FCd3Okk0asr5161j05WRoO5mYjeO4eMJGx5nTa8YCVENUMLQSKOfYr9 QHd7wtX3+4KsTxOqyRVzondNDQ0YMpwAbwx6aeo3QKcqJqfk3kcRpk6AkTTsu5bsLVi3 4GfQYhptBWFtgQUpVwWQbGg5qmMVgidB+cdiZfmSMi+ewfpXpWMiVubWx99ImwPbHC4P wU0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=W+JW9/qURXxdJHu00PKJzuTat8D6D0UTqBo2IDM73ms=; b=S2A/XzVAVY9TP4Rav6oIHq9Zkh7rXwpEl51zQCdl1uzae36RaMmHqKC1RLbrdubaow YMwRu5+X4HKsE/276BRIz7EBlzEXmYWT3GHAH+oaQgA44BPze5obudASmuRdeGKQW/KH gZiyvzcC00LLzPuXYASg1fiks1YSwkX7DZWbrDlbCK3bi2X+ZJhd09znOQJjXV02jpEe drmURkFuxtHgETOPoKZK8vP7/ifryVyR44YxUk99nuNBi66UVUsRaNCPXgwUyBGzijyS PFPyai2JExjeu8QIsUHzYglEXdwiPgLk72eGvKZwwwCzVqa5hpdatkX0fZZ0ryZSRoG8 pDxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=qHldnjF7; 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 k27si8901216ejb.408.2020.08.02.14.47.11; Sun, 02 Aug 2020 14:47:34 -0700 (PDT) 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=qHldnjF7; 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 S1726947AbgHBVoE (ORCPT + 99 others); Sun, 2 Aug 2020 17:44:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725925AbgHBVoE (ORCPT ); Sun, 2 Aug 2020 17:44:04 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D243C06174A for ; Sun, 2 Aug 2020 14:44:03 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id w14so7762233ljj.4 for ; Sun, 02 Aug 2020 14:44:03 -0700 (PDT) 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=W+JW9/qURXxdJHu00PKJzuTat8D6D0UTqBo2IDM73ms=; b=qHldnjF7bttAYl+4vR9WYNVBGhIodj7vux22J4S0paJxxX4KkZ8N7egol8vHxfmd64 +LfdWqs02/fD0tJQPYV22bCXkE0X+YPL0YYg94IIMKswYYYk9BT7gbliSYgxd+o5jw8e fvyu/cs/74qRenHzx5R1FClEPRSomH5g9rkAkzX5KIV3dXLGPVRCdkr39kWDlMmcAdKD xBjBvkL0ssDx62oO2dY5J0as+hohy1WhRtiyfh6Ur4Mnulur072oiwX2i3qw1gz9B/S8 +jg+danNDHtYnULYSj3ptjL+x1ALX/jSyBwV/8gWL1T7JlXCEpXrH/5oj0zu83cisNLZ FYCA== 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=W+JW9/qURXxdJHu00PKJzuTat8D6D0UTqBo2IDM73ms=; b=U1aKtpjyMvt92r2DMBLUsHvf7rosZ8qRnRQaoEWsvgeYVaSSaIDv6U1MnzS4oucyOC mtgFvadh5VSKilnvLdJWZLnrCGwD361Iw/ZJwCvnh3UPABN8Xh5qiAW+6LkWe9R+YV5N wB6xgJ0c9SHcPH2wbkCSdLPGFTuG2MU3/MNfpN5L+h9KPIHYPNe75VIe7r/P/6ePgtVa a125XbWq4x1/C0jjGKZ0PA8JO0pze9eCTA2dlBYCp7CxQyBJqUgVjrW7vkZqSmFjXcf5 M8MmbtbTqTEEJ7qsKjVYoWA1wGRrwWk+HBZZ5YLtiBpED6ZNHId4Q0RcBonODHrzy3AK Xx6g== X-Gm-Message-State: AOAM532wYfIJpsgjzAQcFBeMlgSVVWonLNvu781BIkJlpq4fLveItpDF naa8VZLDp8xrXvTI/qZoZlNA/A== X-Received: by 2002:a05:651c:1104:: with SMTP id d4mr6859667ljo.164.1596404641969; Sun, 02 Aug 2020 14:44:01 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id a19sm3989856lff.25.2020.08.02.14.44.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Aug 2020 14:44:01 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 0AEBC102BA1; Mon, 3 Aug 2020 00:44:08 +0300 (+03) Date: Mon, 3 Aug 2020 00:44:08 +0300 From: "Kirill A. Shutemov" To: Hugh Dickins Cc: Andrew Morton , "Kirill A. Shutemov" , Andrea Arcangeli , Song Liu , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] khugepaged: retract_page_tables() remember to test exit Message-ID: <20200802214408.patvlf3sghro3nhi@box> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 02, 2020 at 12:16:53PM -0700, Hugh Dickins wrote: > Only once have I seen this scenario (and forgot even to notice what > forced the eventual crash): a sequence of "BUG: Bad page map" alerts > from vm_normal_page(), from zap_pte_range() servicing exit_mmap(); > pmd:00000000, pte values corresponding to data in physical page 0. > > The pte mappings being zapped in this case were supposed to be from a > huge page of ext4 text (but could as well have been shmem): my belief > is that it was racing with collapse_file()'s retract_page_tables(), > found *pmd pointing to a page table, locked it, but *pmd had become > 0 by the time start_pte was decided. > > In most cases, that possibility is excluded by holding mmap lock; > but exit_mmap() proceeds without mmap lock. Most of what's run by > khugepaged checks khugepaged_test_exit() after acquiring mmap lock: > khugepaged_collapse_pte_mapped_thps() and hugepage_vma_revalidate() > do so, for example. But retract_page_tables() did not: fix that > (using an mm variable instead of vma->vm_mm repeatedly). Hm. I'm not sure I follow. vma->vm_mm has to be valid as long as we hold i_mmap lock, no? Unlinking a VMA requires it. -- Kirill A. Shutemov