Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5909162pxv; Wed, 7 Jul 2021 14:49:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4DVAqCclvobdnwopAlsivUSaci3+FcS9TZ4pFfVtfQiol2O0gs2K0hXbUaPVQ57cZw8AK X-Received: by 2002:a05:6402:430d:: with SMTP id m13mr14777955edc.88.1625694585762; Wed, 07 Jul 2021 14:49:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625694585; cv=none; d=google.com; s=arc-20160816; b=SwYv/DSwTykiySrlF/hvSkkgqa2AeXPg9BXNwOVfeF290bodgs3s1jkGjvVt8X4jjX kV2HH3ek+RgDHJqZBsf3Z5Q+fqrhoAtQm74w4P4X8WegvEdaiQCFHfOTtfAw80lhSJAV S9LXGqASb5kJCY8y8Jp+ntOf2XtWVsX0dlepw8OrM3inDzI0wdJuDn2QMd+JzsIIfAGf 8Ak4j3BF5TleFFBDgAzqHYt0TiCgEc91lZUIJ0Wza7bA/6guWQ9rgChdeZeVAppcjYyB cF4daDQvwHaIDMtO+Ksm7uCixKbSu5jH6Ai9MGijESC1ErE/YQaFzcSMr7UcPEqFxAuQ /gLw== 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=ZWu3QVOTeUxlL22eAEVvjuwGrqkBirMWX6Uul/gayos=; b=KXiwevUwzmvT5XXq+p6xCcF8exyMPEJiTFOTWMVsIbfpeaz6xwmBRhAnfjubk5/3OV E0gDtaDI1WR7GQyP4k2+w07oSgKIWbQnhUaxoKRi1ZOCUJDheIwpF5eIZFUNq0yWTnKE qmaPUVtNirmScBnhDOMYjtrv7NoTzOkj2sVBH7eF0rj/Mom1z5Aa0oD2/iQMSP3MBFj4 LcGJnKJmZ2t5psdkLsTuHP0dfHUOBSoUTPyIhBVgxNkG66PeAWE0Zneg72O6UCqc/+T7 zoYouYsdCXOVIncP+p4EwpPLWL5+iCFIk5BuxsjU8gmG8KLxZcQKa2fWWA1KDtn1tDMC f53w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=oB1tZvS2; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h1si246875ejf.146.2021.07.07.14.49.20; Wed, 07 Jul 2021 14:49:45 -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=@google.com header.s=20161025 header.b=oB1tZvS2; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232164AbhGGU4Y (ORCPT + 99 others); Wed, 7 Jul 2021 16:56:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232111AbhGGU4Y (ORCPT ); Wed, 7 Jul 2021 16:56:24 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4ED69C061574 for ; Wed, 7 Jul 2021 13:53:41 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id c28so7668355lfp.11 for ; Wed, 07 Jul 2021 13:53:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZWu3QVOTeUxlL22eAEVvjuwGrqkBirMWX6Uul/gayos=; b=oB1tZvS2C6wdt8bXQ6VyPQ06nRjpDgwW4zhA9viHIgemWVC3N7Km/I5aZtZWAzZNHf ziltRaLuxetuvx9MdUC+fS6zoS55xUomEaYfGIwLm6q5g4kitJ228TjDuJQXfQXHfm57 hWBFZSytJ/98ZLAD5LM+/ALH6G3TGOXldp/SVPm2DT/M0iHrzEs7v0OOrU2kr+V6I+4m Syc1GNJYwvznnD4ankuZgO2aCrJKXmNnGpdXVM2Af8PDmhHO8S7za0ZzTcdIwyp8t7WK gGvhuNkiKhVrz096b2/UN7GMOsuRFdipJvXOmgt5G28otO0dnhA+hbVBewa04rQaaoMu t1IA== 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=ZWu3QVOTeUxlL22eAEVvjuwGrqkBirMWX6Uul/gayos=; b=eo26R+m7iqTtfhIs3C95cGdjceNOWEjteHKbTRTLM67Jzyt4Q+TTZI+3n0SZ2f6e3R 8kCU2BYmJyomTSNXuqjSl1Ru9yolcd7Zs2f2C5uVNmGPwUcZvDEyJvBl9WynIJThRc6f caHAS58PPgSdWxmS51ODAoMnRiFSGPSyplwJvlm4/2nLWDBje7JqnMULsfmw48/M2dX1 KHeujsSer+qL8xdKzhd+7GYc/jWsUieP7qm6B4wB7ghzVtoTsPs6S7UcpCStQvUTnYPv JP+x+G4/a8Wo8l73Pb4JflBgnODT1r4EORIYbEybSvFcFFn6+Z2ILsVT4H/fpv6eOhbt iBCg== X-Gm-Message-State: AOAM531cuwxVG4nL0a5zQ9c5tvAwa6fJRm/wUP/Xg8iYV7J8i1Ud++8z 4p1aDWEt4HPhZQBmm0UUiczzOcUz5yv5KNxHd/lEdA== X-Received: by 2002:a2e:a78d:: with SMTP id c13mr21293260ljf.0.1625691217400; Wed, 07 Jul 2021 13:53:37 -0700 (PDT) MIME-Version: 1.0 References: <563ce5b2-7a44-5b4d-1dfd-59a0e65932a9@google.com> In-Reply-To: From: Shakeel Butt Date: Wed, 7 Jul 2021 13:53:26 -0700 Message-ID: Subject: Re: [PATCH 2/4] mm/rmap: fix old bug: munlocking THP missed other mlocks To: Hugh Dickins Cc: Andrew Morton , Alistair Popple , Jason Gunthorpe , Ralph Campbell , Christoph Hellwig , Yang Shi , "Kirill A. Shutemov" , LKML , Linux MM Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 7, 2021 at 1:08 PM Hugh Dickins wrote: > > The kernel recovers in due course from missing Mlocked pages: but there > was no point in calling page_mlock() (formerly known as try_to_munlock()) > on a THP, because nothing got done even when it was found to be mapped in > another VM_LOCKED vma. > > It's true that we need to be careful: Mlocked accounting of pte-mapped > THPs is too difficult (so consistently avoided); but Mlocked accounting > of only-pmd-mapped THPs is supposed to work, even when multiple mappings > are mlocked and munlocked or munmapped. Refine the tests. > > There is already a VM_BUG_ON_PAGE(PageDoubleMap) in page_mlock(), so > page_mlock_one() does not even have to worry about that complication. > > (I said the kernel recovers: but would page reclaim be likely to split > THP before rediscovering that it's VM_LOCKED? I've not followed that up.) I think, yes, page reclaim will split the THP prematurely in this case. > > Fixes: 9a73f61bdb8a ("thp, mlock: do not mlock PTE-mapped file huge pages") > Signed-off-by: Hugh Dickins Reviewed-by: Shakeel Butt