All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] lib: fix MemAvailable parsing
@ 2021-09-28  2:18 Ralph Siemsen
  2021-09-28  7:59 ` Li Wang
  2021-09-29  8:14 ` Richard Palethorpe
  0 siblings, 2 replies; 4+ messages in thread
From: Ralph Siemsen @ 2021-09-28  2:18 UTC (permalink / raw)
  To: ltp

The amount of available memory was not being returned correctly, which
resulted in tests being executed when they should have been skipped.

Fixes: 8759f4 ("lib: adjust the tmpfs size according to .dev_min_size and MemAvailable")
Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org>
---
 lib/tst_memutils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/tst_memutils.c b/lib/tst_memutils.c
index 69077861f..90911da56 100644
--- a/lib/tst_memutils.c
+++ b/lib/tst_memutils.c
@@ -65,9 +65,9 @@ void tst_pollute_memory(size_t maxsize, int fillchar)
 
 long long tst_available_mem(void)
 {
-	long long mem_available;
+	long long mem_available = 0;
 
-	if (FILE_LINES_SCANF("/proc/meminfo", "MemAvailable: %ld",
+	if (FILE_LINES_SCANF("/proc/meminfo", "MemAvailable: %lld",
 		&mem_available)) {
 		mem_available = SAFE_READ_MEMINFO("MemFree:")
 			+ SAFE_READ_MEMINFO("Cached:");
-- 
2.25.1


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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH] lib: fix MemAvailable parsing
  2021-09-28  2:18 [LTP] [PATCH] lib: fix MemAvailable parsing Ralph Siemsen
@ 2021-09-28  7:59 ` Li Wang
  2021-09-29  8:14 ` Richard Palethorpe
  1 sibling, 0 replies; 4+ messages in thread
From: Li Wang @ 2021-09-28  7:59 UTC (permalink / raw)
  To: Ralph Siemsen; +Cc: LTP List


[-- Attachment #1.1: Type: text/plain, Size: 426 bytes --]

> @@ -65,9 +65,9 @@ void tst_pollute_memory(size_t maxsize, int fillchar)
>
>  long long tst_available_mem(void)
>  {
> -       long long mem_available;
> +       long long mem_available = 0;
>

--->  unsigned long long


> -       if (FILE_LINES_SCANF("/proc/meminfo", "MemAvailable: %ld",
> +       if (FILE_LINES_SCANF("/proc/meminfo", "MemAvailable: %lld",
>

I modified it to use '%llu' and pushed.

-- 
Regards,
Li Wang

[-- Attachment #1.2: Type: text/html, Size: 1216 bytes --]

[-- Attachment #2: Type: text/plain, Size: 60 bytes --]


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH] lib: fix MemAvailable parsing
  2021-09-28  2:18 [LTP] [PATCH] lib: fix MemAvailable parsing Ralph Siemsen
  2021-09-28  7:59 ` Li Wang
@ 2021-09-29  8:14 ` Richard Palethorpe
  2021-09-29 14:28   ` Ralph Siemsen
  1 sibling, 1 reply; 4+ messages in thread
From: Richard Palethorpe @ 2021-09-29  8:14 UTC (permalink / raw)
  To: Ralph Siemsen; +Cc: ltp

Hello Ralph,

Ralph Siemsen <ralph.siemsen@linaro.org> writes:

> The amount of available memory was not being returned correctly, which
> resulted in tests being executed when they should have been skipped.
>
> Fixes: 8759f4 ("lib: adjust the tmpfs size according to .dev_min_size and MemAvailable")
> Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org>
> ---
>  lib/tst_memutils.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/tst_memutils.c b/lib/tst_memutils.c
> index 69077861f..90911da56 100644
> --- a/lib/tst_memutils.c
> +++ b/lib/tst_memutils.c
> @@ -65,9 +65,9 @@ void tst_pollute_memory(size_t maxsize, int fillchar)
>  
>  long long tst_available_mem(void)
>  {
> -	long long mem_available;
> +	long long mem_available = 0;
>  
> -	if (FILE_LINES_SCANF("/proc/meminfo", "MemAvailable: %ld",
> +	if (FILE_LINES_SCANF("/proc/meminfo", "MemAvailable: %lld",
>  		&mem_available)) {
>  		mem_available = SAFE_READ_MEMINFO("MemFree:")
>  			+ SAFE_READ_MEMINFO("Cached:");
> -- 
> 2.25.1

Just curious, did you find this on 32-bit ARM?

Anyway looks correct.

Reviewed-by: Richard Palethorpe <rpalethorpe@suse.com>

-- 
Thank you,
Richard.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH] lib: fix MemAvailable parsing
  2021-09-29  8:14 ` Richard Palethorpe
@ 2021-09-29 14:28   ` Ralph Siemsen
  0 siblings, 0 replies; 4+ messages in thread
From: Ralph Siemsen @ 2021-09-29 14:28 UTC (permalink / raw)
  To: Richard Palethorpe; +Cc: ltp

Hi Richard,

On Wed, Sep 29, 2021 at 09:14:56AM +0100, Richard Palethorpe wrote:
>
>Just curious, did you find this on 32-bit ARM?

Yes, it was on 32-bit ARMv7. It happens on the real hardware, and also 
under qemuarm emulation.

You can see my replies in the "fallocate05: increase the the fallocate 
and defallocate size" thread, so see how I ended up discovering this 
problem.

Cheers,
Ralph

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-09-29 14:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-28  2:18 [LTP] [PATCH] lib: fix MemAvailable parsing Ralph Siemsen
2021-09-28  7:59 ` Li Wang
2021-09-29  8:14 ` Richard Palethorpe
2021-09-29 14:28   ` Ralph Siemsen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.