From: Petr Vorel <pvorel@suse.cz>
To: Jan Stancek <jstancek@redhat.com>
Cc: Nirmoy Das <nirmoyd@nvidia.com>,
"ltp@lists.linux.it" <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH v2] getrusage03: account for percpu RSS counter batching
Date: Tue, 22 Sep 2026 19:36:58 +0200 [thread overview]
Message-ID: <20260922173658.GC2287170@pevik> (raw)
In-Reply-To: <CAASaF6y3QWQ--uJBWiizRC8AGo30TbzTWWXB=EameXje3diisA@mail.gmail.com>
Hi Nirmoy, Jan, all,
would you have time to look on this getrusage03 failure on aarch64?
I guess this one [1] is closer than the one from Jan [2].
I'm not sure if we have time to fix this before LTP release (I guess Cyril plans
it sometimes next week) but it'd be worth to fix it even after the release.
[1] https://patchwork.kernel.org/project/ltp/patch/20260902160113.1207205-1-nirmoyd@nvidia.com/
[2] https://patchwork.kernel.org/project/ltp/patch/a308e12198ce96305761a009858fa4a80c91f932.1788518850.git.jstancek@redhat.com/
Kind regards,
Petr
> On Wed, Sep 16, 2026 at 5:59 PM Nirmoy Das <nirmoyd@nvidia.com> wrote:
> > Hi Cyril,
> > I tested Jan’s patch on a machine with 352 online CPUs and 64 KiB pages. Pinning was confirmed, but both the
> > baseline and Jan’s patch failed 10/10 runs:
> > child.children = 270336, expected 307200
> > Pinning keeps the allocation updates on one CPU, but get_mm_counter()
> > still reads only the global count. One batch here is
> > max(32, 352 * 2) = 704 pages, or 45056 KiB. The 36864 KiB shortfall
> > fits within that batch but exceeds the existing 20480 KiB DELTA_MAX.
> > I also tested a small follow-up that increases only the lower allowance
> > for the 100, 300 and 400 MiB checks. It passed 10/10 runs, with all nine
> > subtests passing each time.
> > I will send this follow-up once Jan’s patch is merged.
> Based on your tests it does sound like it's an incomplete fix, so
> I'd suggest you modify it as you see fit, and send v2.
> Thanks,
> Jan
> > Regards,
> > Nirmoy
> > From: Cyril Hrubis <chrubis@suse.cz>
> > Date: Tuesday, 15. September 2026 at 17:29
> > To: Nirmoy Das <nirmoyd@nvidia.com>
> > Cc: ltp@lists.linux.it <ltp@lists.linux.it>; Jan Stancek <jstancek@redhat.com>
> > Subject: Re: [PATCH v2] getrusage03: account for percpu RSS counter batching
> > [You don't often get email from chrubis@suse.cz. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> > Hi!
> > > diff --git a/testcases/kernel/syscalls/getrusage/getrusage03.c b/testcases/kernel/syscalls/getrusage/getrusage03.c
> > > index a2cdd6158..38a100576 100644
> > > --- a/testcases/kernel/syscalls/getrusage/getrusage03.c
> > > +++ b/testcases/kernel/syscalls/getrusage/getrusage03.c
> > > @@ -13,9 +13,13 @@
> > > * this program.
> > > */
> > > +#define _GNU_SOURCE
> > > #include <stdlib.h>
> > > #include <stdio.h>
> > > +#include "lapi/cpuset.h"
> > > +#include "tst_safe_stdio.h"
> > > +#include "tst_cpu.h"
> > > #include "tst_test.h"
> > > #include "getrusage03.h"
> > > @@ -23,12 +27,99 @@
> > > static struct rusage ru;
> > > static long maxrss_init;
> > > +static long lower_allowance;
> > > static const char *const resource[] = {
> > > TESTBIN,
> > > NULL,
> > > };
> > > +static long count_online_cpus(void)
> > > +{
> > > + FILE *fp = SAFE_FOPEN("/proc/stat", "r");
> > > + char line[BUFSIZ];
> > > + long count = 0;
> > > +
> > > + while (fgets(line, sizeof(line), fp)) {
> > > + if (line[0] == 'c' && line[1] == 'p' && line[2] == 'u' &&
> > > + line[3] >= '0' && line[3] <= '9')
> > > + count++;
> > > + }
> > > +
> > > + if (ferror(fp))
> > > + tst_brk(TBROK | TERRNO, "fgets(/proc/stat)");
> > > +
> > > + SAFE_FCLOSE(fp);
> > > +
> > > + if (!count)
> > > + tst_brk(TBROK, "No online CPUs found in /proc/stat");
> > > +
> > > + return count;
> > > +}
> > > +
> > > +static void pin_to_cpu(void)
> > > +{
> > > + long ncpus = tst_ncpus_max();
> > > + size_t size = CPU_ALLOC_SIZE(ncpus);
> > > + cpu_set_t *mask = CPU_ALLOC(ncpus);
> > > + int cpu = -1;
> > > +
> > > + if (!mask)
> > > + tst_brk(TBROK | TERRNO, "CPU_ALLOC()");
> > > +
> > > + CPU_ZERO_S(size, mask);
> > > + if (sched_getaffinity(0, size, mask) < 0) {
> > > + CPU_FREE(mask);
> > > + tst_brk(TBROK | TERRNO, "sched_getaffinity()");
> > > + }
> > > +
> > > + for (long i = 0; i < ncpus; i++) {
> > > + if (CPU_ISSET_S((int)i, size, mask)) {
> > > + cpu = (int)i;
> > > + break;
> > > + }
> > > + }
> > > +
> > > + if (cpu < 0) {
> > > + CPU_FREE(mask);
> > > + tst_brk(TBROK, "sched_getaffinity() returned an empty CPU mask");
> > > + }
> > > +
> > > + CPU_ZERO_S(size, mask);
> > > + CPU_SET_S(cpu, size, mask);
> > > + if (sched_setaffinity(0, size, mask) < 0) {
> > > + CPU_FREE(mask);
> > > + tst_brk(TBROK | TERRNO, "sched_setaffinity()");
> > > + }
> > > +
> > > + CPU_FREE(mask);
> > > +}
> > > +
> > > +static void setup(void)
> > > +{
> > > + long online_cpus = count_online_cpus();
> > > + long batch = MAX(32L, online_cpus * 2);
> > > + long page_size = SAFE_SYSCONF(_SC_PAGESIZE);
> > > + long batch_kib = batch * page_size / 1024;
> > > +
> > > + lower_allowance = MAX(20 * 1024L, batch_kib);
> > > + if (lower_allowance >= 102400L)
> > > + tst_brk(TCONF, "Per-CPU RSS allowance is too large: %li KiB",
> > > + lower_allowance);
> > As long as we pin to a single CPU the whole batch accounting shouldn't
> > be needed.
> > FYI Jan send a similar patch that just pins the process to a single CPU:
> > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.kernel.org%2Fproject%2Fltp%2Fpatch%2Fa308e12198ce96305761a009858fa4a80c91f932.1788518850.git.jstancek%40redhat.com%2F&data=05%7C02%7Cnirmoyd%40nvidia.com%7C5c88fc4e5490430569b008df133e14f3%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C639250829531773556%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=qOkWQ7VsVwFS38S1zQgxue5eo8kNqUJ%2BEHl4rN80qIQ%3D&reserved=0
> > As far as I can tell that should be enough to fix the test.
> > --
> > Cyril Hrubis
> > chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-09-22 17:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 15:25 [LTP] [RFC PATCH] getrusage03: account for percpu RSS counter batching Nirmoy Das via ltp
2026-08-25 17:34 ` [LTP] " linuxtestproject.agent
2026-09-02 12:25 ` [LTP] [RFC PATCH] " Cyril Hrubis
2026-09-02 16:01 ` [LTP] [PATCH v2] " Nirmoy Das via ltp
2026-09-02 17:42 ` [LTP] " linuxtestproject.agent
2026-09-15 15:29 ` [LTP] [PATCH v2] " Cyril Hrubis
2026-09-16 15:58 ` Nirmoy Das via ltp
2026-09-17 12:36 ` Jan Stancek via ltp
2026-09-22 17:36 ` Petr Vorel [this message]
2026-10-01 18:55 ` Nirmoy Das via ltp
2026-09-24 11:26 ` Cyril Hrubis
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=20260922173658.GC2287170@pevik \
--to=pvorel@suse.cz \
--cc=jstancek@redhat.com \
--cc=ltp@lists.linux.it \
--cc=nirmoyd@nvidia.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox