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 E1A5CC54E94 for ; Thu, 26 Jan 2023 08:51:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 500A86B0071; Thu, 26 Jan 2023 03:51:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 48A4D6B0072; Thu, 26 Jan 2023 03:51:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2DD3E6B0073; Thu, 26 Jan 2023 03:51:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 18F196B0071 for ; Thu, 26 Jan 2023 03:51:43 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id EABFA1C5CFB for ; Thu, 26 Jan 2023 08:51:42 +0000 (UTC) X-FDA: 80396332044.13.8276989 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf19.hostedemail.com (Postfix) with ESMTP id 20D191A000F for ; Thu, 26 Jan 2023 08:51:40 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b="Q8VEQb/Y"; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf19.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674723101; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zhUKCEK410sVcblH9sTdY8t3/h5I9I8XF7De6bKLRfE=; b=vBaWw2efgaNY0g/2UL5MbSN9PQXyJX4Kn8/QzH061tENcD+Ao/yndbQe0n0x/m1Jh/unXM NMq+uEMv04orgYQ6abGV8laa3bkBWB1n8bDV73NMlsL0TYMCEv0qJSoVUiFa+dF0/q47wl +EtY0FoQeNRvZhLaKZQ5XZwgFzxvFgk= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b="Q8VEQb/Y"; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf19.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674723101; a=rsa-sha256; cv=none; b=jMKSokpXOWYc03Wu/2I4scmi3FhiGAFFVEIJyTfyz+4G8MvOsGNyf8BqHMSh4WRIwu7j/X c9pdp3QX4RbiJBrjSsiuxgBKfk62lVU21rLRhqzLinqNAQoCF8XJuMBvAjsEAZlVOAgrp3 ZGOS0LIgRaqSRJvRBRhx060TMc8KSng= 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 D869321B2B; Thu, 26 Jan 2023 08:51:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1674723099; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zhUKCEK410sVcblH9sTdY8t3/h5I9I8XF7De6bKLRfE=; b=Q8VEQb/Y0zSRA4hZPXDEYtdUxu+Pi/6wg24mVu7usqgL+xGcOXeXmv65m5qM9QL1OvzEUk 7kIXlSt5NFZcoV6qUlwn4LHTo18uRV/j2o3vlu3vnJAZBI9ttnWU2zyxUYH/S5fIil7p1l 8wcoVyKnGjk4GOFfHTyjJsHXUY0Rja0= 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 B966A139B3; Thu, 26 Jan 2023 08:51:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mbRmKhs/0mNzRAAAMHmgww (envelope-from ); Thu, 26 Jan 2023 08:51:39 +0000 Date: Thu, 26 Jan 2023 09:51:39 +0100 From: Michal Hocko To: Minchan Kim Cc: Andrew Morton , Suren Baghdasaryan , Matthew Wilcox , linux-mm , LKML Subject: Re: [PATCH v2] mm/madvise: add vmstat statistics for madvise_[cold|pageout] Message-ID: References: <20230125005457.4139289-1-minchan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 20D191A000F X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: 4rtaa5fnyfzgrc8pxmpxjbzwghusk1cb X-HE-Tag: 1674723100-461438 X-HE-Meta: U2FsdGVkX1/y19AshjmWpMNI7/he6wbXmvHy4olRVJ5vb96SbblzzagqVxoJFyucOO3ZowPmuryhZvi4Jbpc75NYG2o/Qo756cA/2nuh6iikTb9TCdi5srWyogDppvLjOZcsWlRcRUgbpdyFI5OYUgJkkVvQKQx+vA3DryadSD34jJfJG1IkfsPyhQBT0xakaKL1S5ExN9umcl42GEomkjFVSrEr5wN9Sq8VUqeudah+0q6FC/kmDkaHt/PSwXhH3ADz1D5x5Ynj6GKwQsXs6MOzqbfbwysPoUfekaqeCNmuNyVlTLHTufqCQYFfr1iPuF+ms5GhJfuB7Ab/A2PjgfOEbRVgum0Sq3ykRbtWRpFfoEoCTLtVvetYTu5e3rr3UO9mkSYAIqrKkp8XycGZSxpXyCu8QLmmnCxaDUmzMN2ueue0LT0DeIniuCfAtMW4IfjiQBrZUl3FYsqZ+Iie5DxYYDg51UCv/cUXVQ6KtY7opmzJOyXbcqoB4xXqSE3OKG6yoOOgKqtbBHLdCau7WmfMvqRagnIZ0NS+QwQcxgv3haHOPqTNHiyoP9XoExXE0Ty3gBSrg86eC4ZRDswq09JPE8WpkDgcI7N4SXG6ApefesxVEQekHRPV/tIoeXtdFo2pPIKWsBDPxgT/i4z8WVu/ChGy7Gieb0kqK/hVRXfTyqJVt6i03ToTMmkfqpwKs/G8CGiaRjqH+VKxzf7sgKn9NENmboG7Q5Vw0rrGnH6TLfIGMxrRP21zIcACENvd0uwwdxJ0kCHbNwPFa+p/MJP8igM1XlzvSjQFcfHX2v+8ktv+Qe7O6QR8OcHVcGZa3tnFlyq8f3bvTGUYfk5+COJJVZE8MJmdxjCO/wE6C1Ch+82OVPmcscgIWk+3G2dfwRk63SoDW7x0Wily6OUBeQoyh3QeJQedZiOLP2qPcrGh1BOGUZvt2CA3mcWUfJfdCt/UuSiOaTcUU2zUBGQ XqjZBJqZ nZywF0RCF6sLk89+9BKkI7wW0DDeebpsWC1Sv3d3snhiOrrcWtlYW6UHY6KgWCTIbq0ICZiFj16dPhDFBhPrWyxx/GP/ZFDbG7MDTofshKxLenwc937+ojGeMs3Yj6qaglerLk+92xvOWDYKX8X+yGF5qG9OS01cgzPGgSBUlrTubk9KWued8SOnnZAoxAQxNreaentuCyiyRhIlKsK5VuGy8AQ== 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 Thu 26-01-23 09:50:38, Michal Hocko wrote: > On Wed 25-01-23 14:21:35, Minchan Kim wrote: > > On Wed, Jan 25, 2023 at 10:37:59PM +0100, Michal Hocko wrote: > > > On Wed 25-01-23 10:07:49, Minchan Kim wrote: > > > > On Wed, Jan 25, 2023 at 06:07:00PM +0100, Michal Hocko wrote: > > > > > On Wed 25-01-23 08:36:02, Minchan Kim wrote: > > > > > > On Wed, Jan 25, 2023 at 09:04:16AM +0100, Michal Hocko wrote: > > > > > > > On Tue 24-01-23 16:54:57, Minchan Kim wrote: > > > > > > > > madvise LRU manipulation APIs need to scan address ranges to find > > > > > > > > present pages at page table and provides advice hints for them. > > > > > > > > > > > > > > > > Likewise pg[scan/steal] count on vmstat, madvise_pg[scanned/hinted] > > > > > > > > shows the proactive reclaim efficiency so this patch adds those > > > > > > > > two statistics in vmstat. > > > > > > > > > > > > > > > > madvise_pgscanned, madvise_pghinted > > > > > > > > > > > > > > > > Since proactive reclaim using process_madvise(2) as userland > > > > > > > > memory policy is popular(e.g,. Android ActivityManagerService), > > > > > > > > those stats are helpful to know how efficiently the policy works > > > > > > > > well. > > > > > > > > > > > > > > The usecase description is still too vague. What are those values useful > > > > > > > for? Is there anything actionable based on those numbers? How do you > > > > > > > deal with multiple parties using madvise resp. process_madvise so that > > > > > > > their stats are combined? > > > > > > > > > > > > The metric helps monitoing system MM health under fleet and experimental > > > > > > tuning with diffrent policies from the centralized userland memory daemon. > > > > > > > > > > That is just too vague for me to imagine anything more specific then, we > > > > > have numbers and we can show them in a report. What does it actually > > > > > mean that madvise_pgscanned is high. Or that pghinted / pgscanned is > > > > > low (that you tend to manually reclaim sparse mappings)? > > > > > > > > If that's low, it means the userspace daemon's current tune/policy are > > > > inefficient or too aggressive since it is working on address spacess > > > > of processes which don't have enough memory the hint can work(e.g., > > > > shared addresses, cold address ranges or some special address ranges like > > > > VM_PFNMAP) so sometime, we can detect regression to find culprit or > > > > have a chance to look into better ideas to improve. > > > > > > Are you sure this is really meaningful metric? Just consider a large and > > > sparsely populated mapping. This can be a perfect candidate for user > > > space reclaim target (e.g. consider a mapping covering a large matrix > > > or other similar data structure). pghinted/pgscanned would be really > > > small while the reclaim efficiency could be quite high in that case, > > > wouldn't it? > > > > Why do you think it's efficient? It need to spend quite CPU cycle to > > scan a few of pages to evict. I don't see it's efficient if it happens > > quite a lot. > > Because it doesn't really matter how many page tables you have to scan > but how easily you can reclaim the memory behind that. Because it is the > memory that matters. Just consider THP vs. 4k backed address ranges. You > are going to scan much more for latter by design. That doesn't really > mean that this is a worse candidate for reclaim and you should be only > focusing on THP backed mappings. See? > > I suspect you try to mimic pgscan/pgsteal effectivness metric on the dang. I meant pgsteal/pgscan > address space but that is a fundamentally different thing. -- Michal Hocko SUSE Labs