public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] linux: Remove shmmax check from tst-sysvshm-linux
@ 2021-02-02 12:58 Adhemerval Zanella
  2021-02-02 14:09 ` Andreas Schwab
  0 siblings, 1 reply; 3+ messages in thread
From: Adhemerval Zanella @ 2021-02-02 12:58 UTC (permalink / raw)
  To: libc-alpha

The shmmax expected value is tricky to check because kernel clamps it
to INT_MAX in two cases:

  1. Compat symbols with IPC_64, i.e, 32-bit binaries running on 64-bit
     kernels.

  2. Default symbol without IPC_64 (defined as IPC_OLD within Linux) and
     glibc always use IPC_64 for 32-bit ABIs (to support 64-bit time_t).
     It means that 32-bit binaries running on 32-bit kernels will not see
     shmmax being clamped.

And finding out whether the compat symbol is used would require checking
the underlying kernel against the current ABI.  The shmall and shmmni
already provided enough coverage.

Checked on x86_64-linux-gnu and i686-linux-gnu.  It should fix the
tst-sysvshm-linux failures on 32-bit kernels.

I will commit this shortly if noone opposes it.
---
 sysdeps/unix/sysv/linux/tst-sysvshm-linux.c | 25 +++++++++++----------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/tst-sysvshm-linux.c b/sysdeps/unix/sysv/linux/tst-sysvshm-linux.c
index 2f05f21e4a..6986443c8f 100644
--- a/sysdeps/unix/sysv/linux/tst-sysvshm-linux.c
+++ b/sysdeps/unix/sysv/linux/tst-sysvshm-linux.c
@@ -122,18 +122,20 @@ do_test (void)
   if (shmid == -1)
     FAIL_EXIT1 ("shmget failed: %m");
 
+  /* It does check shmmax because kernel clamp its value to INT_MAX for:
+
+     1. Compat symbols with IPC_64, i.e, 32-bit binaries running on 64-bit
+        kernels.
+
+     2. Default symbol without IPC_64 (defined as IPC_OLD within Linux) and
+        glibc always use IPC_64 for 32-bit ABIs (to support 64-bit time_t).
+        It means that 32-bit binaries running on 32-bit kernels will not see
+        shmmax being clamped.
+
+     And finding out whether the compat symbol is used would require checking
+     the underlying kernel against the current ABI.  The shmall and shmmni
+     already provided enough coverage.  */
   struct test_shminfo tipcinfo;
-  {
-    uint64_t v = read_proc_file ("/proc/sys/kernel/shmmax");
-#if LONG_MAX == INT_MAX
-    /* Kernel explicit clamp the value for shmmax on compat symbol (32-bit
-       binaries running on 64-bit kernels).  */
-    if (sizeof (__syscall_ulong_t) == sizeof (unsigned long int)
-        && v > INT_MAX)
-      v = INT_MAX;
-#endif
-    tipcinfo.shmmax = v;
-  }
   tipcinfo.shmall = read_proc_file ("/proc/sys/kernel/shmall");
   tipcinfo.shmmni = read_proc_file ("/proc/sys/kernel/shmmni");
 
@@ -152,7 +154,6 @@ do_test (void)
       FAIL_EXIT1 ("shmctl with IPC_INFO failed: %m");
 
     TEST_COMPARE (ipcinfo.shmall, tipcinfo.shmall);
-    TEST_COMPARE (ipcinfo.shmmax, tipcinfo.shmmax);
     TEST_COMPARE (ipcinfo.shmmni, tipcinfo.shmmni);
   }
 
-- 
2.25.1


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

* Re: [PATCH] linux: Remove shmmax check from tst-sysvshm-linux
  2021-02-02 12:58 [PATCH] linux: Remove shmmax check from tst-sysvshm-linux Adhemerval Zanella
@ 2021-02-02 14:09 ` Andreas Schwab
  2021-02-02 14:11   ` Adhemerval Zanella
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2021-02-02 14:09 UTC (permalink / raw)
  To: Adhemerval Zanella via Libc-alpha

On Feb 02 2021, Adhemerval Zanella via Libc-alpha wrote:

> +  /* It does check shmmax because kernel clamp its value to INT_MAX for:

does not?

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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

* Re: [PATCH] linux: Remove shmmax check from tst-sysvshm-linux
  2021-02-02 14:09 ` Andreas Schwab
@ 2021-02-02 14:11   ` Adhemerval Zanella
  0 siblings, 0 replies; 3+ messages in thread
From: Adhemerval Zanella @ 2021-02-02 14:11 UTC (permalink / raw)
  To: Andreas Schwab, Adhemerval Zanella via Libc-alpha



On 02/02/2021 11:09, Andreas Schwab wrote:
> On Feb 02 2021, Adhemerval Zanella via Libc-alpha wrote:
> 
>> +  /* It does check shmmax because kernel clamp its value to INT_MAX for:
> 
> does not?
> 

It should be 'does not'. Fixed locally, thanks.

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

end of thread, other threads:[~2021-02-02 14:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-02 12:58 [PATCH] linux: Remove shmmax check from tst-sysvshm-linux Adhemerval Zanella
2021-02-02 14:09 ` Andreas Schwab
2021-02-02 14:11   ` Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).