* [patch] add alloc_pages/free_pages support
@ 2002-10-03 0:03 David Mosberger
2002-10-03 0:20 ` Ulrich Drepper
0 siblings, 1 reply; 17+ messages in thread
From: David Mosberger @ 2002-10-03 0:03 UTC (permalink / raw)
To: libc-hacker; +Cc: davidm
Below is a patch to add support for the new
alloc_hugepages()/free_hugepages() system call. I hope I got all the
details right. If not, ring...
Thanks,
--david
2002-10-02 David Mosberger <davidm@hpl.hp.com>
* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Mention
sys/hugepage.h.
* sysdeps/unix/sysv/linux/syscalls.list: Make alloc_hugepages and
free_hugepages weak symbols.
* sysdeps/unix/sysv/linux/Versions: Mention alloc_hugepages and
free_hugepages.
2002-10-01 Rohit Seth <rohit.seth@intel.com>,
David Mosberger <davidm@hpl.hp.com>
* sysdeps/unix/sysv/linux/syscalls.list: Add alloc_hugepages and
free_hugepages.
* sysdeps/unix/sysv/linux/sys/hugepage.h: New file.
Index: sysdeps/unix/sysv/linux/Makefile
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/Makefile,v
retrieving revision 1.121
diff -u -r1.121 Makefile
--- sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/Makefile 15 Sep 2002 02:30:28 -0000 1.121
+++ sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/Makefile 3 Oct 2002 07:01:33 -0000
@@ -20,7 +20,7 @@
sys/kd.h sys/soundcard.h sys/vt.h \
sys/quota.h sys/fsuid.h \
scsi/sg.h scsi/scsi.h scsi/scsi_ioctl.h sys/pci.h \
- sys/ultrasound.h sys/raw.h sys/personality.h
+ sys/ultrasound.h sys/raw.h sys/personality.h sys/hugepage.h
install-others += $(inst_includedir)/bits/syscall.h
Index: sysdeps/unix/sysv/linux/Versions
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/Versions,v
retrieving revision 1.18
diff -u -r1.18 Versions
--- sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/Versions 30 Aug 2002 01:30:55 -0000 1.18
+++ sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/Versions 3 Oct 2002 07:01:33 -0000
@@ -102,6 +102,9 @@
# r*
readahead;
+ alloc_hugepages;
+ free_hugepages;
+
#errlist-compat 126
_sys_errlist; sys_errlist; _sys_nerr; sys_nerr;
}
Index: sysdeps/unix/sysv/linux/syscalls.list
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/syscalls.list,v
retrieving revision 1.94
diff -u -r1.94 syscalls.list
--- sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/syscalls.list 15 Aug 2002 08:25:16 -0000 1.94
+++ sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/syscalls.list 3 Oct 2002 07:01:33 -0000
@@ -80,3 +80,5 @@
lremovexattr EXTRA lremovexattr i:ss lremovexattr
fremovexattr EXTRA fremovexattr i:is fremovexattr
+alloc_hugepages EXTRA alloc_hugepages b:ianii __alloc_hugepages alloc_hugepages
+free_hugepages EXTRA free_hugepages i:a __free_hugepages free_hugepages
Index: sysdeps/unix/sysv/linux/sys/hugepage.h
===================================================================
RCS file: sysdeps/unix/sysv/linux/sys/hugepage.h
diff -N sysdeps/unix/sysv/linux/sys/hugepage.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sysdeps/unix/sysv/linux/sys/sysdeps/unix/sysv/linux/sys/hugepage.h 3 Oct 2002 07:01:33 -0000
@@ -0,0 +1,8 @@
+#ifndef _SYS_HUGEPAGE_H
+#define _SYS_HUGEPAGE_H 1
+
+extern void *alloc_hugepages (int key, void *addr, size_t len, int prot,
+ int flag);
+extern int free_hugepages (void *addr);
+
+#endif
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch] add alloc_pages/free_pages support
2002-10-03 0:03 [patch] add alloc_pages/free_pages support David Mosberger
@ 2002-10-03 0:20 ` Ulrich Drepper
2002-10-03 12:37 ` David Mosberger
2002-10-03 15:05 ` David Mosberger
0 siblings, 2 replies; 17+ messages in thread
From: Ulrich Drepper @ 2002-10-03 0:20 UTC (permalink / raw)
To: davidm; +Cc: libc-hacker, davidm
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
David Mosberger wrote:
ee_hugepages i:a __free_hugepages free_hugepages
> Index: sysdeps/unix/sysv/linux/sys/hugepage.h
> ===================================================================
> RCS file: sysdeps/unix/sysv/linux/sys/hugepage.h
> diff -N sysdeps/unix/sysv/linux/sys/hugepage.h
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ sysdeps/unix/sysv/linux/sys/sysdeps/unix/sysv/linux/sys/hugepage.h 3 Oct 2002 07:01:33 -0000
> @@ -0,0 +1,8 @@
> +#ifndef _SYS_HUGEPAGE_H
> +#define _SYS_HUGEPAGE_H 1
> +
> +extern void *alloc_hugepages (int key, void *addr, size_t len, int prot,
> + int flag);
> +extern int free_hugepages (void *addr);
> +
> +#endif
- - no copyright comment
- - parameters have no leading __
- - no comment for the functions explaining the purpose and the parameters
- --
- --------------. ,-. 444 Castro Street
Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA
Red Hat `--' drepper at redhat.com `---------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE9m+812ijCOnn/RHQRAm/JAKCBTSsvsgr9tFHOoHuJOmr61OXAJwCgzKUO
gNmKIAL34a6EQB/MPnP9abc=
=xITk
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch] add alloc_pages/free_pages support
2002-10-03 0:20 ` Ulrich Drepper
@ 2002-10-03 12:37 ` David Mosberger
2002-10-03 14:44 ` David Mosberger
2002-10-03 15:05 ` David Mosberger
1 sibling, 1 reply; 17+ messages in thread
From: David Mosberger @ 2002-10-03 12:37 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: davidm, libc-hacker
>>>>> On Thu, 03 Oct 2002 00:18:09 -0700, Ulrich Drepper <drepper@redhat.com> said:
Uli> - - no copyright comment
Uli> - - parameters have no leading __
Uli> - - no comment for the functions explaining the purpose and the
Uli> parameters
OK, how about the attached patch? It takes care of the above comments
and also adds a gethugepage() function.
--david
2002-10-03 David Mosberger <davidm@hpl.hp.com>
* sysdeps/unix/sysv/linux/getsysstats.c (get_meminfo): New function.
(phys_pages_info): Implementing on the basis of get_meminfo().
(__gethugepagesize): New function.
* sysdeps/unix/sysv/linux/Versions: Mention gethugepagesize().
2002-10-02 David Mosberger <davidm@hpl.hp.com>
* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Mention
sys/hugepage.h.
* sysdeps/unix/sysv/linux/syscalls.list: Make alloc_hugepages and
free_hugepages weak symbols.
* sysdeps/unix/sysv/linux/Versions: Mention alloc_hugepages and
free_hugepages.
2002-10-01 Rohit Seth <rohit.seth@intel.com>,
David Mosberger <davidm@hpl.hp.com>
* sysdeps/unix/sysv/linux/syscalls.list: Add alloc_hugepages and
free_hugepages.
* sysdeps/unix/sysv/linux/sys/hugepage.h: New file.
2002-10-02 David Mosberger <davidm@hpl.hp.com>
* sysdeps/ia64/bzero.S: Rewritten by Sverre Jarp to tune for
Itanium 2 (and Itanium).
Fix unwind directives and make it fit in 80 columns.
* sysdeps/ia64/memset.S: Ditto.
* sysdeps/ia64/memcpy.S: Ditto.
Move jump table to .rodata section.
Index: sysdeps/unix/sysv/linux/Makefile
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/Makefile,v
retrieving revision 1.121
diff -u -r1.121 Makefile
--- sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/Makefile 15 Sep 2002 02:30:28 -0000 1.121
+++ sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/Makefile 3 Oct 2002 19:34:12 -0000
@@ -20,7 +20,7 @@
sys/kd.h sys/soundcard.h sys/vt.h \
sys/quota.h sys/fsuid.h \
scsi/sg.h scsi/scsi.h scsi/scsi_ioctl.h sys/pci.h \
- sys/ultrasound.h sys/raw.h sys/personality.h
+ sys/ultrasound.h sys/raw.h sys/personality.h sys/hugepage.h
install-others += $(inst_includedir)/bits/syscall.h
Index: sysdeps/unix/sysv/linux/Versions
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/Versions,v
retrieving revision 1.18
diff -u -r1.18 Versions
--- sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/Versions 30 Aug 2002 01:30:55 -0000 1.18
+++ sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/Versions 3 Oct 2002 19:34:12 -0000
@@ -102,6 +102,10 @@
# r*
readahead;
+ gethugepagesize;
+ alloc_hugepages;
+ free_hugepages;
+
#errlist-compat 126
_sys_errlist; sys_errlist; _sys_nerr; sys_nerr;
}
Index: sysdeps/unix/sysv/linux/getsysstats.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/getsysstats.c,v
retrieving revision 1.22
diff -u -r1.22 getsysstats.c
--- sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/getsysstats.c 21 Sep 2002 05:26:12 -0000 1.22
+++ sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/getsysstats.c 3 Oct 2002 19:34:12 -0000
@@ -230,11 +230,8 @@
#endif
weak_alias (__get_nprocs_conf, get_nprocs_conf)
-/* General function to get information about memory status from proc
- filesystem. */
static long int
-internal_function
-phys_pages_info (const char *format)
+get_meminfo (const char *format)
{
FILE *fp;
char buffer[8192];
@@ -264,7 +261,7 @@
while (fgets_unlocked (buffer, sizeof buffer, fp) != NULL)
if (sscanf (buffer, format, &result) == 1)
{
- result /= (__getpagesize () / 1024);
+ result /= 1024;
break;
}
@@ -279,6 +276,20 @@
return result;
}
+/* General function to get information about memory status from proc
+ filesystem. */
+static long int
+internal_function
+phys_pages_info (const char *format)
+{
+ long int result = get_meminfo (format);
+
+ if (result != -1)
+ result /= __getpagesize ();
+
+ return result;
+}
+
/* Return the number of pages of physical memory in the system. There
is currently (as of version 2.0.21) no system call to determine the
@@ -320,6 +331,12 @@
}
weak_alias (__get_avphys_pages, get_avphys_pages)
+long int
+__gethugepagesize ()
+{
+ return get_meminfo ("HugePageSize: %lu kB");
+}
+weak_alias (__gethugepagesize, gethugepagesize);
static void
free_mem (void)
Index: sysdeps/unix/sysv/linux/syscalls.list
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/syscalls.list,v
retrieving revision 1.94
diff -u -r1.94 syscalls.list
--- sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/syscalls.list 15 Aug 2002 08:25:16 -0000 1.94
+++ sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/syscalls.list 3 Oct 2002 19:34:12 -0000
@@ -80,3 +80,5 @@
lremovexattr EXTRA lremovexattr i:ss lremovexattr
fremovexattr EXTRA fremovexattr i:is fremovexattr
+alloc_hugepages EXTRA alloc_hugepages b:ianii __alloc_hugepages alloc_hugepages
+free_hugepages EXTRA free_hugepages i:a __free_hugepages free_hugepages
Index: sysdeps/unix/sysv/linux/sys/hugepage.h
===================================================================
RCS file: sysdeps/unix/sysv/linux/sys/hugepage.h
diff -N sysdeps/unix/sysv/linux/sys/hugepage.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sysdeps/unix/sysv/linux/sys/sysdeps/unix/sysv/linux/sys/hugepage.h 3 Oct 2002 19:34:12 -0000
@@ -0,0 +1,75 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_HUGEPAGE_H
+#define _SYS_HUGEPAGE_H 1
+
+/* This header file defines the huge page interface. A huge page is a
+ non-swappable (pinned) page of virtual memory. As the name
+ suggests, the size of a huge page is typically orders of magnitudes
+ bigger than the value returned by getpagesize(). For example,
+ depending on kernel configuration, on x86 it may be 2MBytes or
+ 4MBytes and on ia64 it is typically one of 16MB, 256MBytes, or
+ 4GBytes. Note that because huge pages are never swapped, they are
+ a relatively rare commodity and applications are expected to fall
+ back to allocating regular pages if a huge page cannot be
+ allocated. */
+
+#include <features.h>
+
+__BEGIN_DECLS
+
+/* Return the size of a huge page. */
+
+extern long int __gethugepagesize (void) __attribute__ ((__const__));
+libc_hidden_proto (__gethugepagesize);
+
+/* Allocate LEN bytes worth of huge pages. LEN must be an integer
+ multiple of the huge page size. ADDR is the preferred starting
+ address for the memory. PROT is a mask of protection bits that
+ specify how the memory is to be mapped (PROT_NONE or any
+ combination of PROT_READ, PROT_WRITE, or PROT_EXEC). If KEY has is
+ a positive number, FLAG can be set to IPC_CREAT to request the
+ creation of a new shared memory segment or to zero to request
+ attaching to an existing shared memory segment.
+
+ Return value: On success, alloc_hugepages() returns a pointer to
+ the allocated memory. On error, MAP_FAILED ((void *) -1) is
+ returned and ERRNO is set appropriately.
+
+ Errors:
+ EINVAL LEN is not a integer multiple of gethugepagesize()
+ or KEY is a negative value.
+
+ ENOENT No shared segment matching KEY was found and FLAGS
+ was zero. */
+
+extern void *alloc_hugepages (int __key, void *__addr, size_t __len,
+ int __prot, int __flag);
+
+/* Free the huge page resources from the current process's address
+ space. ADDR must be an address returned by a previous call to
+ alloc_hugepages (). Note that for shared memory segments, the
+ underlying physical memory will be freed only after the last
+ process using them has freed them up or has exited. */
+
+extern int free_hugepages (void *__addr);
+
+__END_DECLS
+
+#endif /* sys/hugepage.h */
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch] add alloc_pages/free_pages support
2002-10-03 12:37 ` David Mosberger
@ 2002-10-03 14:44 ` David Mosberger
0 siblings, 0 replies; 17+ messages in thread
From: David Mosberger @ 2002-10-03 14:44 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: davidm, libc-hacker
>>>>> On Thu, 03 Oct 2002 00:18:09 -0700, Ulrich Drepper <drepper@redhat.com> said:
Uli> - - no copyright comment
Uli> - - parameters have no leading __
Uli> - - no comment for the functions explaining the purpose and the
Uli> parameters
OK, how about the attached patch? It takes care of the above comments
and also adds a gethugepage() function.
--david
2002-10-03 David Mosberger <davidm@hpl.hp.com>
* sysdeps/unix/sysv/linux/getsysstats.c (get_meminfo): New function.
(phys_pages_info): Implementing on the basis of get_meminfo().
(__gethugepagesize): New function.
* sysdeps/unix/sysv/linux/Versions: Mention gethugepagesize().
2002-10-02 David Mosberger <davidm@hpl.hp.com>
* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Mention
sys/hugepage.h.
* sysdeps/unix/sysv/linux/syscalls.list: Make alloc_hugepages and
free_hugepages weak symbols.
* sysdeps/unix/sysv/linux/Versions: Mention alloc_hugepages and
free_hugepages.
2002-10-01 Rohit Seth <rohit.seth@intel.com>,
David Mosberger <davidm@hpl.hp.com>
* sysdeps/unix/sysv/linux/syscalls.list: Add alloc_hugepages and
free_hugepages.
* sysdeps/unix/sysv/linux/sys/hugepage.h: New file.
2002-10-02 David Mosberger <davidm@hpl.hp.com>
* sysdeps/ia64/bzero.S: Rewritten by Sverre Jarp to tune for
Itanium 2 (and Itanium).
Fix unwind directives and make it fit in 80 columns.
* sysdeps/ia64/memset.S: Ditto.
* sysdeps/ia64/memcpy.S: Ditto.
Move jump table to .rodata section.
Index: sysdeps/unix/sysv/linux/Makefile
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/Makefile,v
retrieving revision 1.121
diff -u -r1.121 Makefile
--- sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/Makefile 15 Sep 2002 02:30:28 -0000 1.121
+++ sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/Makefile 3 Oct 2002 19:34:12 -0000
@@ -20,7 +20,7 @@
sys/kd.h sys/soundcard.h sys/vt.h \
sys/quota.h sys/fsuid.h \
scsi/sg.h scsi/scsi.h scsi/scsi_ioctl.h sys/pci.h \
- sys/ultrasound.h sys/raw.h sys/personality.h
+ sys/ultrasound.h sys/raw.h sys/personality.h sys/hugepage.h
install-others += $(inst_includedir)/bits/syscall.h
Index: sysdeps/unix/sysv/linux/Versions
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/Versions,v
retrieving revision 1.18
diff -u -r1.18 Versions
--- sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/Versions 30 Aug 2002 01:30:55 -0000 1.18
+++ sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/Versions 3 Oct 2002 19:34:12 -0000
@@ -102,6 +102,10 @@
# r*
readahead;
+ gethugepagesize;
+ alloc_hugepages;
+ free_hugepages;
+
#errlist-compat 126
_sys_errlist; sys_errlist; _sys_nerr; sys_nerr;
}
Index: sysdeps/unix/sysv/linux/getsysstats.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/getsysstats.c,v
retrieving revision 1.22
diff -u -r1.22 getsysstats.c
--- sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/getsysstats.c 21 Sep 2002 05:26:12 -0000 1.22
+++ sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/getsysstats.c 3 Oct 2002 19:34:12 -0000
@@ -230,11 +230,8 @@
#endif
weak_alias (__get_nprocs_conf, get_nprocs_conf)
-/* General function to get information about memory status from proc
- filesystem. */
static long int
-internal_function
-phys_pages_info (const char *format)
+get_meminfo (const char *format)
{
FILE *fp;
char buffer[8192];
@@ -264,7 +261,7 @@
while (fgets_unlocked (buffer, sizeof buffer, fp) != NULL)
if (sscanf (buffer, format, &result) == 1)
{
- result /= (__getpagesize () / 1024);
+ result /= 1024;
break;
}
@@ -279,6 +276,20 @@
return result;
}
+/* General function to get information about memory status from proc
+ filesystem. */
+static long int
+internal_function
+phys_pages_info (const char *format)
+{
+ long int result = get_meminfo (format);
+
+ if (result != -1)
+ result /= __getpagesize ();
+
+ return result;
+}
+
/* Return the number of pages of physical memory in the system. There
is currently (as of version 2.0.21) no system call to determine the
@@ -320,6 +331,12 @@
}
weak_alias (__get_avphys_pages, get_avphys_pages)
+long int
+__gethugepagesize ()
+{
+ return get_meminfo ("Hugepagesize: %lu kB");
+}
+weak_alias (__gethugepagesize, gethugepagesize);
static void
free_mem (void)
Index: sysdeps/unix/sysv/linux/syscalls.list
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/syscalls.list,v
retrieving revision 1.94
diff -u -r1.94 syscalls.list
--- sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/syscalls.list 15 Aug 2002 08:25:16 -0000 1.94
+++ sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/syscalls.list 3 Oct 2002 19:34:12 -0000
@@ -80,3 +80,5 @@
lremovexattr EXTRA lremovexattr i:ss lremovexattr
fremovexattr EXTRA fremovexattr i:is fremovexattr
+alloc_hugepages EXTRA alloc_hugepages b:ianii __alloc_hugepages alloc_hugepages
+free_hugepages EXTRA free_hugepages i:a __free_hugepages free_hugepages
Index: sysdeps/unix/sysv/linux/sys/hugepage.h
===================================================================
RCS file: sysdeps/unix/sysv/linux/sys/hugepage.h
diff -N sysdeps/unix/sysv/linux/sys/hugepage.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sysdeps/unix/sysv/linux/sys/sysdeps/unix/sysv/linux/sys/hugepage.h 3 Oct 2002 19:34:12 -0000
@@ -0,0 +1,75 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_HUGEPAGE_H
+#define _SYS_HUGEPAGE_H 1
+
+/* This header file defines the huge page interface. A huge page is a
+ non-swappable (pinned) page of virtual memory. As the name
+ suggests, the size of a huge page is typically orders of magnitudes
+ bigger than the value returned by getpagesize(). For example,
+ depending on kernel configuration, on x86 it may be 2MBytes or
+ 4MBytes and on ia64 it is typically one of 16MB, 256MBytes, or
+ 4GBytes. Note that because huge pages are never swapped, they are
+ a relatively rare commodity and applications are expected to fall
+ back to allocating regular pages if a huge page cannot be
+ allocated. */
+
+#include <features.h>
+
+__BEGIN_DECLS
+
+/* Return the size of a huge page. */
+
+extern long int __gethugepagesize (void) __attribute__ ((__const__));
+libc_hidden_proto (__gethugepagesize);
+
+/* Allocate LEN bytes worth of huge pages. LEN must be an integer
+ multiple of the huge page size. ADDR is the preferred starting
+ address for the memory. PROT is a mask of protection bits that
+ specify how the memory is to be mapped (PROT_NONE or any
+ combination of PROT_READ, PROT_WRITE, or PROT_EXEC). If KEY has is
+ a positive number, FLAG can be set to IPC_CREAT to request the
+ creation of a new shared memory segment or to zero to request
+ attaching to an existing shared memory segment.
+
+ Return value: On success, alloc_hugepages() returns a pointer to
+ the allocated memory. On error, MAP_FAILED ((void *) -1) is
+ returned and ERRNO is set appropriately.
+
+ Errors:
+ EINVAL LEN is not a integer multiple of gethugepagesize()
+ or KEY is a negative value.
+
+ ENOENT No shared segment matching KEY was found and FLAGS
+ was zero. */
+
+extern void *alloc_hugepages (int __key, void *__addr, size_t __len,
+ int __prot, int __flag);
+
+/* Free the huge page resources from the current process's address
+ space. ADDR must be an address returned by a previous call to
+ alloc_hugepages (). Note that for shared memory segments, the
+ underlying physical memory will be freed only after the last
+ process using them has freed them up or has exited. */
+
+extern int free_hugepages (void *__addr);
+
+__END_DECLS
+
+#endif /* sys/hugepage.h */
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch] add alloc_pages/free_pages support
2002-10-03 0:20 ` Ulrich Drepper
2002-10-03 12:37 ` David Mosberger
@ 2002-10-03 15:05 ` David Mosberger
[not found] ` <200210032146.g93LkB119076@magilla.sf.frob.com>
1 sibling, 1 reply; 17+ messages in thread
From: David Mosberger @ 2002-10-03 15:05 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: davidm, libc-hacker
I just resent the hugepage patch with a small change. The mail
escaped before I had a chance to describe what changed:
The only change in the followup patch is that the spelling of
"HugePageSize" is changed to "Hugepagesize" (getsysstats.c). This is
so we're in sync with the (forthcoming) kernel.
Thanks,
--david
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch] add alloc_pages/free_pages support
[not found] ` <200210032146.g93LkB119076@magilla.sf.frob.com>
@ 2002-10-03 15:30 ` David Mosberger
2002-10-03 15:34 ` Ulrich Drepper
0 siblings, 1 reply; 17+ messages in thread
From: David Mosberger @ 2002-10-03 15:30 UTC (permalink / raw)
To: Roland McGrath; +Cc: libc-hacker, davidm
>>>>> On Thu, 3 Oct 2002 14:46:11 -0700, Roland McGrath <roland@redhat.com> said:
Roland> I think gethugepagesize should return size_t rather than long int.
Yeah, you're probably right.
getpagesize() returns "int" but that doesn't work for
gethugepagesize() since McKinley already supports 4GB huge pages.
Uli, do you have any other feedback or are you OK with it?
Thanks,
--david
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch] add alloc_pages/free_pages support
2002-10-03 15:30 ` David Mosberger
@ 2002-10-03 15:34 ` Ulrich Drepper
2002-10-03 22:48 ` David Mosberger
2002-10-04 0:14 ` David Mosberger
0 siblings, 2 replies; 17+ messages in thread
From: Ulrich Drepper @ 2002-10-03 15:34 UTC (permalink / raw)
To: davidm; +Cc: Roland McGrath, libc-hacker
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
> Uli, do you have any other feedback or are you OK with it?
The header still isn't right. You cannot have the hidden macros in
there. And the function prototypes are missing __THROW.
- --
- --------------. ,-. 444 Castro Street
Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA
Red Hat `--' drepper at redhat.com `---------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE9nMUg2ijCOnn/RHQRAv2hAJwN8QLZSvSdMbaTbeTo9Vt2brUTagCbBGHP
jGZMhJEXVhhH2aIkH0F4N1M=
=qxLq
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch] add alloc_pages/free_pages support
2002-10-03 15:34 ` Ulrich Drepper
@ 2002-10-03 22:48 ` David Mosberger
2002-10-04 0:14 ` David Mosberger
1 sibling, 0 replies; 17+ messages in thread
From: David Mosberger @ 2002-10-03 22:48 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: davidm, Roland McGrath, libc-hacker
>>>>> On Thu, 03 Oct 2002 15:30:56 -0700, Ulrich Drepper <drepper@redhat.com> said:
Uli> The header still isn't right. You cannot have the hidden macros in
Uli> there.
OK, so what's the right way to declare a function that has both weak and
strong variants? Just duplicate the proto, like so:
extern size_t __gethugepagesize (void) __attribute__ ((__const__));
extern size_t gethugepagesize (void) __attribute__ ((__const__));
Uli> And the function prototypes are missing __THROW.
For all three of them?
--david
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch] add alloc_pages/free_pages support
2002-10-03 15:34 ` Ulrich Drepper
2002-10-03 22:48 ` David Mosberger
@ 2002-10-04 0:14 ` David Mosberger
2002-10-04 20:02 ` Andreas Jaeger
1 sibling, 1 reply; 17+ messages in thread
From: David Mosberger @ 2002-10-04 0:14 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: davidm, libc-hacker
>>>>> On Thu, 03 Oct 2002 15:30:56 -0700, Ulrich Drepper <drepper@redhat.com> said:
Uli> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
>> Uli, do you have any other feedback or are you OK with it?
Uli> The header still isn't right. You cannot have the hidden
Uli> macros in there. And the function prototypes are missing
Uli> __THROW.
OK, how is this?
--david
2002-10-03 David Mosberger <davidm@hpl.hp.com>
* sysdeps/unix/sysv/linux/getsysstats.c (get_meminfo): New function.
(phys_pages_info): Implementing on the basis of get_meminfo().
(__gethugepagesize): New function.
* sysdeps/unix/sysv/linux/Versions: Mention gethugepagesize().
2002-10-02 David Mosberger <davidm@hpl.hp.com>
* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Mention
sys/hugepage.h.
* sysdeps/unix/sysv/linux/syscalls.list: Make alloc_hugepages and
free_hugepages weak symbols.
* sysdeps/unix/sysv/linux/Versions: Mention alloc_hugepages and
free_hugepages.
2002-10-01 Rohit Seth <rohit.seth@intel.com>,
David Mosberger <davidm@hpl.hp.com>
* sysdeps/unix/sysv/linux/syscalls.list: Add alloc_hugepages and
free_hugepages.
* sysdeps/unix/sysv/linux/sys/hugepage.h: New file.
2002-10-02 David Mosberger <davidm@hpl.hp.com>
* sysdeps/ia64/bzero.S: Rewritten by Sverre Jarp to tune for
Itanium 2 (and Itanium).
Fix unwind directives and make it fit in 80 columns.
* sysdeps/ia64/memset.S: Ditto.
* sysdeps/ia64/memcpy.S: Ditto.
Move jump table to .rodata section.
Index: sysdeps/unix/sysv/linux/Makefile
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/Makefile,v
retrieving revision 1.121
diff -u -r1.121 Makefile
--- sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/Makefile 15 Sep 2002 02:30:28 -0000 1.121
+++ sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/Makefile 4 Oct 2002 05:45:31 -0000
@@ -20,7 +20,7 @@
sys/kd.h sys/soundcard.h sys/vt.h \
sys/quota.h sys/fsuid.h \
scsi/sg.h scsi/scsi.h scsi/scsi_ioctl.h sys/pci.h \
- sys/ultrasound.h sys/raw.h sys/personality.h
+ sys/ultrasound.h sys/raw.h sys/personality.h sys/hugepage.h
install-others += $(inst_includedir)/bits/syscall.h
Index: sysdeps/unix/sysv/linux/Versions
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/Versions,v
retrieving revision 1.18
diff -u -r1.18 Versions
--- sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/Versions 30 Aug 2002 01:30:55 -0000 1.18
+++ sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/Versions 4 Oct 2002 05:45:31 -0000
@@ -102,6 +102,10 @@
# r*
readahead;
+ gethugepagesize;
+ alloc_hugepages;
+ free_hugepages;
+
#errlist-compat 126
_sys_errlist; sys_errlist; _sys_nerr; sys_nerr;
}
Index: sysdeps/unix/sysv/linux/getsysstats.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/getsysstats.c,v
retrieving revision 1.22
diff -u -r1.22 getsysstats.c
--- sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/getsysstats.c 21 Sep 2002 05:26:12 -0000 1.22
+++ sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/getsysstats.c 4 Oct 2002 05:45:32 -0000
@@ -230,11 +230,8 @@
#endif
weak_alias (__get_nprocs_conf, get_nprocs_conf)
-/* General function to get information about memory status from proc
- filesystem. */
static long int
-internal_function
-phys_pages_info (const char *format)
+get_meminfo (const char *format)
{
FILE *fp;
char buffer[8192];
@@ -264,7 +261,7 @@
while (fgets_unlocked (buffer, sizeof buffer, fp) != NULL)
if (sscanf (buffer, format, &result) == 1)
{
- result /= (__getpagesize () / 1024);
+ result /= 1024;
break;
}
@@ -279,6 +276,20 @@
return result;
}
+/* General function to get information about memory status from proc
+ filesystem. */
+static long int
+internal_function
+phys_pages_info (const char *format)
+{
+ long int result = get_meminfo (format);
+
+ if (result != -1)
+ result /= __getpagesize ();
+
+ return result;
+}
+
/* Return the number of pages of physical memory in the system. There
is currently (as of version 2.0.21) no system call to determine the
@@ -320,6 +331,12 @@
}
weak_alias (__get_avphys_pages, get_avphys_pages)
+size_t
+__gethugepagesize ()
+{
+ return get_meminfo ("Hugepagesize: %lu kB");
+}
+weak_alias (__gethugepagesize, gethugepagesize);
static void
free_mem (void)
Index: sysdeps/unix/sysv/linux/syscalls.list
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/syscalls.list,v
retrieving revision 1.94
diff -u -r1.94 syscalls.list
--- sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/syscalls.list 15 Aug 2002 08:25:16 -0000 1.94
+++ sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/syscalls.list 4 Oct 2002 05:45:32 -0000
@@ -80,3 +80,5 @@
lremovexattr EXTRA lremovexattr i:ss lremovexattr
fremovexattr EXTRA fremovexattr i:is fremovexattr
+alloc_hugepages EXTRA alloc_hugepages b:ianii __alloc_hugepages alloc_hugepages
+free_hugepages EXTRA free_hugepages i:a __free_hugepages free_hugepages
Index: sysdeps/unix/sysv/linux/sys/hugepage.h
===================================================================
RCS file: sysdeps/unix/sysv/linux/sys/hugepage.h
diff -N sysdeps/unix/sysv/linux/sys/hugepage.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sysdeps/unix/sysv/linux/sys/sysdeps/unix/sysv/linux/sys/hugepage.h 4 Oct 2002 05:45:36 -0000
@@ -0,0 +1,78 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_HUGEPAGE_H
+#define _SYS_HUGEPAGE_H 1
+
+/* This header file defines the huge page interface. A huge page is a
+ non-swappable (pinned) page of virtual memory. As the name
+ suggests, the size of a huge page is typically orders of magnitudes
+ bigger than the value returned by getpagesize(). For example,
+ depending on kernel configuration, on x86 it may be 2MBytes or
+ 4MBytes and on ia64 it is typically one of 16MB, 256MBytes, or
+ 4GBytes. Note that because huge pages are never swapped, they are
+ a relatively rare commodity and applications are expected to fall
+ back to allocating regular pages if a huge page cannot be
+ allocated. */
+
+#include <features.h>
+
+#define __need_size_t
+#include <stddef.h>
+
+__BEGIN_DECLS
+
+/* Return the size of a huge page. */
+
+extern size_t __gethugepagesize (void) __attribute__ ((__const__)) __THROW;
+extern size_t gethugepagesize (void) __attribute__ ((__const__)) __THROW;
+
+/* Allocate LEN bytes worth of huge pages. LEN must be an integer
+ multiple of the huge page size. ADDR is the preferred starting
+ address for the memory. PROT is a mask of protection bits that
+ specify how the memory is to be mapped (PROT_NONE or any
+ combination of PROT_READ, PROT_WRITE, or PROT_EXEC). If KEY has is
+ a positive number, FLAG can be set to IPC_CREAT to request the
+ creation of a new shared memory segment or to zero to request
+ attaching to an existing shared memory segment.
+
+ Return value: On success, alloc_hugepages() returns a pointer to
+ the allocated memory. On error, MAP_FAILED ((void *) -1) is
+ returned and ERRNO is set appropriately.
+
+ Errors:
+ EINVAL LEN is not a integer multiple of gethugepagesize()
+ or KEY is a negative value.
+
+ ENOENT No shared segment matching KEY was found and FLAGS
+ was zero. */
+
+extern void *alloc_hugepages (int __key, void *__addr, size_t __len,
+ int __prot, int __flag) __THROW;
+
+/* Free the huge page resources from the current process's address
+ space. ADDR must be an address returned by a previous call to
+ alloc_hugepages (). Note that for shared memory segments, the
+ underlying physical memory will be freed only after the last
+ process using them has freed them up or has exited. */
+
+extern int free_hugepages (void *__addr) __THROW;
+
+__END_DECLS
+
+#endif /* sys/hugepage.h */
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch] add alloc_pages/free_pages support
2002-10-04 0:14 ` David Mosberger
@ 2002-10-04 20:02 ` Andreas Jaeger
2002-10-22 19:39 ` David Mosberger
0 siblings, 1 reply; 17+ messages in thread
From: Andreas Jaeger @ 2002-10-04 20:02 UTC (permalink / raw)
To: davidm; +Cc: Ulrich Drepper, libc-hacker
David Mosberger <davidm@napali.hpl.hp.com> writes:
>>>>>> On Thu, 03 Oct 2002 15:30:56 -0700, Ulrich Drepper <drepper@redhat.com> said:
>
> Uli> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
>
>
> >> Uli, do you have any other feedback or are you OK with it?
>
> Uli> The header still isn't right. You cannot have the hidden
> Uli> macros in there. And the function prototypes are missing
> Uli> __THROW.
>
> OK, how is this?
> [...]
> Index: sysdeps/unix/sysv/linux/Versions
> ===================================================================
> RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/Versions,v
> retrieving revision 1.18
> diff -u -r1.18 Versions
> --- sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/Versions 30 Aug 2002 01:30:55 -0000 1.18
> +++ sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/Versions 4 Oct 2002 05:45:31 -0000
> @@ -102,6 +102,10 @@
> # r*
> readahead;
>
> + gethugepagesize;
> + alloc_hugepages;
> + free_hugepages;
> +
With glibc 2.3 out of the door, this has to be added with version
glibc 2.3.1.
> Index: sysdeps/unix/sysv/linux/sys/hugepage.h
> ===================================================================
> RCS file: sysdeps/unix/sysv/linux/sys/hugepage.h
> diff -N sysdeps/unix/sysv/linux/sys/hugepage.h
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ sysdeps/unix/sysv/linux/sys/sysdeps/unix/sysv/linux/sys/hugepage.h 4 Oct 2002 05:45:36 -0000
> @@ -0,0 +1,78 @@
> +/* Copyright (C) 2002 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, write to the Free
> + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
> + 02111-1307 USA. */
> +
> +#ifndef _SYS_HUGEPAGE_H
> +#define _SYS_HUGEPAGE_H 1
> +
> +/* This header file defines the huge page interface. A huge page is a
> + non-swappable (pinned) page of virtual memory. As the name
> + suggests, the size of a huge page is typically orders of magnitudes
> + bigger than the value returned by getpagesize(). For example,
> + depending on kernel configuration, on x86 it may be 2MBytes or
> + 4MBytes and on ia64 it is typically one of 16MB, 256MBytes, or
> + 4GBytes. Note that because huge pages are never swapped, they are
> + a relatively rare commodity and applications are expected to fall
> + back to allocating regular pages if a huge page cannot be
> + allocated. */
> +
> +#include <features.h>
> +
> +#define __need_size_t
> +#include <stddef.h>
> +
> +__BEGIN_DECLS
> +
> +/* Return the size of a huge page. */
> +
> +extern size_t __gethugepagesize (void) __attribute__ ((__const__)) __THROW;
The header installed in the user level include should not have the
__gethugepagesize. If you need the prototype, we add it to an
internal header.
Andreas
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch] add alloc_pages/free_pages support
2002-10-04 20:02 ` Andreas Jaeger
@ 2002-10-22 19:39 ` David Mosberger
2002-10-22 23:52 ` Ulrich Drepper
0 siblings, 1 reply; 17+ messages in thread
From: David Mosberger @ 2002-10-22 19:39 UTC (permalink / raw)
To: libc-hacker; +Cc: Andreas Jaeger, Ulrich Drepper, rohit.seth, davidm
>>>>> On Fri, 04 Oct 2002 09:11:09 +0200, Andreas Jaeger <aj@suse.de> said:
>> + gethugepagesize; + alloc_hugepages; + free_hugepages; +
Andreas> With glibc 2.3 out of the door, this has to be added with
Andreas> version glibc 2.3.1.
OK, I made this change.
Andreas> The header installed in the user level include should not
Andreas> have the __gethugepagesize. If you need the prototype, we
Andreas> add it to an internal header.
Ditto.
If it looks OK, please apply the attached patch.
Thanks,
--david
2002-10-03 David Mosberger <davidm@hpl.hp.com>
* sysdeps/unix/sysv/linux/getsysstats.c (get_meminfo): New function.
(phys_pages_info): Implementing on the basis of get_meminfo().
(__gethugepagesize): New function.
* sysdeps/unix/sysv/linux/Versions: Mention gethugepagesize().
2002-10-02 David Mosberger <davidm@hpl.hp.com>
* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Mention
sys/hugepage.h.
* sysdeps/unix/sysv/linux/syscalls.list: Make alloc_hugepages and
free_hugepages weak symbols.
* sysdeps/unix/sysv/linux/Versions: Mention alloc_hugepages and
free_hugepages.
2002-10-01 Rohit Seth <rohit.seth@intel.com>,
David Mosberger <davidm@hpl.hp.com>
* sysdeps/unix/sysv/linux/syscalls.list: Add alloc_hugepages and
free_hugepages.
* sysdeps/unix/sysv/linux/sys/hugepage.h: New file.
Index: sysdeps/unix/sysv/linux/Makefile
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/Makefile,v
retrieving revision 1.123
diff -u -r1.123 Makefile
--- sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/Makefile 16 Oct 2002 03:02:50 -0000 1.123
+++ sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/Makefile 23 Oct 2002 01:42:58 -0000
@@ -20,7 +20,7 @@
sys/kd.h sys/soundcard.h sys/vt.h \
sys/quota.h sys/fsuid.h \
scsi/sg.h scsi/scsi.h scsi/scsi_ioctl.h sys/pci.h \
- sys/ultrasound.h sys/raw.h sys/personality.h
+ sys/ultrasound.h sys/raw.h sys/personality.h sys/hugepage.h
install-others += $(inst_includedir)/bits/syscall.h
Index: sysdeps/unix/sysv/linux/Versions
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/Versions,v
retrieving revision 1.18
diff -u -r1.18 Versions
--- sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/Versions 30 Aug 2002 01:30:55 -0000 1.18
+++ sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/Versions 23 Oct 2002 01:42:58 -0000
@@ -105,6 +105,11 @@
#errlist-compat 126
_sys_errlist; sys_errlist; _sys_nerr; sys_nerr;
}
+ GLIBC_2.3.1 {
+ gethugepagesize;
+ alloc_hugepages;
+ free_hugepages;
+ }
GLIBC_PRIVATE {
# needed by libpthread.
__libc_sigaction;
Index: sysdeps/unix/sysv/linux/getsysstats.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/getsysstats.c,v
retrieving revision 1.22
diff -u -r1.22 getsysstats.c
--- sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/getsysstats.c 21 Sep 2002 05:26:12 -0000 1.22
+++ sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/getsysstats.c 23 Oct 2002 01:42:58 -0000
@@ -230,11 +230,8 @@
#endif
weak_alias (__get_nprocs_conf, get_nprocs_conf)
-/* General function to get information about memory status from proc
- filesystem. */
static long int
-internal_function
-phys_pages_info (const char *format)
+get_meminfo (const char *format)
{
FILE *fp;
char buffer[8192];
@@ -263,10 +260,7 @@
bytes are really enough. */
while (fgets_unlocked (buffer, sizeof buffer, fp) != NULL)
if (sscanf (buffer, format, &result) == 1)
- {
- result /= (__getpagesize () / 1024);
- break;
- }
+ break;
fclose (fp);
}
@@ -279,6 +273,20 @@
return result;
}
+/* General function to get information about memory status from proc
+ filesystem. */
+static long int
+internal_function
+phys_pages_info (const char *format)
+{
+ long int result = get_meminfo (format);
+
+ if (result != -1)
+ result /= __getpagesize () / 1024;
+
+ return result;
+}
+
/* Return the number of pages of physical memory in the system. There
is currently (as of version 2.0.21) no system call to determine the
@@ -320,6 +328,17 @@
}
weak_alias (__get_avphys_pages, get_avphys_pages)
+size_t
+__gethugepagesize ()
+{
+ long int result = get_meminfo ("Hugepagesize: %lu kB");
+
+ if (result != -1)
+ result *= 1024;
+
+ return result;
+}
+weak_alias (__gethugepagesize, gethugepagesize);
static void
free_mem (void)
Index: sysdeps/unix/sysv/linux/syscalls.list
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/syscalls.list,v
retrieving revision 1.96
diff -u -r1.96 syscalls.list
--- sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/syscalls.list 14 Oct 2002 01:03:01 -0000 1.96
+++ sysdeps/unix/sysv/linux/sysdeps/unix/sysv/linux/syscalls.list 23 Oct 2002 01:42:59 -0000
@@ -82,3 +82,6 @@
removexattr EXTRA removexattr i:ss removexattr
lremovexattr EXTRA lremovexattr i:ss lremovexattr
fremovexattr EXTRA fremovexattr i:is fremovexattr
+
+alloc_hugepages EXTRA alloc_hugepages b:ianii __alloc_hugepages alloc_hugepages
+free_hugepages EXTRA free_hugepages i:a __free_hugepages free_hugepages
Index: sysdeps/unix/sysv/linux/sys/hugepage.h
===================================================================
RCS file: sysdeps/unix/sysv/linux/sys/hugepage.h
diff -N sysdeps/unix/sysv/linux/sys/hugepage.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sysdeps/unix/sysv/linux/sys/sysdeps/unix/sysv/linux/sys/hugepage.h 23 Oct 2002 01:43:01 -0000
@@ -0,0 +1,77 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_HUGEPAGE_H
+#define _SYS_HUGEPAGE_H 1
+
+/* This header file defines the huge page interface. A huge page is a
+ non-swappable (pinned) page of virtual memory. As the name
+ suggests, the size of a huge page is typically orders of magnitudes
+ bigger than the value returned by getpagesize(). For example,
+ depending on kernel configuration, on x86 it may be 2MBytes or
+ 4MBytes and on ia64 it is typically one of 16MB, 256MBytes, or
+ 4GBytes. Note that because huge pages are never swapped, they are
+ a relatively rare commodity and applications are expected to fall
+ back to allocating regular pages if a huge page cannot be
+ allocated. */
+
+#include <features.h>
+
+#define __need_size_t
+#include <stddef.h>
+
+__BEGIN_DECLS
+
+/* Return the size of a huge page. */
+
+extern size_t gethugepagesize (void) __attribute__ ((__const__)) __THROW;
+
+/* Allocate LEN bytes worth of huge pages. LEN must be an integer
+ multiple of the huge page size. ADDR is the preferred starting
+ address for the memory. PROT is a mask of protection bits that
+ specify how the memory is to be mapped (PROT_NONE or any
+ combination of PROT_READ, PROT_WRITE, or PROT_EXEC). If KEY has is
+ a positive number, FLAG can be set to IPC_CREAT to request the
+ creation of a new shared memory segment or to zero to request
+ attaching to an existing shared memory segment.
+
+ Return value: On success, alloc_hugepages() returns a pointer to
+ the allocated memory. On error, MAP_FAILED ((void *) -1) is
+ returned and ERRNO is set appropriately.
+
+ Errors:
+ EINVAL LEN is not a integer multiple of gethugepagesize()
+ or KEY is a negative value.
+
+ ENOENT No shared segment matching KEY was found and FLAGS
+ was zero. */
+
+extern void *alloc_hugepages (int __key, void *__addr, size_t __len,
+ int __prot, int __flag) __THROW;
+
+/* Free the huge page resources from the current process's address
+ space. ADDR must be an address returned by a previous call to
+ alloc_hugepages (). Note that for shared memory segments, the
+ underlying physical memory will be freed only after the last
+ process using them has freed them up or has exited. */
+
+extern int free_hugepages (void *__addr) __THROW;
+
+__END_DECLS
+
+#endif /* sys/hugepage.h */
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch] add alloc_pages/free_pages support
2002-10-22 19:39 ` David Mosberger
@ 2002-10-22 23:52 ` Ulrich Drepper
2002-10-22 23:58 ` David Mosberger
0 siblings, 1 reply; 17+ messages in thread
From: Ulrich Drepper @ 2002-10-22 23:52 UTC (permalink / raw)
To: davidm; +Cc: libc-hacker
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
David Mosberger wrote:
> If it looks OK, please apply the attached patch.
Actually, I won't apply the patch. There is talk again about removing
these syscalls and I surely hope it'll happen. If such mapping should
happen use mmap. Until Linus makes a final decision nothing happens.
- --
- --------------. ,-. 444 Castro Street
Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA
Red Hat `--' drepper at redhat.com `---------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE9tgwu2ijCOnn/RHQRAhYSAKCjBPt58UJ2KCJdWjSkuZ/IbPfS3QCePlC7
p0FCE7ieK6neCU+YxqHyNP8=
=DchU
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch] add alloc_pages/free_pages support
2002-10-22 23:52 ` Ulrich Drepper
@ 2002-10-22 23:58 ` David Mosberger
2002-10-23 8:20 ` Ulrich Drepper
0 siblings, 1 reply; 17+ messages in thread
From: David Mosberger @ 2002-10-22 23:58 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: rohit.seth, davidm, libc-hacker
>>>>> On Tue, 22 Oct 2002 19:40:46 -0700, Ulrich Drepper <drepper@redhat.com> said:
Uli> Actually, I won't apply the patch. There is talk again about
Uli> removing these syscalls and I surely hope it'll happen. If
Uli> such mapping should happen use mmap. Until Linus makes a final
Uli> decision nothing happens.
Linus *has* made a final decision. Those syscalls were added upon his
explicit request. Go back and check the mail archives.
Please apply the patch.
--david
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch] add alloc_pages/free_pages support
2002-10-22 23:58 ` David Mosberger
@ 2002-10-23 8:20 ` Ulrich Drepper
2002-10-23 10:34 ` David Mosberger
0 siblings, 1 reply; 17+ messages in thread
From: Ulrich Drepper @ 2002-10-23 8:20 UTC (permalink / raw)
To: davidm; +Cc: libc-hacker
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
David Mosberger wrote:
> Linus *has* made a final decision. Those syscalls were added upon his
> explicit request. Go back and check the mail archives.
Read the current discussions. Wrong decisions can easily be undone.
> Please apply the patch.
No.
- --
- --------------. ,-. 444 Castro Street
Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA
Red Hat `--' drepper at redhat.com `---------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE9tkje2ijCOnn/RHQRAqJbAKCQqdIVo4NwT+B7cFthat6q+5QyBACeIwaB
xIV7SeBJhbFi26LAQKy1JrY=
=EeNN
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch] add alloc_pages/free_pages support
2002-10-23 8:20 ` Ulrich Drepper
@ 2002-10-23 10:34 ` David Mosberger
2002-10-23 11:46 ` Ulrich Drepper
0 siblings, 1 reply; 17+ messages in thread
From: David Mosberger @ 2002-10-23 10:34 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: rohit.seth, davidm, libc-hacker
>>>>> On Tue, 22 Oct 2002 23:59:42 -0700, Ulrich Drepper <drepper@redhat.com> said:
Uli> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Uli> David Mosberger wrote:
>> Linus *has* made a final decision. Those syscalls were added
>> upon his explicit request. Go back and check the mail archives.
Uli> Read the current discussions.
I did (assuming you're referring to the shared page table discussion;
see
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=E1844h3-0002Bt-00%40w-gerrit2&rnum=4&prev=/groups%3Fq%3Dben%2Blahaise%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26scoring%3Dd%26selm%3DE1844h3-0002Bt-00%2540w-gerrit2%26rnum%3D4).
There is nothing new there. Now if you'd read the original
discussion, you'd see that Linus considered those objections and still
preferred separate system calls. You have to realize that the huge
page syscalls are NOT a replacement for transparent superpages. They
serve a different purpose and have a different scope (we're talking
about pages of the size of 256MB and more, not merely something that's
a small multiple of the base page size).
Please apply the patch.
--david
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch] add alloc_pages/free_pages support
2002-10-23 10:34 ` David Mosberger
@ 2002-10-23 11:46 ` Ulrich Drepper
2002-10-23 14:51 ` David Mosberger
0 siblings, 1 reply; 17+ messages in thread
From: Ulrich Drepper @ 2002-10-23 11:46 UTC (permalink / raw)
To: davidm; +Cc: libc-hacker
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
David Mosberger wrote:
> Please apply the patch.
David, stop it. I won't apply anything until the decisions are truly
final. When Linus says it explicitly (again) I'll add it.
If you, as it seems, have something riding on this (some benchmark?) it
is your problem. I'm not giving the proponents of this interface a
reason for saying "it cannot be removed because it's already in use".
- --
- --------------. ,-. 444 Castro Street
Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA
Red Hat `--' drepper at redhat.com `---------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE9tt3e2ijCOnn/RHQRAu6mAJ0bJY4myRu6YCSNg51cUEaEwk+qIQCgu2Ak
t65rLDV1BIRD6WE7g2i5ajk=
=MmAL
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [patch] add alloc_pages/free_pages support
2002-10-23 11:46 ` Ulrich Drepper
@ 2002-10-23 14:51 ` David Mosberger
0 siblings, 0 replies; 17+ messages in thread
From: David Mosberger @ 2002-10-23 14:51 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: davidm, libc-hacker
>>>>> On Wed, 23 Oct 2002 10:35:26 -0700, Ulrich Drepper <drepper@redhat.com> said:
Uli> David, stop it. I won't apply anything until the decisions are
Uli> truly final. When Linus says it explicitly (again) I'll add
Uli> it.
You ought to stop it. The interface has been discussed at great
length and Linus decided for the new system calls. If you take a few
minutes to read the discussions and think about it, I think you too
would see why Linus decided for the current solution.
Uli> If you, as it seems, have something riding on this (some
Uli> benchmark?) it is your problem. I'm not giving the proponents
Uli> of this interface a reason for saying "it cannot be removed
Uli> because it's already in use".
You're making unfounded accusations.
Please remember that Linus is the Linux kernel maintainer...
--david
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2002-10-23 18:46 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-03 0:03 [patch] add alloc_pages/free_pages support David Mosberger
2002-10-03 0:20 ` Ulrich Drepper
2002-10-03 12:37 ` David Mosberger
2002-10-03 14:44 ` David Mosberger
2002-10-03 15:05 ` David Mosberger
[not found] ` <200210032146.g93LkB119076@magilla.sf.frob.com>
2002-10-03 15:30 ` David Mosberger
2002-10-03 15:34 ` Ulrich Drepper
2002-10-03 22:48 ` David Mosberger
2002-10-04 0:14 ` David Mosberger
2002-10-04 20:02 ` Andreas Jaeger
2002-10-22 19:39 ` David Mosberger
2002-10-22 23:52 ` Ulrich Drepper
2002-10-22 23:58 ` David Mosberger
2002-10-23 8:20 ` Ulrich Drepper
2002-10-23 10:34 ` David Mosberger
2002-10-23 11:46 ` Ulrich Drepper
2002-10-23 14:51 ` David Mosberger
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 read-only IMAP folder(s) and NNTP newsgroup(s).