From patchwork Mon Nov 13 23:34:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13454611 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 90E6BC4167D for ; Mon, 13 Nov 2023 23:44:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B77A26B0207; Mon, 13 Nov 2023 18:44:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AD7F26B028F; Mon, 13 Nov 2023 18:44:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 951356B0290; Mon, 13 Nov 2023 18:44:50 -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 7E8626B0207 for ; Mon, 13 Nov 2023 18:44:50 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 49810809CD for ; Mon, 13 Nov 2023 23:44:50 +0000 (UTC) X-FDA: 81454563540.09.106F1F8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 8AF141A0014 for ; Mon, 13 Nov 2023 23:44:48 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="ME51gA/E"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699919088; 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: references:references:dkim-signature; bh=MWLskBwSdWDZ41yFDXxOzxCovYMtUiIkublLbv2soJQ=; b=s9QWVFMgg9xsBBWNP1kpfu+QpnsTjERZgTsvCVMT+WFj2rNh+r3okLWwZxYUEMF6tCYjTY U7o/3x0bayKePh3FNDbtXvyuKFeGRnKoL/bAhexrSg4nrbEwYKLQswnd0368Ve+JQdeOms ePg9eaMpGuG+ahSVvjs9i2C6DLrjYL8= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="ME51gA/E"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699919088; a=rsa-sha256; cv=none; b=YMweC4Bl9kA75UQ2Uc/7HDQOxYjGfcvd00pJIB+19TFzBcYLnqKd9s6gDKaiaPWrOs4/sf ktszbTpqzk0Tuvtt/IDRqaU5lj4XEAXbP5xx/VtlNG7RV4vwokhXJzlzrt9GJEHn2yW4WI SeWNfzHp90RahwPVoWcvY4ceYlEpqw0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699919087; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=MWLskBwSdWDZ41yFDXxOzxCovYMtUiIkublLbv2soJQ=; b=ME51gA/EONpCMLNG5YGyuZLGAxoWAvb7UUeVWKSb3bg4BRMYjdPsRlQpYM1TXzFMFbMII0 Z5ybHbz2WiRmPoRwwieoNftQXjWtz5L4HhYZqb1cFTocIra1xgGiQnATaOzWjGcYStX/bF qyOlyER8r20H3Y7RD97MCdz6u506TmE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-154-HezSOEpmMgCumBzIQGPfFQ-1; Mon, 13 Nov 2023 18:44:44 -0500 X-MC-Unique: HezSOEpmMgCumBzIQGPfFQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1261C810FC0; Mon, 13 Nov 2023 23:44:42 +0000 (UTC) Received: from tpad.localdomain (ovpn-112-2.gru2.redhat.com [10.97.112.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CC5882166B26; Mon, 13 Nov 2023 23:44:41 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 2C3E9409B6035; Mon, 13 Nov 2023 20:35:57 -0300 (-03) Message-ID: <20231113233502.563575851@redhat.com> User-Agent: quilt/0.67 Date: Mon, 13 Nov 2023 20:34:21 -0300 From: Marcelo Tosatti To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Michal Hocko , Vlastimil Babka , Andrew Morton , David Hildenbrand , Peter Xu , Marcelo Tosatti Subject: [patch 1/2] mm: vmstat: introduce node_page_state_pages_snapshot References: <20231113233420.446465795@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Rspam-User: X-Stat-Signature: qcd97z7dh8seryg9gpt771jxqs55u8m7 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 8AF141A0014 X-HE-Tag: 1699919088-358518 X-HE-Meta: U2FsdGVkX18F7Rjuav/0toyyUUD/xJrQW+PXreHJp798FsFKIzRg1JknvQu3G7VRGLGu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5vy7Zmeua7kOxclGG0OEuwnjhPwk/ywV1MK6oGgUjgDCDeN4SbT4cUp130xVeMNRnVkcfU 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: List-Subscribe: List-Unsubscribe: Introduce a _snapshot variant of node_page_state_snapshot, similar to zone_page_state_snapshot. To be used by next patch. Signed-off-by: Marcelo Tosatti --- include/linux/vmstat.h | 4 ++++ mm/vmstat.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) Index: linux/mm/vmstat.c =================================================================== --- linux.orig/mm/vmstat.c +++ linux/mm/vmstat.c @@ -1031,6 +1031,34 @@ unsigned long node_page_state(struct pgl return node_page_state_pages(pgdat, item); } + +/* + * Determine the per node value of a stat item, snapshot version + * (see comment on top zone_page_state_snapshot). + */ +unsigned long node_page_state_pages_snapshot(struct pglist_data *pgdat, + enum node_stat_item item) +{ + long x = atomic_long_read(&pgdat->vm_stat[item]); +#ifdef CONFIG_SMP + int cpu; + + for_each_online_cpu(cpu) + x += per_cpu_ptr(pgdat->per_cpu_nodestats, cpu)->vm_node_stat_diff[item]; + + if (x < 0) + x = 0; +#endif + return x; +} + +unsigned long node_page_state_snapshot(struct pglist_data *pgdat, + enum node_stat_item item) +{ + VM_WARN_ON_ONCE(vmstat_item_in_bytes(item)); + + return node_page_state_pages(pgdat, item); +} #endif #ifdef CONFIG_COMPACTION Index: linux/include/linux/vmstat.h =================================================================== --- linux.orig/include/linux/vmstat.h +++ linux/include/linux/vmstat.h @@ -262,6 +262,10 @@ extern unsigned long node_page_state(str enum node_stat_item item); extern unsigned long node_page_state_pages(struct pglist_data *pgdat, enum node_stat_item item); +extern unsigned long node_page_state_snapshot(struct pglist_data *pgdat, + enum node_stat_item item); +extern unsigned long node_page_state_pages_snapshot(struct pglist_data *pgdat, + enum node_stat_item item); extern void fold_vm_numa_events(void); #else #define sum_zone_node_page_state(node, item) global_zone_page_state(item)