All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/3] lib: add tst_available_mem function
@ 2021-09-24  7:07 Li Wang
  2021-09-24  7:07 ` [LTP] [PATCH 2/3] swapping01: make use of tst_available_mem Li Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Li Wang @ 2021-09-24  7:07 UTC (permalink / raw)
  To: ltp

tst_available_mem helps to get the value of MemAvailable
from /proc/meminfo, if no support on older kernels,
return 'MemFree + Cached' for instead.

Signed-off-by: Li Wang <liwang@redhat.com>
---
 include/tst_memutils.h |  6 ++++++
 lib/tst_memutils.c     | 13 +++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/include/tst_memutils.h b/include/tst_memutils.h
index 91dad07cd..f605f544e 100644
--- a/include/tst_memutils.h
+++ b/include/tst_memutils.h
@@ -19,4 +19,10 @@
  */
 void tst_pollute_memory(size_t maxsize, int fillchar);
 
+/*
+ * Read the value of MemAvailable from /proc/meminfo, if no support on
+ * older kernels, return 'MemFree + Cached' for instead.
+ */
+long long tst_available_mem(void);
+
 #endif /* TST_MEMUTILS_H__ */
diff --git a/lib/tst_memutils.c b/lib/tst_memutils.c
index 70b60091f..69077861f 100644
--- a/lib/tst_memutils.c
+++ b/lib/tst_memutils.c
@@ -62,3 +62,16 @@ void tst_pollute_memory(size_t maxsize, int fillchar)
 
 	free(map_blocks);
 }
+
+long long tst_available_mem(void)
+{
+	long long mem_available;
+
+	if (FILE_LINES_SCANF("/proc/meminfo", "MemAvailable: %ld",
+		&mem_available)) {
+		mem_available = SAFE_READ_MEMINFO("MemFree:")
+			+ SAFE_READ_MEMINFO("Cached:");
+	}
+
+	return mem_available;
+}
-- 
2.31.1


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

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

* [LTP] [PATCH 2/3] swapping01: make use of tst_available_mem
  2021-09-24  7:07 [LTP] [PATCH 1/3] lib: add tst_available_mem function Li Wang
@ 2021-09-24  7:07 ` Li Wang
  2021-09-24 14:17   ` Petr Vorel
  2021-09-24  7:07 ` [LTP] [PATCH 3/3] lib: unlimit the tmpfs size when test on small systems Li Wang
  2021-09-24 14:15 ` [LTP] [PATCH 1/3] lib: add tst_available_mem function Petr Vorel
  2 siblings, 1 reply; 18+ messages in thread
From: Li Wang @ 2021-09-24  7:07 UTC (permalink / raw)
  To: ltp

Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/mem/include/mem.h         | 1 +
 testcases/kernel/mem/swapping/swapping01.c | 6 +-----
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/testcases/kernel/mem/include/mem.h b/testcases/kernel/mem/include/mem.h
index 10712cf0c..f995f45b0 100644
--- a/testcases/kernel/mem/include/mem.h
+++ b/testcases/kernel/mem/include/mem.h
@@ -4,6 +4,7 @@
 #include "tst_test.h"
 #include "tst_cgroup.h"
 #include "ksm_helper.h"
+#include "tst_memutils.h"
 
 #if defined(__powerpc__) || defined(__powerpc64__)
 #define MAXNODES		256
diff --git a/testcases/kernel/mem/swapping/swapping01.c b/testcases/kernel/mem/swapping/swapping01.c
index 66fc65cbe..392b79d65 100644
--- a/testcases/kernel/mem/swapping/swapping01.c
+++ b/testcases/kernel/mem/swapping/swapping01.c
@@ -83,11 +83,7 @@ static void test_swapping(void)
 static void init_meminfo(void)
 {
 	swap_free_init = SAFE_READ_MEMINFO("SwapFree:");
-	if (FILE_LINES_SCANF("/proc/meminfo", "MemAvailable: %ld",
-		&mem_available_init)) {
-		mem_available_init = SAFE_READ_MEMINFO("MemFree:")
-			+ SAFE_READ_MEMINFO("Cached:");
-	}
+	mem_available_init = tst_available_mem();
 	mem_over = mem_available_init * COE_SLIGHT_OVER;
 	mem_over_max = mem_available_init * COE_DELTA;
 
-- 
2.31.1


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

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

* [LTP] [PATCH 3/3] lib: unlimit the tmpfs size when test on small systems
  2021-09-24  7:07 [LTP] [PATCH 1/3] lib: add tst_available_mem function Li Wang
  2021-09-24  7:07 ` [LTP] [PATCH 2/3] swapping01: make use of tst_available_mem Li Wang
