From: Mark Mason <mason@postdiluvian.org>
To: linux-mtd@lists.infradead.org
Subject: Scheduler latency problems when using NAND
Date: Wed, 29 Sep 2010 18:14:01 -0400 [thread overview]
Message-ID: <20100929221401.GA32583@postdiluvian.org> (raw)
Hi all,
I hope this is the right place for this question. I'm having some
problems with scheduler latency when using UBIFS, and I'm hoping for
some suggestions.
Linux 2.6.29-6, with a newer MTD, dating from probably around six
months ago. Embedded PowerPC 8315, with built-in NAND controller,
using nand/fsl_elbc_nand.c. NAND is a Samsung K9WAG08U1B two-die
stack (one package with two chip selects), 2Gbyte x 8 bit. The system
has plenty of memory, but is short on CPU.
The application is storing streaming video, almost entirely large
sequential files, roughly 250K to 15M, to a 1.6G filesystem. There's
no seeking or rewriting, just creat, write, close, repeat. No
compression is used on the filesystem.
The problem I'm seeing is excessively large scheduler latency when
data is flushed to NAND.
Originally this had been happening during erases. I noticed that
hundreds of erases (up to around 700) were being issued in rapid
succession, and I was seeing other threads unable to run for sometimes
as much as the expected 7 seconds (I measured 1.1 ms per erase). To
address this, I split the erase command in two halves - FIR_OP_CM0 |
FIR_OP_PA | FIR_OP_CM2 and FIR_OP_CW1 | FIR_OP_RS - with schedule()
called in between. This had the effect if issuing the erase, calling
schedule(), then waiting for the erase to complete if it hadn't
already, but usually it had.
I'm surprised this helped so much, since the calling thread should
have been put to sleep for the duration of the erase by the call to
wait_event_timeout(), but it definitely did - I guess it was the
explicit schedule().
The erases are no longer a significant bottleneck, but now the writes
are. A page program takes 200us, which seems too short for an
explicit schedule(), and I am seeing periods with the busy line
asserted in back-to-back 200us chunks for most of a second.
I have played with thread priorities a bit, but I wound up with too
many threads being "most important". There is some hardware that
can't tolerate large latencies, and unfortunately the existing code
base doesn't have enough separation between critical and non-critical
tasks to allow us to run just the critical stuff at a higher priority.
On average, the system can keep up with the load, but it has problems
with the burstiness of the flushes to NAND, so I'm hoping for some
ideas to smooth the traffic out, or even a totally different way to
approach the problem. I tried lowering the priority of the UBI
background thread, the failure mode there is pretty obvious. I tried
lowering dirty_background_centisecs, that helped a little bit, but not
enough, and there's also a SATA drive, although a smaller commit
interval probably wouldn't bother it since the traffic is similar.
I'm contemplating something along the lines of a smaller commit
interval, an even higher background thread priority, and a sleep with
a schedule during the page program, but that many extra context
switches are liable to be a problem - there's no L2 cache on this CPU,
so context switches are extra expensive.
Does anyone have any suggestions, ideas, hints, advice, etc?
Thanks!
next reply other threads:[~2010-09-29 22:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-29 22:14 Mark Mason [this message]
2010-09-30 0:26 ` Scheduler latency problems when using NAND Iwo Mergler
2010-09-30 15:08 ` Joakim Tjernlund
2010-10-09 17:42 ` Mark Mason
2010-10-10 7:56 ` Joakim Tjernlund
2010-10-11 22:54 ` Iwo Mergler
2010-10-12 16:05 ` Mark Mason
2010-09-30 4:56 ` Artem Bityutskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100929221401.GA32583@postdiluvian.org \
--to=mason@postdiluvian.org \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).