All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Garzik <jgarzik@pobox.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Ingo Molnar" <mingo@elte.hu>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Björn Steinbrink" <B.Steinbrink@gmx.de>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: 2.6.24-git: kmap_atomic() WARN_ON()
Date: Tue, 26 Feb 2008 17:59:27 -0500	[thread overview]
Message-ID: <47C499CF.2000605@pobox.com> (raw)
In-Reply-To: <20080226133715.d9cd32e7.akpm@linux-foundation.org>

Andrew Morton wrote:
> On Tue, 26 Feb 2008 21:49:43 +0100 Ingo Molnar <mingo@elte.hu> wrote:
>> i.e. to introduce a kmap_atomic_irqsave(...,flags) and 
>> kunmap_atomic_irqrestore() API variant. _That_ then could be mapped by 
>> -rt to a non-irq disabling thing.

> Sure.  But iirc we haven't had a need for this before.  Which is a bit odd.

We have such a need -- we just always paper over it with 
spin_lock_irqsave() or local_irq_save() because those are "the rules." 
grep around :)

See ata_pio_sector() in libata-core.c, where we do:

>         if (PageHighMem(page)) {
>                 unsigned long flags;
> 
>                 /* FIXME: use a bounce buffer */
>                 local_irq_save(flags);
>                 buf = kmap_atomic(page, KM_IRQ0);
> 
>                 /* do the actual data transfer */
>                 ap->ops->data_xfer(qc->dev, buf + offset, qc->sect_size, do_write);
> 
>                 kunmap_atomic(buf, KM_IRQ0);
>                 local_irq_restore(flags);
>         } else {
>                 buf = page_address(page);
>                 ap->ops->data_xfer(qc->dev, buf + offset, qc->sect_size, do_write);
>         }

This is a core non-DMA data transfer routine.  Given the high cost of 
disabling interrupts during the relatively-slow PIO data transfer, we 
added extra logic to only disable interrupts for the highmem case.

The code in libata-scsi generally only deals with a single buffer, on 
average less than 128 bytes in length.  So the memcpy() isn't really 
that expensive in the case being discussed -- unlike the 
ata_pio_sector() case, where the cost is very, very high.

Aside: The "FIXME: use bounce buffer" comment above indicates the more 
optimal PIO data xfer approach of

	local_irq_save()
	kmap_atomic()
	memcpy into bounce buffer
	kunmap_atomic()
	local_irq_restore()

	/* do slow PIO bitbanging data transfer */
	ap->ops->data_xfer(...)

Regards,

	Jeff



  reply	other threads:[~2008-02-26 23:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-06 23:58 2.6.24-git: kmap_atomic() WARN_ON() Thomas Gleixner
2008-02-13 22:39 ` Rafael J. Wysocki
2008-02-14  1:13   ` Thomas Gleixner
2008-02-25 19:59 ` Björn Steinbrink
2008-02-25 20:08   ` Jeff Garzik
2008-02-25 20:35     ` Björn Steinbrink
2008-02-25 20:40     ` Andrew Morton
2008-02-25 22:01       ` Thomas Gleixner
2008-02-25 22:17         ` Andrew Morton
2008-02-25 23:19         ` Jeff Garzik
2008-02-26  8:39           ` Ingo Molnar
2008-02-26 16:32             ` Jeff Garzik
2008-02-26 18:19               ` Andrew Morton
2008-02-26 20:49                 ` Ingo Molnar
2008-02-26 21:37                   ` Andrew Morton
2008-02-26 22:59                     ` Jeff Garzik [this message]
2008-02-27  0:02                       ` Alan Cox
2008-02-26 23:49                   ` Nick Piggin
2008-02-26  8:50           ` Thomas Gleixner

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=47C499CF.2000605@pobox.com \
    --to=jgarzik@pobox.com \
    --cc=B.Steinbrink@gmx.de \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.