Is there an option to just reduce the polling rate ? Once every 10 seconds would have minimal CPU load but still allow inserted cards to be auto mounted.
PeterO
Re: High CPU usage when booting from USB
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Re: High CPU usage when booting from USB
I already asked here https://github.com/raspberrypi/linux/is ... -392761118 but didn't quite get the answer.
And when checking mysellf I got a bit lost but I guess it is hardcoded once per second.
I guess the right method is mmc_rescan which is first set to be scheduled here
https://elixir.bootlin.com/linux/v4.14/ ... ost.c#L390and after it is first called it reschedules itself with HZ (=1 second?) delay when it ends here:
https://elixir.bootlin.com/linux/v4.14/ ... re.c#L2665
EDIT:
Oh, looks like HZ is much faster than once per second
https://www.google.cz/search?q=kernel+HZ
EDIT2: It is 1 second after all. While the value varies the meaning is number of kernel ticks per second so sleeping fo HZ ticks should last one second.
And when checking mysellf I got a bit lost but I guess it is hardcoded once per second.
I guess the right method is mmc_rescan which is first set to be scheduled here
https://elixir.bootlin.com/linux/v4.14/ ... ost.c#L390
Code: Select all
INIT_DELAYED_WORK(&host->detect, mmc_rescan);
https://elixir.bootlin.com/linux/v4.14/ ... re.c#L2665
Code: Select all
mmc_schedule_delayed_work(&host->detect, HZ);
EDIT:
Oh, looks like HZ is much faster than once per second
https://www.google.cz/search?q=kernel+HZ
EDIT2: It is 1 second after all. While the value varies the meaning is number of kernel ticks per second so sleeping fo HZ ticks should last one second.
Last edited by fanoush on Wed May 30, 2018 3:17 pm, edited 1 time in total.
Re: High CPU usage when booting from USB
I would agree, but my Pi's are up for months at a time, the "one file" fix was my choice.
Easy enough to remove the ExecStop and have a separate script handle adding the driver back if desired (or break all the code out into a script).
What I don't know about systemd is if there is a way to detect if the start/stop is executing because of a system startup or shutdown(maybe a better target choice?). If so, not processing the "stop" process during an actual shutdown would be ideal.
I don't have enough time to go googling, but would welcome insight if anyone knows.
Re: High CPU usage when booting from USB
I updated the original post (viewtopic.php?f=28&t=211912#p1321571) with a check for shutdown. The rebind should not occur during a shutdown.
That said, I'm not sure it was ever occurring. There is no console output for it during shutdown. It may just be too late in the sequence for console output. Adding the check is still worthwhile.
Re: High CPU usage when booting from USB
I updated the systemd hack for Jessie compatibility: viewtopic.php?f=28&t=211912#p1321571.
Also, looks like the sdtweak.dtbo changes have been merged and should available via rpi-update now.
The sdtweak method is the better of the two. It hopefully will be good going forward.For now, if you don't want to do a full rpi-update for, you can copy over just updated sdtweak.dtbo from the git repository: https://github.com/raspberrypi/firmware ... tweak.dtbo.
For those that still need Jessie, even though the sdtweak.dtbo overlay was built against the Stretch kernel/firmware/drivers, it appears to work as expected when copied into an otherwise pure Jessie boot(at least as of today's version).
EDIT: The updated sdtweak.dtbo is now in the official Raspbian as of the 06-27-2018 release and will be installed with your preferred apt commands. No rpi-update needed.
Also, looks like the sdtweak.dtbo changes have been merged and should available via rpi-update now.
The sdtweak method is the better of the two. It hopefully will be good going forward.
For those that still need Jessie, even though the sdtweak.dtbo overlay was built against the Stretch kernel/firmware/drivers, it appears to work as expected when copied into an otherwise pure Jessie boot(at least as of today's version).
EDIT: The updated sdtweak.dtbo is now in the official Raspbian as of the 06-27-2018 release and will be installed with your preferred apt commands. No rpi-update needed.
Last edited by jerrm on Fri Jun 29, 2018 1:02 pm, edited 4 times in total.
Re: High CPU usage when booting from USB
Has anyone written a simple sd slot control script...
"sdslot on" and "sdslot off" would seem useful.
PeterO
"sdslot on" and "sdslot off" would seem useful.
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Re: High CPU usage when booting from USB
Just cut and paste the code from the systemd script. The only thing to change is the "%n" value for the /var/run file - replace it with something like "$(basename $0)".
Also - no problem installing the systemd script but leaving disabled, then just toggle with systemctl start/stop.
Re: High CPU usage when booting from USB
The updated sdtweak.dtbo is now in the official Raspbian as of the 06-27-2018 release and will be installed with your preferred apt commands. No rpi-update needed.
Re: High CPU usage when booting from USB
Has this issue gone away for you with the latest updates? For me it hasn't. No SD card, happy flashing..
www.TheDigitalPictureFrame.com - Build a really great digital picture frame with the Raspberry Pi.
With lots of great tips from this forum.
With lots of great tips from this forum.
Re: High CPU usage when booting from USB
It won't just go away, you need to set it up yourself to not to check for card, this is feature, not bug 
https://www.raspberrypi.org/forums/view ... 2#p1321458

https://www.raspberrypi.org/forums/view ... 2#p1321458
Re: High CPU usage when booting from USB
As pointed out by fanoush you need to set it not to check for the card.fanoush wrote: ↑Mon Sep 10, 2018 7:03 pmIt won't just go away, you need to set it up yourself to not to check for card, this is feature, not bug
https://www.raspberrypi.org/forums/view ... 2#p1321458
to summarize from the link you only need to add one line to the config.txt to "silence" the led
Code: Select all
dtoverlay=sdtweak,poll_once
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"
Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"
Come to me with 'problems' and I'll help you find solutions"
Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"