Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp4009025pxb; Fri, 11 Feb 2022 12:51:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXnrNXCPqSU3dCXN+VeeF/UEovFzo97tykVfa5aLsmL97bhM1izyMs4IMhM6uSD9fRIRmq X-Received: by 2002:aa7:92cd:: with SMTP id k13mr3417073pfa.46.1644612678305; Fri, 11 Feb 2022 12:51:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644612678; cv=none; d=google.com; s=arc-20160816; b=F+006g/vlOK1sEsnmrdueCyH1qVicojbXXgj223aJ0gwBm8sgI2WwH0le5LMyiyw00 HQnO+UaT0FWJabi0s0SXVpRZGTbU819Cery1F2D48dm9TgQfisv5zSVlwZXPXmOLqvL9 OpuUL461zYmS9Il+HKQmN/5Y2LZL9skfS1rZ9LqoZ4qA0Eu4pi1wNytB2h7iG0mcW4lH M4ro+2xWPu7Cp9FfME+PNboX61aezDILSWzcCImjfaYmzdIjHi/8oJKvCBijDNNCV7vk MYms/15JvafNQbYE2sQ3d6OHt3Ev+pg+k5cc1EbKKGD1SfzFzhAaSoFAVhZSOposURvh rkPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=tQFbjKgXBQhPR1Tis7coIjTSRK1bvjGaqsCPLGRRs2w=; b=qcS+RrkTz+3krRZSTZTnVU6kiJGY7mRyfosE36GAWA2tiJTFOifAl/PgC/PiLFEdEM 5iQLGGK2urtS83hiwdsgCUH5SRWnZZ7Xkj5tbVNTIkW9F0iOFsPkafAvMBnSbie22Krd Q89Rc/EWb6V1AEt9U+5SBEbB+OvC8R6go/Sg7w+BSMAIweaMLNtRb1EhTNTDWjKankjV VhuPWrifPGd6tDCF7QguWLN2d7oDSZ5XYrjdpxn9OtpHHCi+/I1ew3cK2Zma3yxn9PtT TKAE4BU/T0ewWJEzBWFrF/qF27DKGiz5CbAOd41tnuNy2+LTRuKbFl7Jgd7N6eD2Yqk/ Ia4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=ajC8L4bj; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 d12si22927742pfl.206.2022.02.11.12.51.04; Fri, 11 Feb 2022 12:51:18 -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=@suse.cz header.s=susede2_rsa header.b=ajC8L4bj; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 S1349539AbiBKLmO (ORCPT + 99 others); Fri, 11 Feb 2022 06:42:14 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232547AbiBKLmN (ORCPT ); Fri, 11 Feb 2022 06:42:13 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FA7BE9B for ; Fri, 11 Feb 2022 03:42:12 -0800 (PST) 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-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS,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 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