coredump: Improve error handling when reading VRAM
It is possible for the runtime to receive an interrupt while trying to
access VRAM data using /proc/self/mem. In such case, pread(2) would
return -1 and set errno to -EINTR. This is not an error case, the
pread(2) call just need to be restarted, however current implementation
would tread it as an error.
This patch changes the the implementation to correctly retry on EINTR.
While at it, this patch also handles cases where pread(2) reads less
data than originally requested.
Change-Id: I6a72fc5eda4afd90319f0d24b35c9eac6d1ff41c
Signed-off-by: David Yat Sin <David.YatSin@amd.com>
[ROCm/ROCR-Runtime commit: 3e0d3d6d61]
This commit is contained in:
committed by
David Yat Sin
parent
d7a0c72661
commit
96545e914b
@@ -249,10 +249,25 @@ struct LoadSegmentBuilder : public SegmentBuilder {
|
||||
|
||||
hsa_status_t Read(void* buf, size_t buf_size, off_t offset) override {
|
||||
if (fd_ == -1) return HSA_STATUS_ERROR;
|
||||
if (pread(fd_, buf, buf_size, offset) == -1) {
|
||||
perror("Failed to read GPU memory");
|
||||
|
||||
size_t done = 0;
|
||||
ssize_t read;
|
||||
do {
|
||||
read = pread(fd_, buf + done, buf_size - done, offset + done);
|
||||
|
||||
if (read == -1 && errno != EINTR) {
|
||||
perror("Failed to read GPU memory");
|
||||
return HSA_STATUS_ERROR;
|
||||
}
|
||||
else if (read > 0)
|
||||
done += read;
|
||||
} while (read != 0 && done < buf_size);
|
||||
|
||||
if (read == 0 && done < buf_size) {
|
||||
fprintf(stderr, "Reached unexpected EOF while reading VRAM.\n");
|
||||
return HSA_STATUS_ERROR;
|
||||
}
|
||||
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user