Re: Thermal zone support for arm64
Mark Kettenis wrote in <543892945e900...@bloch.sibelius.xs4all.nl>: |Many of the cheap arm64 (and armv7) boards will overheat if you run |the CPU cores at full throttle for a while. Adding a heatsink may |help a little bit, but not enough. Some boards have a microcontroller |that monitors the temperature and throttles the CPUs if necessary. |Other boards don't and will eventually hit a critical temperature |where it will either do an emergency powerdown or will start to become |unreliable. | |In order to prevent this, the OS is supposed to monitor the |temperature and cool the device (either actively or passively) when |the temperature gets too high. There are device tree bindings for |so-called thermal zones that link together temperature sensors and |cooling devices and define trip points that define the temperatures at |which we have to start cooling. Most boards use passive cooling |through reducing the CPU clock speed and voltage. This is very interesting. These dense (x86-64) packages heat up immensely and very fast, even with hyperthreading turned off (though overheating no longer occurs like so). I hooked into a Linux bug report a few months back, my new box (i jumped a decade of hardware development in March/April) just did/does not keep up, ending in massive fan power stepping in. I asked why no adaptive strategy is used instead, and mentioned a fan control shell script i have, as simple as it is, keeping a notion of the last and the current level, which makes for a difference, and the heat up/cool down trend, which makes for a distance. Like that a simple adaption can take place. Well, in the meantime LWN reported work on the scheduler, so that hot CPUs are scheduled less work than others, which is of course an approach way more sophisticated. --steffen | |Der Kragenbaer,The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt)
Re: [diff] events.html - add 2 more BSDCan 2019 videos
Hi Ross, Ross L Richardson wrote on Sat, Jun 22, 2019 at 02:17:26PM +1000: > Probably in acceptable form :-) Committed, thanks. Ingo > Index: events.html > === > RCS file: /cvs/www/events.html,v > retrieving revision 1.1174 > diff -u -p -r1.1174 events.html > --- events.html 18 Jun 2019 15:01:52 - 1.1174 > +++ events.html 22 Jun 2019 04:09:17 - > @@ -68,7 +68,9 @@ May 15-18, 2019, Ottawa, Canada. > (http://bhyvecon.org/";>bhyvecon Ottawa 2019) > Bob Beck - > https://github.com/bob-beck/libtls/blob/master/TUTORIAL.md";>libtls > for beginners conference tutorial > -Theo Buehler - Design and verification of the TLS 1.3 handshake state > machine in LibreSSL (slides) > +Theo Buehler - Design and verification of the TLS 1.3 handshake state > + machine in LibreSSL (slides, > + https://www.youtube.com/watch?v=MCVIBwGOwNY";>video) > Florian Obser - https://man.openbsd.org/unwind.8";>unwind(8) >a privilege-separated, validating DNS recursive nameserver for every laptop >(slides, > @@ -82,7 +84,8 @@ May 15-18, 2019, Ottawa, Canada. >(slides, >https://www.youtube.com/watch?v=s6rAXaHylFM";>video) > Bob Beck > -Unveil in OpenBSD > + Unveil in OpenBSD > + (https://www.youtube.com/watch?v=gvmGfpMgny4";>video) > Jan Klemkow - Network booted OpenBSD Workstations >(slides, >https://www.youtube.com/watch?v=kFqHXfWEB4o";>video)
Re: [diff] www/libressl/papers.html - add video link
Hi Ross, Ross L Richardson wrote on Sat, Jun 22, 2019 at 02:24:46PM +1000: > The following corresponds with the events.html patch... Almost... Committed with the correct YT ID MCVIBwGOwNY instead of gvmGfpMgny4 which is beck@'s unveil(2) talk. Thanks anyway, Ingo > Index: papers.html > === > RCS file: /cvs/www/libressl/papers.html,v > retrieving revision 1.16 > diff -u -p -r1.16 papers.html > --- papers.html 13 Jun 2019 07:34:36 - 1.16 > +++ papers.html 22 Jun 2019 04:20:59 - > @@ -19,7 +19,7 @@ Presentations and Papers > > https://www.openbsd.org/papers/bsdcan2019-tls13.pdf";>Design and > verification of the TLS 1.3 handshake state machine in LibreSSL > by Theo Buehler > - > + ( href="https://www.youtube.com/watch?v=gvmGfpMgny4";>video) > > > Presentation: FSec 2015
mg(1) dired-goto-file
This add dired-goto-file to mg. Comments/ok? Mark Index: dired.c === RCS file: /cvs/src/usr.bin/mg/dired.c,v retrieving revision 1.90 diff -u -p -u -p -r1.90 dired.c --- dired.c 28 Jun 2019 13:35:02 - 1.90 +++ dired.c 29 Jun 2019 16:47:06 - @@ -51,6 +51,7 @@ static int d_backline(int, int); static int d_killbuffer_cmd(int, int); static int d_refreshbuffer(int, int); static int d_filevisitalt(int, int); +static int d_gotofile(int, int); static void reaper(int); static struct buffer *refreshbuffer(struct buffer *); static int createlist(struct buffer *); @@ -127,7 +128,10 @@ static PF direda[] = { d_del, /* d */ d_findfile, /* e */ d_findfile, /* f */ - d_refreshbuffer /* g */ + d_refreshbuffer,/* g */ + rescan, /* h */ + rescan, /* i */ + d_gotofile /* j */ }; static PF diredn[] = { @@ -186,7 +190,7 @@ static struct KEYMAPE (7) diredmap = { CCHR('Z'), '+', diredcz, (KEYMAP *) & metamap }, { - 'a', 'g', direda, NULL + 'a', 'j', direda, NULL }, { 'n', 'x', diredn, NULL @@ -208,6 +212,7 @@ dired_init(void) funmap_add(d_findfile, "dired-find-file"); funmap_add(d_ffotherwindow, "dired-find-file-other-window"); funmap_add(d_del, "dired-flag-file-deletion"); + funmap_add(d_gotofile, "dired-goto-file"); funmap_add(d_forwline, "dired-next-line"); funmap_add(d_otherwindow, "dired-other-window"); funmap_add(d_backline, "dired-previous-line"); @@ -1071,6 +1076,51 @@ createlist(struct buffer *bp) nlp = lforw(lp); } return (ret); +} + +int +d_gotofile(int f, int n) +{ + struct line *lp, *nlp; + struct buffer *curbp; + char fpath[NFILEN], fname[NFILEN]; + char*p, *fnp = NULL; + int tmp; + + if (getbufcwd(fpath, sizeof(fpath)) != TRUE) + fpath[0] = '\0'; + fnp = eread("Goto file: ", fpath, NFILEN, + EFNEW | EFCR | EFFILE | EFDEF); + if (fnp == NULL) + return (ABORT); + else if (fnp[0] == '\0') + return (FALSE); + + (void)xbasename(fname, fpath, NFILEN); + curbp = curwp->w_bufp; + tmp = 0; + for (lp = bfirstlp(curbp); lp != curbp->b_headp; lp = nlp) { + tmp++; + if ((p = findfname(lp, p)) == NULL) { + nlp = lforw(lp); + continue; + } + if (strcmp(fname, p) == 0) { + curwp->w_dotp = lp; + curwp->w_dotline = tmp; + (void)d_warpdot(curwp->w_dotp, &curwp->w_doto); + tmp--; + break; + } + nlp = lforw(lp); + } + if (tmp == curbp->b_lines - 1) { + ewprintf("File not found %s", fname); + return (FALSE); + } else { + ewprintf(""); + return (TRUE); + } } /* Index: mg.1 === RCS file: /cvs/src/usr.bin/mg/mg.1,v retrieving revision 1.115 diff -u -p -u -p -r1.115 mg.1 --- mg.117 Jun 2019 11:39:26 - 1.115 +++ mg.129 Jun 2019 16:47:06 - @@ -983,6 +983,8 @@ dired-do-copy dired-flag-file-deletion .It g dired-revert +.It j +dired-goto-file .It o dired-find-file-other-window .It p @@ -1025,6 +1027,8 @@ is executed. .It dired-find-file-other-window Open the file on the current line of the dired buffer in a different window. +.It dired-goto-file +Move the cursor to a file name in the dired buffer. .It dired-next-line Move the cursor to the next line. .It dired-other-window
unused sparc64 extern
The following declaration has actually never been used, for `ver' is a local in cpuattach() and locore does rdpr %ver every time it needs the value. Index: include/psl.h === RCS file: /OpenBSD/src/sys/arch/sparc64/include/psl.h,v retrieving revision 1.34 diff -u -p -r1.34 psl.h --- include/psl.h 20 Aug 2018 15:02:07 - 1.34 +++ include/psl.h 29 Jun 2019 10:35:40 - @@ -227,8 +227,6 @@ #if defined(_KERNEL) && !defined(_LOCORE) -extern u_int64_t ver; /* Copy of v9 version register. We need to read this only once, in locore.s. */ - #ifdef DIAGNOSTIC /* * Although this function is implemented in MI code, it must be in this MD
wsdisplay: use timeout_add_msec(9)
This is for the screen burner, which turns off the screen after # wsconsctl -n display.screen_off 6 milliseconds (60 seconds) as documented in wsconsctl.conf(5). Trivial conversion from ticks to milliseconds where macros already come in milliseconds and timeout values only need reduction by hz to use the new API. Tested on a X250 as well as a PowerBook G4 both with xenodm stopped, where setting it to 3000 makes the screen turn off reliably after three seconds. OK? Index: sys/dev/wscons//wsdisplay.c === RCS file: /cvs/src/sys/dev/wscons/wsdisplay.c,v retrieving revision 1.132 diff -u -p -r1.132 wsdisplay.c --- sys/dev/wscons//wsdisplay.c 4 May 2019 11:34:48 - 1.132 +++ sys/dev/wscons//wsdisplay.c 29 Jun 2019 12:07:48 - @@ -162,9 +162,9 @@ struct wsdisplay_softc { #ifdef HAVE_BURNER_SUPPORT struct timeout sc_burner; - int sc_burnoutintvl;/* delay before blanking */ - int sc_burninintvl; /* delay before unblanking */ - int sc_burnout; /* current sc_burner delay */ + int sc_burnoutintvl;/* delay before blanking (milliseconds) */ + int sc_burninintvl; /* delay before unblanking (milliseconds) */ + int sc_burnout; /* current sc_burner delay (milliseconds) */ int sc_burnman; /* nonzero if screen blanked */ int sc_burnflags; #endif @@ -766,8 +766,8 @@ wsdisplay_common_attach(struct wsdisplay wsdisplay_addscreen_print(sc, start, i-start); #ifdef HAVE_BURNER_SUPPORT - sc->sc_burnoutintvl = (hz * WSDISPLAY_DEFBURNOUT) / 1000; - sc->sc_burninintvl = (hz * WSDISPLAY_DEFBURNIN) / 1000; + sc->sc_burnoutintvl = WSDISPLAY_DEFBURNOUT_MSEC; + sc->sc_burninintvl = WSDISPLAY_DEFBURNIN_MSEC; sc->sc_burnflags = WSDISPLAY_BURN_OUTPUT | WSDISPLAY_BURN_KBD | WSDISPLAY_BURN_MOUSE; timeout_set(&sc->sc_burner, wsdisplay_burner, sc); @@ -1196,8 +1196,8 @@ wsdisplay_internal_ioctl(struct wsdispla case WSDISPLAYIO_GBURNER: #define d ((struct wsdisplay_burner *)data) - d->on = sc->sc_burninintvl * 1000 / hz; - d->off = sc->sc_burnoutintvl * 1000 / hz; + d->on = sc->sc_burninintvl; + d->off = sc->sc_burnoutintvl; d->flags = sc->sc_burnflags; return (0); @@ -1223,7 +1223,7 @@ wsdisplay_internal_ioctl(struct wsdispla active = scr; if (d->on) { - sc->sc_burninintvl = hz * d->on / 1000; + sc->sc_burninintvl = d->on; if (sc->sc_burnman) { sc->sc_burnout = sc->sc_burninintvl; /* reinit timeout if changed */ @@ -1232,7 +1232,7 @@ wsdisplay_internal_ioctl(struct wsdispla } } if (d->off) { - sc->sc_burnoutintvl = hz * d->off / 1000; + sc->sc_burnoutintvl = d->off; if (!sc->sc_burnman) { sc->sc_burnout = sc->sc_burnoutintvl; /* reinit timeout if changed */ @@ -2332,7 +2332,7 @@ wsdisplay_burn(void *v, u_int flags) WSDISPLAY_BURN_KBD | WSDISPLAY_BURN_MOUSE)) && sc->sc_accessops->burn_screen) { if (sc->sc_burnout) - timeout_add(&sc->sc_burner, sc->sc_burnout); + timeout_add_msec(&sc->sc_burner, sc->sc_burnout); if (sc->sc_burnman) sc->sc_burnout = 0; } @@ -2350,7 +2350,7 @@ wsdisplay_burner(void *v) s = spltty(); if (sc->sc_burnman) { sc->sc_burnout = sc->sc_burnoutintvl; - timeout_add(&sc->sc_burner, sc->sc_burnout); + timeout_add_msec(&sc->sc_burner, sc->sc_burnout); } else sc->sc_burnout = sc->sc_burninintvl; sc->sc_burnman = !sc->sc_burnman; Index: sys/dev/wscons//wsdisplayvar.h === RCS file: /cvs/src/sys/dev/wscons/wsdisplayvar.h,v retrieving revision 1.32 diff -u -p -r1.32 wsdisplayvar.h --- sys/dev/wscons//wsdisplayvar.h 4 May 2019 11:34:48 - 1.32 +++ sys/dev/wscons//wsdisplayvar.h 26 Jun 2019 21:34:44 - @@ -253,6 +253,5 @@ void wsscrollback(void *v, int op); /* * screen burner */ -#defineWSDISPLAY_DEFBURNOUT0 /* disabled */ -#defineWSDISPLAY_DEFBURNIN 250 /* ms */ - +#defineWSDISPLAY_DEFBURNOUT_MSEC 0 /* disabled */ +#defineWSDISPLAY_DEFBURNIN_MSEC250 /* milliseconds */
[patch] openrsync: improve unveil(2) for multiple sources and also symlink behaviou
Hi, I've noticed an issue with openrsync and more than 1 source arguments and with it's symlink behaviour (separate issues). Reproduce: cd /tmp mkdir -p a b openrsync -av a/ b/ c/ Output: /usr/src/usr.bin/rsync/flist.c:823: error: b/: lstat: No such file or directory /usr/src/usr.bin/rsync/flist.c:1032: error: flist_gen_dirent /usr/src/usr.bin/rsync/sender.c:391: error: flist_gen /usr/src/usr.bin/rsync/client.c:85: error: rsync_sender This is because in flist.c unveil(2) is called per argument. unveil(2) will remove visibility after it's first call as described in the man page: " The first call to unveil removes visibility of the entire filesystem from all other filesystem-related system calls (such as open(2), chmod(2) and rename(2)), except for the specified path and permissions. " For both files and recursive directories a list is created. I think the logic can be simplified and unified and unveil(2) called on these list items after the list is created. After changing the unveil(2) logic, there is an error in the duplicate working path detection code: /usr/src/usr.bin/rsync/flist.c:119: error: .: duplicate working path for possibly different file: a/., b/. /usr/src/usr.bin/rsync/flist.c:1149: error: flist_dedupe /usr/src/usr.bin/rsync/sender.c:391: error: flist_gen /usr/src/usr.bin/rsync/client.c:85: error: rsync_sender In the below patch I have removed this code for now. There is also an issue with symlinks: mkdir -p /tmp/a cd /tmp/a ln -s b a cd /tmp openrsync -av a/ b/ Result: /usr/src/usr.bin/rsync/symlinks.c:48: error: a/a: readlink: No such file or directory /usr/src/usr.bin/rsync/flist.c:985: error: symlink_read /usr/src/usr.bin/rsync/flist.c:1032: error: flist_gen_dirent /usr/src/usr.bin/rsync/sender.c:391: error: flist_gen /usr/src/usr.bin/rsync/client.c:85: error: rsync_sender I think this is because the fts(3) interface by default chdir(2) to a directory before running the callback function and the path is then incorrect there. I think it can safely pass FTS_NOCHDIR as a flag (and also optimization) to fts_open(3). Work-in-progress patch below, feedback is welcome: diff --git usr.bin/rsync/flist.c usr.bin/rsync/flist.c index 4860e20f428..07285b87362 100644 --- usr.bin/rsync/flist.c +++ usr.bin/rsync/flist.c @@ -113,12 +113,6 @@ flist_dedupe(struct flist **fl, size_t *sz) fnext->path = fnext->link = NULL; continue; } - - ERRX("%s: duplicate working path for " - "possibly different file: %s, %s", - f->wpath, f->path, fnext->path); - free(new); - return 0; } /* Don't forget the last entry. */ @@ -834,10 +828,6 @@ flist_gen_dirent(struct sess *sess, char *root, struct flist **fl, size_t *sz, ERRX1("flist_append"); return 0; } - if (unveil(root, "r") == -1) { - ERR("%s: unveil", root); - return 0; - } return 1; } else if (S_ISLNK(st.st_mode)) { if (!sess->opts->preserve_links) { @@ -854,10 +844,6 @@ flist_gen_dirent(struct sess *sess, char *root, struct flist **fl, size_t *sz, ERRX1("flist_append"); return 0; } - if (unveil(root, "r") == -1) { - ERR("%s: unveil", root); - return 0; - } return 1; } else if (!S_ISDIR(st.st_mode)) { WARNX("%s: skipping special", root); @@ -892,7 +878,7 @@ flist_gen_dirent(struct sess *sess, char *root, struct flist **fl, size_t *sz, * We'll make sense of it in flist_send. */ - if ((fts = fts_open(cargv, FTS_PHYSICAL, NULL)) == NULL) { + if ((fts = fts_open(cargv, FTS_PHYSICAL|FTS_NOCHDIR, NULL)) == NULL) { ERR("fts_open"); return 0; } @@ -994,10 +980,6 @@ flist_gen_dirent(struct sess *sess, char *root, struct flist **fl, size_t *sz, ERR("fts_read"); goto out; } - if (unveil(root, "r") == -1) { - ERR("%s: unveil", root); - goto out; - } LOG3("generated %zu filenames: %s", flsz, root); rc = 1; @@ -1091,10 +1073,6 @@ flist_gen_files(struct sess *sess, size_t argc, char **argv, /* Add this file to our file-system worldview. */ - if (unveil(argv[i], "r") == -1) { - ERR("%s: unveil", argv[i]); - goto out; - } if (!flist_append(f, &st, argv[i])) { ERRX1("flist_append");
Thermal zone support for arm64
Many of the cheap arm64 (and armv7) boards will overheat if you run the CPU cores at full throttle for a while. Adding a heatsink may help a little bit, but not enough. Some boards have a microcontroller that monitors the temperature and throttles the CPUs if necessary. Other boards don't and will eventually hit a critical temperature where it will either do an emergency powerdown or will start to become unreliable. In order to prevent this, the OS is supposed to monitor the temperature and cool the device (either actively or passively) when the temperature gets too high. There are device tree bindings for so-called thermal zones that link together temperature sensors and cooling devices and define trip points that define the temperatures at which we have to start cooling. Most boards use passive cooling through reducing the CPU clock speed and voltage. The diff below implements support for these thermal zones. Most of the code is implemented in the generic FDT support code in dev/ofw. Sensors and cooling devices make themselves known to this layer by registering themselves just like we do for clocks and regulators. This means the code is available on armv7 and octeon as well. On arm64, the CPUs are registered as cooling devices and implement passive cooling by simply clipping the available DVFS states instead of modifying perflevel. I also added registration code to rktemp(4). With these changes my RockPro64 can do a make build without reaching the critical temperature while building clang. The CPU temperature now hovers around 70 degC, which is the temperature associated with the lowest trip point that throttles only the "big" cores. ok? Index: arch/arm64/arm64/cpu.c === RCS file: /cvs/src/sys/arch/arm64/arm64/cpu.c,v retrieving revision 1.32 diff -u -p -r1.32 cpu.c --- arch/arm64/arm64/cpu.c 23 Jun 2019 17:14:49 - 1.32 +++ arch/arm64/arm64/cpu.c 29 Jun 2019 09:38:31 - @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -600,10 +601,14 @@ void cpu_opp_mountroot(struct device *); void cpu_opp_dotask(void *); void cpu_opp_setperf(int); +uint32_t cpu_opp_get_cooling_level(void *, uint32_t *); +void cpu_opp_set_cooling_level(void *, uint32_t *, uint32_t); + void cpu_opp_init(struct cpu_info *ci, uint32_t phandle) { struct opp_table *ot; + struct cooling_device *cd; int count, node, child; uint32_t opp_hz, opp_microvolt; uint32_t values[3]; @@ -670,8 +675,16 @@ cpu_opp_init(struct cpu_info *ci, uint32 LIST_INSERT_HEAD(&opp_tables, ot, ot_list); ci->ci_opp_table = ot; + ci->ci_opp_max = ot->ot_nopp - 1; ci->ci_cpu_supply = OF_getpropint(ci->ci_node, "cpu-supply", 0); + cd = malloc(sizeof(struct cooling_device), M_DEVBUF, M_ZERO | M_WAITOK); + cd->cd_node = ci->ci_node; + cd->cd_cookie = ci; + cd->cd_get_level = cpu_opp_get_cooling_level; + cd->cd_set_level = cpu_opp_set_cooling_level; + cooling_device_register(cd); + /* * Do addional checks at mountroot when all the clocks and * regulators are available. @@ -775,7 +788,7 @@ cpu_opp_dotask(void *arg) if (ot->ot_master && ot->ot_master != ci) continue; - opp_idx = ci->ci_opp_idx; + opp_idx = MIN(ci->ci_opp_idx, ci->ci_opp_max); opp_hz = ot->ot_opp[opp_idx].opp_hz; opp_microvolt = ot->ot_opp[opp_idx].opp_microvolt; @@ -844,4 +857,30 @@ cpu_opp_setperf(int level) * regulators might need process context. */ task_add(systq, &cpu_opp_task); +} + +uint32_t +cpu_opp_get_cooling_level(void *cookie, uint32_t *cells) +{ + struct cpu_info *ci = cookie; + struct opp_table *ot = ci->ci_opp_table; + + return ot->ot_nopp - ci->ci_opp_max - 1; +} + +void +cpu_opp_set_cooling_level(void *cookie, uint32_t *cells, uint32_t level) +{ + struct cpu_info *ci = cookie; + struct opp_table *ot = ci->ci_opp_table; + int opp_max; + + if (level > (ot->ot_nopp - 1)) + level = ot->ot_nopp - 1; + + opp_max = (ot->ot_nopp - level - 1); + if (ci->ci_opp_max != opp_max) { + ci->ci_opp_max = opp_max; + task_add(systq, &cpu_opp_task); + } } Index: arch/arm64/dev/mainbus.c === RCS file: /cvs/src/sys/arch/arm64/dev/mainbus.c,v retrieving revision 1.13 diff -u -p -r1.13 mainbus.c --- arch/arm64/dev/mainbus.c23 May 2019 13:41:53 - 1.13 +++ arch/arm64/dev/mainbus.c29 Jun 2019 09:38:32 - @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -147,6 +148,8 @@ mainbus_attach(struct device *parent, st /* Attach secondary CPUs. */ mainbus_attach_cpus(self