Return-Path: Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1PLYIS-0002nD-1O for ltp-list@lists.sourceforge.net; Thu, 25 Nov 2010 09:39:20 +0000 Received: from mx4-phx2.redhat.com ([209.132.183.25]) by sog-mx-3.v43.ch3.sourceforge.com with esmtp (Exim 4.69) id 1PLYIQ-00016Q-Pu for ltp-list@lists.sourceforge.net; Thu, 25 Nov 2010 09:39:20 +0000 Received: from mail06.corp.redhat.com (zmail06.collab.prod.int.phx2.redhat.com [10.5.5.45]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oAP9dCsU012187 for ; Thu, 25 Nov 2010 04:39:12 -0500 Date: Thu, 25 Nov 2010 04:39:12 -0500 (EST) From: Zhouping Liu Message-ID: <866793969.448021290677952870.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com> In-Reply-To: <410759402.447991290677851090.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_24725_771721000.1290677952869" Subject: [LTP] [PATCH v2]fix a SEGBUS signal error about hugemmap List-Id: Linux Test Project General Discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-list-bounces@lists.sourceforge.net To: ltp-list@lists.sourceforge.net ------=_Part_24725_771721000.1290677952869 Content-Type: multipart/alternative; boundary="----=_Part_24726_1661102767.1290677952869" ------=_Part_24726_1661102767.1290677952869 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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 #include #include #include 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 Signed-off-by: Zhouping Liu < zliu@redhat.com > --- ------=_Part_24726_1661102767.1290677952869 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable <= div style=3D'font-family: Times New Roman; font-size: 12pt; color: #000000'= >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 de= bug it, it returned error with the 'SEGBUS' signal error,
and the error= occurred in the 178 lines '*(int*)addr =3D 0;'.
it's okay when I add t= his line
write(fildes, "write some words to the TEMPFILE file\n",40); <= br>you can run this c program to find the error :
$ cat test.c
#incl= ude <stdio.h>
#include <stdlib.h>
#include <fcntl.h>= ;
#include <sys/mman.h>
char * TEMPFILE=3D"mmapfile";
int fr= eepages =3D 0;
int main()
{
    long *addr;
&nb= sp;   int fd;
    long long mapsize;
 &= nbsp;  if ((fd =3D open(TEMPFILE, O_RDWR | O_CREAT | O_TRUNC,00777)) &= lt; 0) {
        printf("open error\n");        return -2;
    }<= br>    freepages =3D 100;
    mapsize =3D(= long long)freepages * 2048 * 1024;
    printf("mapsize is= %lld \n",mapsize);
    addr =3D (long *)mmap(NULL,mapsiz= e,
            PROT_READ |= PROT_WRITE, MAP_SHARED, fd,0);
    if (addr =3D=3D MAP_F= AILED) {
        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 =3D 0;
    printf("Successfull= y!\n");
    close(fd);
    return 0;}
$./test
mapsize is 209715200
Bus error (core dumped)

= ---------------------------------------------------------------------------= -----
v2: modified the patch's format
Signed-off-by: Zhouping Liu &l= t;zliu@redhat.com&= gt;
--- ------=_Part_24726_1661102767.1290677952869-- ------=_Part_24725_771721000.1290677952869 Content-Type: text/x-patch; name=0001-fix-a-SEGBUS-signal-error-about-hugemmap.patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-fix-a-SEGBUS-signal-error-about-hugemmap.patch From 81b15a0b8a4de0aab5a9b5e720522681b41c70ca Mon Sep 17 00:00:00 2001 From: Zhouping Liu Date: Thu, 25 Nov 2010 17:08:54 +0800 Subject: [PATCH] fix a SEGBUS signal error about hugemmap Signed-off-by: Zhouping Liu --- testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c index 485b465..8ec984b 100644 --- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c +++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c @@ -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; } -- 1.7.2.3 ------=_Part_24725_771721000.1290677952869 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ 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 ------=_Part_24725_771721000.1290677952869 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list ------=_Part_24725_771721000.1290677952869--