From: "dada1" <dada1@cosmosbay.com>
To: "Christoph Hellwig" <hch@infradead.org>
Cc: "Rik van Riel" <riel@conectiva.com.br>,
"Benjamin LaHaise" <bcrl@redhat.com>,
"Andrew Morton" <akpm@digeo.com>, <linux-mm@kvack.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [patch] remove hugetlb syscalls
Date: Thu, 14 Nov 2002 16:13:56 +0100 [thread overview]
Message-ID: <002b01c28bf0$751a3960$760010ac@edumazet> (raw)
In-Reply-To: 20021114141310.A25747@infradead.org
Thanks Christoph
If I asked, this is because I tried the obvious and it doesnt work.
# cat /proc/version
Linux version 2.5.47 (root@whatever.com) (gcc version 3.2) #10 Tue Nov 12
11:27:43 CET 2002
# cat /proc/sys/vm/nr_hugepages
4
# cat /proc/meminfo | grep Huge
HugePages_Total: 4
HugePages_Free: 4
Hugepagesize: 4096 kB
# mount | grep huge
whocares on /huge type hugetlbfs (rw)
# cat huge.c
#include <unistd.h>
#include <asm/unistd.h>
#include <errno.h>
#include <stdio.h>
#include <sys/mman.h>
#ifndef __NR_sys_alloc_hugepages
# define __NR_sys_alloc_hugepages 250
#endif
#define BIGSZ (4*1024*1024)
_syscall5(void *, sys_alloc_hugepages, int, key, unsigned long, addr,
size_t, len, int, prot, int, flag)
main(argc, argv)
int argc ;
char *argv[] ;
{
char *ptr ;
int c ;
int fd = -1 ;
int nbp = 1 ;
while ((c = getopt(argc, argv, "n:f:")) != EOF) {
switch (c) {
case 'n':
nbp = atoi(optarg) ; break ;
case 'f' :
fd = open(optarg, 2) ; break ;
}
}
if (fd != -1) {
ftruncate(fd, nbp*BIGSZ) ;
ptr = mmap(0, nbp*BIGSZ, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0) ;
if (ptr == (char *)-1)
ptr = mmap(0, nbp*BIGSZ, PROT_READ|PROT_WRITE, MAP_PRIVATE,
fd, 0) ;
}
else
ptr = sys_alloc_hugepages(0, 0, nbp*BIGSZ, PROT_READ|PROT_WRITE, 0) ;
printf("alloc %d 4Mo pages ptr=%p errno=%d\n", nbp, ptr, errno) ;
pause() ;
}
# ./huge # (using the syscall)
alloc 1 4Mo pages ptr=0x40400000 errno=0
^C
# ls -l /huge/BIG
-rw-r--r-- 1 root root 4194304 Nov 14 15:57 /huge/BIG
# ./huge -f /huge/BIG (using mmap)
./huge -f /huge/BIG
alloc 1 4Mo pages ptr=0xffffffff errno=22
^C
# strace ...
open("/huge/BIG", O_RDWR) = 3
ftruncate(3, 4194304) = 0
mmap2(NULL, 4194304, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0) = -1 EINVAL
(Invalid argument)
mmap2(NULL, 4194304, PROT_READ|PROT_WRITE, MAP_PRIVATE, 3, 0) = -1 EINVAL
(Invalid argument)
Not a trivial task it seems. The syscall is very easy.. sorry.
Thanks
From: "Christoph Hellwig" <hch@infradead.org>
> On Thu, Nov 14, 2002 at 09:52:33AM +0100, dada1 wrote:
> > I beg to differ.
> >
> > I already use the syscalls.
>
> For what?
>
> > How one is supposed to use hugetlbfs ? That's not documented.
>
> mount -t hugetlbfs whocares /huge
>
> fd = open("/huge/nose", ..)
>
> mmap(.., fd, ..)
>
WARNING: multiple messages have this Message-ID (diff)
From: "dada1" <dada1@cosmosbay.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Rik van Riel <riel@conectiva.com.br>,
Benjamin LaHaise <bcrl@redhat.com>,
Andrew Morton <akpm@digeo.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [patch] remove hugetlb syscalls
Date: Thu, 14 Nov 2002 16:13:56 +0100 [thread overview]
Message-ID: <002b01c28bf0$751a3960$760010ac@edumazet> (raw)
In-Reply-To: 20021114141310.A25747@infradead.org
Thanks Christoph
If I asked, this is because I tried the obvious and it doesnt work.
# cat /proc/version
Linux version 2.5.47 (root@whatever.com) (gcc version 3.2) #10 Tue Nov 12
11:27:43 CET 2002
# cat /proc/sys/vm/nr_hugepages
4
# cat /proc/meminfo | grep Huge
HugePages_Total: 4
HugePages_Free: 4
Hugepagesize: 4096 kB
# mount | grep huge
whocares on /huge type hugetlbfs (rw)
# cat huge.c
#include <unistd.h>
#include <asm/unistd.h>
#include <errno.h>
#include <stdio.h>
#include <sys/mman.h>
#ifndef __NR_sys_alloc_hugepages
# define __NR_sys_alloc_hugepages 250
#endif
#define BIGSZ (4*1024*1024)
_syscall5(void *, sys_alloc_hugepages, int, key, unsigned long, addr,
size_t, len, int, prot, int, flag)
main(argc, argv)
int argc ;
char *argv[] ;
{
char *ptr ;
int c ;
int fd = -1 ;
int nbp = 1 ;
while ((c = getopt(argc, argv, "n:f:")) != EOF) {
switch (c) {
case 'n':
nbp = atoi(optarg) ; break ;
case 'f' :
fd = open(optarg, 2) ; break ;
}
}
if (fd != -1) {
ftruncate(fd, nbp*BIGSZ) ;
ptr = mmap(0, nbp*BIGSZ, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0) ;
if (ptr == (char *)-1)
ptr = mmap(0, nbp*BIGSZ, PROT_READ|PROT_WRITE, MAP_PRIVATE,
fd, 0) ;
}
else
ptr = sys_alloc_hugepages(0, 0, nbp*BIGSZ, PROT_READ|PROT_WRITE, 0) ;
printf("alloc %d 4Mo pages ptr=%p errno=%d\n", nbp, ptr, errno) ;
pause() ;
}
# ./huge # (using the syscall)
alloc 1 4Mo pages ptr=0x40400000 errno=0
^C
# ls -l /huge/BIG
-rw-r--r-- 1 root root 4194304 Nov 14 15:57 /huge/BIG
# ./huge -f /huge/BIG (using mmap)
./huge -f /huge/BIG
alloc 1 4Mo pages ptr=0xffffffff errno=22
^C
# strace ...
open("/huge/BIG", O_RDWR) = 3
ftruncate(3, 4194304) = 0
mmap2(NULL, 4194304, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0) = -1 EINVAL
(Invalid argument)
mmap2(NULL, 4194304, PROT_READ|PROT_WRITE, MAP_PRIVATE, 3, 0) = -1 EINVAL
(Invalid argument)
Not a trivial task it seems. The syscall is very easy.. sorry.
Thanks
From: "Christoph Hellwig" <hch@infradead.org>
> On Thu, Nov 14, 2002 at 09:52:33AM +0100, dada1 wrote:
> > I beg to differ.
> >
> > I already use the syscalls.
>
> For what?
>
> > How one is supposed to use hugetlbfs ? That's not documented.
>
> mount -t hugetlbfs whocares /huge
>
> fd = open("/huge/nose", ..)
>
> mmap(.., fd, ..)
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/
next prev parent reply other threads:[~2002-11-14 15:07 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-13 23:45 [patch] remove hugetlb syscalls Benjamin LaHaise
2002-11-13 23:45 ` Benjamin LaHaise
2002-11-14 0:42 ` Rik van Riel
2002-11-14 0:42 ` Rik van Riel
2002-11-14 8:52 ` dada1
2002-11-14 8:52 ` dada1
2002-11-14 14:13 ` Christoph Hellwig
2002-11-14 14:13 ` Christoph Hellwig
[not found] ` <ugel9oa vk4.fsf@panda.mostang.com>
2002-11-14 15:13 ` dada1 [this message]
2002-11-14 15:13 ` dada1
2002-11-14 15:31 ` Benjamin LaHaise
2002-11-14 15:31 ` Benjamin LaHaise
2002-11-14 15:38 ` dada1
2002-11-14 15:38 ` dada1
[not found] ` <3DD3FED2.2010901@unix-os.sc.intel.com>
2002-11-14 20:01 ` Benjamin LaHaise
2002-11-14 20:01 ` Benjamin LaHaise
2002-11-14 21:06 ` Benjamin LaHaise
2002-11-14 21:06 ` Benjamin LaHaise
2002-11-14 20:11 ` Rohit Seth
2002-11-14 20:11 ` Rohit Seth
2002-11-14 20:36 ` William Lee Irwin III
2002-11-14 20:36 ` William Lee Irwin III
2002-11-14 17:51 ` David Mosberger-Tang
2002-11-14 18:31 ` Alan Cox
2002-11-14 18:53 ` David Mosberger-Tang
2002-11-14 19:52 ` Alan Cox
2002-11-14 20:14 ` Alan Cox
2002-11-16 18:23 ` Jan Niehusmann
2002-11-14 20:34 ` William Lee Irwin III
2002-11-14 21:31 ` David Mosberger-Tang
2002-11-14 21:38 ` William Lee Irwin III
2002-11-14 21:46 ` David Mosberger-Tang
2002-11-14 19:28 ` Jeff Garzik
2002-11-14 20:15 ` Alan Cox
2002-11-16 18:00 ` Rik van Riel
2002-11-16 18:15 ` Linus Torvalds
2002-11-14 20:30 ` William Lee Irwin III
2002-11-14 20:30 ` William Lee Irwin III
2002-11-14 20:48 ` Benjamin LaHaise
2002-11-14 20:48 ` Benjamin LaHaise
2002-11-14 21:02 ` William Lee Irwin III
2002-11-14 21:02 ` William Lee Irwin III
2002-11-14 21:11 ` Benjamin LaHaise
2002-11-14 21:11 ` Benjamin LaHaise
2002-11-14 21:31 ` William Lee Irwin III
2002-11-14 21:31 ` William Lee Irwin III
2002-11-14 21:40 ` Rohit Seth
2002-11-14 21:40 ` Rohit Seth
2002-11-14 21:59 ` Benjamin LaHaise
2002-11-14 21:59 ` Benjamin LaHaise
2002-11-14 21:06 ` Benjamin LaHaise
2002-11-14 21:06 ` Benjamin LaHaise
2002-11-14 21:06 ` Benjamin LaHaise
2002-11-14 21:06 ` Benjamin LaHaise
-- strict thread matches above, loose matches on Subject: below --
2002-11-14 22:12 Seth, Rohit
2002-11-14 22:12 ` Seth, Rohit
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='002b01c28bf0$751a3960$760010ac@edumazet' \
--to=dada1@cosmosbay.com \
--cc=akpm@digeo.com \
--cc=bcrl@redhat.com \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=riel@conectiva.com.br \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.