Repository navigation
Conversation
|
@amastbaum please review |
|
|
||
| fp = fopen(syscall_file, "r"); | ||
| if (fp == NULL) { | ||
| ucm_error("failed to open %s", syscall_file); |
There was a problem hiding this comment.
| ucm_error("failed to open %s", syscall_file); | |
| ucm_error("failed to open %s: %m", syscall_file); |
| fclose(fp); | ||
|
|
||
| if (res == NULL) { | ||
| ucm_error("failed to read %s", syscall_file); |
There was a problem hiding this comment.
| ucm_error("failed to read %s", syscall_file); | |
| ucm_error("failed to read %s: %m", syscall_file); |
| } | ||
| } | ||
|
|
||
| out: |
There was a problem hiding this comment.
minor: out label is optional, break would suffice
| break; | ||
| } | ||
|
|
||
| ucm_bistro_wait_sec(0.5); |
There was a problem hiding this comment.
maybe make it shorter time? or use grace_duration ?
| snprintf(syscall_file, sizeof(syscall_file), "%s/%s/syscall", task_dir, | ||
| entry->d_name); | ||
|
|
||
| fp = fopen(syscall_file, "r"); |
There was a problem hiding this comment.
- we cannot call any functions that may allocate memory to avoid deadlock with malloc(), and in general better avoid any comples C library calls
- IMO better ust procfs to check instruction pointer of other threads (it's possible) and wait until it's outside the patched function code
There was a problem hiding this comment.
seems procfs doesn't give instruction pointer if process is "not blocked"
| 0) { | ||
| for (bpos = 0; bpos < nread;) { | ||
| entry = (struct linux_dirent*)(dir_buf + bpos); | ||
|
|
There was a problem hiding this comment.
maybe first make sure it is DT_DIR for future proof?
| (curr_syscall == syscall_num)) { | ||
| found = 1; | ||
| break; | ||
| if (read_bytes < 0) { |
There was a problem hiding this comment.
also return error if read_bytes == sizeof(line)-1 as it might have been truncated?
There was a problem hiding this comment.
seems redundant IMO (and also sscanf would fail in that case)
| fd = open(syscall_file, O_RDONLY); | ||
| if (fd < 0) { | ||
| ucm_error("failed to open %s: %m", syscall_file); | ||
| break; |
There was a problem hiding this comment.
if we can't read some thread data, I think it's normal because thread might have been terminated. We should not break, but continue?
|
|
||
| if (read_bytes < 0) { | ||
| ucm_error("failed to read %s: %m", syscall_file); | ||
| break; |
| for (bpos = 0; bpos < nread;) { | ||
| entry = (struct linux_dirent64*)(dir_buf + bpos); | ||
|
|
||
| if ((entry->d_name[0] == '.') || (entry->d_type != DT_DIR)) { |
There was a problem hiding this comment.
d_type may be DT_UNKNOWN on some systems, maybe we skip this condition
| if ((sscanf(line, "%d", &curr_syscall) == 1) && | ||
| (curr_syscall == syscall_num)) { | ||
| found = 1; | ||
| break; |
There was a problem hiding this comment.
this breaks only the inner loop?
What?
Wait for syscall completion before patching
Why?
Reduce race condition if a syscall is in progress while trying to patch a function
solves https://redmine.mellanox.com/issues/4739519