Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5531708pxb; Mon, 14 Feb 2022 01:01:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+vIWueXD+aBwrbvGnN0niFytWkadsnq2joZtMzg8Xo7d3xZZksU6B3ei9lnP5BAaiRopL X-Received: by 2002:a05:6a00:88e:: with SMTP id q14mr13462440pfj.47.1644829295623; Mon, 14 Feb 2022 01:01:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644829295; cv=none; d=google.com; s=arc-20160816; b=yV3/SLDHZ5sHIuEsAw1a26oTf9i1V9h6RlqxZF4MIoKmfWoQWmqaF+9kgRjZmrLogM JvBqy2k0Nti6G/mziKfhoy+IRAD7oncZCt/LHgL6mtod9rBrUxD2UyiIe44vcS490Nht TLjjMeT9QZnYLHN2a9A6VSUR9+R7xaAQft5pe9Dd03KBYkXJFx+GoFQ9JB3s0UsTgrCp qw68rNJXeosi+JVHCMWGyx8f7ERlsaL1Z+CFrd4DVyLJD1wTit6q2pcsHLtylOgKtraJ u/X90dkU6ORuN7K8JVSMgrearrYliQGb1h8oRpMP7WnH6eXOOaQCxSP/7wrkBvVVzaH6 fX2A== 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=lagKek43O/qlYtO4egbfLmplkVBaMU559cGMwzFezxo=; b=ikQc01+ux8vX/M7eaz6b6613c79iNhFth4hl+9654Jo5o5xthSandn0BjMACqKQsw7 Ujm4GSBDY2O4LHMCZHN8NLQ70TqE9PKkxFp6XW6lMCqk5Evupx7HKFBwX6gR0DwqfXB/ XD88uKaCOyJvvcj+iam866bbNWqqaViDsOGTi4ijDJTwfXGePIgcWoi8ZXaGhEU6X6Sh uW3KFGwxT2voeCbRGdBbksWitUDDBv7kUIz2fJSHT65plg/rDZ9JfSeVyHjiF0Q80+1u brhfzPPreDb2S6oClGf8m85FQ3aEDC7Lp/ChvEfvx6AuOzDxSsffyTUf2gt2BRdInI1f GIHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=K2BX9sNS; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=KTQc5p58; 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 b4si6098854pjw.99.2022.02.14.01.01.21; Mon, 14 Feb 2022 01:01:35 -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=K2BX9sNS; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=KTQc5p58; 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 S1352655AbiBKS0q (ORCPT + 93 others); Fri, 11 Feb 2022 13:26:46 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:37842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351978AbiBKS0o (ORCPT ); Fri, 11 Feb 2022 13:26:44 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7362A196 for ; Fri, 11 Feb 2022 10:26:42 -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-out2.suse.de (Postfix) with ESMTPS id 292341F3A8; Fri, 11 Feb 2022 18:26:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1644604001; 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=lagKek43O/qlYtO4egbfLmplkVBaMU559cGMwzFezxo=; b=K2BX9sNSDjEWvAhU0x5qHgKPtI+KVUPLVavnf8/L/YHsPtXCtzqGjOVvbTjjJKJ+GuEnfB 5+Gf651FgODORs5XHOhZarftbYzk0C8wdhBfe12w1McvstvCUMNOs6aC2ZgY/N7E3EVZX8 k4M44X3assACkkUXkQrBIyg9lPmi0IM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1644604001; 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=lagKek43O/qlYtO4egbfLmplkVBaMU559cGMwzFezxo=; b=KTQc5p58rG+TvkAyrmsRVSVOg6xbHTtJXRQyYs1EK7uTfiYIrNczq97jvoYa4oiiFrPFnh d1aP+yYUh7Omf0AA== 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 D79F613CA5; Fri, 11 Feb 2022 18:26:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id WZsCNGCqBmJrIAAAMHmgww (envelope-from ); Fri, 11 Feb 2022 18:26:40 +0000 Message-ID: <64fd7f7d-f797-fa3a-303b-cf36c1a62820@suse.cz> Date: Fri, 11 Feb 2022 19:26:40 +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 10/13] mm/munlock: mlock_page() munlock_page() batch by pagevec 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> From: Vlastimil Babka In-Reply-To: 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:47, Hugh Dickins wrote: > A weakness of the page->mlock_count approach is the need for lruvec lock > while holding page table lock. That is not an overhead we would allow on > normal pages, but I think acceptable just for pages in an mlocked area. > But let's try to amortize the extra cost by gathering on per-cpu pagevec > before acquiring the lruvec lock. > > I have an unverified conjecture that the mlock pagevec might work out > well for delaying the mlock processing of new file pages until they have > got off lru_cache_add()'s pagevec and on to LRU. > > The initialization of page->mlock_count is subject to races and awkward: > 0 or !!PageMlocked or 1? Was it wrong even in the implementation before > this commit, which just widens the window? I haven't gone back to think > it through. Maybe someone can point out a better way to initialize it. Not me, it seems. > Bringing lru_cache_add_inactive_or_unevictable()'s mlock initialization > into mm/mlock.c has helped: mlock_new_page(), using the mlock pagevec, > rather than lru_cache_add()'s pagevec. > > Experimented with various orderings: the right thing seems to be for > mlock_page() and mlock_new_page() to TestSetPageMlocked before adding to > pagevec, but munlock_page() to leave TestClearPageMlocked to the later > pagevec processing. > > Dropped the VM_BUG_ON_PAGE(PageTail)s this time around: they have made > their point, and the thp_nr_page()s already contain a VM_BUG_ON_PGFLAGS() > for that. > > This still leaves acquiring lruvec locks under page table lock each time > the pagevec fills (or a THP is added): which I suppose is rather silly, > since they sit on pagevec waiting to be processed long after page table > lock has been dropped; but I'm disinclined to uglify the calling sequence > until some load shows an actual problem with it (nothing wrong with > taking lruvec lock under page table lock, just "nicer" to do it less). > > Signed-off-by: Hugh Dickins Acked-by: Vlastimil Babka