public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Petr Vorel <pvorel@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 09/13] testcases/kernel/mem: Move KSM bits to ksm tests
Date: Mon, 10 Feb 2025 12:17:31 +0100	[thread overview]
Message-ID: <Z6ngS8alAdHF95kP@yuki.lan> (raw)
In-Reply-To: <20241227113648.GI317565@pevik>

Hi!
> > new file mode 100644
> > index 000000000..ebce8197c
> > --- /dev/null
> > +++ b/testcases/kernel/mem/ksm/ksm_test.h
> ...
> > +static inline void ksm_child_memset(int child_num, int size, int total_unit,
> > +		 struct ksm_merge_data ksm_merge_data, char **memory)
> > +{
> > +	int i = 0, j;
> > +	int unit = size / total_unit;
> > +
> > +	tst_res(TINFO, "child %d continues...", child_num);
> > +
> > +	if (ksm_merge_data.mergeable_size == size * TST_MB) {
> This introduces new warnings, because the original code used MB which is long. 
> 
> #define MB                  (1UL<<20)
> 
> Now we use TST_MB, which is plain int.
> 
> In file included from ksm_common.h:16,
>                  from ksm04.c:42:
> ksm_test.h: In function ‘ksm_child_memset’:
> ksm_test.h:108:43: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
>   108 |         if (ksm_merge_data.mergeable_size == size * TST_MB) {
>       |                                           ^~
> ksm_test.h:119:45: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
>   119 |                 for (i = 0; (unsigned int)i < unit * TST_MB; i++)
>       |                                             ^
> ksm_test.h:126:43: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
>   126 |         if (ksm_merge_data.mergeable_size < size * TST_MB)
>       |                                           ^
> ksm_test.h: In function ‘create_ksm_child’:
> ksm_test.h:166:54: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
>   166 |                 if (ksm_merge_data[j].mergeable_size < size * TST_MB) {
>       |                                                      ^
> It would be nice to add cast before merge.

So the size is signed but it was implicitly casted to unsigned by the
TST_MB being unsigned. I guess that the best fix here is to make the
size and unit unsigned to begin with since these are numbers that should
not be negative at all.

> > +		tst_res(TINFO, "child %d allocates %d TST_MB filled with '%c'",
> 
> This should use MB (replace to whole file obviously should exclude strings):
> 
> 		tst_res(TINFO, "child %d allocates %d MB filled with '%c'",
> 
> > +			child_num, size, ksm_merge_data.data);
> > +
> > +	} else {
> > +		tst_res(TINFO, "child %d allocates %d TST_MB filled with '%c'"
> 
> And here as well.
> 		tst_res(TINFO, "child %d allocates %d MB filled with '%c'"
> > +				" except one page with 'e'",
> > +				child_num, size, ksm_merge_data.data);
> > +	}

Ah, sorry, that is a result from blindly doing sed s/...

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2025-02-10 11:17 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-18 18:45 [LTP] [PATCH 00/13] Get rid of testcases/kernel/mem/lib library Cyril Hrubis
2024-12-18 18:45 ` [LTP] [PATCH 01/13] lib: tst_sys_conf: Add two functions Cyril Hrubis
2024-12-19  3:10   ` Li Wang
2024-12-27  9:04   ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 02/13] lib: Replace path_exist() with tst_path_exists() Cyril Hrubis
2024-12-19 14:31   ` Petr Vorel
2024-12-19 15:04     ` Cyril Hrubis
2024-12-20  8:02       ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 03/13] lib: Add tst_mapping_in_range() Cyril Hrubis
2024-12-27 10:25   ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 04/13] testcases/kernel/mem: Move get_a_numa_node() Cyril Hrubis
2024-12-27 10:27   ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 05/13] testcases/kernel/mem: Move update_shm_size() Cyril Hrubis
2024-12-27 10:34   ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 06/13] testcases/kernel/mem: Move check_hugepage() + PATH_THP Cyril Hrubis
2024-12-27 10:48   ` Petr Vorel
2025-02-07 17:00     ` Cyril Hrubis
2025-02-10  9:16       ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 07/13] testcases/kernel/mem: Move NUMA bits to numa_helper.h Cyril Hrubis
2024-12-27 11:01   ` Petr Vorel
2024-12-27 11:09   ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 08/13] testcases/kernel/mem: Move oom() fucntions to oom tests Cyril Hrubis
2024-12-27 11:06   ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 09/13] testcases/kernel/mem: Move KSM bits to ksm tests Cyril Hrubis
2024-12-19  2:52   ` Li Wang
2024-12-19  2:55     ` Li Wang
2024-12-19  9:08     ` Cyril Hrubis
2024-12-19  9:11       ` Li Wang
2024-12-27 11:15   ` Petr Vorel
2024-12-27 11:36   ` Petr Vorel
2025-02-10 11:17     ` Cyril Hrubis [this message]
2024-12-27 11:37   ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 10/13] mem/swapping: Remove mem/lib refrence Cyril Hrubis
2024-12-27 11:42   ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 11/13] mem/vma: Remove mem/lib dependency Cyril Hrubis
2024-12-27 11:44   ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 12/13] mem/hugetlb: Remove mem/lib depenency Cyril Hrubis
2024-12-27 11:47   ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 13/13] testcases/kernel/mem: Remove library Cyril Hrubis
2024-12-27 11:48   ` Petr Vorel
2024-12-18 18:58 ` [LTP] [PATCH 00/13] Get rid of testcases/kernel/mem/lib library Petr Vorel

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=Z6ngS8alAdHF95kP@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=pvorel@suse.cz \
    /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