Re: 2.6.24-git: kmap_atomic() WARN_ON()
From: Andrew Morton
Date: Mon Feb 25 2008 - 17:22:53 EST
On Mon, 25 Feb 2008 23:01:59 +0100 (CET) Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
> On Mon, 25 Feb 2008, Andrew Morton wrote:
> > On Mon, 25 Feb 2008 15:08:35 -0500 Jeff Garzik <jgarzik@xxxxxxxxx> wrote:
> > > There are plenty of drivers that do the same thing that ahci does, in
> > > terms of interrupt handler locking... and I will definitely push back
> > > on efforts to convert otherwise-100%-safe spin_lock() into
> > > spin_lock_irqsave() just to quiet lockdep.
> > >
> > > Very interesting email, thanks...
> > >
> >
> > I suspect this is a bug in my old kmap_atomic debugging patch. It doesn't
> > know about the implicit irq-disablememnt which interrupt handlers enjoy. I
> > don't think...
>
> I suspect here is confusion. The implicit irq-disablement of lockdep
> is actually hiding the warning.
>
> The code which emits the warning is:
>
> if (type == KM_IRQ0 || type == KM_IRQ1 || type == KM_BOUNCE_READ ||
> type == KM_BIO_SRC_IRQ || type == KM_BIO_DST_IRQ) {
> if (!irqs_disabled()) {
> WARN_ON(1);
> warn_count--;
> }
>
> It checks for _NOT_ irqs_disabled. The calling code is
> ata_scsi_rbuf_get() which calls with:
>
> buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset;
>
> This happens with interrupts enabled. So the warning is according to
> the well documented km_type enum and the equally well documented
> highmem debug code correct.
>
> Bjoern decoded it very well, just Jeff jumped to very interesting
> conclusions.
>
Ah, OK, yes. ata is wrong. It must disable interrupts here. Otherwise
this CPU could get interrupted by some other device whose handler also uses
KM_IRQ0, resulting in data corruption.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/