~/public_html/src/bsd/fixes/freebsd/src/gen/usr.sbin/powerd/powerd.c.p3.2021-11-10.REL=12.2-RELEASE.diff
was a recursive sym link, so refilled with a copy of powerd.c.p3.2021-11-10.REL=CURRENT.diff
Patch From Gary 2021-11-10.
Purpose:
For more than 4 [core ?] machines
To ensure an idle machine that starts playing a video does not switch all cores to high power.
To also ensure a build world Does switch to high frequency & power.
Gary if you can better phrase this please do.
Compatability tests by jhs@:
6.4-RELEASE
Hunk #1 failed at 104.
Hunk #2 failed at 501.
No such line 593 in input file, ignoring
Hunk #3 failed at 600.
Hunk #4 failed at 796.
4 out of 4 hunks failed--saving rejects to powerd.c.rej
7.4-RELEASE
Hunk #1 failed at 104.
Hunk #2 failed at 501.
Hunk #3 succeeded at 535 with fuzz 2 (offset -65 lines).
Hunk #4 failed at 731.
3 out of 4 hunks failed--saving rejects to powerd.c.rej
8.4-RELEASE
Hunk #1 succeeded at 97 (offset -7 lines).
Hunk #2 failed at 494.
Hunk #3 succeeded at 550 with fuzz 2 (offset -50 lines).
Hunk #4 failed at 746.
2 out of 4 hunks failed--saving rejects to powerd.c.rej
9.2-RELEASE
Hunk #1 succeeded at 101 (offset -3 lines).
Hunk #2 failed at 498.
Hunk #3 succeeded at 550 with fuzz 2 (offset -50 lines).
Hunk #4 failed at 746.
2 out of 4 hunks failed--saving rejects to powerd.c.rej
9.3-RELEASE
Hunk #1 succeeded at 101 (offset -3 lines).
Hunk #2 failed at 498.
Hunk #3 succeeded at 551 with fuzz 2 (offset -49 lines).
Hunk #4 failed at 747.
2 out of 4 hunks failed--saving rejects to powerd.c.rej
10.4-RELEASE
Hunk #1 succeeded at 102 (offset -2 lines).
Hunk #2 failed at 499.
Hunk #3 succeeded at 557 with fuzz 2 (offset -43 lines).
Hunk #4 failed at 753.
2 out of 4 hunks failed--saving rejects to powerd.c.rej
11.4-RELEASE
Hunk #1 succeeded at 104.
Hunk #2 failed at 501.
Hunk #3 succeeded at 587 with fuzz 2 (offset -13 lines).
Hunk #4 failed at 783.
12.2-RELEASE
Hunk #1 succeeded at 104.
Hunk #2 succeeded at 501.
Hunk #3 succeeded at 600.
Hunk #4 succeeded at 796.
13.0-RELEASE
Pending
--- 2021-11-10.REL=CURRENT/src/usr.sbin/powerd/powerd.c 2021-09-21 15:34:05.914536000 +0200
+++ new-generic/src/usr.sbin/powerd/powerd.c 2021-11-10 15:15:21.653237000 +0100
@@ -104,6 +104,10 @@
static int levels_mib[4];
static int acline_mib[4];
static size_t acline_mib_len;
+/* GJ - hw.ncpu (only the first int is set?) */
+static int nsmt_mib[4];
+/* GJ - hw.ncpu from the mib */
+static int nsmt;
/* Configuration */
static int cpu_running_mark;
@@ -497,6 +501,8 @@
uint64_t mjoules_used;
size_t len;
int nonice;
+ /* GJ */
+ int tload;
/* Default mode for all AC states is adaptive. */
mode_ac = mode_none = MODE_HIADAPTIVE;
@@ -594,6 +600,19 @@
if (sysctlnametomib("dev.cpu.0.freq_levels", levels_mib, &len))
err(1, "lookup freq_levels");
+ /* GJ */
+ len = 4;
+ /* sysctlnametomib() did not work */
+ if (sysctlbyname("hw.ncpu", nsmt_mib, &len, NULL, 0))
+ err(1, "lookup hw.ncpu");
+ nsmt = nsmt_mib[0];
+#ifdef DEBUG
+ printf("hw.ncpu %d\n", nsmt);
+#endif
+ /* prob no advantage to use scaling with so few SMTs */
+ if (nsmt <= 4)
+ nsmt = 1;
+
/* Check if we can read the load and supported freqs. */
if (read_usage_times(NULL, nonice))
err(1, "read_usage_times");
@@ -777,12 +796,14 @@
}
/* Adaptive mode; get the current CPU usage times. */
- if (read_usage_times(&load, nonice)) {
+ if (read_usage_times(&tload, nonice)) {
if (vflag)
warn("read_usage_times() failed");
continue;
}
+ /* GJ - nsmt == hw.ncpu IFF > 4, else 1 */
+ load = tload/nsmt;
if (mode == MODE_ADAPTIVE) {
if (load > cpu_running_mark) {
if (load > 95 || load > cpu_running_mark * 2)