-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
Changes for managarm cancelable syscalls #884
base: master
Are you sure you want to change the base?
Conversation
@@ -60,31 +60,42 @@ int sys_waitpid(pid_t pid, int *status, int flags, struct rusage *ru, pid_t *ret | |||
return ENOSYS; | |||
} | |||
|
|||
SignalGuard sguard; | |||
//SignalGuard sguard; |
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.
Leftover I guess.
HEL_CHECK(recv_resp.error()); | ||
|
||
managarm::posix::SvrResponse<MemoryAllocator> resp(getSysdepsAllocator()); | ||
resp.ParseFromArray(recv_resp.data(), recv_resp.length()); | ||
if(resp.error() == managarm::posix::Errors::ILLEGAL_ARGUMENTS) { | ||
return EINVAL; | ||
} | ||
if (resp.error() == managarm::posix::Errors::INTERRUPTED) { | ||
mlibc::infoLogger() << "returning EINT" << frg::endlog; |
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.
Should we put this behind some debug flag?
Yeah there are quite some debug logs left currently 😅 |
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
I do have a question, since this is not instantly obvious to me: would this code work without the changes in managarm, or are we looking at circular dependencies here? To my knowledge, merging in the managarm side first would result in some weird behavior.
@@ -1,3 +1,4 @@ | |||
#include "mlibc/debug.hpp" |
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.
Is this LSP? In any case, this should be replaced with <>
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, this should be <>
.
1c76936
to
ac7c83e
Compare
ac7c83e
to
506d9e4
Compare
506d9e4
to
922dd20
Compare
@@ -1,3 +1,4 @@ | |||
#include "mlibc/debug.hpp" |
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, this should be <>
.
auto element = globalQueue.dequeueSingle(false); | ||
if (!element) { | ||
element = globalQueue.dequeueSingle(); | ||
__ensure(element); | ||
} |
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.
This is the only call where we pass false
to dequeueSingle()
(AFAICT) and we immediately call into dequeueSingle()
again. So what is the difference compared to just doing dequeueSingle(true)
here?
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.
Note we use protocol errors to signify cancellation (e.g., in read()
you check for managarm::fs::Errors::INTERRUPTED
), so maybe the ignoreCancel = false
case is not necessary (and we can always re-try if helFutexWait
is interrupted)?
auto result = parseSimple(element); | ||
if (!element) { | ||
return EINTR; | ||
} | ||
auto result = parseSimple(*element); |
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.
We have this change for sleep but AFAICT sleep()
is still not cancelable since we don't integrate it with the cancellation event. We could drop support for sleep()
in the initial PR.
@@ -1628,12 +1629,14 @@ int sys_mknodat(int dirfd, const char *path, int mode, int dev) { | |||
} | |||
|
|||
int sys_read(int fd, void *data, size_t max_size, ssize_t *bytes_read) { | |||
SignalGuard sguard; |
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.
Why do we need to do this?
This prevents a signal to be raised (= posix-subsystem
won't jump to the signal handler), but it should not prevent POSIX from interrupting the thread. I think we still want to keep this.
Since the changes are incomplete and a little unstable, marking it as draft right now.