This is the bug/patch tracker for Rockbox. Click here for more information.
Quick links: Bugs · Patches · Rockbox frontpage
FS#11043 - High dircache stack usage after usb connection
Attached to Project:
Rockbox
Opened by Michael Chicoine (mc2739) - Sunday, 21 February 2010, 00:24 GMT+2
Last edited by amaury pouly (pamaury) - Friday, 23 April 2010, 10:08 GMT+2
Opened by Michael Chicoine (mc2739) - Sunday, 21 February 2010, 00:24 GMT+2
Last edited by amaury pouly (pamaury) - Friday, 23 April 2010, 10:08 GMT+2
|
DetailsI am seeing high dircache stack usage after USB connection on my e280v1.
I tested as far back as r24419 and up to current (r24794). Steps to reproduce: 1. Clear all settings on boot 2. Check dircache usage on debug screen 3. Attach USB cable 4. Eject or safely remove 5. Remove USB cable 6. Check dircache usage on debug screen 7. Enable dircache 8. Reboot 9. Check dircache usage on debug screen 10. Attach USB cable 11. Eject or safely remove 12. Remove USB cable 13. Check dircache usage on debug screen With r24419, the stack usage for steps 2, 6, 9, and 10 were 2%, 3%, 2%, and 82%. This 82% level was also present after rebooting. With r24657, there was an increase in stack usage. The levels recorded were: 2%, 3%, 2%, and 93%. With r24708, there was another increase in stack usage. The levels recorded were: 4%, 7%, 4%, and 97%. Current svn gives the same values as those recorded for r24708. As I have enabled other features in Rockbox, I have started to see "Stkov dircache (0)" panics. These panics continue after reboot and require editing the config.cfg file in USB mode to disable dircache. After disabling dircache, it will reboot without problems. |
This task depends upon
Closed by amaury pouly (pamaury)
Friday, 23 April 2010, 10:08 GMT+2
Reason for closing: Fixed
Additional comments about closing: r25696, r25697
Friday, 23 April 2010, 10:08 GMT+2
Reason for closing: Fixed
Additional comments about closing: r25696, r25697
The stack usage of dircache is supposed to be completely independent of all other features of rockbox and depends only the maximum directory depth.
The current code should accomodate a depth of 20 approximately.
What is the maximum depth of your directory tree ?
I will look at the commit you quote however.
I was able to get the dircache stack back to 97% from 99% by deleting my .rockbox directory. This helps some, but I will still get a stkov after a disconnect and rolo of a new firmware.
I really can't understand how this is possible. I myself have a e280v1 and I get 62% usage with pretty deep structures.
If it continues, you add this line in firmware/common/dircache.c:
#define LOGF_ENABLE
just before
#include "logf.h"
Recompile and paste logf output after usb connection.
dircache os stack usage (dircache disabled)
before USB connection: 4%
after USB connection: 7%
dircache os stack usage (dircache enabled)
before USB connection: 4%
after USB connection: 63%
directory depth: 4
from stats plugin
Files: 319
Music: 0
Dirs: 36
Max files in Dir: 43
from Windows Vista dir listing:
Total Files Listed:
319 File(s) 15,135,905 bytes
104 Dir(s) 5,982,404,608 bytes free
These are stats from my e270r after restoring music (r25259)
dircache os stack usage (dircache disabled)
before USB connection: 4%
after USB connection: 7%
dircache os stack usage (dircache enabled)
before USB connection: 4%
after USB connection: 97%
directory depth: 4
from stats plugin
Files: 671
Music: 298
Dirs: 64
Max files in Dir: 43
from Windows Vista dir listing:
Total Files Listed:
667 File(s) 5,698,753,068 bytes
188 Dir(s) 297,766,912 bytes free
These are stats from my e270r using logf build (r25259M)
dircache os stack usage (dircache disabled)
before USB connection: 4%
after USB connection: 7%
dircache os stack usage (dircache enabled)
before USB connection: 4%
after USB connection: 93%
directory depth: 4
from stats plugin
Files: 672
Music: 298
Dirs: 64
Max files in Dir: 43
from Windows Vista dir listing:
Total Files Listed:
668 File(s) 5,698,753,345 bytes
188 Dir(s) 297,762,816 bytes free
dircache.c:
dircache_thread 44
dircache_do_rebuild 28
dircache_scan_and_build 304
sab_process_dir 60
fat.c:
fat_getnext 108
fat_readwrite 92
transfer 28
ata-sd-pp.c:
sd_read_sectors 76
sd_select_bank 580
sd_command 60
The recursive function is sab_process_dir. The non-recursive parts need 1320 bytes. Given that the stack is currently set to 1536 bytes, that leaves some 200 bytes for sab_process_dir. Enough for 3 levels of recursion... If the stack was increased to 2.5 kB (i.e., add 0xA00), it would allow for some 20 levels (a bit overkill perhaps, but better to be on the safe side).
The last point I'm still not sure to understand understand is why on my sd card I can go up to 20, the reason for this seems to be that sd_select_bank is only called on big sd cards (code suggest on SDHC cards).
So the solution is:
* either increase stack size as you propose
* try to reduce sd_select_bank buffer size. The buffer size is 512 bytes but a quick look suggest it can be reduced to 32 bytes. Then we could increase stack size if it's still necessary.
But adding about 500 bytes would only be enough for 11 levels, at least with gcc 4.4.3, so some stack increase is probably needed too.
sorry for the delay, I have been busy and forgot this task for a moment :)
I have commited the fix in r25696 and r25697, I would be nice if you could test it because I can't check the ata-sd-pp change, even though I'm pretty sure it works.
Here are the stack levels I get after USB connection with dircache enabled:
r25695 - 90%
r25696 - 61%
r25697 - 44%