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 C7F56C433F5 for ; Fri, 11 Feb 2022 11:42:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B8CFF6B0078; Fri, 11 Feb 2022 06:42:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B3C2B6B007B; Fri, 11 Feb 2022 06:42:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A044C6B007D; Fri, 11 Feb 2022 06:42:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0080.hostedemail.com [216.40.44.80]) by kanga.kvack.org (Postfix) with ESMTP id 92EE36B0078 for ; Fri, 11 Feb 2022 06:42:13 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 3D6608249980 for ; Fri, 11 Feb 2022 11:42:13 +0000 (UTC) X-FDA: 79130310546.16.BBBD238 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf20.hostedemail.com (Postfix) with ESMTP id 9A1791C0008 for ; Fri, 11 Feb 2022 11:42:12 +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 EFA9221128; Fri, 11 Feb 2022 11:42:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1644579730; 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=tQFbjKgXBQhPR1Tis7coIjTSRK1bvjGaqsCPLGRRs2w=; b=ajC8L4bjMIOFXlm633Vg06ax2yH6r+JQjoEQd38cJrC2URPQY/LL1fv1igh+7mER1s5Xa8 a6Qx1kGcPad31jSeUapRmGo5Z0Op9ZnjubZ/tz07gnmSxQZmZyD7MBcTPadTEkfdaCF0lU RObcoBY54sstDi4i8iovXUPfcjAhfAg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1644579730; 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=tQFbjKgXBQhPR1Tis7coIjTSRK1bvjGaqsCPLGRRs2w=; b=pp55ioSBqvxbC9xkV/TpcKn6H7qtt01rU1bsZiLcWq+5deuq7VEjei0hABqJgfdSVbAuGJ B11kefL2UMPzuNDQ== 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 C04FF13C03; Fri, 11 Feb 2022 11:42:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MC0+LpJLBmJ2VgAAMHmgww (envelope-from ); Fri, 11 Feb 2022 11:42:10 +0000 Message-ID: Date: Fri, 11 Feb 2022 12:42:10 +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 05/13] mm/munlock: replace clear_page_mlock() by final clearance 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> <652a918-8a11-c1e9-a760-854873841bc@google.com> From: Vlastimil Babka In-Reply-To: <652a918-8a11-c1e9-a760-854873841bc@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 9A1791C0008 X-Stat-Signature: k4ac51oqr7yia3jxyi9spendcsh53nky X-Rspam-User: Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=ajC8L4bj; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=pp55ioSB; spf=pass (imf20.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: 1644579732-22736 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:38, Hugh Dickins wrote: > Placing munlock_vma_page() at the end of page_remove_rmap() shifts most > of the munlocking to clear_page_mlock(), since PageMlocked is typically > still set when mapcount has fallen to 0. That is not what we want: we > want /proc/vmstat's unevictable_pgs_cleared to remain as a useful check > on the integrity of of the mlock/munlock protocol - small numbers are > not surprising, but big numbers mean the protocol is not working. > > That could be easily fixed by placing munlock_vma_page() at the start of > page_remove_rmap(); but later in the series we shall want to batch the > munlocking, and that too would tend to leave PageMlocked still set at > the point when it is checked. > > So delete clear_page_mlock() now: leave it instead to release_pages() > (and __page_cache_release()) to do this backstop clearing of Mlocked, > when page refcount has fallen to 0. If a pinned page occasionally gets > counted as Mlocked and Unevictable until it is unpinned, that's okay. > > A slightly regrettable side-effect of this change is that, since > release_pages() and __page_cache_release() may be called at interrupt > time, those places which update NR_MLOCK with interrupts enabled > had better use mod_zone_page_state() than __mod_zone_page_state() > (but holding the lruvec lock always has interrupts disabled). > > This change, forcing Mlocked off when refcount 0 instead of earlier > when mapcount 0, is not fundamental: it can be reversed if performance > or something else is found to suffer; but this is the easiest way to > separate the stats - let's not complicate that without good reason. > > Signed-off-by: Hugh Dickins Acked-by: Vlastimil Babka