From: Zoltan Menyhart <Zoltan.Menyhart_AT_bull.net@nospam.org>
To: Hugh Dickins <hugh@veritas.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: To kunmap_atomic or not to kunmap_atomic ?
Date: Fri, 02 Apr 2004 16:15:15 +0200 [thread overview]
Message-ID: <406D7573.FF5F0B5F@nospam.org> (raw)
In-Reply-To: Pine.LNX.4.44.0404011740190.30126-100000@localhost.localdomain
Hugh Dickins wrote:
>
> On Thu, 1 Apr 2004, Zoltan Menyhart wrote:
> > I can see a couple of functions, like
> >
> > static inline struct mm_struct * ptep_to_mm(pte_t * ptep)
> > {
> > struct page * page = kmap_atomic_to_page(ptep);
> > return (struct mm_struct *) page->mapping;
> > }
> >
> > in "rmap.?" without invoking "kunmap_atomic()".
> > Is it intentional?
> > What if for an architecture "kunmap_atomic()" is not a no-op ?
>
> Amusing misunderstanding. Take a look at kmap_atomic_to_page
> in arch/i386/mm/highmem.c: it doesn't _do_ a kmap_atomic, it
> translates the virtual address already supplied by kmap_atomic
> to the address of the struct page of the physical page backing
> that virtual address. So, in the case of try_to_unmap_one, it
> operates on the virtual address supplied by rmap_ptep_map
> (which does do a kmap_atomic), and at the end there's an
> rmap_ptep_unmap (which does the rmap_ptep_unmap).
>
> Hugh
As you have *map* - *unmap* macros / functions, they give a _hint_
that the original intention of the author was to allow some
architectures - which do need some resources to map things -
manage these resources. See:
static inline void *kmap(struct page *page)
#define kunmap(page)
#define kmap_atomic(page, idx)
#define kunmap_atomic(addr, idx)
#define kmap_atomic_to_page(ptr)
I think we cannot guarantee that we will never ever need to
unmap things. As it is required to use kmap - kunmap in pair,
it is quite logic to use kmap_atomic* in pair with kunmap_atomic.
I think it is a bad programming style to abuse the fact that
some macros are no-ops for the most popular architectures.
I think we should have some global counters in DEBUG mode which
are incremented on each call to *map* and decremented on each
*unpap* call, and we can detect, ooops, it leaks...
Regards,
Zoltán Menyhárt
next prev parent reply other threads:[~2004-04-02 14:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-01 15:37 2.4.26-rc1-pac1 bero
2004-04-01 16:30 ` To kunmap_atomic or not to kunmap_atomic ? Zoltan Menyhart
2004-04-01 16:49 ` Hugh Dickins
2004-04-02 14:15 ` Zoltan Menyhart [this message]
2004-04-02 15:10 ` Hugh Dickins
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=406D7573.FF5F0B5F@nospam.org \
--to=zoltan.menyhart_at_bull.net@nospam.org \
--cc=Zoltan.Menyhart@bull.net \
--cc=hugh@veritas.com \
--cc=linux-kernel@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