@ 2021-09-24  7:07 ` Li Wang
  2021-09-24  9:51   ` Cyril Hrubis
  2021-09-24 10:52   ` [LTP] [PATCH v2 3/3] lib: adjust the tmpfs size according to .dev_min_size and MemAvailable Li Wang
  2021-09-24 14:15 ` [LTP] [PATCH 1/3] lib: add tst_available_mem function Petr Vorel
  2 siblings, 2 replies; 18+ messages in thread
From: Li Wang @ 2021-09-24  7:07 UTC (permalink / raw)
  To: ltp

Since commit c305a53c5 (lib: limit the size of tmpfs in LTP, Jul 9)
Ltp set tmpfs mount size according to the tdev.size. This cause a
new problem on small RAM system, which consume too much memory and
finally trigger OOM.

To fix this, let's cancel the tmpfs size limitation when MemAvailable
is less than twofold of tdev.size.

Reported-by: Ralph Siemsen <ralph.siemsen@linaro.org>
Signed-off-by: Li Wang <liwang@redhat.com>
---
 include/tst_test.h | 1 +
 lib/tst_test.c     | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/include/tst_test.h b/include/tst_test.h
index 5e3619698..3dcb45de0 100644
--- a/include/tst_test.h
+++ b/include/tst_test.h
@@ -42,6 +42,7 @@
 #include "tst_lockdown.h"
 #include "tst_fips.h"
 #include "tst_taint.h"
