munmap() don't check sysctl_max_mapcount
A message that is not in the archive (sent off-list or not yet received): 1166251801.757981291112911689.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com
PATCH 1/1 munmap() don't check sysctl_max_mapcount
From http://lkml.org/lkml/2009/10/2/85:
On ia64, the following test program exit abnormally, because glibc thread library called abort().
========================================================
(gdb) bt
#0 0xa000000000010620 in __kernel_syscall_via_break () #1 0x20000000003208e0 in raise () from /lib/libc.so.6.1 #2 0x2000000000324090 in abort () from /lib/libc.so.6.1 #3 0x200000000027c3e0 in __deallocate_stack () from
/lib/libpthread.so.0
#4 0x200000000027f7c0 in start_thread () from /lib/libpthread.so.0 #5 0x200000000047ef60 in __clone2 () from /lib/libc.so.6.1
========================================================
The fact is, glibc call munmap() when thread exitng time for freeing stack, and it assume munlock() never fail. However, munmap() often make vma splitting and it with many mapcount make -ENOMEM.
Oh well, stack unfreeing is not reasonable option. Also munlock() via free() shouldn't failed.
Thus, munmap() shoudn't check max-mapcount.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/mmap/Makefile | 2 + testcases/kernel/syscalls/mmap/mmap11.c | 161 +++++++++++++++++++++++++++++++ 3 files changed, 164 insertions(+), 0 deletions(-) create mode 100644 testcases/kernel/syscalls/mmap/mmap11.c
runtest/syscalls +1 -0
@@ -1288,3 +1288,4 @@ writev04 writev04 writev05 writev05 writev06 writev06 +mmap11 mmap11 -i 30000
testcases/kernel/syscalls/mmap/Makefile +2 -0
@@ -21,3 +21,5 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk + +LDLIBS += -lpthread
testcases/kernel/syscalls/mmap/mmap11.c new file +161 -0
161 lines not on this page · raw message
Signature · 1 line
1.7.1
From: CAI Qian <[email protected]>
Date: Tue, 30 Nov 2010 18:01:34 +0800
Subject: [PATCH] munmap() don't check sysctl_max_mapcount
From http://lkml.org/lkml/2009/10/2/85:
On ia64, the following test program exit abnormally, because glibc thread library called abort().
========================================================
(gdb) bt
#0 0xa000000000010620 in __kernel_syscall_via_break () #1 0x20000000003208e0 in raise () from /lib/libc.so.6.1 #2 0x2000000000324090 in abort () from /lib/libc.so.6.1 #3 0x200000000027c3e0 in __deallocate_stack () from
/lib/libpthread.so.0
#4 0x200000000027f7c0 in start_thread () from /lib/libpthread.so.0 #5 0x200000000047ef60 in __clone2 () from /lib/libc.so.6.1
========================================================
The fact is, glibc call munmap() when thread exitng time for freeing stack, and it assume munlock() never fail. However, munmap() often make vma splitting and it with many mapcount make -ENOMEM.
Oh well, stack unfreeing is not reasonable option. Also munlock() via free() shouldn't failed.
Thus, munmap() shoudn't check max-mapcount.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/mmap/Makefile | 2 + testcases/kernel/syscalls/mmap/mmap11.c | 161 +++++++++++++++++++++++++++++++ 3 files changed, 164 insertions(+), 0 deletions(-) create mode 100644 testcases/kernel/syscalls/mmap/mmap11.c
runtest/syscalls +1 -0
@@ -1288,3 +1288,4 @@ writev04 writev04 writev05 writev05 writev06 writev06 +mmap11 mmap11 -i 30000
testcases/kernel/syscalls/mmap/Makefile +2 -0
@@ -21,3 +21,5 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk + +LDLIBS += -lpthread
testcases/kernel/syscalls/mmap/mmap11.c new file +161 -0
161 lines not on this page · raw message
Signature · 1 line
1.7.1
------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi!
Quoted 128 lines
On ia64, the following test program exit abnormally, because glibc thread library called
abort().========================================================
(gdb) bt#0 0xa000000000010620 in __kernel_syscall_via_break () #1 0x20000000003208e0 in raise () from /lib/libc.so.6.1 #2 0x2000000000324090 in abort () from /lib/libc.so.6.1 #3 0x200000000027c3e0 in __deallocate_stack () from
/lib/libpthread.so.0
#40x200000000027f7c0instart_thread() from/lib/libpthread.so.0#50x200000000047ef60in__clone2() from/lib/libc.so.6.1
========================================================
The fact is, glibc callmunmap()when thread exitng time for freeing stack, and it assumemunlock()never fail. However,munmap()often make vma splitting and it with many mapcount make-ENOMEM.Oh well, stack unfreeing is not reasonable option. Also
munlock()viafree()shouldn't failed.Thus,
munmap()shoudn't check max-mapcount.Signed-off-by CAI Qian <[email protected]>--- runtest/syscalls | 1 + testcases/kernel/syscalls/mmap/Makefile | 2 + testcases/kernel/syscalls/mmap/mmap11.c | 161 +++++++++++++++++++++++++++++++ 3 files changed, 164 insertions(+), 0 deletions(-) create mode 100644 testcases/kernel/syscalls/mmap/mmap11.cruntest/syscalls +1
-0@@ -1288,3 +1288,4 @@ writev04 writev04 writev05 writev05 writev06 writev06 +mmap11 mmap11 -i 30000testcases/kernel/syscalls/mmap/Makefile +2
-0@@ -21,3 +21,5 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk + +LDLIBS += -lpthreadtestcases/kernel/syscalls/mmap/mmap11.c new file +71
-0@@ -0,0 +1,161 @@ +/* +* munmap() don't check sysctl_max_mapcount +* +* From http://lkml.org/lkml/2009/10/2/85: +* +* On ia64, the following test program exit abnormally, because glibc +* thread library called abort(). +* +* ======================================================== +* (gdb) bt +* #0 0xa000000000010620 in __kernel_syscall_via_break () +* #1 0x20000000003208e0 in raise () from /lib/libc.so.6.1 +* #2 0x2000000000324090 in abort () from /lib/libc.so.6.1 +* #3 0x200000000027c3e0 in __deallocate_stack () from +* /lib/libpthread.so.0 +* #4 0x200000000027f7c0 in start_thread () from /lib/libpthread.so.0 +* #5 0x200000000047ef60 in __clone2 () from /lib/libc.so.6.1 +* ======================================================== +* The fact is, glibc call munmap() when thread exitng time for freeing +* stack, and it assume munlock() never fail. However, munmap() often +* make vma splitting and it with many mapcount make -ENOMEM. +* +* Oh well, stack unfreeing is not reasonable option. Also munlock() via +* free() shouldn't failed. +* +* Thus, munmap() shoudn't check max-mapcount. +* +* Copyright (C) 2010 Red Hat, Inc. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it would be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* +* Further, this software is distributed without any warranty that it is +* free of the rightful claim of any third person regarding infringement +* or the like. Any license provided herein, whether implied or +* otherwise, applies only to this software file. Patent licenses, if +* any, provided herein do not apply to combinations of this program +* with other software, or any other product whatsoever. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write the Free Software Foundation, +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <pthread.h> +#include <errno.h> +#include <unistd.h> +#include "test.h" +#include "usctest.h" + +char *TCID ="mmap11" ; +int TST_TOTAL =1 ; +extern int Tst_count; + +#define MAL_SIZE (100*1024) + +static void *wait_thread (void *args); +static void *wait_thread2 (void *args); +static void setup (void ); +static void cleanup(void) LTP_ATTRIBUTE_NORETURN; +static int check (void ); + +int main (int argc,char *argv[]) +{
testcases/kernel/syscalls/mmap/mmap11.c line 81
Quoted 10 lines
testcases/kernel/syscalls/mmap/mmap11.c new file +10
-0+char *msg; + + msg =parse_opts (argc, argv,NULL ,NULL ); +if (msg !=NULL ) +tst_brkm (TBROK , tst_exit,"OPTION PARSING ERROR - %s" , + msg); +setup (); +TEST (check ()); +cleanup (); +}
I would preffer to add empty line between each two functions (as it is done in the rest of the LTP codebase). The code is much more readable.
Also no need to check return value from check() which always returns zero.
Quoted 12 lines
testcases/kernel/syscalls/mmap/mmap11.c new file +12
-0+void setup (void ) +{ +/* capture signals */ +tst_sig (FORK ,DEF_HANDLER , cleanup); + +/* Pause if that option was specified */ +TEST_PAUSE ; + +tst_tmpdir (); +} +void cleanup (void ) +{
testcases/kernel/syscalls/mmap/mmap11.c line 103
Quoted 10 lines
testcases/kernel/syscalls/mmap/mmap11.c new file +10
-0+/* +* print timing stats if that option was specified. +* print errno log if that option was specified. +*/ +TEST_CLEANUP ; + +/* exit with return code appropriate for results */ +tst_rmdir (); +tst_exit (); +}
Do you need to create temporary directory for testing pthreads?
Quoted 29 lines
testcases/kernel/syscalls/mmap/mmap11.c new file +29
-0+int check (void ) +{ +int lc; +pthread_t *thread, th; +int ret, count =0 ; +pthread_attr_t attr; + + ret =pthread_attr_init (&attr); +if (ret) +tst_brkm (TBROK |TERRNO , cleanup,"pthread_attr_init" ); + + ret =pthread_attr_setdetachstate (&attr, +PTHREAD_CREATE_DETACHED ); +if (ret) +tst_brkm (TBROK |TERRNO , cleanup, +"pthread_attr_setdetachstate" ); + + thread =malloc (STD_LOOP_COUNT *sizeof (pthread_t)); +if (thread ==NULL ) +tst_brkm (TBROK |TERRNO , cleanup,"malloc" ); + +for (lc =0 ;TEST_LOOPING (lc); lc++) { +/* Reset Tst_count in case we are looping. */ + Tst_count =0 ; + + ret =pthread_create (&th, &attr, wait_thread,NULL ); +if (ret) { +tst_resm (TINFO ,"[%d] " , count); + tst_brkm(TBROK|TERRNO, cleanup,
testcases/kernel/syscalls/mmap/mmap11.c line 142
Quoted 10 lines
testcases/kernel/syscalls/mmap/mmap11.c new file +10
-0+ "pthread_create"); + } + count++; + ret =pthread_create (&thread[lc], &attr, wait_thread2, +NULL ); +if (ret) { +tst_resm (TINFO ,"[%d] " , count); +tst_brkm (TBROK |TERRNO , cleanup, +"pthread_create" ); + }
Space after if.
testcases/kernel/syscalls/mmap/mmap11.c line 148
Quoted 6 lines
testcases/kernel/syscalls/mmap/mmap11.c new file +6
-0+ count++; + } +tst_resm (TPASS ,"test completed." ); +free (thread); +return 0 ; +}
This function always returns 0 so there is no need to return anyting. I would change this to void which would be less confusing.
Quoted 13 lines
testcases/kernel/syscalls/mmap/mmap11.c new file +13
-0+void *wait_thread (void *args) +{ +void *addr; + addr =malloc (MAL_SIZE ); +if (addr) +memset (addr,1 ,MAL_SIZE ); +sleep (1 ); +return NULL ; +} +void *wait_thread2 (void *args) +{ +return NULL ; +}
Signature · 13 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list