[openib-general] RE: registering read-only memory

2005-05-30 Thread Eli Cohen
Title: RE: registering read-only memory





OK thanks. I had another problem in MVAPI.


-Original Message-
From: Roland Dreier [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 27, 2005 7:49 PM
To: Eli Cohen
Cc: Michael S. Tsirkin; openib-general@openib.org
Subject: Re: registering read-only memory



    Eli> I saw this this on Suse 9.3 and the memory was like: static
    Eli> const char *my_string = "Hello world"; defined locally in a
    Eli> function. This produced a VMA with VM_IO set.


What kernel version/architecture?


I'm having a hard time seeing how it's possible to get a VMA with
VM_IO set except by using remap_pfn_range(), and I can't see how
ordinary const data from userspace could cause that.


 - R.



___
openib-general mailing list
openib-general@openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

[openib-general] Re: registering read-only memory

2005-05-27 Thread Roland Dreier
Eli> I saw this this on Suse 9.3 and the memory was like: static
Eli> const char *my_string = "Hello world"; defined locally in a
Eli> function. This produced a VMA with VM_IO set.

What kernel version/architecture?

I'm having a hard time seeing how it's possible to get a VMA with
VM_IO set except by using remap_pfn_range(), and I can't see how
ordinary const data from userspace could cause that.

 - R.

___
openib-general mailing list
openib-general@openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general


[openib-general] RE: registering read-only memory

2005-05-26 Thread Eli Cohen
Title: RE: registering read-only memory





R> Are you sure?  It seems to work for me if I just pass write=0 to
R> get_user_pages().


I saw this this on Suse 9.3 and the memory was like:
static const char *my_string = "Hello world";
defined locally in a function. This produced a VMA with VM_IO set.



___
openib-general mailing list
openib-general@openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Re: [openib-general] RE: registering read-only memory

2005-05-26 Thread Roland Dreier
Grant> Sorry - why do you need the physical address of memory?
Grant> Did you mean you need the DMA address?

We don't really need the physical address.  The userspace verbs do
get_user_pages() on a userspace virtual address to get a bunch of
struct page *s, and then pass those to dma_map_sg() to get DMA
addresses.  It's all totally kosher...

 - R.

___
openib-general mailing list
openib-general@openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general


Re: [openib-general] RE: registering read-only memory

2005-05-26 Thread Grant Grundler
On Thu, May 26, 2005 at 10:23:55PM +0300, Eli Cohen wrote:
> I'm afraid that won't solve the problem. From some reason the vma of such a
> region is flagged with VM_IO and that's why get_user_pages() will fail. We
> need to find another way to get the physical address of such memory.

Sorry - why do you need the physical address of memory?
Did you mean you need the DMA address?

grant

> One
> thing I can think of is implementing something similar to follow_page(). Or
> better if the kernel will export follow_page().
> 
> -Original Message-
> From: Roland Dreier [mailto:[EMAIL PROTECTED]
> Sent: Thursday, May 26, 2005 10:09 PM
> To: Eli Cohen
> Cc: Michael S. Tsirkin; openib-general@openib.org
> Subject: Re: registering read-only memory
> 
> 
> OK, I think I understand the problem.  The compiler puts a string
> defined with "const char *foo" on a read-only page, but in
> uverbs_mem.c we always pass write=1 to get_user_pages().  I need to
> fix the code so that it only asks for writeable pages if we're
> registering with writable permissions.
> 
>  - R.

> ___
> openib-general mailing list
> openib-general@openib.org
> http://openib.org/mailman/listinfo/openib-general
> 
> To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general
___
openib-general mailing list
openib-general@openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general


[openib-general] Re: registering read-only memory

2005-05-26 Thread Roland Dreier
Eli> I'm afraid that won't solve the problem. From some reason the
Eli> vma of such a region is flagged with VM_IO and that's why
Eli> get_user_pages() will fail.

Are you sure?  It seems to work for me if I just pass write=0 to
get_user_pages().

 - R.
___
openib-general mailing list
openib-general@openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general


[openib-general] RE: registering read-only memory

2005-05-26 Thread Eli Cohen
Title: RE: registering read-only memory





I'm afraid that won't solve the problem. From some reason the vma of such a region is flagged with VM_IO and that's why get_user_pages() will fail. We need to find another way to get the physical address of such memory. One thing I can think of is implementing something similar to follow_page(). Or better if the kernel will export follow_page().

-Original Message-
From: Roland Dreier [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 26, 2005 10:09 PM
To: Eli Cohen
Cc: Michael S. Tsirkin; openib-general@openib.org
Subject: Re: registering read-only memory



OK, I think I understand the problem.  The compiler puts a string
defined with "const char *foo" on a read-only page, but in
uverbs_mem.c we always pass write=1 to get_user_pages().  I need to
fix the code so that it only asks for writeable pages if we're
registering with writable permissions.


 - R.



___
openib-general mailing list
openib-general@openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Re: [openib-general] Re: registering read-only memory

2005-05-26 Thread Roland Dreier
I just checked in a fix for this.  I'm now able to register read-only
memory (as long as the permissions on the registration are read-only).

 - R.

___
openib-general mailing list
openib-general@openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general


[openib-general] Re: registering read-only memory

2005-05-26 Thread Roland Dreier
OK, I think I understand the problem.  The compiler puts a string
defined with "const char *foo" on a read-only page, but in
uverbs_mem.c we always pass write=1 to get_user_pages().  I need to
fix the code so that it only asks for writeable pages if we're
registering with writable permissions.

 - R.
___
openib-general mailing list
openib-general@openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general


[openib-general] RE: registering read-only memory

2005-05-24 Thread Eli Cohen
Title: RE: registering read-only memory





Please try:
const char *foo="Michael Tsirkin";


as opposed to
const char foo[]="Michael Tsirkin";


-Original Message-
From: Roland Dreier [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 24, 2005 10:07 PM
To: Michael S. Tsirkin
Cc: openib-general@openib.org; Eli Cohen
Subject: Re: registering read-only memory



    > const char foo[]="Michael Tsirkin";
    > ibv_reg_mr(ctx->pd, foo, strlen(foo), 0);


This seemed to work fine on my system (I got a non-null ibv_mr back
with valid-looking L_Key/R_Key).


 - R.



___
openib-general mailing list
openib-general@openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

[openib-general] Re: registering read-only memory

2005-05-24 Thread Roland Dreier
> const char foo[]="Michael Tsirkin";
> ibv_reg_mr(ctx->pd, foo, strlen(foo), 0);

This seemed to work fine on my system (I got a non-null ibv_mr back
with valid-looking L_Key/R_Key).

 - R.
___
openib-general mailing list
openib-general@openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general


[openib-general] Re: registering read-only memory

2005-05-23 Thread Michael S. Tsirkin
Quoting r. Roland Dreier <[EMAIL PROTECTED]>:
> Subject: Re: registering read-only memory
> 
> Michael> What about the patch that I posted?
> 
> Adding the "const" makes sense but adding "volatile" doesn't seem good
> to me.

Could you explain why? Since the library never accesses the data, it has no
effect except turning off a warning.

Volatile says like "this buffer can change without the application
writing there", and thats what we have with hardware writing there, no?

> I think it's better for the tiny subset of people who really
> need "volatile" to add casts.
> 
>  - R.
> 

IMO, you cant always do this. If you have a non-volatile variable and cast
it to a volatile pointer, compiler is permitted to detect
this and ignore the volatile attribute, making the code
that polls data incorrect (I'm not claiming gcc is smart enough to do
this, though).

-- 
MST - Michael S. Tsirkin
___
openib-general mailing list
openib-general@openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general


[openib-general] Re: registering read-only memory

2005-05-23 Thread Roland Dreier
Michael> What about the patch that I posted?

Adding the "const" makes sense but adding "volatile" doesn't seem good
to me.  I think it's better for the tiny subset of people who really
need "volatile" to add casts.

 - R.

___
openib-general mailing list
openib-general@openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general


[openib-general] Re: registering read-only memory

2005-05-23 Thread Michael S. Tsirkin
Quoting r. Roland Dreier <[EMAIL PROTECTED]>:
> Subject: Re: registering read-only memory
> 
> Michael> 2. ibv_reg_mr fails.  Why is that?
> 
> Michael> Returns NULL, naturally.
> 
> ... hmm, I'll take a look.
> 
>  - R.
> 

What about the patch that I posted?

-- 
MST - Michael S. Tsirkin
___
openib-general mailing list
openib-general@openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general


[openib-general] Re: registering read-only memory

2005-05-23 Thread Roland Dreier
Michael> 2. ibv_reg_mr fails.  Why is that?

Michael> Returns NULL, naturally.

... hmm, I'll take a look.

 - R.

___
openib-general mailing list
openib-general@openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general


[openib-general] Re: registering read-only memory

2005-05-19 Thread Michael S. Tsirkin
Quoting r. Roland Dreier <[EMAIL PROTECTED]>:
> Subject: Re: registering read-only memory
> 
> Michael> 2. ibv_reg_mr fails.  Why is that?
> 
> How does it fail?
> 
>   R.
> 

Returns NULL, naturally.

-- 
MST - Michael S. Tsirkin
___
openib-general mailing list
openib-general@openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general


[openib-general] Re: registering read-only memory

2005-05-19 Thread Roland Dreier
Michael> 2. ibv_reg_mr fails.  Why is that?

How does it fail?

  R.
___
openib-general mailing list
openib-general@openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general