+#include "tst_memutils.h"
 
 /*
  * Reports testcase result.
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 4224353da..b50856f20 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -895,6 +895,9 @@ static const char *limit_tmpfs_mount_size(const char *mnt_data,
 	if (strcmp(fs_type, "tmpfs"))
 		return mnt_data;
 
+	if ((tst_available_mem() / 1024) < (tdev.size * 2))
+		return mnt_data;
+
 	if (mnt_data)
 		snprintf(buf, buf_size, "%s,size=%luM", mnt_data, tdev.size);
 	else
-- 
2.31.1


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

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

* Re: [LTP] [PATCH 3/3] lib: unlimit the tmpfs size when test on small systems
  2021-09-24  7:07 ` [LTP] [PATCH 3/3] lib: unlimit the tmpfs size when test on small systems Li Wang
@ 2021-09-24  9:51   ` Cyril Hrubis
  2021-09-24 10:27     ` Li Wang
  2021-09-24 10:40     ` Petr Vorel
  2021-09-24 10:52   ` [LTP] [PATCH v2 3/3] lib: adjust the tmpfs size according to .dev_min_size and MemAvailable Li Wang
  1 sibling, 2 replies; 18+ messages in thread
From: Cyril Hrubis @ 2021-09-24  9:51 UTC (permalink / raw)
  To: Li Wang; +Cc: ltp

Hi!
> Since commit c305a53c5 (lib: limit the size of tmpfs in LTP, Jul 9)
> Ltp set tmpfs mount size according to the tdev.size. This cause a
> new problem on small RAM system, which consume too much memory and
> finally trigger OOM.
> 
> To fix this, let's cancel the tmpfs size limitation when MemAvailable
> is less than twofold of tdev.size.
> 
> Reported-by: Ralph Siemsen <ralph.siemsen@linaro.org>
> Signed-off-by: Li Wang <liwang@redhat.com>
> ---
>  include/tst_test.h | 1 +
>  lib/tst_test.c     | 3 +++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/include/tst_test.h b/include/tst_test.h
> index 5e3619698..3dcb45de0 100644
> --- a/include/tst_test.h
> +++ b/include/tst_test.h
> @@ -42,6 +42,7 @@
>  #include "tst_lockdown.h"
>  #include "tst_fips.h"
>  #include "tst_taint.h"
> +#include "tst_memutils.h"
>  
>  /*
>   * Reports testcase result.
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index 4224353da..b50856f20 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -895,6 +895,9 @@ static const char *limit_tmpfs_mount_size(const char *mnt_data,
>  	if (strcmp(fs_type, "tmpfs"))
>  		return mnt_data;
>  
> +	if ((tst_available_mem() / 1024) < (tdev.size * 2))
> +		return mnt_data;

I'm starting to think that we should do it the other way around, i.e.

- unless the test defines .min_dev_size we should set the size for tmpfs to be really small 16MB or 32MB
- if .min_dev_size is defined and there is not enough free memory -> TCONF
- if .min_dev_size is not set and there is not even 64MB of free memory (for 32MB limit) -> TCONF

I think that this is going to work because most of the tests does not
actually consume more than a megabyte or so of the disk space for the
actuall test, the only reason why we kept bumping the loop device size
is that there are limits on minimal size imposed by filesystems.

>  	if (mnt_data)
>  		snprintf(buf, buf_size, "%s,size=%luM", mnt_data, tdev.size);
>  	else
> -- 
> 2.31.1
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH 3/3] lib: unlimit the tmpfs size when test on small systems
  2021-09-24  9:51   ` Cyril Hrubis
@ 2021-09-24 10:27     ` Li Wang
  2021-09-24 10:40     ` Petr Vorel
  1 sibling, 0 replies; 18+ messages in thread
From: Li Wang @ 2021-09-24 10:27 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: LTP List


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

On Fri, Sep 24, 2021 at 5:51 PM Cyril Hrubis <chrubis@suse.cz> wrote:

> Hi!
> > Since commit c305a53c5 (lib: limit the size of tmpfs in LTP, Jul 9)
> > Ltp set tmpfs mount size according to the tdev.size. This cause a
> > new problem on small RAM system, which consume too much memory and
> > finally trigger OOM.
> >
> > To fix this, let's cancel the tmpfs size limitation when MemAvailable
> > is less than twofold of tdev.size.
> >
> > Reported-by: Ralph Siemsen <ralph.siemsen@linaro.org>
> > Signed-off-by: Li Wang <liwang@redhat.com>
> > ---
> >  include/tst_test.h | 1 +
> >  lib/tst_test.c     | 3 +++
> >  2 files changed, 4 insertions(+)
> >
> > diff --git a/include/tst_test.h b/include/tst_test.h
> > index 5e3619698..3dcb45de0 100644
> > --- a/include/tst_test.h
> > +++ b/include/tst_test.h
> > @@ -42,6 +42,7 @@
> >  #include "tst_lockdown.h"
> >  #include "tst_fips.h"
> >  #include "tst_taint.h"
> > +#include "tst_memutils.h"
> >
> >  /*
> >   * Reports testcase result.
> > diff --git a/lib/tst_test.c b/lib/tst_test.c
> > index 4224353da..b50856f20 100644
> > --- a/lib/tst_test.c
> > +++ b/lib/tst_test.c
> > @@ -895,6 +895,9 @@ static const char *limit_tmpfs_mount_size(const char
> *mnt_data,
> >       if (strcmp(fs_type, "tmpfs"))
> >               return mnt_data;
> >
> > +     if ((tst_available_mem() / 1024) < (tdev.size * 2))
> > +             return mnt_data;
>
> I'm starting to think that we should do it the other way around, i.e.
>
> - unless the test defines .min_dev_size we should set the size for tmpfs
> to be really small 16MB or 32MB
> - if .min_dev_size is defined and there is not enough free memory -> TCONF
> - if .min_dev_size is not set and there is not even 64MB of free memory
> (for 32MB limit) -> TCONF
>

Agree, this is a cogitative handle way.
At least better than unlimit the tmpfs-size roughly when AvailableMem is
short.



> I think that this is going to work because most of the tests does not
> actually consume more than a megabyte or so of the disk space for the
> actuall test, the only reason why we kept bumping the loop device size
> is that there are limits on minimal size imposed by filesystems.
>

+1 Indeed.

Patch V2 is on the way...

-- 
Regards,
Li Wang

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

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


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

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

* Re: [LTP] [PATCH 3/3] lib: unlimit the tmpfs size when test on small systems
  2021-09-24  9:51   ` Cyril Hrubis
  2021-09-24 10:27     ` Li Wang
@ 2021-09-24 10:40     ` Petr Vorel
  1 sibling, 0 replies; 18+ messages in thread
From: Petr Vorel @ 2021-09-24 10:40 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hi Cyril, Li,
> Hi!
> > Since commit c305a53c5 (lib: limit the size of tmpfs in LTP, Jul 9)
> > Ltp set tmpfs mount size according to the tdev.size. This cause a
> > new problem on small RAM system, which consume too much memory and
> > finally trigger OOM.

> > To fix this, let's cancel the tmpfs size limitation when MemAvailable
> > is less than twofold of tdev.size.

...
> > +	if ((tst_available_mem() / 1024) < (tdev.size * 2))
> > +		return mnt_data;

> I'm starting to think that we should do it the other way around, i.e.

> - unless the test defines .min_dev_size we should set the size for tmpfs to be really small 16MB or 32MB
> - if .min_dev_size is defined and there is not enough free memory -> TCONF
> - if .min_dev_size is not set and there is not even 64MB of free memory (for 32MB limit) -> TCONF

> I think that this is going to work because most of the tests does not
> actually consume more than a megabyte or so of the disk space for the
> actuall test, the only reason why we kept bumping the loop device size
> is that there are limits on minimal size imposed by filesystems.

Also LGTM, thanks Li for working on v2.

Kind regards,
Petr


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

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

* [LTP] [PATCH v2 3/3] lib: adjust the tmpfs size according to .dev_min_size and MemAvailable
  2021-09-24  7:07 ` [LTP] [PATCH 3/3] lib: unlimit the tmpfs size when test on small systems Li Wang
  2021-09-24  9:51   ` Cyril Hrubis
@ 2021-09-24 10:52   ` Li Wang
  2021-09-24 11:05     ` Cyril Hrubis
  2021-09-24 14:23     ` Petr Vorel
  1 sibling, 2 replies; 18+ messages in thread
From: Li Wang @ 2021-09-24 10:52 UTC (permalink / raw)
  To: ltp

Since commit c305a53c5 (lib: limit the size of tmpfs in LTP, Jul 9)
Ltp set tmpfs mount size according to the tdev.size. This cause a
new problem on small RAM system, which consume too much memory and
finally trigger OOM.

To fix this, let's adjust the tmpfs-size according to both free memory
and .dev_min_size:

 - if .dev_min_size is defined and system has enough free memory,
   set tmpfs-size to tdev.size

 - if .dev_min_size is defined and there is not enough free
   memory -> TCONF

 - if the test not define .dev_min_size, set the size for tmpfs to
   be really small 32MB

 - if .dev_min_size is not define and there is not even 64MB of free
   memory (for 32MB limit) -> TCONF

Reported-by: Ralph Siemsen <ralph.siemsen@linaro.org>
Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Li Wang <liwang@redhat.com>
---
 include/tst_test.h |  1 +
 lib/tst_test.c     | 16 +++++++++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/include/tst_test.h b/include/tst_test.h
index 5e3619698..3dcb45de0 100644
--- a/include/tst_test.h
+++ b/include/tst_test.h
@@ -42,6 +42,7 @@
 #include "tst_lockdown.h"
 #include "tst_fips.h"
 #include "tst_taint.h"
+#include "tst_memutils.h"
 
 /*
  * Reports testcase result.
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 4224353da..ec80e17a6 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -892,15 +892,25 @@ static void prepare_and_mount_dev_fs(const char *mntpoint)
 static const char *limit_tmpfs_mount_size(const char *mnt_data,
 		char *buf, size_t buf_size, const char *fs_type)
 {
+	unsigned int tmpfs_size;
+
 	if (strcmp(fs_type, "tmpfs"))
 		return mnt_data;
 
+	if (!tst_test->dev_min_size)
+		tmpfs_size = 32;
+	else
+		tmpfs_size = tdev.size;
+
+	if ((tst_available_mem() / 1024) < (tmpfs_size * 2))
+		tst_brk(TCONF, "No enough memory for tmpfs use");
+
 	if (mnt_data)
-		snprintf(buf, buf_size, "%s,size=%luM", mnt_data, tdev.size);
+		snprintf(buf, buf_size, "%s,size=%luM", mnt_data, tmpfs_size);
 	else
-		snprintf(buf, buf_size, "size=%luM", tdev.size);
+		snprintf(buf, buf_size, "size=%luM", tmpfs_size);
 
-	tst_res(TINFO, "Limiting tmpfs size to %luMB", tdev.size);
+	tst_res(TINFO, "Limiting tmpfs size to %luMB", tmpfs_size);
 
 	return buf;
 }
-- 
2.31.1


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

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

* Re: [LTP] [PATCH v2 3/3] lib: adjust the tmpfs size according to .dev_min_size and MemAvailable
  2021-09-24 10:52   ` [LTP] [PATCH v2 3/3] lib: adjust the tmpfs size according to .dev_min_size and MemAvailable Li Wang
@ 2021-09-24 11:05     ` Cyril Hrubis
  2021-09-24 11:32       ` Li Wang
  2021-09-24 14:23     ` Petr Vorel
  1 sibling, 1 reply; 18+ messages in thread
From: Cyril Hrubis @ 2021-09-24 11:05 UTC (permalink / raw)
  To: Li Wang; +Cc: ltp

Hi!
Looks good.

For the whole patchset:

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

Also I guess that we should remove the .dev_min_size from the fallocate
as a last step, right?

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v2 3/3] lib: adjust the tmpfs size according to .dev_min_size and MemAvailable
  2021-09-24 11:05     ` Cyril Hrubis
@ 2021-09-24 11:32       ` Li Wang
  0 siblings, 0 replies; 18+ messages in thread
From: Li Wang @ 2021-09-24 11:32 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: LTP List


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

On Fri, Sep 24, 2021 at 7:05 PM Cyril Hrubis <chrubis@suse.cz> wrote:

> Hi!
> Looks good.
>
> For the whole patchset:
>
> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
>

Thanks for your reivews!

>
> Also I guess that we should remove the .dev_min_size from the fallocate
> as a last step, right?
>

Yes, as we have DEV_SIZE_MB for all other filesystems,
.dev_min_size is no need for fallocate05.

-- 
Regards,
Li Wang

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

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


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

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

* Re: [LTP] [PATCH 1/3] lib: add tst_available_mem function
  2021-09-24  7:07 [LTP] [PATCH 1/3] lib: add tst_available_mem function Li Wang
  2021-09-24  7:07 ` [LTP] [PATCH 2/3] swapping01: make use of tst_available_mem Li Wang
  2021-09-24  7:07 ` [LTP] [PATCH 3/3] lib: unlimit the tmpfs size when test on small systems Li Wang
@ 2021-09-24 14:15 ` Petr Vorel
  2 siblings, 0 replies; 18+ messages in thread
From: Petr Vorel @ 2021-09-24 14:15 UTC (permalink / raw)
  To: Li Wang; +Cc: ltp

Hi Li,

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH 2/3] swapping01: make use of tst_available_mem
  2021-09-24  7:07 ` [LTP] [PATCH 2/3] swapping01: make use of tst_available_mem Li Wang
@ 2021-09-24 14:17   ` Petr Vorel
  0 siblings, 0 replies; 18+ messages in thread
From: Petr Vorel @ 2021-09-24 14:17 UTC (permalink / raw)
  To: Li Wang; +Cc: ltp

Hi Li,

obviously correct, thanks!

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v2 3/3] lib: adjust the tmpfs size according to .dev_min_size and MemAvailable
  2021-09-24 10:52   ` [LTP] [PATCH v2 3/3] lib: adjust the tmpfs size according to .dev_min_size and MemAvailable Li Wang
  2021-09-24 11:05     ` Cyril Hrubis
@ 2021-09-24 14:23     ` Petr Vorel
  2021-09-27  2:39       ` Li Wang
  1 sibling, 1 reply; 18+ messages in thread
From: Petr Vorel @ 2021-09-24 14:23 UTC (permalink / raw)
  To: Li Wang; +Cc: ltp

Hi Li,

Reviewed-by: Petr Vorel <pvorel@suse.cz>

nit: I'd add Fixes: c305a53c5 ("lib: limit the size of tmpfs in LTP")
if anybody searches on Fixes.

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v2 3/3] lib: adjust the tmpfs size according to .dev_min_size and MemAvailable
  2021-09-24 14:23     ` Petr Vorel
@ 2021-09-27  2:39       ` Li Wang
  2021-09-27 15:12         ` Ralph Siemsen
  0 siblings, 1 reply; 18+ messages in thread
From: Li Wang @ 2021-09-27  2:39 UTC (permalink / raw)
  To: Petr Vorel, Cyril Hrubis; +Cc: LTP List


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

On Fri, Sep 24, 2021 at 10:23 PM Petr Vorel <pvorel@suse.cz> wrote:

> Hi Li,
>
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
>
> nit: I'd add Fixes: c305a53c5 ("lib: limit the size of tmpfs in LTP")
> if anybody searches on Fixes.
>

Thanks for the review, I added this and pushed it.

Btw, according to Ralph's test (153MB MemAva) result:

* test trigger OOM with mount 32MB tmpfs size
* test PASS with unlimited mount tmpfs size
   (actually, it consume 134MB, from the log)

This is more like a kernel-specific problem but not LTP general issue.

-- 
Regards,
Li Wang

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

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


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

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

* Re: [LTP] [PATCH v2 3/3] lib: adjust the tmpfs size according to .dev_min_size and MemAvailable
  2021-09-27  2:39       ` Li Wang
@ 2021-09-27 15:12         ` Ralph Siemsen
  2021-09-27 19:09           ` Ralph Siemsen
  0 siblings, 1 reply; 18+ messages in thread
From: Ralph Siemsen @ 2021-09-27 15:12 UTC (permalink / raw)
  To: Li Wang; +Cc: LTP List

On Mon, Sep 27, 2021 at 10:39:23AM +0800, Li Wang wrote:
>On Fri, Sep 24, 2021 at 10:23 PM Petr Vorel <pvorel@suse.cz> wrote:
>
>> Hi Li,
>>
>> Reviewed-by: Petr Vorel <pvorel@suse.cz>
>>
>> nit: I'd add Fixes: c305a53c5 ("lib: limit the size of tmpfs in LTP")
>> if anybody searches on Fixes.
>>
>
>Thanks for the review, I added this and pushed it.

I just tested the 20210927 release (commit 12beeda351) under qemu ARM. 
It seems that fallocate05 test is fine now, even with the 32MB fallback.

However fallocate06 test is failing with OOM. It seems this one still 
contains .dev_min_size = 512 , should this be removed?

Ralph

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

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

* Re: [LTP] [PATCH v2 3/3] lib: adjust the tmpfs size according to .dev_min_size and MemAvailable
  2021-09-27 15:12         ` Ralph Siemsen
@ 2021-09-27 19:09           ` Ralph Siemsen
  2021-09-28  1:19             ` Li Wang
  0 siblings, 1 reply; 18+ messages in thread
From: Ralph Siemsen @ 2021-09-27 19:09 UTC (permalink / raw)
  To: Li Wang; +Cc: LTP List

On Mon, Sep 27, 2021 at 11:12:20AM -0400, Ralph Siemsen wrote:
>
>However fallocate06 test is failing with OOM. It seems this one still 
>contains .dev_min_size = 512 , should this be removed?

With .dev_min_size = 512 the test should be skipped on my system since I 
have only ~120 MB of free RAM. But something is wrong with the test.

I added code to print the value returned by tst_available() and found 
that it was a very very large number.

After investigation, the format string "%ld" seems to be the culprit.

--- a/lib/tst_memutils.c
+++ b/lib/tst_memutils.c
@@ -65,13 +65,15 @@ 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:");
	}

+       tst_res(TINFO, "RFS: tst_available_mem returning %lld\n", mem_available);
+
	return mem_available;
  }

With the above change, tst_available() returns a reasonable value, and 
the fallocate06 test is skipped:

tst_test.c:1436: TINFO: Testing on tmpfs
tst_test.c:937: TINFO: Skipping mkfs for TMPFS filesystem
tst_memutils.c:81: TINFO: RFS: tst_available_mem return 120592
tst_test.c:907: TINFO: RFS: tmpfs_size = 512 avail=120592
tst_test.c:911: TCONF: No enough memory for tmpfs use


Also, when I remove the .dev_min_size=512 from fallocate06, then it uses 
the default size of 32MB, and the fallocate06 test runs and passes.

Regards,
Ralph

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

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

* Re: [LTP] [PATCH v2 3/3] lib: adjust the tmpfs size according to .dev_min_size and MemAvailable
  2021-09-27 19:09           ` Ralph Siemsen
@ 2021-09-28  1:19             ` Li Wang
  2021-09-28  2:22               ` Ralph Siemsen
  0 siblings, 1 reply; 18+ messages in thread
From: Li Wang @ 2021-09-28  1:19 UTC (permalink / raw)
  To: Ralph Siemsen; +Cc: LTP List


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

Hi Ralph,

On Tue, Sep 28, 2021 at 3:09 AM Ralph Siemsen <ralph.siemsen@linaro.org>
wrote:

> On Mon, Sep 27, 2021 at 11:12:20AM -0400, Ralph Siemsen wrote:
> >
> >However fallocate06 test is failing with OOM. It seems this one still
> >contains .dev_min_size = 512 , should this be removed?
>
> With .dev_min_size = 512 the test should be skipped on my system since I
> have only ~120 MB of free RAM. But something is wrong with the test.
>
> I added code to print the value returned by tst_available() and found
> that it was a very very large number.
>
> After investigation, the format string "%ld" seems to be the culprit.
>

Thanks for the debugging. Can you send a patch?



>
> --- a/lib/tst_memutils.c
> +++ b/lib/tst_memutils.c
> @@ -65,13 +65,15 @@ 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:");
>         }
>
> +       tst_res(TINFO, "RFS: tst_available_mem returning %lld\n",
> mem_available);
> +
>         return mem_available;
>   }
>
> With the above change, tst_available() returns a reasonable value, and
> the fallocate06 test is skipped:
>
> tst_test.c:1436: TINFO: Testing on tmpfs
> tst_test.c:937: TINFO: Skipping mkfs for TMPFS filesystem
> tst_memutils.c:81: TINFO: RFS: tst_available_mem return 120592
> tst_test.c:907: TINFO: RFS: tmpfs_size = 512 avail=120592
> tst_test.c:911: TCONF: No enough memory for tmpfs use
>
>
> Also, when I remove the .dev_min_size=512 from fallocate06, then it uses
> the default size of 32MB, and the fallocate06 test runs and passes.
>
> Regards,
> Ralph
>
>

-- 
Regards,
Li Wang

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

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


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

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

* Re: [LTP] [PATCH v2 3/3] lib: adjust the tmpfs size according to .dev_min_size and MemAvailable
  2021-09-28  1:19             ` Li Wang
@ 2021-09-28  2:22               ` Ralph Siemsen
  2021-09-28  7:53                 ` Li Wang
  0 siblings, 1 reply; 18+ messages in thread
From: Ralph Siemsen @ 2021-09-28  2:22 UTC (permalink / raw)
  To: Li Wang; +Cc: LTP List

On Tue, Sep 28, 2021 at 09:19:28AM +0800, Li Wang wrote:
>
>Thanks for the debugging. Can you send a patch?

Yes, I will send one in a few moments (and then it's off to sleep).

>> Also, when I remove the .dev_min_size=512 from fallocate06, then it 
>> uses the default size of 32MB, and the fallocate06 test runs and 
>> passes.

Should we also change fallocate96 test to not request 512MB?

Regards,
Ralph

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

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

* Re: [LTP] [PATCH v2 3/3] lib: adjust the tmpfs size according to .dev_min_size and MemAvailable
  2021-09-28  2:22               ` Ralph Siemsen
@ 2021-09-28  7:53                 ` Li Wang
  0 siblings, 0 replies; 18+ messages in thread
From: Li Wang @ 2021-09-28  7:53 UTC (permalink / raw)
  To: Ralph Siemsen; +Cc: LTP List


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

>
> >> Also, when I remove the .dev_min_size=512 from fallocate06, then it
> >> uses the default size of 32MB, and the fallocate06 test runs and
> >> passes.
>
> Should we also change fallocate96 test to not request 512MB?
>

I think yes, there is no place that shows it needs a specific size 512.

-- 
Regards,
Li Wang

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

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


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

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

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

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-24  7:07 [LTP] [PATCH 1/3] lib: add tst_available_mem function Li Wang
2021-09-24  7:07 ` [LTP] [PATCH 2/3] swapping01: make use of tst_available_mem Li Wang
2021-09-24 14:17   ` Petr Vorel
2021-09-24  7:07 ` [LTP] [PATCH 3/3] lib: unlimit the tmpfs size when test on small systems Li Wang
2021-09-24  9:51   ` Cyril Hrubis
2021-09-24 10:27     ` Li Wang
2021-09-24 10:40     ` Petr Vorel
2021-09-24 10:52   ` [LTP] [PATCH v2 3/3] lib: adjust the tmpfs size according to .dev_min_size and MemAvailable Li Wang
2021-09-24 11:05     ` Cyril Hrubis
2021-09-24 11:32       ` Li Wang
2021-09-24 14:23     ` Petr Vorel
2021-09-27  2:39       ` Li Wang
2021-09-27 15:12         ` Ralph Siemsen
2021-09-27 19:09           ` Ralph Siemsen
2021-09-28  1:19             ` Li Wang
2021-09-28  2:22               ` Ralph Siemsen
2021-09-28  7:53                 ` Li Wang
2021-09-24 14:15 ` [LTP] [PATCH 1/3] lib: add tst_available_mem function Petr Vorel

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.