Skip to contentSkip to conversation

fix a SEGBUS signal error about hugemmap

PATCH New Zhouping Liu 1 participant 1 message Nov 25, 2010 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 410759402.447991290677851090.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com

#1 lore raw

PATCH v2 1/1 fix a SEGBUS signal error about hugemmap

Hi,all
when I run the below test program :
#./hugemmap04 -I 3600 -H /var/hugetlbfs
I found it returned quickly.
I used gdb tool to debug it, it returned error with the 'SEGBUS' signal error, and the error occurred in the 178 lines '*(int*)addr = 0;'.
it's okay when I add this line
write(fildes, "write some words to the TEMPFILE file\n",40);
you can run this c program to find the error :

$ cat test.c 
#include <stdio.h> 
#include <stdlib.h> 
#include <fcntl.h> 
#include <sys/mman.h> 
char * TEMPFILE="mmapfile"; 
int freepages = 0; 
int main() 
{ 
long *addr; 
int fd; 
long long mapsize; 
if ((fd = open(TEMPFILE, O_RDWR | O_CREAT | O_TRUNC,00777)) < 0) { 
printf("open error\n"); 
return -2; 
} 
freepages = 100; 
mapsize =(long long)freepages * 2048 * 1024; 
printf("mapsize is %lld \n",mapsize); 
addr = (long *)mmap(NULL,mapsize, 
PROT_READ | PROT_WRITE, MAP_SHARED, fd,0); 
if (addr == MAP_FAILED) { 
printf("mmap error\n"); 
return -1; 
} 
/* if you enable this line,there will be no error. */ 
//write(fd,"just write some words.\n",20); 
*(int *)addr = 0; 
printf("Successfully!\n"); 
close(fd); 
return 0; 
} 
$./test 
mapsize is 209715200 
Bus error (core dumped) 

--------------------------------------------------------------------------------
v2: modified the patch's format

---

From 81b15a0b8a4de0aab5a9b5e720522681b41c70ca Mon Sep 17 00:00:00 2001
From: Zhouping Liu <[email protected]>
Date: Thu, 25 Nov 2010 17:08:54 +0800
Subject: [PATCH] fix a SEGBUS signal error about hugemmap

---
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c +2 -0
index 485b465..8ec984b 100644
@@ -174,6 +174,8 @@ main(int ac, char **av)
 			continue;
 		} else {
 			tst_resm(TPASS, "Succeeded mapping file using %d pages",freepages);
+			/* the write function just do initialization */
+			write(fildes, " write some words to the TEMPFILE file\n",40);
 			/* force to allocate page and change HugePages_Free */
 			*(int*)addr = 0;
 		}
Signature · 1 line
1.7.2.3

------------------------------------------------------------------------------
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