Re: Faster unhibernate by skipping devices
You are talking about -current. -current unhibernate has a shortcut where it skips attaching some devices in the bsd.booted "unhibernate" kernel. 7.0 does not have that change. Does 7.0 behave better? If 7.0 behaves better, are you able to backout the the diff which skips attaching devices, and try that, or do you need help.. Lucas wrote: > Since I'm using a snapshot with this, almost everytime I unhibernate I > get a "false start": devices start to get enumerated and at one point, > the machine reboots and goes back to the POST screen. Most of the time, > the second time it boots normally. > > If it helps, most of the time there are around 8 hours between > hibernating and unhibernating, as I basically do it instead of powering > it off. > > dmesg below. It's worth noting that I *think* everytime it reboots after > printing the line following `pckbc0 at isa0 port 0x60/5 irq 1 irq 12`. > I still haven't managed to read if it prints `pckbd0 at pckbc0 (kbd > slot)` or something else. > > OpenBSD 7.0-current (GENERIC.MP) #72: Fri Nov 5 10:08:43 MDT 2021 > dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP > real mem = 12534018048 (11953MB) > avail mem = 12138131456 (11575MB) > random: good seed from bootblocks > mpath0 at root > scsibus0 at mpath0: 256 targets > mainbus0 at root > bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xdae9d000 (70 entries) > bios0: vendor LENOVO version "G2ET33WW (1.13 )" date 07/24/2012 > bios0: LENOVO 2325BG4 > acpi0 at bios0: ACPI 4.0 > acpi0: sleep states S0 S3 S4 S5 > acpi0: tables DSDT FACP SLIC TCPA SSDT SSDT SSDT HPET APIC MCFG ECDT FPDT > ASF! UEFI UEFI POAT SSDT SSDT DMAR UEFI > acpi0: wakeup devices LID_(S4) SLPB(S3) IGBE(S4) EXP3(S4) XHCI(S3) EHC1(S3) > EHC2(S3) HDEF(S4) > acpitimer0 at acpi0: 3579545 Hz, 24 bits > acpihpet0 at acpi0: 14318179 Hz > acpimadt0 at acpi0 addr 0xfee0: PC-AT compat > cpu0 at mainbus0: apid 0 (boot processor) > cpu0: Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz, 1197.48 MHz, 06-3a-09 > cpu0: > FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,RDTSCP,LONG,LAHF,PERF,ITSC,FSGSBASE,SMEP,ERMS,MD_CLEAR,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,MELTDOWN > cpu0: 256KB 64b/line 8-way L2 cache > cpu0: smt 0, core 0, package 0 > mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges > cpu0: apic clock running at 99MHz > cpu0: mwait min=64, max=64, C-substates=0.2.1.1.2, IBE > cpu1 at mainbus0: apid 2 (application processor) > cpu1: Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz, 1197.29 MHz, 06-3a-09 > cpu1: > FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,RDTSCP,LONG,LAHF,PERF,ITSC,FSGSBASE,SMEP,ERMS,MD_CLEAR,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,MELTDOWN > cpu1: 256KB 64b/line 8-way L2 cache > cpu1: smt 0, core 1, package 0 > ioapic0 at mainbus0: apid 2 pa 0xfec0, version 20, 24 pins > acpimcfg0 at acpi0 > acpimcfg0: addr 0xf800, bus 0-63 > acpiec0 at acpi0 > acpiprt0 at acpi0: bus 0 (PCI0) > acpiprt1 at acpi0: bus -1 (PEG_) > acpiprt2 at acpi0: bus 2 (EXP1) > acpiprt3 at acpi0: bus 3 (EXP2) > acpiprt4 at acpi0: bus 4 (EXP3) > acpibtn0 at acpi0: LID_ > acpibtn1 at acpi0: SLPB > acpipci0 at acpi0 PCI0: 0x 0x0011 0x0001 > acpicmos0 at acpi0 > tpm0 at acpi0 TPM_ 1.2 (TIS) addr 0xfed4/0x5000, device 0x104a rev > 0x4e > acpibat0 at acpi0: BAT0 model "45N1029" serial 15304 type LION oem "LGC" > acpiac0 at acpi0: AC unit offline > acpithinkpad0 at acpi0: version 1.0 > "PNP0C14" at acpi0 not configured > "PNP0C14" at acpi0 not configured > acpicpu0 at acpi0: C3(200@87 mwait.1@0x30), C2(500@59 mwait.1@0x10), > C1(1000@1 mwait.1), PSS > acpicpu1 at acpi0: C3(200@87 mwait.1@0x30), C2(500@59 mwait.1@0x10), > C1(1000@1 mwait.1), PSS > acpipwrres0 at acpi0: PUBS, resource for XHCI, EHC1, EHC2 > acpitz0 at acpi0: critical temperature is 103 degC > acpidock0 at acpi0: GDCK not docked (0) > acpivideo0 at acpi0: VID_ > acpivout0 at acpivideo0: LCD0 > acpivideo1 at acpi0: VID_ > cpu0: using VERW MDS workaround (except on vmm entry) > cpu0: Enhanced SpeedStep 1197 MHz: speeds: 2601, 2600, 2500, 2400, 2300, > 2200, 2100, 2000, 1900, 1800, 1700, 1600, 1500, 1400, 1300, 1200 MHz > pci0 at mainbus0 bus 0 > pchb0 at pci0 dev 0 function 0 "Intel Core 3G Host" rev 0x09 > inteldrm0 at pci0 dev 2 function 0 "Intel HD Graphics 4000" rev 0x09 > drm0 at inteldrm0 > inteldrm0: msi, IVYBRIDGE, gen 7 > xhci0 at pci0 dev 20 function 0 "Intel 7 Series xHCI" rev 0x04: msi, xHCI 1.0 > usb0 at xhci0: USB revision 3.0 > uhub0 at usb0 configuration 1 interface 0 "Intel xHCI root hub" rev 3.00/1.00 >
Re: Faster unhibernate by skipping devices
Since I'm using a snapshot with this, almost everytime I unhibernate I get a "false start": devices start to get enumerated and at one point, the machine reboots and goes back to the POST screen. Most of the time, the second time it boots normally. If it helps, most of the time there are around 8 hours between hibernating and unhibernating, as I basically do it instead of powering it off. dmesg below. It's worth noting that I *think* everytime it reboots after printing the line following `pckbc0 at isa0 port 0x60/5 irq 1 irq 12`. I still haven't managed to read if it prints `pckbd0 at pckbc0 (kbd slot)` or something else. OpenBSD 7.0-current (GENERIC.MP) #72: Fri Nov 5 10:08:43 MDT 2021 dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP real mem = 12534018048 (11953MB) avail mem = 12138131456 (11575MB) random: good seed from bootblocks mpath0 at root scsibus0 at mpath0: 256 targets mainbus0 at root bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xdae9d000 (70 entries) bios0: vendor LENOVO version "G2ET33WW (1.13 )" date 07/24/2012 bios0: LENOVO 2325BG4 acpi0 at bios0: ACPI 4.0 acpi0: sleep states S0 S3 S4 S5 acpi0: tables DSDT FACP SLIC TCPA SSDT SSDT SSDT HPET APIC MCFG ECDT FPDT ASF! UEFI UEFI POAT SSDT SSDT DMAR UEFI acpi0: wakeup devices LID_(S4) SLPB(S3) IGBE(S4) EXP3(S4) XHCI(S3) EHC1(S3) EHC2(S3) HDEF(S4) acpitimer0 at acpi0: 3579545 Hz, 24 bits acpihpet0 at acpi0: 14318179 Hz acpimadt0 at acpi0 addr 0xfee0: PC-AT compat cpu0 at mainbus0: apid 0 (boot processor) cpu0: Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz, 1197.48 MHz, 06-3a-09 cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,RDTSCP,LONG,LAHF,PERF,ITSC,FSGSBASE,SMEP,ERMS,MD_CLEAR,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,MELTDOWN cpu0: 256KB 64b/line 8-way L2 cache cpu0: smt 0, core 0, package 0 mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges cpu0: apic clock running at 99MHz cpu0: mwait min=64, max=64, C-substates=0.2.1.1.2, IBE cpu1 at mainbus0: apid 2 (application processor) cpu1: Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz, 1197.29 MHz, 06-3a-09 cpu1: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,RDTSCP,LONG,LAHF,PERF,ITSC,FSGSBASE,SMEP,ERMS,MD_CLEAR,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,MELTDOWN cpu1: 256KB 64b/line 8-way L2 cache cpu1: smt 0, core 1, package 0 ioapic0 at mainbus0: apid 2 pa 0xfec0, version 20, 24 pins acpimcfg0 at acpi0 acpimcfg0: addr 0xf800, bus 0-63 acpiec0 at acpi0 acpiprt0 at acpi0: bus 0 (PCI0) acpiprt1 at acpi0: bus -1 (PEG_) acpiprt2 at acpi0: bus 2 (EXP1) acpiprt3 at acpi0: bus 3 (EXP2) acpiprt4 at acpi0: bus 4 (EXP3) acpibtn0 at acpi0: LID_ acpibtn1 at acpi0: SLPB acpipci0 at acpi0 PCI0: 0x 0x0011 0x0001 acpicmos0 at acpi0 tpm0 at acpi0 TPM_ 1.2 (TIS) addr 0xfed4/0x5000, device 0x104a rev 0x4e acpibat0 at acpi0: BAT0 model "45N1029" serial 15304 type LION oem "LGC" acpiac0 at acpi0: AC unit offline acpithinkpad0 at acpi0: version 1.0 "PNP0C14" at acpi0 not configured "PNP0C14" at acpi0 not configured acpicpu0 at acpi0: C3(200@87 mwait.1@0x30), C2(500@59 mwait.1@0x10), C1(1000@1 mwait.1), PSS acpicpu1 at acpi0: C3(200@87 mwait.1@0x30), C2(500@59 mwait.1@0x10), C1(1000@1 mwait.1), PSS acpipwrres0 at acpi0: PUBS, resource for XHCI, EHC1, EHC2 acpitz0 at acpi0: critical temperature is 103 degC acpidock0 at acpi0: GDCK not docked (0) acpivideo0 at acpi0: VID_ acpivout0 at acpivideo0: LCD0 acpivideo1 at acpi0: VID_ cpu0: using VERW MDS workaround (except on vmm entry) cpu0: Enhanced SpeedStep 1197 MHz: speeds: 2601, 2600, 2500, 2400, 2300, 2200, 2100, 2000, 1900, 1800, 1700, 1600, 1500, 1400, 1300, 1200 MHz pci0 at mainbus0 bus 0 pchb0 at pci0 dev 0 function 0 "Intel Core 3G Host" rev 0x09 inteldrm0 at pci0 dev 2 function 0 "Intel HD Graphics 4000" rev 0x09 drm0 at inteldrm0 inteldrm0: msi, IVYBRIDGE, gen 7 xhci0 at pci0 dev 20 function 0 "Intel 7 Series xHCI" rev 0x04: msi, xHCI 1.0 usb0 at xhci0: USB revision 3.0 uhub0 at usb0 configuration 1 interface 0 "Intel xHCI root hub" rev 3.00/1.00 addr 1 "Intel 7 Series MEI" rev 0x04 at pci0 dev 22 function 0 not configured puc0 at pci0 dev 22 function 3 "Intel 7 Series KT" rev 0x04: ports: 16 com com4 at puc0 port 0 apic 2 int 19: ns16550a, 16 byte fifo com4: probed fifo depth: 0 bytes em0 at pci0 dev 25 function 0 "Intel 82579LM" rev 0x04: msi, address 3c:97:0e:31:1f:fa ehci0 at pci0 dev 26 function 0 "Intel 7 Series USB" rev 0x04: apic 2 int 16 usb1 at ehci0: USB revision 2.0 uhub1 at usb1 configuration 1 interface 0 "Intel EHCI root hub" rev 2.00/1.00 addr 1
Faster unhibernate by skipping devices
At the last hackathon I observed high elapsed time when the unhibernate bsd.booted kernel attaches unneccessary drivers, and then detatches a vast number of them when suspending to bounce to the old image. This diff skips attaching those devices. The current list is all tape and network devices (based upon DV_TAPE and DV_NET), plus vmm, azalia, and usb sub-devices (based upon a new CD_SKIPHIBERNATE flag). The usb sub-devices in particular make a big difference. Adding additional devices to the list only requires putting CD_SKIPHIBERNATE into struct cfdriver. To test, upgrade the bootblocks -- which must pass a new boothowto flag indicating the unhibernate operation -- previously the bsd.booted kernel was unaware of the circumstances until inspecting swap for a unhib signature, but this is too late (obviously it is after device configure): cd /usr/src/sys/arch/amd64/stand make && make install installboot -v sd0 (or whatever) Then install a new kernel, and perform an unhibernate cycle. Surface go2 has a pretty fast BIOS and many iic + usb devices, so this cuts unhibernate elapsed time by roughly a third. The other laptop I trialed this on, x1nano, has fewer devices to skip so the speedup is less dramatic. I had some weird experiences developing this. Consider reverting the sys/dev/usb subdirectory flagging before reporting a problem, because I suspect my weird problems came from those drivers. Index: kern/subr_autoconf.c === RCS file: /cvs/src/sys/kern/subr_autoconf.c,v retrieving revision 1.94 diff -u -p -u -r1.94 subr_autoconf.c --- kern/subr_autoconf.c30 Dec 2019 23:56:26 - 1.94 +++ kern/subr_autoconf.c23 Oct 2021 20:42:16 - @@ -51,6 +51,7 @@ #include #include #include +#include #include "hotplug.h" #include "mpath.h" @@ -188,7 +189,7 @@ config_search(cfmatch_t fn, struct devic m.parent = parent; m.match = NULL; m.aux = aux; - m.indirect = parent && parent->dv_cfdata->cf_driver->cd_indirect; + m.indirect = parent && (parent->dv_cfdata->cf_driver->cd_mode & CD_INDIRECT); m.pri = 0; for (cf = cfdata; cf->cf_driver; cf++) { @@ -202,6 +203,14 @@ config_search(cfmatch_t fn, struct devic if (cf->cf_fstate == FSTATE_DNOTFOUND || cf->cf_fstate == FSTATE_DSTAR) continue; + if (boothowto & RB_UNHIBERNATE) { + if (cf->cf_driver->cd_mode & CD_SKIPHIBERNATE) + continue; + if (cf->cf_driver->cd_class == DV_IFNET) + continue; + if (cf->cf_driver->cd_class == DV_TAPE) + continue; + } for (p = cf->cf_parents; *p >= 0; p++) if (parent->dv_cfdata == [*p]) mapply(, cf); @@ -237,7 +246,7 @@ config_scan(cfscan_t fn, struct device * void *match; int indirect; - indirect = parent && parent->dv_cfdata->cf_driver->cd_indirect; + indirect = parent && (parent->dv_cfdata->cf_driver->cd_mode & CD_INDIRECT); for (cf = cfdata; cf->cf_driver; cf++) { /* @@ -348,7 +357,7 @@ config_attach(struct device *parent, voi autoconf_attdet++; mtx_leave(_attdet_mtx); - if (parent && parent->dv_cfdata->cf_driver->cd_indirect) { + if (parent && (parent->dv_cfdata->cf_driver->cd_mode & CD_INDIRECT)) { dev = match; cf = dev->dv_cfdata; } else { Index: sys/device.h === RCS file: /cvs/src/sys/sys/device.h,v retrieving revision 1.55 diff -u -p -u -r1.55 device.h --- sys/device.h10 Sep 2018 16:18:34 - 1.55 +++ sys/device.h23 Oct 2021 20:42:16 - @@ -136,11 +136,15 @@ struct cfattach { #defineDETACH_FORCE0x01/* force detachment; hardware gone */ #defineDETACH_QUIET0x02/* don't print a notice */ +/* For cd_mode, below */ +#define CD_INDIRECT1 +#define CD_SKIPHIBERNATE 2 + struct cfdriver { void**cd_devs; /* devices found */ char*cd_name; /* device name */ enumdevclass cd_class; /* device classification */ - int cd_indirect;/* indirectly configure subdevices */ + int cd_mode;/* device type subclassification */ int cd_ndevs; /* size of cd_devs array */ }; Index: sys/reboot.h === RCS file: /cvs/src/sys/sys/reboot.h,v retrieving revision 1.19 diff -u -p -u -r1.19 reboot.h --- sys/reboot.h23 May 2020 00:40:53 - 1.19 +++ sys/reboot.h23 Oct 2021 20:42:16 - @@