diff --git a/launch_chffrplus.sh b/launch_chffrplus.sh index e7fd3a25..c2060886 100755 --- a/launch_chffrplus.sh +++ b/launch_chffrplus.sh @@ -19,6 +19,19 @@ function two_init { # openpilot gets all the cores echo 0-3 > /dev/cpuset/app/cpus + # set up governors + # +50mW offroad, +500mW onroad for 30% more RAM bandwidth + echo "performance" > /sys/class/devfreq/soc:qcom,cpubw/governor + echo 1056000 > /sys/class/devfreq/soc:qcom,m4m/max_freq + echo "performance" > /sys/class/devfreq/soc:qcom,m4m/governor + + # unclear if these help, but they don't seem to hurt + echo "performance" > /sys/class/devfreq/soc:qcom,memlat-cpu0/governor + echo "performance" > /sys/class/devfreq/soc:qcom,memlat-cpu2/governor + + # /sys/class/devfreq/soc:qcom,mincpubw is the only one left at "powersave" + # it seems to gain nothing but a wasted 500mW + # Collect RIL and other possibly long-running I/O interrupts onto CPU 1 echo 1 > /proc/irq/78/smp_affinity_list # qcom,smd-modem (LTE radio) echo 1 > /proc/irq/33/smp_affinity_list # ufshcd (flash storage) diff --git a/scripts/waste b/scripts/waste index 506ce9c7..e3154ab0 100755 Binary files a/scripts/waste and b/scripts/waste differ diff --git a/scripts/waste.c b/scripts/waste.c index 52951dfe..afdcbddb 100644 --- a/scripts/waste.c +++ b/scripts/waste.c @@ -36,8 +36,23 @@ void waste(int pid) { double sec = seconds_since_boot(); while (1) { for (int i = 0; i < 8; i++) { - for (int j = 0; j < 0x1000000; j+=2) { - out = vmlaq_f32(out, tmp[j], tmp[j+1]); + for (int j = 0; j < 0x1000000; j+=0x20) { + out = vmlaq_f32(out, tmp[j+0], tmp[j+1]); + out = vmlaq_f32(out, tmp[j+2], tmp[j+3]); + out = vmlaq_f32(out, tmp[j+4], tmp[j+5]); + out = vmlaq_f32(out, tmp[j+6], tmp[j+7]); + out = vmlaq_f32(out, tmp[j+8], tmp[j+9]); + out = vmlaq_f32(out, tmp[j+10], tmp[j+11]); + out = vmlaq_f32(out, tmp[j+12], tmp[j+13]); + out = vmlaq_f32(out, tmp[j+14], tmp[j+15]); + out = vmlaq_f32(out, tmp[j+16], tmp[j+17]); + out = vmlaq_f32(out, tmp[j+18], tmp[j+19]); + out = vmlaq_f32(out, tmp[j+20], tmp[j+21]); + out = vmlaq_f32(out, tmp[j+22], tmp[j+23]); + out = vmlaq_f32(out, tmp[j+24], tmp[j+25]); + out = vmlaq_f32(out, tmp[j+26], tmp[j+27]); + out = vmlaq_f32(out, tmp[j+28], tmp[j+29]); + out = vmlaq_f32(out, tmp[j+30], tmp[j+31]); } } double nsec = seconds_since_boot(); diff --git a/selfdrive/loggerd/loggerd.cc b/selfdrive/loggerd/loggerd.cc index 51ac005e..6360a555 100644 --- a/selfdrive/loggerd/loggerd.cc +++ b/selfdrive/loggerd/loggerd.cc @@ -599,7 +599,7 @@ int main(int argc, char** argv) { int err; #ifdef QCOM - set_realtime_priority(50); + setpriority(PRIO_PROCESS, 0, -12); #endif if (argc > 1 && strcmp(argv[1], "--bootlog") == 0) { diff --git a/selfdrive/modeld/dmonitoringmodeld.cc b/selfdrive/modeld/dmonitoringmodeld.cc index a3ddfea0..3a9b134e 100644 --- a/selfdrive/modeld/dmonitoringmodeld.cc +++ b/selfdrive/modeld/dmonitoringmodeld.cc @@ -3,6 +3,7 @@ #include #include #include +#include #include "common/visionbuf.h" #include "common/visionipc.h" @@ -23,7 +24,7 @@ static void set_do_exit(int sig) { int main(int argc, char **argv) { int err; - set_realtime_priority(51); + setpriority(PRIO_PROCESS, 0, -15); #ifdef QCOM2 set_core_affinity(5); diff --git a/selfdrive/modeld/modeld.cc b/selfdrive/modeld/modeld.cc index c528ba98..9b956e85 100644 --- a/selfdrive/modeld/modeld.cc +++ b/selfdrive/modeld/modeld.cc @@ -157,6 +157,7 @@ int main(int argc, char **argv) { uint32_t frame_id = 0, last_vipc_frame_id = 0; double last = 0; int desire = -1; + uint32_t run_count = 0; while (!do_exit) { VIPCBuf *buf; VIPCBufExtra extra; @@ -179,6 +180,8 @@ int main(int argc, char **argv) { double mt1 = 0, mt2 = 0; if (run_model_this_iter) { + run_count++; + float vec_desire[DESIRE_LEN] = {0}; if (desire >= 0 && desire < DESIRE_LEN) { vec_desire[desire] = 1.0; @@ -198,6 +201,7 @@ int main(int argc, char **argv) { // tracked dropped frames uint32_t vipc_dropped_frames = extra.frame_id - last_vipc_frame_id - 1; frames_dropped = (1. - frame_filter_k) * frames_dropped + frame_filter_k * (float)std::min(vipc_dropped_frames, 10U); + if (run_count < 10) frames_dropped = 0; // let frame drops warm up float frame_drop_ratio = frames_dropped / (1 + frames_dropped); model_publish(pm, extra.frame_id, frame_id, vipc_dropped_frames, frame_drop_ratio, model_buf, extra.timestamp_eof, model_execution_time); diff --git a/selfdrive/rtshield.py b/selfdrive/rtshield.py old mode 100644 new mode 100755 index e7602250..9a638c91 --- a/selfdrive/rtshield.py +++ b/selfdrive/rtshield.py @@ -1,16 +1,20 @@ #!/usr/bin/env python3 +import os import time from common.realtime import set_core_affinity, set_realtime_priority - # RT shield - ensure CPU 3 always remains available for RT processes # runs as SCHED_FIFO with minimum priority to ensure kthreads don't # get scheduled onto CPU 3, but it's always preemptible by realtime # openpilot processes def main(): - set_core_affinity(3) + set_core_affinity(int(os.getenv("CORE", "3"))) set_realtime_priority(1) while True: time.sleep(0.000001) + +if __name__ == "__main__": + main() + diff --git a/selfdrive/thermald/thermald.py b/selfdrive/thermald/thermald.py index df606f8b..c36e9cdb 100755 --- a/selfdrive/thermald/thermald.py +++ b/selfdrive/thermald/thermald.py @@ -377,7 +377,6 @@ def thermald_thread(): if started_ts is None: started_ts = sec_since_boot() started_seen = True - os.system('echo performance > /sys/class/devfreq/soc:qcom,cpubw/governor') else: if startup_conditions["ignition"] and (startup_conditions != startup_conditions_prev): cloudlog.event("Startup blocked", startup_conditions=startup_conditions) @@ -387,7 +386,6 @@ def thermald_thread(): started_ts = None if off_ts is None: off_ts = sec_since_boot() - os.system('echo powersave > /sys/class/devfreq/soc:qcom,cpubw/governor') # Offroad power monitoring pm.calculate(health)