Idle CPU Usage of usbmuxd

Using 22.03.2 r19803-9a599fee93 on WNDR3700v1 as a backup cellular WAN router.

Even when a phone isn't connected, usbmuxd is eating up 30-40% of cpu. I tried rebooting without ever connecting a phone and the issue persists. I tried killing and restarting usbmuxd and that didn't help either.

1 Like

Hi, has this issue been resolved?

My framework is openwrt-22.03.2/target/linux/ath79

still there, hovers between 20-40%:

I found the reason is because of the "HAVE_PPOLL" macro definition in the usbmuxd package
Removing this macro definition will fix it

1 Like

what does HAVE_PPOLL macro do?

/etc/init.d/usbmuxd stop
usbmuxd -f -vvvv

English, please.

You can debug with the following command:

I am not an expert in debugging openwrt code. Are you saying that this polling is not necessary for usb tethering?

Normally polling would wait 100s, but it didn't

If this is a bug do I need to report it somewhere else?

what architecture is your cpu
I'm not sure if it's caused by the architecture
mine is ipq40xx

No idea, whatever architecture wndr3700v1 is :slight_smile:

For Netgear WNDR3700V1 it's ar71xx (Atheros AR7161).

Here is the culprit:

struct timespec
	time_t tv_sec;
	long int tv_nsec;

If usbmuxd is compiled with 64 bit time_t, but ppoll expects it to be 32 bit, the following timespec data is interpreted by ppoll:

// little endianness: timeout is 100 seconds
int32_t tv_sec = 100;
int32_t tv_nsec = 0;
int32_t unused = 0;

// big endianness: timeout is 100 nano-seconds
int32_t tv_sec = 0;
int32_t tv_nsec = 100;
int32_t unused = 0;

I was able to confirm this by defining a timespec32 structure, setting tv_sec = 1 and then casting its pointer to (struct timespec *). This results in timeouts of 1 second as expected. Only big endianness CPUs are affected. That's why I have no issues with WRT3200ACM, while the old TL-WR1043ND is affected.
Before I submit a patch, I need to find why usbmuxd is compiled with 64 bit time_t and change it to match ppoll. This looks like wrong include paths or incorrect macros.

Edit: issue and fix

1 Like

thank you.

Fixed on master. Expect a backport to 22.03 soon. :beers: