Make it possible to use +RTS -qn without -N
authorSimon Marlow <marlowsd@gmail.com>
Fri, 28 Oct 2016 15:34:44 +0000 (16:34 +0100)
committerSimon Marlow <marlowsd@gmail.com>
Fri, 28 Oct 2016 19:14:41 +0000 (20:14 +0100)
It's entirely reasonable to set +RTS -qn without setting -N, because the
program might later call setNumCapabilities.  If we disallow it, there's
no way to use -qn on programs that use setNumCapabilities.

rts/RtsFlags.c
rts/Schedule.c

index d86b154..aeb2fe5 100644 (file)
@@ -1487,13 +1487,6 @@ static void normaliseRtsOpts (void)
             RtsFlags.ParFlags.parGcLoadBalancingGen = 1;
         }
     }
-
-#ifdef THREADED_RTS
-    if (RtsFlags.ParFlags.parGcThreads > RtsFlags.ParFlags.nCapabilities) {
-        errorBelch("GC threads (-qn) must be between 1 and the value of -N");
-        errorUsage();
-    }
-#endif
 }
 
 static void errorUsage (void)
index 06db3fe..a44512b 100644 (file)
@@ -1596,7 +1596,11 @@ scheduleDoGC (Capability **pcap, Task *task USED_IF_THREADS,
             // enabled_capabilities may change if requestSync() below fails and
             // we retry.
             if (gc_type == SYNC_GC_PAR && n_gc_threads > 0) {
-                need_idle = stg_max(0, enabled_capabilities - n_gc_threads);
+                if (n_gc_threads >= enabled_capabilities) {
+                    need_idle = 0;
+                } else {
+                    need_idle = enabled_capabilities - n_gc_threads;
+                }
             } else {
                 need_idle = 0;
             }