mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Phillip Lougher <phillip@lougher.demon.co.uk>
Cc: linux-kernel@vger.kernel.org, greg@kroah.com
Subject: Re: Kmap_atomic vs Kmap
Date: Fri, 18 Mar 2005 19:41:34 -0800	[thread overview]
Message-ID: <20050318194134.5b710075.akpm@osdl.org> (raw)
In-Reply-To: <423B86C6.7030107@lougher.demon.co.uk>

Phillip Lougher <phillip@lougher.demon.co.uk> wrote:
>
> Andrew Morton wrote in relation to my initial SquashFS patch:
> > Phillip Lougher <phillip@lougher.demon.co.uk> wrote:
> > 
> >>+skip_read:
> >>+	memset(pageaddr + bytes, 0, PAGE_CACHE_SIZE - bytes);
> >>+	kunmap(page);
> >>+	flush_dcache_page(page);
> >>+	SetPageUptodate(page);
> >>+	unlock_page(page);
> >>+
> >>+	return 0;
> >>+}
> 
> > See if you can use kmap_atomic() here - kmap() is slow, theoretically
> > deadlocky and is deprecated.
> > 
> 
>  From some browsing of the kernel source and a useful article on lwn.net 
> I think I can replace all the readpage_xxx (symlink, readpage & 
> readpage4k) kmap/kunmaps with kmap_atomic(page, KM_USER0)/kunmap(kaddr, 
> KM_USER0)...

Yes.

Generally the only reason the kernel needs to modify pagecache pages is to
do a quick memset or to copy a string in there or something like that.  So
a quick kmap_atomic/memory copy/kunmap_atomic() cycle is a fairly common
pattern.

The one exception is the directory-in-pagecache code where we tend to do a
lot of stuff while holding the kmap.  Not that there's any particular
reason why we needed to do it that way.

> The lwn.net article mentions that k[un]map_atomic is the new alternative 
> to kmap (as Andrew Morton mentioned).
> 
> I've noticed in asm-ppc/highmem.h the following comment
> 
> /*
>   * The use of kmap_atomic/kunmap_atomic is discouraged - kmap/kunmap
>   * gives a more generic (and caching) interface. But kmap_atomic can
>   * be used in IRQ contexts, so in some (very limited) cases we need
>   * it.
>   */
> 
> Given what Andrew and the lwn.net article says, this comment is rather 
> confusing.  Is it wrong?

I'd say so, yes.  For a start, kmap_high() takes a global lock.

  reply	other threads:[~2005-03-19  3:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-14 16:24 [PATCH][1/2] SquashFS Phillip Lougher
2005-03-15  0:38 ` Matt Mackall
2005-03-15  1:47   ` Nick Piggin
2005-03-15  2:33     ` Matt Mackall
2005-03-15  8:47     ` Paul Jackson
2005-03-15 15:50       ` Phillip Lougher
2005-03-15 17:27         ` Matt Mackall
2005-03-15 16:19           ` Phillip Lougher
2005-03-15 19:06             ` Paul Jackson
2005-03-16  1:50               ` Junio C Hamano
2005-03-16  7:14                 ` Paul Jackson
2005-03-17 20:06                 ` jerome lacoste
2005-03-15  0:51 ` Andrew Morton
2005-03-19  1:56   ` Kmap_atomic vs Kmap Phillip Lougher
2005-03-19  3:41     ` Andrew Morton [this message]
2005-03-20 23:11   ` Function stack size usage (was [PATCH][1/2] SquashFS) Phillip Lougher
2005-03-21  0:59     ` Andrew Morton

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=20050318194134.5b710075.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phillip@lougher.demon.co.uk \
    /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

Powered by JetHome