From: Petr Vorel <pvorel@suse.cz>
To: Shirisha G <shirisha@linux.ibm.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] Add hugemmap41(Migrating the libhugetlbfs/testcases/slbpacaflush.c test)
Date: Mon, 19 Feb 2024 23:18:11 +0100 [thread overview]
Message-ID: <20240219221811.GC1067220@pevik> (raw)
In-Reply-To: <20231213084753.61762-1-shirisha@linux.ibm.com>
Hi Shirisha,
> +void check_online_cpus(int online_cpus[], int nr_cpus_needed)
> +{
> + char cpu_state, path_buf[64];
> + int total_cpus, cpu_idx, fd, ret, i;
> +
> + total_cpus = get_nprocs_conf();
> + cpu_idx = 0;
> +
> + if (get_nprocs() < nr_cpus_needed)
> + tst_res(TFAIL, "Atleast online %d cpus are required", nr_cpus_needed);
s/Atleast/At least/
(or better: "minimum %d online cpus" ..., but I'm not a native speaker.)
Also test should exit when not enough online CPU, right? (it's a test
requirement not a subject of testing). Therefore tst_brk(TCONF, ...) should be
used instead of tst_res(TFAIL).
And shouldn't this be a setup function (i.e. run only once, before test starts -
test itself can be run more times, eg 3x with -i3).
> +
> + for (i = 0; i < total_cpus && cpu_idx < nr_cpus_needed; i++) {
> + errno = 0;
> + sprintf(path_buf, SYSFS_CPU_ONLINE_FMT, i);
> + fd = open(path_buf, O_RDONLY);
> + if (fd < 0) {
> + /* If 'online' is absent, the cpu cannot be offlined */
> + if (errno == ENOENT) {
> + online_cpus[cpu_idx] = i;
> + cpu_idx++;
> + continue;
> + } else {
> + tst_res(TFAIL, "Unable to open %s: %s", path_buf,
> + strerror(errno));
> + }
> + }
> +
> + ret = read(fd, &cpu_state, 1);
> + if (ret < 1)
> + tst_res(TFAIL, "Unable to read %s: %s", path_buf,
> + strerror(errno));
> +
> + if (cpu_state == '1') {
> + online_cpus[cpu_idx] = i;
> + cpu_idx++;
> + }
> +
> + if (fd >= 0)
> + SAFE_CLOSE(fd);
> + }
> +
> + if (cpu_idx < nr_cpus_needed)
> + tst_res(TFAIL, "Atleast %d online cpus were not found", nr_cpus_needed);
Also here tst_brk(TCONF, ...)
> +}
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2024-02-19 22:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-13 8:47 [LTP] [PATCH] Add hugemmap41(Migrating the libhugetlbfs/testcases/slbpacaflush.c test) Shirisha G
2024-02-19 22:10 ` Petr Vorel
2024-04-16 8:30 ` Shirisha ganta
2024-02-19 22:18 ` Petr Vorel [this message]
2024-04-16 8:11 ` Shirisha ganta
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=20240219221811.GC1067220@pevik \
--to=pvorel@suse.cz \
--cc=ltp@lists.linux.it \
--cc=shirisha@linux.ibm.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