From: Pengfei Xu <pengfei.xu@intel.com>
To: Cyril Hrubis <chrubis@suse.cz>
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 22:05:21 +0800 [thread overview]
Message-ID: <ZFpTIVcGoMTKyRCD@xpf.sh.intel.com> (raw)
In-Reply-To: <ZFo1hUZCCXbfhEXY@yuki>
Hi Cyril,
On 2023-05-09 at 13:59:01 +0200, Cyril Hrubis wrote:
> 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:
I tried as follow:
# ./get_mempolicy01
tst_test.c:1560: TINFO: Timeout per run is 0h 00m 30s
tst_numa.c:208: TINFO: Found 3 NUMA memory nodes
tst_numa.c:162: TWARN: Faield to parse '/sys/devices/system/node/node0/meminfo' MemUsed:65220292
tst_numa.c:162: TWARN: Faield to parse '/sys/devices/system/node/node1/meminfo' MemUsed:65167784
tst_numa.c:162: TWARN: Faield to parse '/sys/devices/system/node/node2/meminfo' MemUsed:4194304
get_mempolicy01.c:149: TCONF: test requires at least one NUMA memory node
Node 0 and 1 could not be tested with follow patch installed, seems when
node2/meminfo "MemUsed: 0",sscanf("...%li", &val) will return 0 if only 0 value
will be scaned, and the while loop will scan the char one by one and impact all
other node meminfo scan result, it's strange.
If used my patch, I didn't meet this issue.
Thanks!
BR.
>
> 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 14:04 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
2023-05-09 14:05 ` Pengfei Xu [this message]
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=ZFpTIVcGoMTKyRCD@xpf.sh.intel.com \
--to=pengfei.xu@intel.com \
--cc=chrubis@suse.cz \
--cc=heng.su@intel.com \
--cc=ltp@lists.linux.it \
--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