lkml.org 
[lkml]   [2003]   [Aug]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: How to use hugetlb for the text of a program ?
Date

From: "Andrew Morton" <akpm@osdl.org>
> "dada1" <dada1@cosmosbay.com> wrote:
> >
> > The msync() call produces this kernel message (linux-2.6.0-test3)
> > mm/msync.c:52: bad pmd 108000e7.
>
> please post the whole test application, and the command line which was
used
> to demonstrate this failure.

My problem came from the choice of _end : it was not the last byte of the
text segment.

I changed the ldscript to define _last_byte (after .rodata, .rodata1,
.gcc_except_table) and now it's ok.

However the msync() problem stays. And a 4M mem leak happens.

Here is a sample program.

# cat msync.c
/* start of msync.c */
#include <sys/mman.h>
#include <fcntl.h>
#include <stdio.h>

#define HUGESZ 4*1024*1024 /* size of one 4M page*/

int main(int argc, char *argv[])
{
int fd ;
char *ptr ;
const char *filename ;

if (argc < 2) {
fprintf(stderr, "Usage : msync filename\n") ;
exit(1) ;
}
filename = argv[1] ;
fd = open(filename, O_RDWR | O_CREAT, 0644) ;
if (fd == -1) {perror("filename") ; return 1; }
ftruncate(fd, 0) ;
ftruncate(fd, HUGESZ) ;
ptr = mmap((char *)0x10000000, HUGESZ, PROT_READ|PROT_WRITE, MAP_SHARED, fd,
0) ;
if (ptr == (char *)-1) { perror("mmap") ; close(fd);return 2;}
msync(ptr, HUGESZ, MS_SYNC) ;
close(fd) ;
munmap(ptr, HUGESZ) ;
return 0 ;
}
/* end of msync.c */
# gcc -o msync msync.c
# ./msync /huge/testfile
mm/msync.c:52: bad pmd 114000e7
# ./msync /huge/testfile
mm/msync.c:52: bad pmd 118000e7
# ./msync /huge/testfile
mm/msync.c:52: bad pmd 11c000e7
# ./msync /huge/testfile
mmap: Cannot allocate memory

# grep HugePages /proc/meminfo
HugePages_Total: 16
HugePages_Free: 0

Thanks

Eric Dumazet

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:47    [W:0.743 / U:1.456 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site