Hi,
Shmem_test_06 still fail occasionally because it tries to attach segments to
fixed addresses. It
is still possible that one of those addresses has been used due to address
space randomization or
whatever reason. For example, we have seen the following on a s390x machine.
../shmem_test_06: IPC Shared Memory TestSuite program
mykey to uniquely identify the shared memory segment 0x3310053f
Get shared memory segment (1048576 bytes)
Attach shared memory segment to process
Shared memory segment address : 0x20000000
Index through shared memory segment ...
mykey to uniquely identify the shared memory segment 0x3410053f
Get shared memory segment (1048576 bytes)
Attach shared memory segment to process
Shared memory segment address : 0x30000000
Index through shared memory segment ...
mykey to uniquely identify the shared memory segment 0x3510053f
Get shared memory segment (1048576 bytes)
Attach shared memory segment to process
Shared memory segment address : 0x48000000
Index through shared memory segment ...
mykey to uniquely identify the shared memory segment 0x3610053f
Get shared memory segment (1048576 bytes)
Attach shared memory segment to process
Shared memory segment address : 0x50000000
Index through shared memory segment ...
mykey to uniquely identify the shared memory segment 0x3710053f
Get shared memory segment (1048576 bytes)
Attach shared memory segment to process
Shared memory segment address : 0x60000000
Index through shared memory segment ...
mykey to uniquely identify the shared memory segment 0x3810053f
Get shared memory segment (1048576 bytes)
Attach shared memory segment to process
Shared memory segment address : 0x70000000
Index through shared memory segment ...
mykey to uniquely identify the shared memory segment 0x3910053f
Get shared memory segment (1048576 bytes)
Attach shared memory segment to process
heap 0x80003000
20000000-20100000 rw-s 00000000 00:09 0
/SYSV3310053f (deleted)
30000000-30100000 rw-s 00000000 00:09 32769
/SYSV3410053f (deleted)
48000000-48100000 rw-s 00000000 00:09 65538
/SYSV3510053f (deleted)
50000000-50100000 rw-s 00000000 00:09 98307
/SYSV3610053f (deleted)
60000000-60100000 rw-s 00000000 00:09 131076
/SYSV3710053f (deleted)
70000000-70100000 rw-s 00000000 00:09 163845
/SYSV3810053f (deleted)
80000000-80002000 r-xp 00000000 fd:00 1013178
/root/caiqian/ltp/testcases/kernel/ipc/ipc_stress/shmem_test_06
80002000-80003000 rw-p 00001000 fd:00 1013178
/root/caiqian/ltp/testcases/kernel/ipc/ipc_stress/shmem_test_06
4268f8b000-4268faa000 r-xp 00000000 fd:00 66022
/lib64/ld-2.5.so
4268faa000-4268fab000 r--p 0001e000 fd:00 66022
/lib64/ld-2.5.so
4268fab000-4268fac000 rw-p 0001f000 fd:00 66022
/lib64/ld-2.5.so
4268fae000-4269122000 r-xp 00000000 fd:00 2940537
/lib64/libc-2.5.so
4269122000-4269126000 r--p 00173000 fd:00 2940537
/lib64/libc-2.5.so
4269126000-4269127000 rw-p 00177000 fd:00 2940537
/lib64/libc-2.5.so
4269127000-426912b000 rw-p 4269127000 00:00 0
42691d6000-42691ed000 r-xp 00000000 fd:00 65416
/lib64/libpthread-2.5.so
42691ed000-42691ee000 r--p 00016000 fd:00 65416
/lib64/libpthread-2.5.so
42691ee000-42691ef000 rw-p 00017000 fd:00 65416
/lib64/libpthread-2.5.so
42691ef000-42691f3000 rw-p 42691ef000 00:00 0
20000000000-20000002000 rw-p 20000000000 00:00 0
20000010000-20000013000 rw-p 20000010000 00:00 0
3ffffbd7000-3ffffbec000 rw-p 3ffffbd7000 00:00 0 [stack]
ERROR [line: 212] shmat failed - return: -1: Invalid argument
This is because the chosen address starting from 80000000 has already been used.
This patch fixes the problem by letting system choose suitable addresses at
which to attach the
segments, and still satisfy the purpose of the test - simultaneous attachment
of more than ten
shared memory regions to a process. Using segment registers 0x3 to 0xC and 0xE.
Now, the test
works fine.
../shmem_test_06: IPC Shared Memory TestSuite program
mykey to uniquely identify the shared memory segment 0x3310053f
Get shared memory segment (1048576 bytes)
Attach shared memory segment to process
Shared memory segment address : 0x20000013000
Index through shared memory segment ...
mykey to uniquely identify the shared memory segment 0x3410053f
Get shared memory segment (1048576 bytes)
Attach shared memory segment to process
Shared memory segment address : 0x20000113000
Index through shared memory segment ...
mykey to uniquely identify the shared memory segment 0x3510053f
Get shared memory segment (1048576 bytes)
Attach shared memory segment to process
Shared memory segment address : 0x20000213000
Index through shared memory segment ...
mykey to uniquely identify the shared memory segment 0x3610053f
Get shared memory segment (1048576 bytes)
Attach shared memory segment to process
Shared memory segment address : 0x20000313000
Index through shared memory segment ...
mykey to uniquely identify the shared memory segment 0x3710053f
Get shared memory segment (1048576 bytes)
Attach shared memory segment to process
Shared memory segment address : 0x20000413000
Index through shared memory segment ...
mykey to uniquely identify the shared memory segment 0x3810053f
Get shared memory segment (1048576 bytes)
Attach shared memory segment to process
Shared memory segment address : 0x20000513000
Index through shared memory segment ...
mykey to uniquely identify the shared memory segment 0x3910053f
Get shared memory segment (1048576 bytes)
Attach shared memory segment to process
Shared memory segment address : 0x20000613000
Index through shared memory segment ...
mykey to uniquely identify the shared memory segment 0x4110053f
Get shared memory segment (1048576 bytes)
Attach shared memory segment to process
Shared memory segment address : 0x20000713000
Index through shared memory segment ...
mykey to uniquely identify the shared memory segment 0x4210053f
Get shared memory segment (1048576 bytes)
Attach shared memory segment to process
Shared memory segment address : 0x20000813000
Index through shared memory segment ...
mykey to uniquely identify the shared memory segment 0x4310053f
Get shared memory segment (1048576 bytes)
Attach shared memory segment to process
Shared memory segment address : 0x20000913000
Index through shared memory segment ...
mykey to uniquely identify the shared memory segment 0x4510053f
Get shared memory segment (1048576 bytes)
Attach shared memory segment to process
Shared memory segment address : 0x20000a13000
Index through shared memory segment ...
Detach from the segment using the shmdt subroutine
Release shared memory
successful!
Tested successfully on i386 and s390x machines.
Signed-off-by: CAI Qian <[EMAIL PROTECTED]>
--- testcases/kernel/ipc/ipc_stress/shmem_test_06.c.orig 2008-10-25
20:13:38.426276085 +0800
+++ testcases/kernel/ipc/ipc_stress/shmem_test_06.c 2008-10-25
20:47:16.934277383 +0800
@@ -80,20 +80,7 @@
#include <sys/ipc.h>
#include <sys/stat.h>
-off_t offsets[] = {
-0x20000000,
-0x30000000,
-0x48000000,
-0x50000000,
-0x60000000,
-0x70000000,
-0x80000000,
-0x90000000,
-0xA0000000,
-0xB0000000,
-0xBF000000,
-};
-int offsets_cnt = sizeof (offsets) /sizeof (offsets[0]);
+int offsets_cnt = 11;
/* Defines
*
* MAX_SHMEM_SIZE: maximum shared memory segment size of 256MB
@@ -151,7 +138,6 @@
+---------------------------------------------------------------------*/
int main (int argc, char **argv)
{
- off_t offset;
int i;
int shmid[MAX_SHMEM_NUMBER]; /* (Unique) Shared memory identifier */
@@ -195,12 +181,8 @@
printf ("\n\tAttach shared memory segment to process\n");
- /*
- * Attach the shared memory segment to the process
- */
- offset = offsets[i];
- if ((long)(shmptr[i] = (char *) shmat (shmid[i], (const void*)offset,
0)) == -1)
+ if ((long)(shmptr[i] = (char *) shmat (shmid[i], NULL, 0)) == -1)
{
/* If shmat(2) failed, we need the currect process address
space layout to debug. The failure can be random. */
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list