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=-4.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 7841FC07E96 for ; Thu, 8 Jul 2021 14:26:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0364C6186A for ; Thu, 8 Jul 2021 14:26:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0364C6186A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7D5D26B005D; Thu, 8 Jul 2021 10:26:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7AC4F6B006C; Thu, 8 Jul 2021 10:26:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 626936B0070; Thu, 8 Jul 2021 10:26:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0063.hostedemail.com [216.40.44.63]) by kanga.kvack.org (Postfix) with ESMTP id 3FF7E6B005D for ; Thu, 8 Jul 2021 10:26:50 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 50C71184823F4 for ; Thu, 8 Jul 2021 14:26:48 +0000 (UTC) X-FDA: 78339646896.06.D8885D7 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by imf07.hostedemail.com (Postfix) with ESMTP id 40ABF100369C for ; Thu, 8 Jul 2021 14:26:46 +0000 (UTC) Received: by mail-wr1-f51.google.com with SMTP id v5so7800023wrt.3 for ; Thu, 08 Jul 2021 07:26:46 -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=RTQMNsYkH54gTZYg5JDo/dsYjbW4P2+8PHeW4ZHkno8=; b=gKecfPmI02OLNoie4L136UAox+LToVyA9H3yfCLewhc3MAJfq5CB1cnK+BK9W7USVP YiEOEFddz6oVpWLL1RF9gOYp0iwEcL0KzMwnV15wdxQU2z/pcH3wSNA7v9O9D+hPflQi MObaUt7NIL//UMryaxKl17vqo2IjBFZgAt/YGKGntBI/SXxEM+qUxtBytKPPzN4SffLo G5nnsk++yww4Sc/oYiP21+5bFLVHjIrk2R54VjDaiXgfltun4gPgA3NU1j2WfDFBq5AV rkU1DjmGXhFZVjafaJczJHgVrNBwE9kTcTSF05Ij+FxZ1tX0IA9diuO5AnYHLFNwIXrA lwHQ== 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=RTQMNsYkH54gTZYg5JDo/dsYjbW4P2+8PHeW4ZHkno8=; b=ie5A5MHmAilmz+7ODSBZw9YnFjMsR8GKy9sjPVeG1KITFetmKYOjRbdLmdLMD2PqGb a9gZ9BzZK8Qk2eP9FEnZ7gk0KcCvAQ6MzVQZPFRYplb36B1/WLQ0VypV1QAsf/kELRrB dSohXHuzLev9jS0c6VKKaCbwSg3fVg4XEuVkm6CTdjg8oHYKlZtdfvpJrlK6JVjP/QR1 UMMpIym8e5vNytKbvu8brcXZB+OXEcGvilNUw9CRqF1Llaq/3nRxnVnzlvZfqVuiJxcu XFiDFvnmopdWSgxm9Qy9sH65To6jx8695pr5QHGriyHpFhsjHrDhd6K7etMghd5jGALE rQDQ== X-Gm-Message-State: AOAM5333pNKMS5+uKR9i1PeHDmip6mKxYGFVm4tnUZjosds/sHoXMB+c jhFPHHl9gHGlkjprRb5f2lfp/Tf1IcRPzg== X-Google-Smtp-Source: ABdhPJwW+Ex9xsSpyg9Pb3vhDSaDTE/P+lD1YFK0vaxIg4+WDF9ongDtWtza8/vtU8CtMb8nCLtx/w== X-Received: by 2002:a05:651c:178b:: with SMTP id bn11mr24068444ljb.43.1625752691451; Thu, 08 Jul 2021 06:58:11 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id z1sm205549lfh.137.2021.07.08.06.58.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jul 2021 06:58:10 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id C77E5102878; Thu, 8 Jul 2021 16:58:11 +0300 (+03) Date: Thu, 8 Jul 2021 16:58:11 +0300 From: "Kirill A. Shutemov" To: Hugh Dickins Cc: Andrew Morton , Alistair Popple , Jason Gunthorpe , Ralph Campbell , Christoph Hellwig , Yang Shi , "Kirill A. Shutemov" , Shakeel Butt , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 2/4] mm/rmap: fix old bug: munlocking THP missed other mlocks Message-ID: <20210708135811.775drqgwkwc76vcb@box.shutemov.name> References: <563ce5b2-7a44-5b4d-1dfd-59a0e65932a9@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=gKecfPmI; spf=none (imf07.hostedemail.com: domain of kirill@shutemov.name has no SPF policy when checking 209.85.221.51) smtp.mailfrom=kirill@shutemov.name; dmarc=none X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 40ABF100369C X-Rspam-User: nil X-Stat-Signature: etcx61pw1ydfcdp3sw1iidjyrfnopjaj X-HE-Tag: 1625754406-565397 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 Wed, Jul 07, 2021 at 01:08:53PM -0700, 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. Well, that's true that it should be fine to mlock only-pmd-mapped THPs, but the refined check doesn't gurantee that the page is not mapped with PTEs. !PageDoubleMap(page) only guarantees that the page in not mapped with both PMDs and PTEs at the same time. For anon pages, we clear the flag when the last PMD mapping is gone and only PTEs left. Do I miss some detail here? Maybe we exclude anon pages here somehow? I don't see it. -- Kirill A. Shutemov