Blame SOURCES/0011-hugeutils-Add-utility-to-check-if-slices-are-support.patch

fc9b0e
From 8cc33a134681892a71a4f67397bb13a541bb463e Mon Sep 17 00:00:00 2001
fc9b0e
Message-Id: <8cc33a134681892a71a4f67397bb13a541bb463e.1566225007.git.aquini@redhat.com>
fc9b0e
In-Reply-To: <d42f467a923dfc09309acb7a83b42e3285fbd8f4.1566225007.git.aquini@redhat.com>
fc9b0e
References: <d42f467a923dfc09309acb7a83b42e3285fbd8f4.1566225007.git.aquini@redhat.com>
fc9b0e
From: Sandipan Das <sandipan@linux.ibm.com>
fc9b0e
Date: Thu, 15 Aug 2019 13:08:38 +0530
fc9b0e
Subject: [RHEL7 PATCH 11/31] hugeutils: Add utility to check if slices are
fc9b0e
 supported
fc9b0e
fc9b0e
This adds an utility to check if the current processor
fc9b0e
architecture supports slices. Slices are used to divide
fc9b0e
up a virtual address space and put certain restrictions
fc9b0e
like on powerpc64 with Hash MMU where one can have only
fc9b0e
one page size per slice.
fc9b0e
fc9b0e
Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
fc9b0e
Signed-off-by: Eric B Munson <emunson@mgebm.net>
fc9b0e
Signed-off-by: Rafael Aquini <aquini@redhat.com>
fc9b0e
---
fc9b0e
 hugeutils.c              | 21 +++++++++++++++++++++
fc9b0e
 libhugetlbfs_privutils.h |  3 +++
fc9b0e
 2 files changed, 24 insertions(+)
fc9b0e
fc9b0e
diff --git a/hugeutils.c b/hugeutils.c
fc9b0e
index fc64946..e573622 100644
fc9b0e
--- a/hugeutils.c
fc9b0e
+++ b/hugeutils.c
fc9b0e
@@ -800,6 +800,27 @@ int hpool_sizes(struct hpage_pool *pools, int pcnt)
fc9b0e
 	return (which < pcnt) ? which : -1;
fc9b0e
 }
fc9b0e
 
fc9b0e
+int arch_has_slice_support(void)
fc9b0e
+{
fc9b0e
+#ifdef __powerpc64__
fc9b0e
+	char mmu_type[16];
fc9b0e
+	FILE *fp;
fc9b0e
+
fc9b0e
+	fp = popen("cat /proc/cpuinfo | grep MMU | awk '{ print $3}'", "r");
fc9b0e
+	if (!fp || fscanf(fp, "%s", mmu_type) < 0) {
fc9b0e
+		ERROR("Failed to determine MMU type\n");
fc9b0e
+		abort();
fc9b0e
+	}
fc9b0e
+
fc9b0e
+	pclose(fp);
fc9b0e
+	return strcmp(mmu_type, "Hash") == 0;
fc9b0e
+#elif defined(__powerpc__) && !defined(PPC_NO_SEGMENTS)
fc9b0e
+	return 1;
fc9b0e
+#else
fc9b0e
+	return 0;
fc9b0e
+#endif
fc9b0e
+}
fc9b0e
+
fc9b0e
 /*
fc9b0e
  * If we have a default page size then we support hugepages.
fc9b0e
  */
fc9b0e
diff --git a/libhugetlbfs_privutils.h b/libhugetlbfs_privutils.h
fc9b0e
index 149e42f..8b12fed 100644
fc9b0e
--- a/libhugetlbfs_privutils.h
fc9b0e
+++ b/libhugetlbfs_privutils.h
fc9b0e
@@ -53,6 +53,9 @@ int set_nr_hugepages(long pagesize, unsigned long val);
fc9b0e
 #define set_nr_overcommit_hugepages __pu_set_nr_overcommit_hugepages
fc9b0e
 int set_nr_overcommit_hugepages(long pagesize, unsigned long val);
fc9b0e
 
fc9b0e
+#define arch_has_slice_support __pu_arch_has_slice_support
fc9b0e
+int arch_has_slice_support(void);
fc9b0e
+
fc9b0e
 #define kernel_has_hugepages __pu_kernel_has_hugepages
fc9b0e
 int kernel_has_hugepages(void);
fc9b0e
 
fc9b0e
-- 
fc9b0e
1.8.3.1
fc9b0e