OpenVZ Forum


Home » Mailing lists » Devel » [PATCH] mark read_crX() asm code as volatile
Re: [PATCH] mark read_crX() asm code as volatile [message #21196 is a reply to message #21177] Tue, 02 October 2007 15:49 Go to previous messageGo to previous message
Nick Piggin is currently offline  Nick Piggin
Messages: 35
Registered: March 2006
Member
On Wednesday 03 October 2007 16:18, H. Peter Anvin wrote:
> Nick Piggin wrote:
> >> This should work because the result gets used before reading again:
> >>
> >> read_cr3(a);
> >> write_cr3(a | 1);
> >> read_cr3(a);
> >>
> >> But this might be reordered so that b gets read before the write:
> >>
> >> read_cr3(a);
> >> write_cr3(a | 1);
> >> read_cr3(b);
> >>
> >> ?
> >
> > I don't see how, as write_cr3 clobbers memory.
>
> Because read_cr3() doesn't depend on memory, and b could be stored in a
> register.

How does the compiler know it doesn't depend on memory?

How do you say it depends on memory? You really need something
as heavy as volatile?
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [PATCH] Consolidate IPC namespace cleanup functions
Next Topic: [patch 0/1][NETNS49] Make af_unix autobind per namespace
Goto Forum:
  


Current Time: Thu Aug 15 07:38:42 GMT 2024

Total time taken to generate the page: 0.03054 seconds