-
Notifications
You must be signed in to change notification settings - Fork 13
Use memory barriers defined by xen headers #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,10 +73,22 @@ | |
| #include "io_port.h" | ||
| #include "option.h" | ||
|
|
||
| /* Get the correct defines for memory barriers - do not fall | ||
| * back to those provided by the kernel */ | ||
| /* from <xen-barrier.h> in 4.20.0 */ | ||
|
|
||
| #define xen_barrier() asm volatile ( "" : : : "memory") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this added if it is not used? Having said that, I think it might be preferable to simply include a copy of |
||
|
|
||
| #if defined(__i386__) | ||
| # define smp_mb() asm volatile ( "lock addl $0, -4(%%esp)" ::: "memory" ) | ||
| #define xen_mb() asm volatile ( "lock addl $0, -4(%%esp)" ::: "memory" ) | ||
| #elif defined(__x86_64__) | ||
| # define smp_mb() asm volatile ( "lock addl $0, -32(%%rsp)" ::: "memory" ) | ||
| #define xen_mb() asm volatile ( "lock addl $0, -32(%%rsp)" ::: "memory" ) | ||
| #elif defined(__arm__) | ||
| #define xen_mb() asm volatile ("dmb" : : : "memory") | ||
| #elif defined(__aarch64__) | ||
| #define xen_mb() asm volatile ("dmb sy" : : : "memory") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a monster of a barrier. This orders against all observers: every core in every cluster, plus outer-shareable and non-shareable agents, GPU, other DMA masters, the interconnect fabric. This brings the entire system to a halt. In the Linux kernel there a number of barriers defined for core coherency:
|
||
| #else | ||
| #error "Define barriers" | ||
| #endif | ||
|
|
||
| #define IO_PORT_ADDRESS 0x0100 | ||
|
|
@@ -551,15 +563,15 @@ varstored_poll_iopage(unsigned int i) | |
| fprintf(stderr, "IO request not ready\n"); | ||
| return; | ||
| } | ||
| smp_mb(); | ||
| xen_mb(); | ||
|
|
||
| ioreq->state = STATE_IOREQ_INPROCESS; | ||
|
|
||
| handle_ioreq(ioreq); | ||
| smp_mb(); | ||
| xen_mb(); | ||
|
|
||
| ioreq->state = STATE_IORESP_READY; | ||
| smp_mb(); | ||
| xen_mb(); | ||
|
|
||
| xenevtchn_notify(varstored_state.evth, varstored_state.ioreq_local_port[i]); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we do:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I wouldn't even wait for including the
xen-barrier.hheader. Because after discussing with @andyhhp I would just add my own barrier code, which doesn't dodmb syfor performance.