All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] hugetlb: Initialize orig_shmmax and orig_shmmni value
@ 2019-10-31  6:44 Eric Lin
  2019-10-31  8:17 ` Li Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Lin @ 2019-10-31  6:44 UTC (permalink / raw)
  To: ltp

When doing save_nr_hugepages() in setup() and there
is no Huge page support in system, it will call
cleanup() and write wrong orig_shmmax and orig_shmmni
value back to file.

To fix it, we initialize the orig_shmmax and
orig_shmmni to -1 and check it in cleanup().

Signed-off-by: Eric Lin <tesheng@andestech.com>
---
 testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c   | 5 +++--
 testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c
index d375810cb..c76e4167f 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c
@@ -38,7 +38,7 @@
 static long huge_free;
 static long huge_free2;
 static long hugepages;
-static long orig_shmmax, new_shmmax;
+static long orig_shmmax = -1, new_shmmax;
 
 static void shared_hugepage(void);
 
@@ -106,7 +106,8 @@ static void setup(void)
 static void cleanup(void)
 {
 	restore_nr_hugepages();
-	SAFE_FILE_PRINTF(PATH_SHMMAX, "%ld", orig_shmmax);
+	if (orig_shmmax != -1)
+		SAFE_FILE_PRINTF(PATH_SHMMAX, "%ld", orig_shmmax);
 }
 
 static struct tst_test test = {
diff --git a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
index d5255228b..f2ecc465d 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
@@ -39,7 +39,7 @@ static int num_shms;
 static int shm_id_arr[MAXIDS];
 
 static long hugepages = 128;
-static long orig_shmmni;
+static long orig_shmmni = -1;
 static struct tst_option options[] = {
 	{"s:", &nr_opt, "-s   num  Set the number of the been allocated hugepages"},
 	{NULL, NULL, NULL}
@@ -105,7 +105,8 @@ static void cleanup(void)
 	for (i = 0; i < num_shms; i++)
 		rm_shm(shm_id_arr[i]);
 
-	FILE_PRINTF(PATH_SHMMNI, "%ld", orig_shmmni);
+	if (orig_shmmni != -1)
+		FILE_PRINTF(PATH_SHMMNI, "%ld", orig_shmmni);
 	restore_nr_hugepages();
 }
 
-- 
2.17.0


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

* [LTP] [PATCH] hugetlb: Initialize orig_shmmax and orig_shmmni value
  2019-10-31  6:44 [LTP] [PATCH] hugetlb: Initialize orig_shmmax and orig_shmmni value Eric Lin
@ 2019-10-31  8:17 ` Li Wang
  2019-11-01  6:13   ` Li Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Li Wang @ 2019-10-31  8:17 UTC (permalink / raw)
  To: ltp

On Thu, Oct 31, 2019 at 2:45 PM Eric Lin <tesheng@andestech.com> wrote:

> When doing save_nr_hugepages() in setup() and there
> is no Huge page support in system, it will call
> cleanup() and write wrong orig_shmmax and orig_shmmni
> value back to file.
>
> To fix it, we initialize the orig_shmmax and
> orig_shmmni to -1 and check it in cleanup().
>
> Signed-off-by: Eric Lin <tesheng@andestech.com>
>
Reviewed-by: Li Wang <liwang@redhat.com>


> ---
>  testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c   | 5 +++--
>  testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c | 5 +++--
>  2 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c
> b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c
> index d375810cb..c76e4167f 100644
> --- a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c
> +++ b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c
> @@ -38,7 +38,7 @@
>  static long huge_free;
>  static long huge_free2;
>  static long hugepages;
> -static long orig_shmmax, new_shmmax;
> +static long orig_shmmax = -1, new_shmmax;
>
>  static void shared_hugepage(void);
>
> @@ -106,7 +106,8 @@ static void setup(void)
>  static void cleanup(void)
>  {
>         restore_nr_hugepages();
> -       SAFE_FILE_PRINTF(PATH_SHMMAX, "%ld", orig_shmmax);
> +       if (orig_shmmax != -1)
> +               SAFE_FILE_PRINTF(PATH_SHMMAX, "%ld", orig_shmmax);
>  }
>
>  static struct tst_test test = {
> diff --git a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
> b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
> index d5255228b..f2ecc465d 100644
> --- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
> +++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
> @@ -39,7 +39,7 @@ static int num_shms;
>  static int shm_id_arr[MAXIDS];
>
>  static long hugepages = 128;
> -static long orig_shmmni;
> +static long orig_shmmni = -1;
>  static struct tst_option options[] = {
>         {"s:", &nr_opt, "-s   num  Set the number of the been allocated
> hugepages"},
>         {NULL, NULL, NULL}
> @@ -105,7 +105,8 @@ static void cleanup(void)
>         for (i = 0; i < num_shms; i++)
>                 rm_shm(shm_id_arr[i]);
>
> -       FILE_PRINTF(PATH_SHMMNI, "%ld", orig_shmmni);
> +       if (orig_shmmni != -1)
> +               FILE_PRINTF(PATH_SHMMNI, "%ld", orig_shmmni);
>         restore_nr_hugepages();
>  }
>
> --
> 2.17.0
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>


-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191031/8515c390/attachment-0001.htm>

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

* [LTP] [PATCH] hugetlb: Initialize orig_shmmax and orig_shmmni value
  2019-10-31  8:17 ` Li Wang
@ 2019-11-01  6:13   ` Li Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Li Wang @ 2019-11-01  6:13 UTC (permalink / raw)
  To: ltp

On Thu, Oct 31, 2019 at 4:17 PM Li Wang <liwang@redhat.com> wrote:

>
>
> On Thu, Oct 31, 2019 at 2:45 PM Eric Lin <tesheng@andestech.com> wrote:
>
>> When doing save_nr_hugepages() in setup() and there
>> is no Huge page support in system, it will call
>> cleanup() and write wrong orig_shmmax and orig_shmmni
>> value back to file.
>>
>> To fix it, we initialize the orig_shmmax and
>> orig_shmmni to -1 and check it in cleanup().
>>
>> Signed-off-by: Eric Lin <tesheng@andestech.com>
>
> Reviewed-by: Li Wang <liwang@redhat.com>
>

Pushed.

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191101/3ce2e419/attachment.htm>

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

end of thread, other threads:[~2019-11-01  6:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-31  6:44 [LTP] [PATCH] hugetlb: Initialize orig_shmmax and orig_shmmni value Eric Lin
2019-10-31  8:17 ` Li Wang
2019-11-01  6:13   ` Li Wang

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.