Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp273868pxb; Tue, 15 Feb 2022 13:03:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJz643/nlW+kMQhdA1xvVj7rvPJ70GWssKU8GTfa3NEoQS0s7IMQx3E6Z3g1d8FvVUiDv+Sw X-Received: by 2002:a17:906:8a4b:: with SMTP id gx11mr801165ejc.48.1644958993863; Tue, 15 Feb 2022 13:03:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644958993; cv=none; d=google.com; s=arc-20160816; b=0ebcEesi2ljwCD1c+ptpHanDahon9EnCTETMbrUD0nEX2L3O9Cwg5CsMQ3Ze3bF7W/ Dcx7d/p4o0yTsCwO18ep5YgZ4SkU6mT8uo/WgfkaMyyPe2RAT/lngljY8Vi6hS/8F2Wg yJiCY54eN4y5iF6ve4VPhbgJ94tYSXAY02em7mO/EeA3mvOkP3nkgoSgSRWAmZVhYDG5 HwFUYvd6G6nDmr/mLDQIYhncsC/Wq5bBGjMqRB+JR6kDvveCoNxiyulPBH5gtEk3Tyoo MKtH5NTtDpogbI8mVVrXef8N/V0Cvju3OCBmouMM0ORITDczNe/GOHr6AiK9fUwmAnaB Yf8A== 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=4CEufNPi0mf8HHPhcFQPBOMOzkgqFViDRsTOMQmjSo4=; b=a+LbQlsIBBQPTdIvR9YnlUnoAhYv4ch5pt/oGBOqf7E2U265lTurP0Xel5af+vN+6R b8Umuu7Ksqf1C0Y5YrjNEbsxZnkwxqR8XOLfDdArHArmWqIc13XIcYeUaT/4BVDjKBZR xvWKvZEHLjQbyXo6d95QwnhBzdq7l0cvZFo9ow9iwSHksdaEBTQrgCJTO5bgwsreist0 kpQrbWqFoteq7k74mjw33ZdJfN9HPuI/l1MLKJYPAt/w24DRT4949WmC9cT/xzTMw0/M P/szNs8IaEyDnezpRw7WjaK7kCFyyxKcvXKbMscoIB0B32YoEYTPdp+W/jLUzrGKdxjQ KedQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=JNIiCzym; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g9si685796edz.440.2022.02.15.13.02.47; Tue, 15 Feb 2022 13:03:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=JNIiCzym; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239552AbiBOPWw (ORCPT + 99 others); Tue, 15 Feb 2022 10:22:52 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:59164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239643AbiBOPWv (ORCPT ); Tue, 15 Feb 2022 10:22:51 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E92A8A32E for ; Tue, 15 Feb 2022 07:22:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=4CEufNPi0mf8HHPhcFQPBOMOzkgqFViDRsTOMQmjSo4=; b=JNIiCzymk35zUKtFR2HzYl9tZj 9RCXKtLExlprEpeih1IkSb5+dI5T8lAdB4b8Mx44AxPsy5SYOcaCWKo9BFbZiG9jDnmztNfoc5+CA 2zXllkSE5GZwZ2iA96jJxpZywgDQb1LiAyZ7MiU5MolALnSfEpFtB4xrlzgCfbBSdeXBYDApUL7GA vTMxCFCMS3Vy2TM6LlyJoXRSgXN1xACyFc15ivWf7/bSI4gkSm8PDji/AhhnOinxEGvsNesbCZieL ftoozfC885x6q+zKHMSkZOz1X5yAw9oMfumQL/KsSQxiuAp597Upw9fJMriMllDAJhxJudDoFNo2B ih0LzK9A==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJzes-00DwfC-4U; Tue, 15 Feb 2022 15:22:26 +0000 Date: Tue, 15 Feb 2022 15:22:26 +0000 From: Matthew Wilcox To: Hugh Dickins Cc: Andrew Morton , Michal Hocko , Vlastimil Babka , "Kirill A. Shutemov" , David Hildenbrand , Alistair Popple , Johannes Weiner , Rik van Riel , Suren Baghdasaryan , Yu Zhao , Greg Thelen , Shakeel Butt , Yang Li , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2 04/13] mm/munlock: rmap call mlock_vma_page() munlock_vma_page() Message-ID: References: <55a49083-37f9-3766-1de9-9feea7428ac@google.com> <501673c-a5a-6c5f-ab65-38545dfb723d@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <501673c-a5a-6c5f-ab65-38545dfb723d@google.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 14, 2022 at 06:26:39PM -0800, Hugh Dickins wrote: > Add vma argument to mlock_vma_page() and munlock_vma_page(), make them > inline functions which check (vma->vm_flags & VM_LOCKED) before calling > mlock_page() and munlock_page() in mm/mlock.c. > > Add bool compound to mlock_vma_page() and munlock_vma_page(): this is > because we have understandable difficulty in accounting pte maps of THPs, > and if passed a PageHead page, mlock_page() and munlock_page() cannot > tell whether it's a pmd map to be counted or a pte map to be ignored. > [...] > > Mlock accounting on THPs has been hard to define, differed between anon > and file, involved PageDoubleMap in some places and not others, required > clear_page_mlock() at some points. Keep it simple now: just count the > pmds and ignore the ptes, there is no reason for ptes to undo pmd mlocks. How would you suggest we handle the accounting for folios which are intermediate in size between PMDs and PTEs? eg, an order-4 page? Would it make sense to increment mlock_count by HUGE_PMD_NR for each PMD mapping and by 1 for each PTE mapping?