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

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