[PATCH 0/2] use hrtimer in nand_wait

Artem Bityutskiy dedekind1 at gmail.com
Tue May 22 03:23:29 EDT 2012


On Mon, 2012-05-21 at 10:42 +0200, Johan Gunnarsson wrote:
> I've narrowed it down to the nand_wait routine and its dependency on a
> reliable jiffies counter. Sadly, jiffies is not reliable when handling
> of timer interrupts are delayed or even completely discarded. If
> interrupts are disabled for, say, 3 timer periods, jiffies will stop
> counting during this time and have a very fast increment by 3 when
> interrupts are later enabled.

I can follow up to this point.

>  This combined with unfortunate timing can cause the timeout loop
> think a 20ms timeout is happening when just <0.1ms has passed in wall
> clock time.

What is you HZ? Let's say it is 100, then jiffie increments every 10ms,
right? How can it increment by 2 after 0.1 ms?
> 
> To illustrate the jiffies/interrupt-relationship:
> 
> Interrupts: |      |      |                    |      |      |      |
> Jiffies:    |      |      |                    |||    |      |      |
> 
> This obviously only happen on multi-core CPUs, where the write and
> interrupts are executed by different cores simultaneously. Switching
> to hrtimer-based timeout solves this problem for me. I found a second
> (less serious) issue which included in the first patch.

Sorry, I do not understand why this happens only on SMP. Could you
please explain some more?

I do not disagree that we should stop using jiffies, if we can, I just
want to understand what is happening.

-- 
Best Regards,
Artem Bityutskiy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-mtd/attachments/20120522/6513b1bf/attachment-0001.sig>


More information about the linux-mtd mailing list