Re: [RFC] atomic highmem kmap page pinning

From: Nicolas Pitre
Date: Sat Mar 07 2009 - 17:28:29 EST


On Fri, 6 Mar 2009, Minchan Kim wrote:

> On Fri, Mar 6, 2009 at 7:59 AM, Russell King - ARM Linux
> <linux@xxxxxxxxxxxxxxxx> wrote:
> > On Fri, Mar 06, 2009 at 07:23:44AM +0900, Minchan Kim wrote:
> >> > +#ifdef ARCH_NEEDS_KMAP_HIGH_GET
> >> > +/**
> >> > + * kmap_high_get - pin a highmem page into memory
> >> > + * @page: &struct page to pin
> >> > + *
> >> > + * Returns the page's current virtual memory address, or NULL if no mapping
> >> > + * exists. ÂWhen and only when a non null address is returned then a
> >> > + * matching call to kunmap_high() is necessary.
> >> > + *
> >> > + * This can be called from any context.
> >> > + */
> >> > +void *kmap_high_get(struct page *page)
> >> > +{
> >> > + Â Â Â unsigned long vaddr, flags;
> >> > +
> >> > + Â Â Â spin_lock_kmap_any(flags);
> >> > + Â Â Â vaddr = (unsigned long)page_address(page);
> >> > + Â Â Â if (vaddr) {
> >> > + Â Â Â Â Â Â Â BUG_ON(pkmap_count[PKMAP_NR(vaddr)] < 1);
> >> > + Â Â Â Â Â Â Â pkmap_count[PKMAP_NR(vaddr)]++;
> >> > + Â Â Â }
> >> > + Â Â Â spin_unlock_kmap_any(flags);
> >> > + Â Â Â return (void*) vaddr;
> >> > +}
> >> > +#endif
> >>
> >> Let's add empty function for architecture of no ARCH_NEEDS_KMAP_HIGH_GET,
> >
> > The reasoning being?
>
> I thought it can be used in common arm function.
> so, for VIVT, it can be work but for VIPT, it can be nulled as
> preventing compile error.

The issue is not about VIVT vs VIPT, but rather about the fact that IO
transactions don't snoop the cache. So this is needed even for current
VIPT implementations.

> But, I don't know where we use kmap_high_get since I didn't see any
> patch which use it.
> If it is only used architecture specific place, pz, forgot my comment.

Yes, that's the case. And it is much preferable to have a compilation
error than providing an empty stub to silently mask out misuses.


Nicolas