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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A72BAC433EF for ; Fri, 11 Feb 2022 10:29:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1CFB96B0078; Fri, 11 Feb 2022 05:29:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 17F7E6B007B; Fri, 11 Feb 2022 05:29:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0482C6B007D; Fri, 11 Feb 2022 05:29:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0112.hostedemail.com [216.40.44.112]) by kanga.kvack.org (Postfix) with ESMTP id E8B766B0078 for ; Fri, 11 Feb 2022 05:29:53 -0500 (EST) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8C03C8249980 for ; Fri, 11 Feb 2022 10:29:53 +0000 (UTC) X-FDA: 79130128266.31.0085614 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf22.hostedemail.com (Postfix) with ESMTP id D0DFFC0004 for ; Fri, 11 Feb 2022 10:29:52 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 412C921128; Fri, 11 Feb 2022 10:29:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1644575391; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GW7hPp8S196ICKXiVx/9snE9bFc+0wtN2XNyXb5NVwk=; b=x6FCekV0/pdOfIhIB0TMRFA1MHk138uXkTCmK6U2a5LW8ag27HpEf6GcKG9oF3sAL4k+Bv 7SNhcZg+t+G14dd8k/iHjB8tFa4ZgPBZFuvG5x+cEJyYen7PbKwAdYmBWU0ORp1Re9Q63U t+hSL3u5UnV+CPHmBeZhz09WI4IJuxo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1644575391; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GW7hPp8S196ICKXiVx/9snE9bFc+0wtN2XNyXb5NVwk=; b=euZCpMrbeYkxcGwbG2R9UA4Z+LKEJIqMjR/Jic1ODwVeJCqhZWTWcoWMcvWCo1bTsLyqIa GkswS8s6WLwZfLAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 07F8D13BD9; Fri, 11 Feb 2022 10:29:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id zBwjAZ86BmKHMQAAMHmgww (envelope-from ); Fri, 11 Feb 2022 10:29:51 +0000 Message-ID: Date: Fri, 11 Feb 2022 11:29:50 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH 04/13] mm/munlock: rmap call mlock_vma_page() munlock_vma_page() Content-Language: en-US To: Hugh Dickins , Andrew Morton Cc: Michal Hocko , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Alistair Popple , Johannes Weiner , Rik van Riel , Suren Baghdasaryan , Yu Zhao , Greg Thelen , Shakeel Butt , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <8e4356d-9622-a7f0-b2c-f116b5f2efea@google.com> <9f9ca113-ffb9-498e-4bd6-6bfeaaa10b7@google.com> From: Vlastimil Babka In-Reply-To: <9f9ca113-ffb9-498e-4bd6-6bfeaaa10b7@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: D0DFFC0004 X-Stat-Signature: o3qaxgztx317mfgq93hxtao6pxjs8i4n X-Rspam-User: Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=x6FCekV0; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=euZCpMrb; spf=pass (imf22.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none X-HE-Tag: 1644575392-583663 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 2/6/22 22:36, 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. > > Add vma arg to page_add_file_rmap() and page_remove_rmap(), like the > others, and use that to call mlock_vma_page() at the end of the page > adds, and munlock_vma_page() at the end of page_remove_rmap() (end or > beginning? unimportant, but end was easier for assertions in testing). > > No page lock is required (although almost all adds happen to hold it): > delete the "Serialize with page migration" BUG_ON(!PageLocked(page))s. > Certainly page lock did serialize with page migration, but I'm having > difficulty explaining why that was ever important. > > 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. > > page_add_new_anon_rmap() callers unchanged: they have long been calling > lru_cache_add_inactive_or_unevictable(), which does its own VM_LOCKED > handling (it also checks for not VM_SPECIAL: I think that's overcautious, > and inconsistent with other checks, that mmap_region() already prevents > VM_LOCKED on VM_SPECIAL; but haven't quite convinced myself to change it). > > Signed-off-by: Hugh Dickins Yeah, much better when most of the sites are encapsulated in rmap operations like this. Acked-by: Vlastimil Babka