rts: Throw better error if --numa is used without libnuma support
authorBen Gamari <bgamari.foss@gmail.com>
Thu, 3 May 2018 16:42:24 +0000 (12:42 -0400)
committerBen Gamari <ben@smart-cactus.org>
Thu, 3 May 2018 19:01:17 +0000 (15:01 -0400)
Test Plan: Validate, run program with `+RTS --numa` without libnuma
support compiled in

Reviewers: erikd, simonmar

Subscribers: thomie, carter

GHC Trac Issues: #14956

Differential Revision: https://phabricator.haskell.org/D4556

rts/RtsFlags.c
rts/posix/OSMem.c
rts/sm/OSMem.h
rts/win32/OSMem.c

index 461c416..7c292d2 100644 (file)
@@ -906,6 +906,12 @@ error = true;
                   }
 #if defined(THREADED_RTS)
                   else if (!strncmp("numa", &rts_argv[arg][2], 4)) {
+                      if (!osBuiltWithNumaSupport()) {
+                          errorBelch("%s: This GHC build was compiled without NUMA support.",
+                                     rts_argv[arg]);
+                          error = true;
+                          break;
+                      }
                       OPTION_SAFE;
                       StgWord mask;
                       if (rts_argv[arg][6] == '=') {
index f603644..9ecd53e 100644 (file)
@@ -591,6 +591,15 @@ void osReleaseHeapMemory(void)
 
 #endif
 
+bool osBuiltWithNumaSupport(void)
+{
+#if HAVE_LIBNUMA
+    return true;
+#else
+    return false;
+#endif
+}
+
 bool osNumaAvailable(void)
 {
 #if HAVE_LIBNUMA
index 3b0cee9..7dd0efd 100644 (file)
@@ -18,6 +18,7 @@ void osFreeAllMBlocks(void);
 size_t getPageSize (void);
 StgWord64 getPhysicalMemorySize (void);
 void setExecutable (void *p, W_ len, bool exec);
+bool osBuiltWithNumaSupport(void); // See #14956
 bool osNumaAvailable(void);
 uint32_t osNumaNodes(void);
 uint64_t osNumaMask(void);
index d05151c..c62ee3b 100644 (file)
@@ -499,6 +499,11 @@ void osReleaseHeapMemory (void)
 
 #endif
 
+bool osBuiltWithNumaSupport(void)
+{
+    return true;
+}
+
 bool osNumaAvailable(void)
 {
     return osNumaNodes() > 1;