linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "dada1" <dada1@cosmosbay.com>
To: "Andrew Morton" <akpm@osdl.org>
Cc: <linux-kernel@vger.kernel.org>
Subject: Re: How to use hugetlb for the text of a program ?
Date: Wed, 13 Aug 2003 14:42:53 +0200	[thread overview]
Message-ID: <024601c36198$6c934560$4600a8c0@edumazet> (raw)
In-Reply-To: 20030813022650.56cfa680.akpm@osdl.org


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


  reply	other threads:[~2003-08-13 12:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-13  8:31 2.6.0-test3-mm2 Andrew Morton
2003-08-13  9:11 ` How to use hugetlb for the text of a program ? dada1
2003-08-13  9:26   ` Andrew Morton
2003-08-13 12:42     ` dada1 [this message]
2003-08-13  9:22 ` 2.6.0-test3-mm2 hugang
2003-08-13 10:48   ` 2.6.0-test3-mm2 Andrew Morton
2003-08-13 13:02 ` 2.6.0-test3-mm2 Con Kolivas
2003-08-13 13:35   ` 2.6.0-test3-mm2 Luiz Capitulino
2003-08-13 13:36   ` 2.6.0-test3-mm2 Luiz Capitulino
2003-08-13 14:32   ` 2.6.0-test3-mm2 Hugh Dickins
2003-08-13 16:16     ` 2.6.0-test3-mm2 Martin J. Bligh
2003-08-13 16:18     ` 2.6.0-test3-mm2 Luiz Capitulino
2003-08-15 19:38 ` Compile problem with CONFIG_X86_CYCLONE_TIMER 2.6.0-test3-mm2 Mike Fedyk
2003-08-15 20:23   ` Mike Fedyk
2003-08-15 20:36     ` Mike Fedyk
2003-08-16 20:32       ` Dave Hansen
2003-08-27  1:08         ` Compile problem with CONFIG_X86_CYCLONE_TIMER Re: 2.6.0-test4-mm1 Mike Fedyk
2003-08-27  4:41           ` Dave Hansen
2003-08-27 16:00             ` Mike Fedyk
2003-08-27 16:15               ` Dave Hansen
2003-08-17 20:37 ` 2.6.0-test3-mm2 Peter Osterlund

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='024601c36198$6c934560$4600a8c0@edumazet' \
    --to=dada1@cosmosbay.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).