Re: [RFC][PATCH] kmap_atomic_push

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Mon, 12 Oct 2009, Andi Kleen wrote:

> Peter Zijlstra <peterz@xxxxxxxxxxxxx> writes:
> > -
> > -static inline void debug_kmap_atomic(enum km_type type)
> > +static inline int kmap_atomic_push_idx(void)
> >  {
> > +	int idx = __get_cpu_var(__kmap_atomic_depth)++;
> 
> The counter needs to be of local atomic type. Otherwise kmap_atomic cannot
> be done from interrupts/nmis, which is unfortunately occasionally needed.

I thought so too on lookin gat it initially, but it's not actually true.

It's both IRQ and NMI safe as-is, for a very simple reason: any interrupts 
that happen will always undo whatever changes they did. So even with a 
totally non-atomic "load + increment + store" model, it really doesn't 
matter if you get an interrupt or an NMI anywhere in the sequence, because 
by the time the interrupt returns, it will have undone any changes it did.

So as long as it's per-cpu (which it is) and non-preemptible (which it 
also is, thanks to kmap_atomic() doing the whole "disable_mm_fault()" 
thing or whatever), it's all fine.

Btw, this is not some new thing. It's exactly the same logic we rely on 
for other counts like the preempt-count etc.

			Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-arch" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux