Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: David Brownell
Date: Monday, November 12, 2007 - 6:26 pm

> >	 It seems info on raw spinlocks is out

I'd be happy if, as originally presented, it were possible to just
pass a raw_spinlock_t to spin_lock_irqsave() and friends.



I don't think we really want to be scheduling on bit ops;
that seems a bit more fundamental.



It was caused by some debug options I run with all the time,
which don't otherwise have easily observed performance effects.

DEBUG_PREEMPT, DEBUG_SPINLOCK, and DEBUG_SPINLOCK_SLEEP, but not
LOCKDEP (which I run with all the time, on platforms where it's
available).  There were other options too, which didn't matter.
This was with a basically idle system, note ... there was no
preemption happening.



Think RT kernels, with threaded IRQs and spinlocks morphed to mutexes.

Only irq handlers marked IRQF_NODELAY|IRQF_DISABLED will always be
"hard irqs" [1] which run the way you describe ... i.e. the way the
current mainstream kernel always works for IRQ handlers.



That was a single bitbanged I2C bit transfer, with embedded udelay()s.
I believe that was four gpio operations, as summarized at the end of
that email above.  Enabling preempt + debug increased the cost of
each GPIO call from whatever it was (reasonable) by 1.2 usecs.



See above; that was probably four lock/unlocks; 1.2 usec a pair.

But per-bit preemption for GPIOs would in any case be Just Wrong;
much like making test_bit(), set_bit(), and clear_bit() become
preemption points would be wrong.



They were from a relatively normal speed embedded processor; exactly
the kind which tends to both use these operations, and not uncommonly
also involve bitbanging.  In this case it was an AVR32 devel board,
BogoMips about 250 (comparable to ARM5 ones with BogoMips around 90).



They weren't originally supposed to be like that.  They were to be
reserved for cases where their behavior was necessary ... like, to
synch with IRQF_NODELAY ("hard irq") handlers, and in other cases
where preemption would be wrong.



That's what I thought I did.  As I summarized it in the message
with the URL given above:


At most, I think one counter-argument would be that the costs of that
preempt (and debug) code aren't "enough" to merit using raw spinlocks;
a judgement call.

But that would have ignored the fact that such bit operations shouldn't
really be preemption points.  Only the "cansleep" versions should be;
they need to work through e.g. an I2C or SPI gpio expanders.

- Dave 

[1] http://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, David Brownell, (Fri Nov 9, 12:36 pm)
Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, David Brownell, (Mon Nov 12, 6:26 pm)
Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, David Brownell, (Tue Nov 13, 12:22 pm)
Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, David Brownell, (Tue Nov 13, 11:52 pm)
Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, Haavard Skinnemoen, (Wed Nov 14, 2:54 am)
Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, Thomas Gleixner, (Wed Nov 14, 5:14 am)
Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, David Brownell, (Wed Nov 14, 11:23 pm)
Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, David Brownell, (Wed Nov 14, 11:28 pm)
Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, David Brownell, (Wed Nov 14, 11:50 pm)
Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, David Brownell, (Thu Nov 15, 12:02 am)
Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, David Brownell, (Thu Nov 15, 12:17 am)
Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, Thomas Gleixner, (Thu Nov 15, 12:32 am)
Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, Thomas Gleixner, (Thu Nov 15, 12:35 am)
Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, Haavard Skinnemoen, (Thu Nov 15, 1:43 am)
Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, Haavard Skinnemoen, (Thu Nov 15, 1:51 am)
Re: [patch 2.6.24-rc2 1/3] generic gpio -- gpio_chip support, David Brownell, (Thu Nov 15, 11:55 am)