aboutsummaryrefslogtreecommitdiff
path: root/kernel-features.c
AgeCommit message (Collapse)Author
2012-12-07Remove use of sscanf in library setupEric B Munson
commit cdd2fa33 makes th library setup exhaust any heap allocated on small pages. This covers but does not address the cause of the allocation. As mentioned by Steve Capper, sscanf is the cause of the allocation. This patch removes the usage of sscanf from any function used in library setup prior to replacing _morecore. Signed-off-by: Eric B Munson <emunson@mgebm.net> Cc: Steve Capper <steve.capper@arm.com> Cc: Jan Stancek <jstancek@redhat.com>
2010-11-29Add kernel feature check for MAP_HUGETLBEric B Munson
Since 2.6.32 the kernel has supported pseudo-anonymous mmaps for huge pages without having hugetlbfs mounted. This patch adds a check for that kernel feature. Signed-off-by: Eric B Munson <emunson@mgebm.net> Acked-by: Mel Gorman <mel@csn.ul.ie>
2010-05-17Allow MAP_NORESERVE to be used on an earlier kernelMel Gorman
The patch that allows MAP_NORESERVE to be safely used was unexpectedly merged for 2.6.34 instead of 2.6.35. Update the kernel features test accordingly. Signed-off-by: Mel Gorman <mel@csn.ul.ie> Signed-off-by: Eric B Munson <ebmunson@us.ibm.com>
2010-05-13Allow MAP_NORESERVE to be used for mappingsMel Gorman
Since 2.6.27-rc1, the kernel makes reservations for mappings at mmap() time. This guarantees that the process that successfully calls mmap() will successfully fault all pages within that region. This is nice reliable behaviour but it can be the case the program wants to create a very large sparse mapping. In this case, mmap() will fail even if the program knows the huge pages are available. This patch introduces a --no-reserve switch that uses MAP_NORESERVE. mmap() will always succeed but the fault might not. Unfortunately, on older kernels, use of MAP_NORESERVE can trigger the OOM killer. Hence, this patch also checks the kernel version and only allows use of MAP_NORESERVE if it's safe to do so. Signed-off-by: Mel Gorman <mel@csn.ul.ie> Acked-by: Eric B Munson <ebmunson@us.ibm.com> Signed-off-by: Eric B Munson <ebmunson@us.ibm.com>
2009-01-08Move all getenv calls from various function in hugeutils into ↵Eric B Munson
hugetlbfs_setup_env Signed-off-by: Eric B Munson <ebmunson@us.ibm.com>
2008-11-18Audit verbosity of messages in the library utility functions (V2)Adam Litke
Changes since V1: - In the event that the normal default huge page size cannot be used by libhugetlbfs (due to no usable mount point), if the user specified the size print a WARNING (since semantics are altered), otherwise just print an INFO message. Signed-off-by: Adam Litke <agl@us.ibm.com> Signed-off-by: Eric B Munson <ebmunson@us.ibm.com>
2008-10-27tests: Add helper for comparing kernel versionsAdam Litke
Make use of pre-existing kernel version comparison code and create a helper that can be used by test wrapper scripts to compare two kernel versions. Signed-off-by: Adam Litke <agl@us.ibm.com> Signed-off-by: Eric B Munson <ebmunson@us.ibm.com>
2008-10-27utils: Buglet in kernel version comparison functionAdam Litke
Oops. The greater-than operator (>) is not commutative. While trying to test for a > b, we are accidentally re-testing a < b. Fix. Signed-off-by: Adam Litke <agl@us.ibm.com> Acked-by: Mel Gorman <mel@csn.ul.ie> Signed-off-by: Eric B Munson <ebmunson@us.ibm.com>
2008-10-21whitespace: cleanup whitespace breakage2.1-pre3Andy Whitcroft
We have developed a far amount of whitespace damage over time. Do a one off cleanup of all of the breakage now. Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Eric B Munson <ebmunson@us.ibm.com>
2008-10-21make print_valid_features/check_features_env_valid file staticAndy Whitcroft
Signed-off-by: Andy Whitcroft <apw@shadowen.org> Acked-by: Adam Litke <agl@us.ibm.com> Acked-by: Mel Gorman <mel@csn.ul.ie>
2008-10-21stop exporting kernel detectionAndy Whitcroft
Signed-off-by: Andy Whitcroft <apw@shadowen.org> Acked-by: Adam Litke <agl@us.ibm.com> Acked-by: Mel Gorman <mel@csn.ul.ie>
2008-10-21move to a new library local idiomAndy Whitcroft
Currently we have three types of function: file local -- marked static in the normal way, library local -- external but prefixed with __lh_ library exported -- external and listed in the library.lds file While the library prefix works, it does not allow functions to trivially move from file local to library local as all references to the function have to be modified to the new name. This patch introduces a new idiom. When a function is intended to be library local it is already necessary to declare that function in the libhugetlbfs_internal.h, if we also add a single define for that function adding the __lh_ prefix (as below) then all other references including the original definition may use the original name unchanged but the function will remain unexported: #define hpool_sizes __lh_hpool_sizes extern int hpool_sizes(struct hpage_pool *, int); This patch converts all current library local functions to this new idiom. Signed-off-by: Andy Whitcroft <apw@shadowen.org> Acked-by: Adam Litke <agl@us.ibm.com> Acked-by: Mel Gorman <mel@csn.ul.ie>
2008-09-03Check HUGETLB_FEATURES for correctnessAdam Litke
The HUGETLB_FEATURES environment variable is prone to typos and other errors that could lead the library to behave in strange ways. Make sure that, if specified, the variable is checked for correctness. The string is assumed to be delimited by commas. Each token is then compared against this list of known features to ensure it matches one of them. If no match is found, an error is printed that explains the valid format and the whole variable is ignored. Signed-off-by: Adam Litke <agl@us.ibm.com>
2008-09-03Allow users to override feature detection (V2)Adam Litke
Changes since V1: - Changed the environment variable name and format for specifying overrides. In some cases (such as a distro kernel with backported features) libhugetlbfs will be wrong about the presence of a feature. In these rare cases it will be useful to tell the library whether or not the feature is present in the running kernel. All feature overrides will be specified in the HUGETLB_FEATURES environment variable. The required format is: "[no_]feature1[,[no_]feature2] ... ". The "no_" prefix will mark a feature as absent. Otherwise the named feature is marked present. Signed-off-by: Adam Litke <agl@us.ibm.com>
2008-08-05[RFC] Use the kernel version number to identify kernel functionality V2Adam Litke
Historically, libhugetlbs has relied on kernel features that either: have been known to exist in all supported kernel versions, or are easily detected. As of kernel version 2.6.27-rc1, a new crucial feature has been added that is not possible to reliably detect. Huge page mappings created with the MAP_PRIVATE flag will have huge pages reserved up-front. With private reservations in effect, it is safe to allow demand-faulting of the HUGETLB_MORECORE heap which can lead to dramatic performance improvements on NUMA systems. This is only safe behavior in the presence of private reservations. The only way to identify that a kernel has private reservations support is to examine the kernel version to see if it is more recent than when the feature appeared. I am well aware of the drawbacks of using the kernel version to affect library behavior but I don't see any alternative. I would suggest that the kernel version should be used only in cases when there is no alternative. How it works ============ Kernels are assumed to have a mandatory base version x.y.z (eg. 2.6.17) and one optional modifier: a post version (stable tree x.y.z.q) or a pre version (x.y.z-{preN|rcN}). All other version appendices (such as -mmN) are ignored. The following ordering rules apply: x.y.z-rc(N) < x.y.z-rc(N+1) < x.y.z < x.y.z.(N) < x.y.z.(N+1) When libhugetlbfs initializes, the running kernel version is probed using uname. A list of feature definitions is scanned and those with a minimum kernel version have that version compared to the runninng kernel. If the running kernel is found to be equal to or greater than the minimum required kernel version, a bit in a feature mask is set to indicate the presence of the feature. A feature can be later checked for by using a simple function that checks the bitmask. Changes since V1 (Thanks Andy Whitcroft and Mel Gorman): - Fixed feature_mask handling - Readability improvements