From: Cyril Hrubis <chrubis@suse.cz>
To: Pengfei Xu <pengfei.xu@intel.com>
Cc: Heng Su <heng.su@intel.com>, rpalethorpe@suse.com, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1 1/1] libs: libltpnuma: Fix one fake failure when CXL(Compute eXpress Link) node memory is not used
Date: Tue, 9 May 2023 13:59:01 +0200 [thread overview]
Message-ID: <ZFo1hUZCCXbfhEXY@yuki> (raw)
In-Reply-To: <efa47acd652c93a54fb66e17183524b54e561533.1683274510.git.pengfei.xu@intel.com>
Hi!
>
> - if (!mem_total || !mem_used) {
> - tst_res(TWARN, "Failed to parse '%s'", path);
> + tst_res(TINFO,"Node%i: mem_total:%ld kB, mem_used:%ld kB", node,
> + mem_total, mem_used);
> +
> + if (!mem_total) {
> + tst_res(TWARN, "Failed to parse '%s', MemTotal is 0", path);
> return 0;
Why don't we use the return value from the sscanf instead?
What about:
diff --git a/libs/libltpnuma/tst_numa.c b/libs/libltpnuma/tst_numa.c
index ef4c8e879..7e7504cac 100644
--- a/libs/libltpnuma/tst_numa.c
+++ b/libs/libltpnuma/tst_numa.c
@@ -149,11 +149,19 @@ static int node_has_enough_memory(int node, size_t min_kb)
while (fgets(buf, sizeof(buf), fp)) {
long val;
- if (sscanf(buf, "%*s %*i MemTotal: %li", &val) == 1)
+ if (sscanf(buf, "%*s %*i MemTotal: %li", &val) == 1) {
mem_total = val;
+ } else {
+ tst_res(TWARN, "Faield to parse '%s' MemTotal", path);
+ return 0;
+ }
- if (sscanf(buf, "%*s %*i MemUsed: %li", &val) == 1)
+ if (sscanf(buf, "%*s %*i MemUsed: %li", &val) == 1) {
mem_used = val;
+ } else {
+ tst_res(TWARN, "Faield to parse '%s' MemUsed", path);
+ return 0;
+ }
if (sscanf(buf, "%*s %*i FilePages: %li", &val) == 1)
file_pages = val;
@@ -161,10 +169,6 @@ static int node_has_enough_memory(int node, size_t min_kb)
fclose(fp);
- if (!mem_total || !mem_used) {
- tst_res(TWARN, "Failed to parse '%s'", path);
- return 0;
- }
mem_avail = mem_total - mem_used + (9 * file_pages)/10;
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2023-05-09 11:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1683274510.git.pengfei.xu@intel.com>
2023-05-05 8:18 ` [LTP] [PATCH v1 1/1] libs: libltpnuma: Fix one fake failure when CXL(Compute eXpress Link) node memory is not used Pengfei Xu
2023-05-09 11:59 ` Cyril Hrubis [this message]
2023-05-09 14:05 ` Pengfei Xu
2023-05-09 14:10 ` Cyril Hrubis
2023-05-09 14:27 ` Pengfei Xu
2023-05-10 15:20 ` Cyril Hrubis
2023-05-11 6:43 ` Pengfei Xu
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=ZFo1hUZCCXbfhEXY@yuki \
--to=chrubis@suse.cz \
--cc=heng.su@intel.com \
--cc=ltp@lists.linux.it \
--cc=pengfei.xu@intel.com \
--cc=rpalethorpe@suse.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