2007-06-06 17:03:24

by raz

[permalink] [raw]
Subject: kmap_atomic in 2.6.20.x

Hello

I am running into some problems with kmap_atomic in my driver.
My driver copies some pages coming from
user space to "kernel space kmalloc'ed memory".
I had this code running from 2.6.5 to 2.6.17 without any problems.
I have upgraded to 2.6.20.xx and this code fails to kmap_atomic.
I am running a uni processor 2 GRAM machine, 32bit.

Basically this is code does:

get_user_pages(page,...)

kmap_atomic(page,KM_USER0);
.. copy and stuff
kunmap_atomic(page,KM_USER0)

I have also tried KM_USER1 and KM_SKB_SUNRPC_DATA.
I crash in arch/i386/highmem.c line 42:
...
if (!pte_none(*(kmap_pte-idx)))
BUG();
..

To the best of my understanding ( from "see : understand the linux
kernel" page 310 ) , a different kernel component holds this window. A
fact which is quite strange in the case of KM_SKB_SUNRPC_DATA. I have
nothing that uses it.

1. Why kmap_atomic does not return NULL ?
2. Why am I failing only in high memory mappings ?

--
Raz


2007-06-06 19:10:55

by Jens Axboe

[permalink] [raw]
Subject: Re: kmap_atomic in 2.6.20.x

On Wed, Jun 06 2007, Raz Ben-Jehuda(caro) wrote:
> Hello
>
> I am running into some problems with kmap_atomic in my driver.
> My driver copies some pages coming from
> user space to "kernel space kmalloc'ed memory".
> I had this code running from 2.6.5 to 2.6.17 without any problems.
> I have upgraded to 2.6.20.xx and this code fails to kmap_atomic.
> I am running a uni processor 2 GRAM machine, 32bit.
>
> Basically this is code does:
>
> get_user_pages(page,...)
>
> kmap_atomic(page,KM_USER0);
> .. copy and stuff
> kunmap_atomic(page,KM_USER0)

dst = kmap_atomic(page, KM_USER0);
...
kunmap_atomic(dst, KM_USER0);

Note the subtle difference.

--
Jens Axboe

2007-06-06 20:03:44

by Trond Myklebust

[permalink] [raw]
Subject: Re: kmap_atomic in 2.6.20.x

On Wed, 2007-06-06 at 20:03 +0300, Raz Ben-Jehuda(caro) wrote:
> If my understanding ( from "see : understand the linux
> kernel" page 310 ) , a different kernel component holds this window. A
> fact which is quite strange in the case of KM_SKB_SUNRPC_DATA. I have
> nothing that uses it.

KM_SKB_SUNRPC_DATA is verboten unless you are running in the appropriate
bh-safe socket environment. Otherwise, see Jens' comment.

Trond

2007-06-07 08:56:36

by raz

[permalink] [raw]
Subject: Re: kmap_atomic in 2.6.20.x

On 6/6/07, Jens Axboe <[email protected]> wrote:
> On Wed, Jun 06 2007, Raz Ben-Jehuda(caro) wrote:
> > Hello
> >
> > I am running into some problems with kmap_atomic in my driver.
> > My driver copies some pages coming from
> > user space to "kernel space kmalloc'ed memory".
> > I had this code running from 2.6.5 to 2.6.17 without any problems.
> > I have upgraded to 2.6.20.xx and this code fails to kmap_atomic.
> > I am running a uni processor 2 GRAM machine, 32bit.
> >
> > Basically this is code does:
> >
> > get_user_pages(page,...)
> >
> > kmap_atomic(page,KM_USER0);
> > .. copy and stuff
> > kunmap_atomic(page,KM_USER0)
>
> dst = kmap_atomic(page, KM_USER0);
> ...
> kunmap_atomic(dst, KM_USER0);
>
> Note the subtle difference.
>
> --
> Jens Axboe
>
>

hmm..... hammmm....haaaa
again... many many thanks Jens.
You are correct.

--
Raz