Date: Mon, 24 Feb 2020 01:20:31 +0000 From: bugzilla-noreply@freebsd.org To: usb@FreeBSD.org Subject: [Bug 244356] Writing to a USB 3.0 stick is very slow Message-ID: <bug-244356-19105@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D244356 Bug ID: 244356 Summary: Writing to a USB 3.0 stick is very slow Product: Base System Version: 12.1-RELEASE Hardware: amd64 OS: Any Status: New Severity: Affects Only Me Priority: --- Component: usb Assignee: usb@FreeBSD.org Reporter: seb@boisvert.info Hello, Writing to a USB 3.0 stick is very slow. USB 2.0 sticks work fine. USB 3.0 stick plugged in a USB 2.0 port exhibit the same problem compared to being plugged in a USB 3.0 port. My FreeBSD installation is on a ZFS mirror of 2 identical 7.2 GiB USB 2.0 sticks. Output of 'usbconfig' for these 2 storage devices: ugen1.2: <Kingston DataTraveler 2.0> at usbus1, cfg=3D0 md=3DHOST spd=3DHIGH (480Mbps) pwr=3DON (100mA) ugen0.3: <Kingston DataTraveler 2.0> at usbus0, cfg=3D0 md=3DHOST spd=3DHIGH (480Mbps) pwr=3DON (100mA) Output of gpart: root@atlantis:~ # gpart show da0 =3D> 40 15131560 da0 GPT (7.2G) 40 1024 1 freebsd-boot (512K) 1064 984 - free - (492K) 2048 4194304 2 freebsd-swap (2.0G) 4196352 10934272 3 freebsd-zfs (5.2G) 15130624 976 - free - (488K) root@atlantis:~ # gpart show da1 =3D> 40 15131560 da1 GPT (7.2G) 40 1024 1 freebsd-boot (512K) 1064 984 - free - (492K) 2048 4194304 2 freebsd-swap (2.0G) 4196352 10934272 3 freebsd-zfs (5.2G) 15130624 976 - free - (488K) The directory /usr contains 620 MB of files. Command: # du -sh /usr/ 620M /usr/ It takes 4:31.4 (4 minutes, 31 seconds) to copy /usr to /root. Command: time rsync -av /usr /root/ sent 1,458,070,436 bytes received 952,593 bytes 5,354,212.95 bytes/sec total size is 1,454,334,520 speedup is 1.00 13.724u 17.240s 4:31.94 11.3% 433+221k 59891+57303io 0pf+0w I have a 32 GB USB 3.0 stick. The output of 'usbconfig' is: ugen0.5: <Kingston DataTraveler 3.0> at usbus0, cfg=3D0 md=3DHOST spd=3DSUP= ER (5.0Gbps) pwr=3DON (126mA) The output of 'gpart': root@atlantis:~ # gpart show da2 =3D> 40 60604336 da2 GPT (29G) 40 2008 - free - (1.0M) 2048 60600320 1 freebsd-ufs (29G) 60602368 2008 - free - (1.0M) There is a UFS file system on the USB 3.0 devive. It is mounted in /mnt/ufs It takes 31:34.57 to copy /usr to /mnt/ufs, Command: time rsync -av /usr/ /mnt/ufs/ sent 1,458,070,404 bytes received 952,532 bytes 770,136.15 bytes/sec total size is 1,454,334,520 speedup is 1.00 13.128u 12.211s 31:34.57 1.3% 435+222k 7678+9104io 0pf+0w Using 'truss', I can see that a lot of calls to select() take a lot of time before returning. Command:=20 truss -D rsync -av /usr /mnt/ufs/ >& /root/rsync-truss-ufs-usb-3.log root@atlantis:~ # sort -k1,1rn /root/rsync-truss-ufs-usb-3.log | head -n 20 60.003431924 select(6,{ 5 },{ 4 },{ 5 },{ 60.000000 }) =3D 0 (0x0) 49.165728175 select(6,{ 5 },{ 4 },{ 5 },{ 60.000000 }) =3D 1 (0x1) 42.159206222 select(5,{ },{ 4 },{ },{ 60.000000 }) =3D 1 (0x1) 41.122681159 select(6,{ 5 },{ 4 },{ 5 },{ 60.000000 }) =3D 1 (0x1) 39.143298378 select(6,{ 5 },{ 4 },{ 5 },{ 60.000000 }) =3D 1 (0x1) 38.106784375 select(6,{ 5 },{ 4 },{ 5 },{ 60.000000 }) =3D 1 (0x1) 38.080823335 select(6,{ 5 },{ 4 },{ 5 },{ 60.000000 }) =3D 1 (0x1) 33.890768013 select(6,{ 5 },{ 4 },{ 5 },{ 60.000000 }) =3D 1 (0x1) 32.247561086 select(6,{ 5 },{ 4 },{ 5 },{ 60.000000 }) =3D 1 (0x1) 29.721087531 select(6,{ 5 },{ 4 },{ 5 },{ 60.000000 }) =3D 1 (0x1) 28.045373886 select(6,{ 5 },{ 4 },{ 5 },{ 60.000000 }) =3D 1 (0x1) 27.097321654 select(6,{ 5 },{ 4 },{ 5 },{ 60.000000 }) =3D 1 (0x1) 26.624814418 select(6,{ 5 },{ 4 },{ 5 },{ 60.000000 }) =3D 1 (0x1) 26.183747112 select(6,{ 5 },{ 4 },{ 5 },{ 60.000000 }) =3D 1 (0x1) 23.386795589 select(6,{ 5 },{ 4 },{ 5 },{ 60.000000 }) =3D 1 (0x1) 22.540706824 select(6,{ 5 },{ 4 },{ 5 },{ 60.000000 }) =3D 1 (0x1) 22.448082140 select(6,{ 5 },{ 4 },{ 5 },{ 60.000000 }) =3D 1 (0x1) 21.807824638 select(6,{ 5 },{ 4 },{ 5 },{ 60.000000 }) =3D 1 (0x1) 21.662166794 select(6,{ 5 },{ 4 },{ 5 },{ 60.000000 }) =3D 1 (0x1) 17.910288782 select(6,{ 5 },{ 4 },{ 5 },{ 60.000000 }) =3D 1 (0x1) Using the 'procsystime' dtrace script, I can see the numerous calls to select(). root@atlantis:~ # /usr/local/share/dtrace-toolkit/procsystime Tracing... Hit Ctrl-C to end... dtrace: 357 dynamic variable drops with non-empty dirty list ^C Elapsed Times for all processes, SYSCALL TIME (ns) sigreturn 4899 open 5961 fstatfs 6843 close 8286 openat 13816 fstat 17242 sigaction 22701 mmap 30375 fstatat 39743 getdirentries 40936 sigprocmask 99694 write 633885 __sysctl 873677 ioctl 1227846 read 1428213 _umtx_op 9038575168 select 17245685291 The 'hotkernel' dtrace script shows that the CPU cores are mostly idle. root@atlantis:~ # /usr/local/share/dtrace-toolkit/hotkernel=20 Sampling... Hit Ctrl-C to end. ^C FUNCTION COUNT PCNT kernel`cpu_activeclock 1 0.0% kernel`acpi_cpu_idle 1 0.0% kernel`usbd_in_polling_mode 1 0.0% kernel`xhci_generic_done_sub 1 0.0% kernel`critical_exit_preempt 1 0.0% kernel`softdep_sync_buf 1 0.0% kernel`rdtsc 1 0.0% kernel`cpu_idle_acpi 2 0.0% kernel`ithread_loop 2 0.0% kernel`usbd_get_page 2 0.0% kernel`xhci_setup_generic_chain_sub 3 0.0% kernel`em_update_stats_counters 3 0.0% kernel`tsc_get_timecount_low_mfence 4 0.0% kernel`cpu_search_highest 7 0.0% kernel`xhci_interrupt_poll 8 0.0% kernel`xhci_interrupt 16 0.0% kernel`spinlock_exit 36 0.0% kernel`cpu_idle 2888 3.4% kernel`acpi_cpu_c1 81118 96.5% The 'disklatency' dtrace script shows a high disk latency. root@atlantis:~ # /usr/share/dtrace/disklatency Tracing... Hit Ctrl-C to end. ^C da 2 value ------------- Distribution ------------- count=20=20=20=20 76000 | 0=20=20=20=20=20= =20=20=20 >=3D 80000 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2=20=20=20=20= =20=20=20=20 da 2 2131= 761 da 2 2121= 442 da 2 10= 420 ZFS is completely unusable on this USB 3.0 stick. It took the whole night just to install FreeBSD on ZFS using the installer. Hardware -------- - Processor: AMD Ryzen 5 2600 Six-Core Processor - Socket: AM4 - Memory: Kingston 8GB DDR4-2400ECC Unbuffered DIMM CL171Rx81.2V Micron EDie (Server Premier) - Motherboard: ASRock B450 Gaming-ITX/ac - Chipset: AMD Promontory B450 - Storage (operating system): 2 x Kingston DataTraveler 2.0 7.2 GiB - Storage: Kingston DataTraveler 3.0 PHISON USB3 --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-244356-19105>