Add process safety to cl_cache on Linux

Current flow will be to have one synchronization point
config.file. Read remains unblocking, only write(caching)
operation will be blocking (lock on config.file)

Related-To: NEO-4262

Signed-off-by: Diedrich, Kamil <kamil.diedrich@intel.com>
This commit is contained in:
Diedrich, Kamil
2023-03-08 23:15:36 +01:00
committed by Compute-Runtime-Automation
parent c9fdeb200c
commit 26ca64bb28
15 changed files with 1091 additions and 40 deletions

View File

@@ -8,6 +8,7 @@
#pragma once
#include "shared/source/os_interface/sys_calls_common.h"
#include <dirent.h>
#include <iostream>
#include <poll.h>
#include <sys/mman.h>
@@ -17,6 +18,7 @@ namespace NEO {
namespace SysCalls {
int close(int fileDescriptor);
int open(const char *file, int flags);
int openWithMode(const char *file, int flags, int mode);
void *dlopen(const char *filename, int flag);
int ioctl(int fileDescriptor, unsigned long int request, void *arg);
int getDevicePath(int deviceFd, char *buf, size_t &bufSize);
@@ -33,6 +35,16 @@ ssize_t write(int fd, void *buf, size_t count);
int fcntl(int fd, int cmd);
int fcntl(int fd, int cmd, int arg);
char *realpath(const char *path, char *buf);
int stat(const std::string &filePath, struct stat *statbuf);
int pipe(int pipefd[2]);
int flock(int fd, int flag);
int mkstemp(char *filePath);
int rename(const char *currName, const char *dstName);
int scandir(const char *dirp,
struct dirent ***namelist,
int (*filter)(const struct dirent *),
int (*compar)(const struct dirent **,
const struct dirent **));
int unlink(const std::string &pathname);
} // namespace SysCalls
} // namespace NEO

View File

@@ -8,14 +8,17 @@
#include "shared/source/os_interface/linux/sys_calls.h"
#include <cstdlib>
#include <dirent.h>
#include <dlfcn.h>
#include <fcntl.h>
#include <iostream>
#include <poll.h>
#include <stdio.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <sys/types.h>
#include <unistd.h>
namespace NEO {
@@ -43,6 +46,9 @@ int close(int fileDescriptor) {
int open(const char *file, int flags) {
return ::open(file, flags);
}
int openWithMode(const char *file, int flags, int mode) {
return ::open(file, flags, mode);
}
int ioctl(int fileDescriptor, unsigned long int request, void *arg) {
return ::ioctl(fileDescriptor, request, arg);
}
@@ -114,9 +120,37 @@ char *realpath(const char *path, char *buf) {
return ::realpath(path, buf);
}
int stat(const std::string &filePath, struct stat *statbuf) {
return ::stat(filePath.c_str(), statbuf);
}
int pipe(int pipeFd[2]) {
return ::pipe(pipeFd);
}
int mkstemp(char *filePath) {
return ::mkstemp(filePath);
}
int flock(int fd, int flag) {
return ::flock(fd, flag);
}
int rename(const char *currName, const char *dstName) {
return ::rename(currName, dstName);
}
int scandir(const char *dirp,
struct dirent ***namelist,
int (*filter)(const struct dirent *),
int (*compar)(const struct dirent **,
const struct dirent **)) {
return ::scandir(dirp, namelist, filter, compar);
}
int unlink(const std::string &pathname) {
return ::unlink(pathname.c_str());
}
} // namespace SysCalls
} // namespace NEO