public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: Re: Re: [RFC] PAGE_RW Should be added to PAGE_COPY ?
@ 2006-09-15  3:38 Yingchao Zhou
  2006-09-15  4:30 ` Hugh Dickins
  0 siblings, 1 reply; 8+ messages in thread
From: Yingchao Zhou @ 2006-09-15  3:38 UTC (permalink / raw)
  To: Hugh Dickins; +Cc: linux-kernel, akpm, alan, zxc

>On Fri, 15 Sep 2006, Yingchao Zhou wrote:
>> >
>> >You want to mmap MAP_SHARED, which will use PAGE_SHARED instead,
>> >including the write bit, both before and after the mprotects.
>> >There should be no problem then: do you actually see a problem
>> >when MAP_SHARED is used?
>> It's ok to mmap MAP_SHARED. But is it not a normal way to malloc() a space and
>> then registered to NIC ?
>
>Not that I know of.  How would one register malloc()ed space to a NIC?
>Sorry, I may well be misunderstanding you.
The user-level NIC does this, eg. Myrinet...
>
>> >>      Adding PAGE_RW to PAGE_COPY will resolve this problem.  
>> >
>> >No!  That would give every user write access to shared files they
>> >should have no write access to.
>> I guess you refer to mmap a file MAP_READ|MAP_WRITE in MAP_PRIVATE way.
>> I think it is probably more logical to read the file data into an anoymous page and filled the pte with _PAGE_RW in the first time page-fault. It will probably reduce numbers of page fault interrupt.
>
>do_no_page() does just that when its fault demands write access; but
>doesn't waste memory and time on copying when it's only a read access.
>
Yeah, it is. But this is the source of the problem described above.
>Hugh
>
Yingchao Zhou



^ permalink raw reply	[flat|nested] 8+ messages in thread
* [RFC] PAGE_RW Should be added to PAGE_COPY ?
@ 2006-09-13 14:02 Yingchao Zhou
  2006-09-14 14:48 ` Hugh Dickins
  0 siblings, 1 reply; 8+ messages in thread
From: Yingchao Zhou @ 2006-09-13 14:02 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, alan, zxc


     The current kernel set PAGE_COPY without write bit. This will cause intermittent non-cosistent data for user-level network drivers such as Infiniband, Quadrics and Myrinet. Which has also be mentioned by Costin Iancu in the paper "HUNTing the Overlap " (PACT'05).
    An example of such phenomena is the following sequences: 
	register a memory space BUFF for receive message, 
	receive message,
	call mprotect(...PROT_NONE...) and mprotect(...PROT_READ|PROT_WRITE) one by one, 	
	write into BUFF, 
	then receive again.      
    The second time received data will perhaps not be the data sent by the peer machine but the data written by itself in the 4th step.

     The reson is that :
     1) User-level network driver locks phy pages when memory space is registered;
     2) 2 calls to mprotect change ptes in the space to PAGE_COPY, so write any page in the space will cause a page fault;
     3) In the page fault handler, it goes to do_wp_page, and in it if Page Is Locked, a new page is generated and filled into the pte. So the physical page seen by the host is not the same one by the NIC.

     Adding PAGE_RW to PAGE_COPY will resolve this problem.  
     In my option, the reason for absense of RW is to save memory by mapping all those only read pages into ZERO_PAGE. But is there really programs which make many read-ops in memory space without even initialize them?

___________________________________________________
_      Yingchao Zhou                              _
_      ICT, CAS                                   _
_      (86)010-62601009                           _
___________________________________________________



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-09-25  9:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-15  3:38 Re: Re: [RFC] PAGE_RW Should be added to PAGE_COPY ? Yingchao Zhou
2006-09-15  4:30 ` Hugh Dickins
2006-09-15 14:19   ` Hugh Dickins
2006-09-16  7:42     ` Nick Piggin
2006-09-23 18:51       ` Hugh Dickins
2006-09-25  2:53         ` Nick Piggin
  -- strict thread matches above, loose matches on Subject: below --
2006-09-13 14:02 Yingchao Zhou
2006-09-14 14:48 ` Hugh Dickins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox