Skip to content

Commit

Permalink
Reduce changes
Browse files Browse the repository at this point in the history
Signed-off-by: Ilya Isaev <[email protected]>
  • Loading branch information
isaevil committed Oct 12, 2021
1 parent ef970eb commit b14c0db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/tbbmalloc/tbbmalloc_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ class HugePagesStatus {
void parseSystemMemInfo() {
bool hpAvailable = false;
bool thpAvailable = false;
unsigned long long hugePageSize = 0;
unsigned long long hugePageSize = ULLONG_MAX;

#if __unix__
// Check huge pages existence
Expand All @@ -471,7 +471,7 @@ class HugePagesStatus {
// We parse a counter number, it can't be huge
parseFile</*BUFF_SIZE=*/100>("/proc/sys/vm/nr_hugepages", vmItem);

if (meminfoHugePagesTotal > 0 || vmHugePagesTotal > 0) {
if (hugePageSize < ULLONG_MAX && meminfoHugePagesTotal > 0 || vmHugePagesTotal > 0) {
MALLOC_ASSERT(hugePageSize != 0, "Huge Page size can't be zero if we found preallocated.");

// Any non zero value clearly states that there are preallocated
Expand All @@ -484,7 +484,7 @@ class HugePagesStatus {
parseFileItem thpItem[] = { { "[alwa%cs] madvise never\n", thpPresent } };
parseFile</*BUFF_SIZE=*/100>("/sys/kernel/mm/transparent_hugepage/enabled", thpItem);

if (thpPresent == 'y') {
if (hugePageSize < ULLONG_MAX && thpPresent == 'y') {
MALLOC_ASSERT(hugePageSize != 0, "Huge Page size can't be zero if we found thp existence.");
thpAvailable = true;
}
Expand Down
7 changes: 6 additions & 1 deletion test/common/memory_usage.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,15 @@ namespace utils {

inline bool isTHPEnabledOnMachine() {
unsigned long long thpPresent = 'n';
unsigned long long hugePageSize = ULLONG_MAX;

parseFileItem thpItem[] = { { "[alwa%cs] madvise never\n", thpPresent } };
parseFileItem hpSizeItem[] = { { "Hugepagesize: %llu kB", hugePageSize } };

parseFile</*BUFF_SIZE=*/100>("/sys/kernel/mm/transparent_hugepage/enabled", thpItem);
parseFile</*BUFF_SIZE=*/100>("/proc/meminfo", hpSizeItem);

if (thpPresent == 'y') {
if (hugePageSize < ULLONG_MAX && thpPresent == 'y') {
return true;
} else {
return false;
Expand Down

0 comments on commit b14c0db

Please sign in to comment.