Le Wed, 13 May 2020 17:03:01 +0300, Paul Irofti <p...@irofti.net> a écrit :
> Hi, > > By far one of the most popular and frequently used system calls is > clock_gettime(2). As a result the cost of kernel-userland transitions > out weight the actual work, thus I am proposing we make the data > available directly from userland without passing through a system > call. > > This has been a subject of discussion multiple times across the years > and last I heard from it was at the p2k19 hackthon that I hosted in > Bucharest where espie@ sent me a diff from one of his students(?). > Being busy with organization I have not had the time to look at it and > I am thus getting back to it just now due to robert@ prodding me again > on the subject. The proposed diff is mine, not the student's. > > > The technical bits. > > Please keep in mind that this is only proof of concept. I am looking > for ways to improve the current diff. As it is, it requires a flag day > because it makes use of ELF aux vectors to export the data from the > kernel. > > I have also played with exposing the data via separate ELF sections > and with kbind-mmap alternatives. The frist also involves a flag day > and is more intrusive in my opinion, and the second I could not get > to work. I think that would be the less intrusive way of doing it, > possibly without a flag day, so if anyone knows how, please let me > know. > > The supported clocks are just those that do not require process > specific data. Those can also be handled later if this diff is > decided to be a good thing. > > Clock update inside the kernel is done at the end of tc_windup(). > There might be better places to do it. Let me know where. > > The update currently does the work of clock_gettime(), but it can > probably be changed to only update the timehands and move the logic > elsewhere. Note that if we expose only the timehands to userland, most > of the bintime functionality has to also be made available there. Or > so I think. > > In userland, I wrapped the clock_gettime(2) syscall in libc. There, I > search for the auxiliary vector and fetch the timespec data from it. > As you can see in the diff, parts from the elf_exec header will have > to be exposed to userland if we do it this way. > > > Results. > > To test this diff you need to do a full release(8). I have tested this > with multiple programs. Test programs, base programs and packages. > None the less, this diff touches many important areas of our tree and > is very fragile. I also probably missed changing some parts that > required change due to libc or elf changes. > > If you see regressions, which you probably will, please let me know. With the patch, system crashes reliably at boot when prompting for login I followed release(8) instructions, did I miss something? cd /sys/arch/$(machine)/compile/GENERIC.MP make obj make config make && make install reboot cd /usrc/src make obj make build sysmerge cd /dev && ./MAKEDEV all cd /usr/xenocara make bootstrap make obj make build reboot I got a first panic like « panic init died (signal 0, exit 11) when I typed reboot. Now, if I start the system with the new kernel (old kernel.sp still work), I get either a panic init died or I have ddb but can't type in it. This happens after full boot sequence when I'm prompted for login: I tried to disable all pkg_services and xdm and it still crash at this step, I can't login. 2 screenshots of crashes errors https://perso.pw/IMG_20200514_110104.jpg https://perso.pw/IMG_20200514_110451.jpg dmesg output (from bsd.sp kernel which still boots) OpenBSD 6.7 (GENERIC) #179: Thu May 7 11:02:37 MDT 2020 dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC real mem = 8033624064 (7661MB) avail mem = 7777611776 (7417MB) mpath0 at root scsibus0 at mpath0: 256 targets mainbus0 at root bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xec070 (76 entries) bios0: vendor American Megatrends Inc. version "FB" date 06/25/2014 bios0: Gigabyte Technology Co., Ltd. H81M-D2V acpi0 at bios0: ACPI 5.0 acpi0: sleep states S0 S3 S4 S5 acpi0: tables DSDT FACP APIC FPDT SSDT SSDT MCFG HPET SSDT SSDT acpi0: wakeup devices RP01(S4) PXSX(S4) PXSX(S4) RP03(S4) PXSX(S4) RP04(S4) PXSX(S4) PXSX(S4) PXSX(S4) PXSX(S4) PXSX(S4) GLAN(S4) EHC1(S4) EHC2(S4) XHC_(S4) HDEF(S4) [...] acpitimer0 at acpi0: 3579545 Hz, 24 bits acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat cpu0 at mainbus0: apid 0 (boot processor) cpu0: Intel(R) Core(TM) i3-4160 CPU @ 3.60GHz, 3592.14 MHz, 06-3c-03 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,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,TSC_ADJUST,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,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.2.4, IBE cpu at mainbus0: not configured cpu at mainbus0: not configured cpu at mainbus0: not configured ioapic0 at mainbus0: apid 8 pa 0xfec00000, version 20, 24 pins acpimcfg0 at acpi0 acpimcfg0: addr 0xf8000000, bus 0-63 acpihpet0 at acpi0: 14318179 Hz acpiprt0 at acpi0: bus 0 (PCI0) acpiprt1 at acpi0: bus 2 (RP01) acpiprt2 at acpi0: bus 3 (RP03) acpiprt3 at acpi0: bus 4 (RP04) acpiprt4 at acpi0: bus 1 (PEG0) acpiprt5 at acpi0: bus -1 (PEG1) acpiprt6 at acpi0: bus -1 (PEG2) acpiec0 at acpi0: not present acpicpu0 at acpi0: C2(500@67 mwait.1@0x10), C1(1000@1 mwait.1), PSS acpipwrres0 at acpi0: FN00, resource for FAN0 acpipwrres1 at acpi0: FN01, resource for FAN1 acpipwrres2 at acpi0: FN02, resource for FAN2 acpipwrres3 at acpi0: FN03, resource for FAN3 acpipwrres4 at acpi0: FN04, resource for FAN4 acpitz0 at acpi0: critical temperature is 105 degC acpitz1 at acpi0: critical temperature is 105 degC acpipci0 at acpi0 PCI0: 0x00000010 0x00000011 0x00000000 acpicmos0 at acpi0 acpibtn0 at acpi0: PWRB "PNP0C0B" at acpi0 not configured "PNP0C0B" at acpi0 not configured "PNP0C0B" at acpi0 not configured "PNP0C0B" at acpi0 not configured "PNP0C0B" at acpi0 not configured acpivideo0 at acpi0: GFX0 acpivout0 at acpivideo0: DD1F cpu0: using VERW MDS workaround (except on vmm entry) cpu0: Enhanced SpeedStep 3592 MHz: speeds: 3600, 3400, 3200, 3000, 2900, 2700, 2500, 2300, 2100, 1900, 1700, 1500, 1400, 1200, 1000, 800 MHz pci0 at mainbus0 bus 0 pchb0 at pci0 dev 0 function 0 "Intel Core 4G Host" rev 0x06 ppb0 at pci0 dev 1 function 0 "Intel Core 4G PCIE" rev 0x06: msi pci1 at ppb0 bus 1 vendor "NVIDIA", unknown product 0x1c03 (class display subclass VGA, rev 0xa1) at pci1 dev 0 function 0 not configured azalia0 at pci1 dev 0 function 1 vendor "NVIDIA", unknown product 0x10f1 rev 0xa1: msi azalia0: no supported codecs inteldrm0 at pci0 dev 2 function 0 "Intel HD Graphics 4600" rev 0x06 drm0 at inteldrm0 inteldrm0: msi, HASWELL, gen 7 azalia1 at pci0 dev 3 function 0 "Intel Core 4G HD Audio" rev 0x06: msi azalia1: No codecs found xhci0 at pci0 dev 20 function 0 "Intel 8 Series xHCI" rev 0x05: 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 8 Series MEI" rev 0x04 at pci0 dev 22 function 0 not configured ehci0 at pci0 dev 26 function 0 "Intel 8 Series USB" rev 0x05: apic 8 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 azalia2 at pci0 dev 27 function 0 "Intel 8 Series HD Audio" rev 0x05: msi azalia2: codecs: Realtek/0x0887 audio0 at azalia2 ppb1 at pci0 dev 28 function 0 "Intel 8 Series PCIE" rev 0xd5: msi pci2 at ppb1 bus 2 ppb2 at pci0 dev 28 function 2 "Intel 8 Series PCIE" rev 0xd5: msi pci3 at ppb2 bus 3 re0 at pci3 dev 0 function 0 "Realtek 8168" rev 0x0c: RTL8168G/8111G (0x4c00), msi, address fc:aa:14:68:75:64 rgephy0 at re0 phy 7: RTL8251 PHY, rev. 0 ppb3 at pci0 dev 28 function 3 "Intel 8 Series PCIE" rev 0xd5: msi pci4 at ppb3 bus 4 xhci1 at pci4 dev 0 function 0 "VIA VL805 xHCI" rev 0x01: msi, xHCI 1.0 usb2 at xhci1: USB revision 3.0 uhub2 at usb2 configuration 1 interface 0 "VIA xHCI root hub" rev 3.00/1.00 addr 1 ehci1 at pci0 dev 29 function 0 "Intel 8 Series USB" rev 0x05: apic 8 int 23 usb3 at ehci1: USB revision 2.0 uhub3 at usb3 configuration 1 interface 0 "Intel EHCI root hub" rev 2.00/1.00 addr 1 pcib0 at pci0 dev 31 function 0 "Intel H81 LPC" rev 0x05 ahci0 at pci0 dev 31 function 2 "Intel 8 Series AHCI" rev 0x05: msi, AHCI 1.3 ahci0: port 4: 3.0Gb/s scsibus1 at ahci0: 32 targets sd0 at scsibus1 targ 4 lun 0: <ATA, WDC WD5000AAKX-0, 15.0> naa.50014ee0ae3f2d32 sd0: 476940MB, 512 bytes/sector, 976773168 sectors ichiic0 at pci0 dev 31 function 3 "Intel 8 Series SMBus" rev 0x05: apic 8 int 18 iic0 at ichiic0 spdmem0 at iic0 addr 0x50: 4GB DDR3 SDRAM PC3-12800 spdmem1 at iic0 addr 0x52: 4GB DDR3 SDRAM PC3-12800 isa0 at pcib0 isadma0 at isa0 com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo pckbc0 at isa0 port 0x60/5 irq 1 irq 12 pckbd0 at pckbc0 (kbd slot) wskbd0 at pckbd0: console keyboard pcppi0 at isa0 port 0x61 spkr0 at pcppi0 lpt0 at isa0 port 0x378/4 irq 7 vmm0 at mainbus0: VMX/EPT uhub4 at uhub1 port 1 configuration 1 interface 0 "Intel Rate Matching Hub" rev 2.00/0.05 addr 2 uhub5 at uhub2 port 1 configuration 1 interface 0 "VIA Labs USB2.0 Hub" rev 2.10/4.20 addr 2 uhub6 at uhub5 port 1 configuration 1 interface 0 "ALCOR Generic USB Hub" rev 1.10/3.12 addr 3 uhidev0 at uhub6 port 1 configuration 1 interface 0 "CHERRY Mechanical Keyboard" rev 2.00/0.02 addr 4 uhidev0: iclass 3/1 ukbd0 at uhidev0: 8 variable keys, 6 key codes wskbd1 at ukbd0 mux 1 uhidev1 at uhub6 port 1 configuration 1 interface 1 "CHERRY Mechanical Keyboard" rev 2.00/0.02 addr 4 uhidev1: iclass 3/0, 3 report ids uhid0 at uhidev1 reportid 1: input=2, output=0, feature=0 ukbd1 at uhidev1 reportid 3: 120 variable keys, 0 key codes wskbd2 at ukbd1 mux 1 uhidev2 at uhub6 port 1 configuration 1 interface 2 "CHERRY Mechanical Keyboard" rev 2.00/0.02 addr 4 uhidev2: iclass 3/0 uhid1 at uhidev2: input=64, output=64, feature=64 uhidev3 at uhub6 port 2 configuration 1 interface 0 "SteelSeries Sensei Raw Gaming Mouse" rev 1.10/1.12 addr 5 uhidev3: iclass 3/0 uhid2 at uhidev3: input=32, output=32, feature=255 uhidev4 at uhub6 port 2 configuration 1 interface 1 "SteelSeries Sensei Raw Gaming Mouse" rev 1.10/1.12 addr 5 uhidev4: iclass 3/1 ums0 at uhidev4: 8 buttons, Z dir wsmouse0 at ums0 mux 0 uhidev5 at uhub6 port 2 configuration 1 interface 2 "SteelSeries Sensei Raw Gaming Mouse" rev 1.10/1.12 addr 5 uhidev5: iclass 3/1 ukbd2 at uhidev5: 8 variable keys, 6 key codes wskbd3 at ukbd2 mux 1 uhidev6 at uhub6 port 2 configuration 1 interface 3 "SteelSeries Sensei Raw Gaming Mouse" rev 1.10/1.12 addr 5 uhidev6: iclass 3/0 uhid3 at uhidev6: input=4, output=0, feature=0 uhidev7 at uhub6 port 3 configuration 1 interface 0 "Device 2Port KVMSwitcher" rev 1.10/0.01 addr 6 uhidev7: iclass 3/0 ukbd3 at uhidev7: 8 variable keys, 6 key codes wskbd4 at ukbd3 mux 1 uhidev8 at uhub6 port 3 configuration 1 interface 1 "Device 2Port KVMSwitcher" rev 1.10/0.01 addr 6 uhidev8: no input interrupt endpoint uhub7 at uhub3 port 1 configuration 1 interface 0 "Intel Rate Matching Hub" rev 2.00/0.05 addr 2 vscsi0 at root scsibus2 at vscsi0: 256 targets softraid0 at root scsibus3 at softraid0: 256 targets root on sd0a (9b5c1232128549ea.a) swap on sd0b dump on sd0b WARNING: / was not properly unmounted inteldrm0: 1920x1080, 32bpp wsdisplay0 at inteldrm0 mux 1: console (std, vt100 emulation), using wskbd0 wskbd1: connecting to wsdisplay0 wskbd2: connecting to wsdisplay0 wskbd3: connecting to wsdisplay0 wskbd4: connecting to wsdisplay0 wsdisplay0: screen 1-5 added (std, vt100 emulation)