From nobody Wed Dec 31 00:37:37 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5064C4167D for ; Mon, 13 Nov 2023 23:52:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231942AbjKMXpV (ORCPT ); Mon, 13 Nov 2023 18:45:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231370AbjKMXpQ (ORCPT ); Mon, 13 Nov 2023 18:45:16 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5C258F for ; Mon, 13 Nov 2023 15:44:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699919088; 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=gY2+4zPDrtW6sgBm9w9yN1Kn08GlMkvW+YDfo59mwxrmXIsCpSlccM6/qHaukSNNnEovkY 7Y3S3nQXHuIXIxSek4FqLHPFUU87zStHR9ZCNf+7NBfiRaVm+P/7tN+ZvW4lHYIBoMJep6 Q+dVUw5qCj5DMgiiec0RMA1lmYlQJ04= 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- linux.orig/mm/vmstat.c +++ linux/mm/vmstat.c @@ -1031,6 +1031,34 @@ unsigned long node_page_state(struct pgl =20 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 =3D atomic_long_read(&pgdat->vm_stat[item]); +#ifdef CONFIG_SMP + int cpu; + + for_each_online_cpu(cpu) + x +=3D per_cpu_ptr(pgdat->per_cpu_nodestats, cpu)->vm_node_stat_diff[ite= m]; + + if (x < 0) + x =3D 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 =20 #ifdef CONFIG_COMPACTION Index: linux/include/linux/vmstat.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 *pg= dat, + 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)