-
Notifications
You must be signed in to change notification settings - Fork 82
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
Optimizations to improve the performance of Ramfs #826
Conversation
SigQueues
to rapidly dequeue signals2d232de
to
84e1fc8
Compare
826831b
to
8d0519f
Compare
kernel/aster-nix/src/thread/mod.rs
Outdated
current as u8, | ||
new as u8, | ||
Ordering::Acquire, | ||
Ordering::Relaxed, |
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.
I think that you mean Ordering::Release
, although I'm not sure whether or not this memory order is necessary for the thread status.
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.
The success
describes the required ordering for the read-modify-write operation that takes place if the comparison with current
succeeds.
I think AcqRel
is correct, it has the effects of both Acquire and Release together: For loads it uses Acquire ordering. For stores it uses the Release ordering.
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.
Yes, but you are writing Order::Relaxed
. So you should write Order::Release
instead. I mean, there is a typo.
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.
Sorry, I misunderstood your comment, so it seems we should write success = Ordering::AcqRel
, failure = Ordering::Relaxed/Acquire
(the failure
order depends on whether we want to synchronize with the last status write if the exchange fails).
Well, I thought it would be another great example to discuss together in #831. So leaving this as a TODO for #831 is fine. |
Yes, you are correct, the |
kernel/aster-nix/src/thread/mod.rs
Outdated
@@ -31,7 +31,7 @@ pub struct Thread { | |||
data: Box<dyn Send + Sync + Any>, | |||
|
|||
// mutable part | |||
status: Mutex<ThreadStatus>, | |||
status: AtomicU8, |
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.
To simplify thread/mod.rs
, I think a new type named AtomicThreadStatus
should be provided by thread/status.rs
and used by thread/mod.rs
. Most changes made to thread/mod.rs
can be extracted to and hidden inside AtomicThreadStatus
. This makes the code easier to understand and maintain.
pub struct AtomicThreadStatus(AtomicU8);
impl AtomicThreadStatus {
pub fn load(&self, ordering: Ordering) -> ThreadStatus { ... }
pub fn store(&self, new_status: ThreadStatus, ordering: Ordering) -> ThreadStatus { ... }
pub fn compare_exchange( &self, current: ThreadStatus, new: ThreadStatus, success: Ordering, failure: Ordering ) -> Result<ThreadStatus, ThreadStatus>
}
The methods of AtomicThreadStatus
mirrors that of AtomicU8
. They take Ordering
as input so that the user can decide the ordering.
9692570
to
366bae6
Compare
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.
LGTM. Thanks for the contribution!
Refer to #791
@StevenJiang1110 Please review this commit, thanks.