netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Cc: netdev@vger.kernel.org, linux-kernel-announce@vger.kernel.org,
	Dan Williams <dan.j.williams@intel.com>
Subject: Re: kmap_atomic() oopses in current mainline
Date: Thu, 19 Jul 2007 02:38:31 -0700	[thread overview]
Message-ID: <20070719023831.400f7905.akpm@linux-foundation.org> (raw)
In-Reply-To: <20070719092856.GA15839@2ka.mipt.ru>

On Thu, 19 Jul 2007 13:28:56 +0400 Evgeniy Polyakov <johnpol@2ka.mipt.ru> wrote:

> Hi.
> 
> On Thu, Jul 19, 2007 at 01:33:04AM -0700, Andrew Morton (akpm@linux-foundation.org) wrote:
> > I don't think the 2-year-old Vaio has offload engine support ;) Dan, this:
> > 
> > +		if (flags & ASYNC_TX_KMAP_DST)
> > +			dest_buf = kmap_atomic(dest, KM_USER0) + dest_offset;
> > +		else
> > +			dest_buf = page_address(dest) + dest_offset;
> > +
> > +		if (flags & ASYNC_TX_KMAP_SRC)
> > +			src_buf = kmap_atomic(src, KM_USER0) + src_offset;
> > +		else
> > +			src_buf = page_address(src) + src_offset;
> > +
> > +		memcpy(dest_buf, src_buf, len);
> > +
> > +		if (flags & ASYNC_TX_KMAP_DST)
> > +			kunmap_atomic(dest_buf, KM_USER0);
> > +
> > +		if (flags & ASYNC_TX_KMAP_SRC)
> > +			kunmap_atomic(src_buf, KM_USER0);
> > +
> > 
> > is very wrong if both ASYNC_TX_KMAP_DST and ASYNC_TX_KMAP_SRC can ever be
> > set.  We'll end up using the same kmap slot for both src add dest and we
> > get either corrupted data or a BUG.
> 
> So far it can not since the only user is raid code, which only allows to
> perform either reading from bio or writing into one, which requires only
> one mapping.

hm, so we got lucky?

> Btw, shouldn't it always be kmap_atomic() even if flag is not set.
> That pages are usual one returned by alloc_page().

The code would work OK if the kmap_atomic()s were unconditional, but it
would be a bit more expensive if the page is in highmem and we don't
actually intend to access it with the CPU.

kmap_atomic() against a non-highmem page is basically free: just an
additional test_bit().

  reply	other threads:[~2007-07-19  9:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-19  8:33 kmap_atomic() oopses in current mainline Andrew Morton
2007-07-19  9:28 ` Evgeniy Polyakov
2007-07-19  9:38   ` Andrew Morton [this message]
2007-07-19 10:01     ` Evgeniy Polyakov
2007-07-19 15:23       ` Dan Williams

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=20070719023831.400f7905.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=dan.j.williams@intel.com \
    --cc=johnpol@2ka.mipt.ru \
    --cc=linux-kernel-announce@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).