Commits

Anonymous committed 187520e

Added sysctl for target load.

  • Participants
  • Parent commits 1dafa9a

Comments (0)

Files changed (2)

File Source/IntelEnhancedSpeedStep.cpp

 	return err;
 }
 
-SYSCTL_PROC  (_kern, OID_AUTO, cputhrottle_auto,    CTLTYPE_INT | CTLFLAG_RW, 0, 0, &iess_handle_auto,    "I", "Auto-throttle status");
+static int iess_handle_targetload SYSCTL_HANDLER_ARGS
+{
+	int err = 0;
+	if (req->newptr) {
+		// new ctl being set
+		int target;
+		err = SYSCTL_IN(req, &target, sizeof(int));
+		if (err) return err;
+		if (!Throttler) return kIOReturnError;
+		if (target > 95) return kIOReturnError;
+		dbg("Setting autothrottle target to %d\n", target*10);
+		Throttler->targetCPULoad = target * 10;
+		
+	} else {
+		if (!Throttler) return kIOReturnError;
+		int target = Throttler->targetCPULoad / 10;
+		err = SYSCTL_OUT(req, &target, sizeof(int));
+	}
+	return err;
+}
+
+SYSCTL_PROC  (_kern, OID_AUTO, cputhrottle_auto,	CTLTYPE_INT | CTLFLAG_RW, 0, 0, &iess_handle_auto,    "I", "Auto-throttle status");
+SYSCTL_PROC  (_kern, OID_AUTO, cputhrottle_targetload,	CTLTYPE_INT | CTLFLAG_RW, 0, 0, &iess_handle_targetload,    "I", "Auto-throttle target CPU load");
 
 bool AutoThrottler::setup(OSObject* owner) {
 	if (setupDone) return true;
 	currentPState = NumberOfPStates - 1;
 	perfTimer->setTimeoutMS(1024);
 	clock_get_uptime(&lastTime);
-	targetCPULoad = 200; // % x10
+	targetCPULoad = 300; // % x10
 	setupDone = true;
 	sysctl_register_oid(&sysctl__kern_cputhrottle_auto);
+	sysctl_register_oid(&sysctl__kern_cputhrottle_targetload);
 	return true;
 }
 
 void AutoThrottler::free() {
 	if (enabled) enabled = false;
 	if (setupDone) stop();
-	sysctl_unregister_oid(&sysctl__kern_cputhrottle_ctl);
+	sysctl_unregister_oid(&sysctl__kern_cputhrottle_auto);
+	sysctl_unregister_oid(&sysctl__kern_cputhrottle_targetload);
 	if (perfTimer) {
 		perfTimer->release();
 		perfTimer = 0;
 		}
 	}
 	
-	*total = (total_ticks[cpu_maxload] + 1);
-	*idle  = (*total - load_ticks[cpu_maxload] + 1);
+	*total = total_ticks[cpu_maxload];
+	*idle  = *total - load_ticks[cpu_maxload];
 	
 	dbg("Autothrottle: CPU load %d /10 pc\n", (1000 * (*idle - *total)) / *total);
 /*

File Source/IntelEnhancedSpeedStep.h

 	bool		enabled;	// driver is autothrottling
 	uint8_t		currentPState;
 	uint64_t	lastTime;
-	uint16_t	targetCPULoad;
 	host_t		selfHost;
 #define max_cpus 32
 	processor_t	mach_cpu[max_cpus];
 	processor_cpu_load_info cpu_load_last[max_cpus];
 
 public:
+	uint16_t targetCPULoad;
 	bool setup(OSObject* owner);	// Initialize the throttler
 	void stop();
 	void setEnabled(bool _enabled);