Jan Vlach
2017-05-23 21:33:00 UTC
Hello bugs team,
I've been playing with system accounting a bit and noticed, that sa -c does not show percentages correctly. The multiply by 100 is missing in the calculation in various places.
FreeBSD fixed this in 2007
https://svnweb.freebsd.org/base/head/usr.sbin/sa/pdb.c?r1=168455&r2=168456&
Patch attached. (cvs diff pdb.c)
Tried the fix on 6.1 stable on amd64, applies cleanly on -current on i386 (dmesg below)
Could you please check this?
Thank you,
Jan
### EXAMPLE OUTPUT (sa -c | head -7):
2031267 2957434.95re 15203.74cp 42avio 0k
658 0.00% 3731.97re 0.00% 1621.36cp 0.11% 3271avio 0k ffmpeg
856 0.00% 31754.99re 0.01% 1610.75cp 0.11% 1168avio 0k surf
10424 0.01% 1534.91re 0.00% 1530.84cp 0.10% 14avio 0k cc1plus
19393 0.01% 3675.59re 0.00% 1004.55cp 0.07% 733avio 0k perl
155 0.00% 14729.46re 0.00% 983.00cp 0.06% 2153avio 0k firefox-es
66261 0.03% 1001.52re 0.00% 678.09cp 0.04% 3avio 0k cc1
### EXAMPLE OUTPUT PATCHED (sa -c | head -7):
2031261 2957434.95re 15203.74cp 42avio 0k
658 0.0% 3731.97re 0.1% 1621.36cp 10.7% 3271avio 0k ffmpeg
856 0.0% 31754.99re 1.1% 1610.75cp 10.6% 1168avio 0k surf
10424 0.5% 1534.91re 0.1% 1530.84cp 10.1% 14avio 0k cc1plus
19393 1.0% 3675.59re 0.1% 1004.55cp 6.6% 733avio 0k perl
155 0.0% 14729.46re 0.5% 983.00cp 6.5% 2153avio 0k firefox-es
66261 3.3% 1001.52re 0.0% 678.09cp 4.5% 3avio 0k cc1
### DMESG
OpenBSD 6.1-current (GENERIC.MP) #76: Tue May 23 08:03:51 MDT 2017
***@i386.openbsd.org:/usr/src/sys/arch/i386/compile/GENERIC.MP
cpu0: Intel(R) Atom(TM) CPU N270 @ 1.60GHz ("GenuineIntel" 686-class) 1.61 GHz
cpu0: FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,NXE,SSE3,DTES64,MWAIT,DS-CPL,EST,TM2,SSSE3,xTPR,PDCM,MOVBE,LAHF,PERF,SENSOR
real mem = 2138193920 (2039MB)
avail mem = 2084429824 (1987MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: date 06/11/09, BIOS32 rev. 0 @ 0xf0010, SMBIOS rev. 2.5 @ 0xf0710 (30 entries)
bios0: vendor American Megatrends Inc. version "2103" date 06/11/2009
bios0: ASUSTeK Computer INC. 901
acpi0 at bios0: rev 0
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP APIC MCFG OEMB HPET SSDT
acpi0: wakeup devices P0P2(S4) P0P1(S4) P0P4(S4) P0P6(S4) P0P7(S4) P0P8(S4) P0P9(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 133MHz
cpu0: mwait min=64, max=64, C-substates=0.2.2.0.2, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Atom(TM) CPU N270 @ 1.60GHz ("GenuineIntel" 686-class) 1.61 GHz
cpu1: FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,NXE,SSE3,DTES64,MWAIT,DS-CPL,EST,TM2,SSSE3,xTPR,PDCM,MOVBE,LAHF,PERF,SENSOR
ioapic0 at mainbus0: apid 2 pa 0xfec00000, version 20, 24 pins
acpimcfg0 at acpi0 addr 0xe0000000, bus 0-63
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 5 (P0P4)
acpiprt2 at acpi0: bus 3 (P0P6)
acpiprt3 at acpi0: bus 1 (P0P7)
acpiprt4 at acpi0: bus -1 (P0P8)
acpiprt5 at acpi0: bus -1 (P0P9)
acpiprt6 at acpi0: bus 4 (P0P5)
acpiec0 at acpi0
acpicpu0 at acpi0: !C2(***@1 ***@0x10), C1(***@1 mwait.1), PSS
acpicpu1 at acpi0: !C2(***@1 ***@0x10), C1(***@1 mwait.1), PSS
acpitz0 at acpi0: critical temperature is 85 degC
"PNP0303" at acpi0 not configured
"SYN0A04" at acpi0 not configured
acpibat0 at acpi0: BAT0 model "901" serial type LION oem "ASUS"
acpiac0 at acpi0: AC unit online
acpiasus0 at acpi0
acpibtn0 at acpi0: LID_
acpibtn1 at acpi0: SLPB
acpibtn2 at acpi0: PWRB
acpivideo0 at acpi0: VGA_
bios0: ROM list: 0xc0000/0xec00!
cpu0: Enhanced SpeedStep 1601 MHz: speeds: 1600, 1333, 1067, 800 MHz
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 "Intel 82945GME Host" rev 0x03
inteldrm0 at pci0 dev 2 function 0 "Intel 82945GME Video" rev 0x03
drm0 at inteldrm0
intagp0 at inteldrm0
agp0 at intagp0: aperture at 0xd0000000, size 0x10000000
inteldrm0: apic 2 int 16
inteldrm0: 1024x600, 32bpp
wsdisplay0 at inteldrm0 mux 1: console (std, vt100 emulation)
wsdisplay0: screen 1-5 added (std, vt100 emulation)
"Intel 82945GM Video" rev 0x03 at pci0 dev 2 function 1 not configured
azalia0 at pci0 dev 27 function 0 "Intel 82801GB HD Audio" rev 0x02: msi
azalia0: codecs: Realtek ALC269
audio0 at azalia0
ppb0 at pci0 dev 28 function 0 "Intel 82801GB PCIE" rev 0x02: apic 2 int 16
pci1 at ppb0 bus 5
ppb1 at pci0 dev 28 function 1 "Intel 82801GB PCIE" rev 0x02: apic 2 int 17
pci2 at ppb1 bus 4
ale0 at pci2 dev 0 function 0 "Attansic Technology L1E" rev 0xb0: AR8113, msi, address 00:22:15:36:2d:7f
atphy0 at ale0 phy 0: F1 10/100/1000 PHY, rev. 9
ppb2 at pci0 dev 28 function 2 "Intel 82801GB PCIE" rev 0x02: apic 2 int 18
pci3 at ppb2 bus 3
ppb3 at pci0 dev 28 function 3 "Intel 82801GB PCIE" rev 0x02: apic 2 int 19
pci4 at ppb3 bus 1
ral0 at pci4 dev 0 function 0 "Ralink RT2790" rev 0x00: apic 2 int 19, address 00:15:af:bc:da:cb
ral0: MAC/BBP RT2872 (rev 0x0200), RF RT2720 (MIMO 1T2R)
uhci0 at pci0 dev 29 function 0 "Intel 82801GB USB" rev 0x02: apic 2 int 23
uhci1 at pci0 dev 29 function 1 "Intel 82801GB USB" rev 0x02: apic 2 int 22
uhci2 at pci0 dev 29 function 2 "Intel 82801GB USB" rev 0x02: apic 2 int 21
uhci3 at pci0 dev 29 function 3 "Intel 82801GB USB" rev 0x02: apic 2 int 20
ehci0 at pci0 dev 29 function 7 "Intel 82801GB USB" rev 0x02: apic 2 int 23
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 configuration 1 interface 0 "Intel EHCI root hub" rev 2.00/1.00 addr 1
ppb4 at pci0 dev 30 function 0 "Intel 82801BAM Hub-to-PCI" rev 0xe2
pci5 at ppb4 bus 6
ichpcib0 at pci0 dev 31 function 0 "Intel 82801GBM LPC" rev 0x02: PM disabled
pciide0 at pci0 dev 31 function 2 "Intel 82801GBM SATA" rev 0x02: DMA, channel 0 wired to compatibility, channel 1 wired to compatibility
wd0 at pciide0 channel 0 drive 1: <RunCore 32G-C SSD>
wd0: 1-sector PIO, LBA48, 30800MB, 63078400 sectors
wd0(pciide0:0:1): using PIO mode 4, Ultra-DMA mode 6
wd1 at pciide0 channel 1 drive 0: <ASUS-PHISON SSD>
wd1: 1-sector PIO, LBA, 3847MB, 7880544 sectors
wd1(pciide0:1:0): using PIO mode 4, Ultra-DMA mode 4
ichiic0 at pci0 dev 31 function 3 "Intel 82801GB SMBus" rev 0x02: apic 2 int 19
iic0 at ichiic0
spdmem0 at iic0 addr 0x50: 2GB DDR2 SDRAM non-parity PC2-5300CL5 SO-DIMM
usb1 at uhci0: USB revision 1.0
uhub1 at usb1 configuration 1 interface 0 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb2 at uhci1: USB revision 1.0
uhub2 at usb2 configuration 1 interface 0 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb3 at uhci2: USB revision 1.0
uhub3 at usb3 configuration 1 interface 0 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb4 at uhci3: USB revision 1.0
uhub4 at usb4 configuration 1 interface 0 "Intel UHCI root hub" rev 1.00/1.00 addr 1
isa0 at ichpcib0
isadma0 at isa0
pckbc0 at isa0 port 0x60/5 irq 1 irq 12
pckbd0 at pckbc0 (kbd slot)
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pms0 at pckbc0 (aux slot)
wsmouse0 at pms0 mux 0
pms0: Elantech Touchpad, version 2, firmware 0x20030
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
npx0 at isa0 port 0xf0/16: reported by CPUID; using exception 16
umass0 at uhub0 port 5 configuration 1 interface 0 "Generic Mass Storage Device" rev 2.00/1.05 addr 2
umass0: using SCSI over Bulk-Only
scsibus1 at umass0: 2 targets, initiator 0
sd0 at scsibus1 targ 1 lun 0: <Single, Flash Reader, 1.00> SCSI0 0/direct removable serial.058f6335058F63356336
sd0: 1876MB, 512 bytes/sector, 3842048 sectors
vscsi0 at root
scsibus2 at vscsi0: 256 targets
softraid0 at root
scsibus3 at softraid0: 256 targets
sd1 at scsibus3 targ 1 lun 0: <OPENBSD, SR CRYPTO, 006> SCSI2 0/direct fixed
sd1: 30796MB, 512 bytes/sector, 63070598 sectors
root on sd1a (dc989ffd011ca273.a) swap on sd1b dump on sd1b
I've been playing with system accounting a bit and noticed, that sa -c does not show percentages correctly. The multiply by 100 is missing in the calculation in various places.
FreeBSD fixed this in 2007
https://svnweb.freebsd.org/base/head/usr.sbin/sa/pdb.c?r1=168455&r2=168456&
Patch attached. (cvs diff pdb.c)
Tried the fix on 6.1 stable on amd64, applies cleanly on -current on i386 (dmesg below)
Could you please check this?
Thank you,
Jan
### EXAMPLE OUTPUT (sa -c | head -7):
2031267 2957434.95re 15203.74cp 42avio 0k
658 0.00% 3731.97re 0.00% 1621.36cp 0.11% 3271avio 0k ffmpeg
856 0.00% 31754.99re 0.01% 1610.75cp 0.11% 1168avio 0k surf
10424 0.01% 1534.91re 0.00% 1530.84cp 0.10% 14avio 0k cc1plus
19393 0.01% 3675.59re 0.00% 1004.55cp 0.07% 733avio 0k perl
155 0.00% 14729.46re 0.00% 983.00cp 0.06% 2153avio 0k firefox-es
66261 0.03% 1001.52re 0.00% 678.09cp 0.04% 3avio 0k cc1
### EXAMPLE OUTPUT PATCHED (sa -c | head -7):
2031261 2957434.95re 15203.74cp 42avio 0k
658 0.0% 3731.97re 0.1% 1621.36cp 10.7% 3271avio 0k ffmpeg
856 0.0% 31754.99re 1.1% 1610.75cp 10.6% 1168avio 0k surf
10424 0.5% 1534.91re 0.1% 1530.84cp 10.1% 14avio 0k cc1plus
19393 1.0% 3675.59re 0.1% 1004.55cp 6.6% 733avio 0k perl
155 0.0% 14729.46re 0.5% 983.00cp 6.5% 2153avio 0k firefox-es
66261 3.3% 1001.52re 0.0% 678.09cp 4.5% 3avio 0k cc1
### DMESG
OpenBSD 6.1-current (GENERIC.MP) #76: Tue May 23 08:03:51 MDT 2017
***@i386.openbsd.org:/usr/src/sys/arch/i386/compile/GENERIC.MP
cpu0: Intel(R) Atom(TM) CPU N270 @ 1.60GHz ("GenuineIntel" 686-class) 1.61 GHz
cpu0: FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,NXE,SSE3,DTES64,MWAIT,DS-CPL,EST,TM2,SSSE3,xTPR,PDCM,MOVBE,LAHF,PERF,SENSOR
real mem = 2138193920 (2039MB)
avail mem = 2084429824 (1987MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: date 06/11/09, BIOS32 rev. 0 @ 0xf0010, SMBIOS rev. 2.5 @ 0xf0710 (30 entries)
bios0: vendor American Megatrends Inc. version "2103" date 06/11/2009
bios0: ASUSTeK Computer INC. 901
acpi0 at bios0: rev 0
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP APIC MCFG OEMB HPET SSDT
acpi0: wakeup devices P0P2(S4) P0P1(S4) P0P4(S4) P0P6(S4) P0P7(S4) P0P8(S4) P0P9(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 133MHz
cpu0: mwait min=64, max=64, C-substates=0.2.2.0.2, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Atom(TM) CPU N270 @ 1.60GHz ("GenuineIntel" 686-class) 1.61 GHz
cpu1: FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,NXE,SSE3,DTES64,MWAIT,DS-CPL,EST,TM2,SSSE3,xTPR,PDCM,MOVBE,LAHF,PERF,SENSOR
ioapic0 at mainbus0: apid 2 pa 0xfec00000, version 20, 24 pins
acpimcfg0 at acpi0 addr 0xe0000000, bus 0-63
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 5 (P0P4)
acpiprt2 at acpi0: bus 3 (P0P6)
acpiprt3 at acpi0: bus 1 (P0P7)
acpiprt4 at acpi0: bus -1 (P0P8)
acpiprt5 at acpi0: bus -1 (P0P9)
acpiprt6 at acpi0: bus 4 (P0P5)
acpiec0 at acpi0
acpicpu0 at acpi0: !C2(***@1 ***@0x10), C1(***@1 mwait.1), PSS
acpicpu1 at acpi0: !C2(***@1 ***@0x10), C1(***@1 mwait.1), PSS
acpitz0 at acpi0: critical temperature is 85 degC
"PNP0303" at acpi0 not configured
"SYN0A04" at acpi0 not configured
acpibat0 at acpi0: BAT0 model "901" serial type LION oem "ASUS"
acpiac0 at acpi0: AC unit online
acpiasus0 at acpi0
acpibtn0 at acpi0: LID_
acpibtn1 at acpi0: SLPB
acpibtn2 at acpi0: PWRB
acpivideo0 at acpi0: VGA_
bios0: ROM list: 0xc0000/0xec00!
cpu0: Enhanced SpeedStep 1601 MHz: speeds: 1600, 1333, 1067, 800 MHz
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 "Intel 82945GME Host" rev 0x03
inteldrm0 at pci0 dev 2 function 0 "Intel 82945GME Video" rev 0x03
drm0 at inteldrm0
intagp0 at inteldrm0
agp0 at intagp0: aperture at 0xd0000000, size 0x10000000
inteldrm0: apic 2 int 16
inteldrm0: 1024x600, 32bpp
wsdisplay0 at inteldrm0 mux 1: console (std, vt100 emulation)
wsdisplay0: screen 1-5 added (std, vt100 emulation)
"Intel 82945GM Video" rev 0x03 at pci0 dev 2 function 1 not configured
azalia0 at pci0 dev 27 function 0 "Intel 82801GB HD Audio" rev 0x02: msi
azalia0: codecs: Realtek ALC269
audio0 at azalia0
ppb0 at pci0 dev 28 function 0 "Intel 82801GB PCIE" rev 0x02: apic 2 int 16
pci1 at ppb0 bus 5
ppb1 at pci0 dev 28 function 1 "Intel 82801GB PCIE" rev 0x02: apic 2 int 17
pci2 at ppb1 bus 4
ale0 at pci2 dev 0 function 0 "Attansic Technology L1E" rev 0xb0: AR8113, msi, address 00:22:15:36:2d:7f
atphy0 at ale0 phy 0: F1 10/100/1000 PHY, rev. 9
ppb2 at pci0 dev 28 function 2 "Intel 82801GB PCIE" rev 0x02: apic 2 int 18
pci3 at ppb2 bus 3
ppb3 at pci0 dev 28 function 3 "Intel 82801GB PCIE" rev 0x02: apic 2 int 19
pci4 at ppb3 bus 1
ral0 at pci4 dev 0 function 0 "Ralink RT2790" rev 0x00: apic 2 int 19, address 00:15:af:bc:da:cb
ral0: MAC/BBP RT2872 (rev 0x0200), RF RT2720 (MIMO 1T2R)
uhci0 at pci0 dev 29 function 0 "Intel 82801GB USB" rev 0x02: apic 2 int 23
uhci1 at pci0 dev 29 function 1 "Intel 82801GB USB" rev 0x02: apic 2 int 22
uhci2 at pci0 dev 29 function 2 "Intel 82801GB USB" rev 0x02: apic 2 int 21
uhci3 at pci0 dev 29 function 3 "Intel 82801GB USB" rev 0x02: apic 2 int 20
ehci0 at pci0 dev 29 function 7 "Intel 82801GB USB" rev 0x02: apic 2 int 23
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 configuration 1 interface 0 "Intel EHCI root hub" rev 2.00/1.00 addr 1
ppb4 at pci0 dev 30 function 0 "Intel 82801BAM Hub-to-PCI" rev 0xe2
pci5 at ppb4 bus 6
ichpcib0 at pci0 dev 31 function 0 "Intel 82801GBM LPC" rev 0x02: PM disabled
pciide0 at pci0 dev 31 function 2 "Intel 82801GBM SATA" rev 0x02: DMA, channel 0 wired to compatibility, channel 1 wired to compatibility
wd0 at pciide0 channel 0 drive 1: <RunCore 32G-C SSD>
wd0: 1-sector PIO, LBA48, 30800MB, 63078400 sectors
wd0(pciide0:0:1): using PIO mode 4, Ultra-DMA mode 6
wd1 at pciide0 channel 1 drive 0: <ASUS-PHISON SSD>
wd1: 1-sector PIO, LBA, 3847MB, 7880544 sectors
wd1(pciide0:1:0): using PIO mode 4, Ultra-DMA mode 4
ichiic0 at pci0 dev 31 function 3 "Intel 82801GB SMBus" rev 0x02: apic 2 int 19
iic0 at ichiic0
spdmem0 at iic0 addr 0x50: 2GB DDR2 SDRAM non-parity PC2-5300CL5 SO-DIMM
usb1 at uhci0: USB revision 1.0
uhub1 at usb1 configuration 1 interface 0 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb2 at uhci1: USB revision 1.0
uhub2 at usb2 configuration 1 interface 0 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb3 at uhci2: USB revision 1.0
uhub3 at usb3 configuration 1 interface 0 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb4 at uhci3: USB revision 1.0
uhub4 at usb4 configuration 1 interface 0 "Intel UHCI root hub" rev 1.00/1.00 addr 1
isa0 at ichpcib0
isadma0 at isa0
pckbc0 at isa0 port 0x60/5 irq 1 irq 12
pckbd0 at pckbc0 (kbd slot)
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pms0 at pckbc0 (aux slot)
wsmouse0 at pms0 mux 0
pms0: Elantech Touchpad, version 2, firmware 0x20030
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
npx0 at isa0 port 0xf0/16: reported by CPUID; using exception 16
umass0 at uhub0 port 5 configuration 1 interface 0 "Generic Mass Storage Device" rev 2.00/1.05 addr 2
umass0: using SCSI over Bulk-Only
scsibus1 at umass0: 2 targets, initiator 0
sd0 at scsibus1 targ 1 lun 0: <Single, Flash Reader, 1.00> SCSI0 0/direct removable serial.058f6335058F63356336
sd0: 1876MB, 512 bytes/sector, 3842048 sectors
vscsi0 at root
scsibus2 at vscsi0: 256 targets
softraid0 at root
scsibus3 at softraid0: 256 targets
sd1 at scsibus3 targ 1 lun 0: <OPENBSD, SR CRYPTO, 006> SCSI2 0/direct fixed
sd1: 30796MB, 512 bytes/sector, 63070598 sectors
root on sd1a (dc989ffd011ca273.a) swap on sd1b dump on sd1b
--
Be the change you want to see in the world.
Be the change you want to see in the world.