-
Notifications
You must be signed in to change notification settings - Fork 35
Update L0 provider to use getpidfd function #558
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
Conversation
ab36c40
to
59475d7
Compare
The |
Yeah, looks like it fails because |
Ok, I understand the issue. Prior to this PR we returned |
9f3895e
to
ce00569
Compare
ce00569
to
6b5cb77
Compare
src/utils/utils_posix_common.c
Outdated
switch (errno) { | ||
case EINVAL: | ||
case ESRCH: | ||
return UMF_RESULT_ERROR_INVALID_ARGUMENT; | ||
case EMFILE: | ||
case ENOMEM: | ||
return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY; | ||
case ENODEV: | ||
case ENOSYS: | ||
case ENOTSUP: | ||
return UMF_RESULT_ERROR_NOT_SUPPORTED; | ||
default: | ||
return UMF_RESULT_ERROR_UNKNOWN; | ||
} |
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.
Please create errnoToUmfResult function and use it 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.
Done
|
||
if (ze_ipc_data->pid != utils_getpid()) { | ||
int fd_remote = -1; | ||
memcpy(&fd_remote, &ze_ipc_handle, sizeof(fd_remote)); |
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.
Using memcpy to copy single int is an overkill
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.
Compiler optimizes it. When the size is low enough there is now an actual call to memcpy, it is replaced with move instructions.
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.
It's more code readability issue then performance. Assignment is shorter, and easier to read.
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.
regarding readability, I am not sure:
fd_remote = *(int*)&ze_ipc_handle;
vs
memcpy(&fd_remote, &ze_ipc_handle, sizeof(fd_remote));
and
*((int*)&ze_ipc_handle) = fd_local;
vs
memcpy(&ze_ipc_handle, &fd_local, sizeof(fd_local));
Are you still suggesting to get rid of memcpy? If so, I will do that. Please confirm.
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 IPC api in L0 is awful....
I checked definition of ze_ipc_mem_handle_t and as this is opaque struct, memcpy here make sense here.
NIT: We should consider something like this - as working on opaque structs without clear definition of it's layout is quite error prone.
union umf_ipc_mem_handle {
ze_ipc_mem_handle_t ze;
struct {
int fd;
} def;
};
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.
all this is needed just because L0 IPC implementation is broken.
According to the L0 spec all these steps not needed at all. When L0 driver fix their implementation we will get rid of these changes.
6b5cb77
to
451364f
Compare
67c657c
to
9bddf8e
Compare
9bddf8e
to
8725725
Compare
@vinser52 Please rebase. There is a strange message here: |
That's a new addition. I'm testing a few security options to fix the issue: #580 This precise option seem a little annoying (but perhaps maintainers can just do the update before merging) - I will keep investigating these security options |
8725725
to
c5d2d94
Compare
Done. |
@lplewa please respond to your issues |
c5d2d94
to
a0850d8
Compare
Description
As we agreed, while L0 driver has not fixed IPC implementation, in UMF we will use
getpidfd
approach.So in this PR does the following:
Checklist