From: David Rientjes <rientjes@google.com>
To: Usama Arif <usama.arif@linux.dev>
Cc: Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>,
Christoph Lameter <cl@gentwo.org>,
Vlastimil Babka <vbabka@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [patch 1/3] lib: test_vmstat: add synthetic benchmark for vm stats
Date: Sun, 2 Aug 2026 16:05:22 -0700 (PDT) [thread overview]
Message-ID: <a81c8e4f-d9d1-18ba-cdcd-73ce68df9f8a@google.com> (raw)
In-Reply-To: <20260801132038.2926647-1-usama.arif@linux.dev>
On Sat, 1 Aug 2026, Usama Arif wrote:
> > diff --git a/lib/test_vmstat.c b/lib/test_vmstat.c
> > new file mode 100644
> > index 000000000000..f63f439ab9d2
> > --- /dev/null
> > +++ b/lib/test_vmstat.c
> > @@ -0,0 +1,95 @@
> > +// SPDX-License-Identifier: GPL-2.0-or-later
> > +/*
> > + * Test module for in-kernel synthetic vm statistics performance.
> > + *
> > + * execute
> > + *
> > + * modprobe test_vmstat
> > + *
> > + * to run this test
> > + *
> > + * (C) 2009 Linux Foundation, Christoph Lameter <cl@gentwo.org>
> > + */
> > +
> > +#include <linux/jiffies.h>
> > +#include <linux/compiler.h>
> > +#include <linux/init.h>
> > +#include <linux/module.h>
> > +#include <linux/mm.h>
> > +#include <asm/timex.h>
> > +
> > +#define TEST_COUNT 10000
> > +
> > +static int vmstat_test_init(void)
> > +{
> > + unsigned int i;
> > + cycles_t time1, time2, time;
> > + int rem;
> > + struct page *page = alloc_page(GFP_KERNEL);
> > +
>
> Good to check page != NULL before using it below.
>
> > + pr_alert("VMstat testing\n");
> > + pr_alert("=====================\n");
> > + pr_alert("1. inc_zone_page_state() then dec_zone_page_state()\n");
> > + time1 = get_cycles();
> > + for (i = 0; i < TEST_COUNT; i++)
> > + inc_zone_page_state(page, NR_FREE_CMA_PAGES);
> > +
> > + time2 = get_cycles();
> > + time = time2 - time1;
> > +
> > + pr_alert("%i times inc_zone_page_state() ", i);
> > + time = div_u64_rem(time, TEST_COUNT, &rem);
> > + pr_cont("-> %llu cycles ", (unsigned long long) time);
> > +
> > + time1 = get_cycles();
> > + for (i = 0; i < TEST_COUNT; i++)
> > + __dec_zone_page_state(page, NR_FREE_CMA_PAGES);
>
> Why use inc_zone_page_state() but the __ variant for decrement?
>
> Checking the 2 functions, __dec_zone_page_state() might cause
> problems if preemption is enabled?
>
Fixed both, thanks!
next prev parent reply other threads:[~2026-08-02 23:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 4:26 [patch 0/3] lib: add synthetic MM benchmarks David Rientjes
2026-07-31 4:26 ` [patch 1/3] lib: test_vmstat: add synthetic benchmark for vm stats David Rientjes
2026-08-01 13:20 ` Usama Arif
2026-08-02 23:05 ` David Rientjes [this message]
2026-08-02 23:06 ` [patch v2] " David Rientjes
2026-07-31 4:26 ` [patch 2/3] lib: test_slab: add synthetic benchmark for slab David Rientjes
2026-07-31 4:27 ` [patch 3/3] lib: test_pagealloc: add synthetic benchmark for page allocator David Rientjes
2026-07-31 9:00 ` [patch 0/3] lib: add synthetic MM benchmarks David Hildenbrand (Arm)
2026-08-02 22:19 ` David Rientjes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a81c8e4f-d9d1-18ba-cdcd-73ce68df9f8a@google.com \
--to=rientjes@google.com \
--cc=akpm@linux-foundation.org \
--cc=cl@gentwo.org \
--cc=david@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=usama.arif@linux.dev \
--cc=vbabka@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.