summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorngc224 <[email protected]>2025-08-13 22:53:15 +0300
committerngc224 <[email protected]>2025-08-13 23:08:36 +0300
commit8178c9f219c9745cd68e203262436c36e1a686b7 (patch)
treeae498dd90ab83090f0777d214c1c022e25dff0fb
parent411243c593977a11a6b69bacceaeb3f58f75660d (diff)
Improve uring support detection
commit_hash:0bac56bb004a47e8fc18f8ac18586280661e4110
-rw-r--r--yt/yt/core/misc/proc.cpp42
-rw-r--r--yt/yt/core/misc/proc.h7
2 files changed, 49 insertions, 0 deletions
diff --git a/yt/yt/core/misc/proc.cpp b/yt/yt/core/misc/proc.cpp
index 2426199f9d3..929d2643e11 100644
--- a/yt/yt/core/misc/proc.cpp
+++ b/yt/yt/core/misc/proc.cpp
@@ -1768,6 +1768,48 @@ const TString& GetLinuxKernelVersion()
#endif
}
+std::vector<int> ParseLinuxKernelVersion()
+{
+#ifdef _linux_
+ const auto& version = GetLinuxKernelVersion();
+ if (version == "unknown") {
+ return {};
+ }
+
+ std::vector<int> parsedVersion;
+
+ TStringBuf significantVersion, remainder;
+ TStringBuf(version).Split('-', significantVersion, remainder);
+
+ StringSplitter(significantVersion).Split('.').ParseInto(&parsedVersion);
+
+ return parsedVersion;
+#else
+ return {};
+#endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+bool IsUringEnabled()
+{
+#ifdef _linux_
+ try {
+ TFileInput stream("/proc/sys/kernel/io_uring_perm");
+
+ return stream.ReadLine() != "0";
+ } catch (const TSystemError& ex) {
+ if (ex.Status() == ENOENT) {
+ return false;
+ } else {
+ throw;
+ }
+ }
+#else
+ return false;
+#endif
+}
+
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT
diff --git a/yt/yt/core/misc/proc.h b/yt/yt/core/misc/proc.h
index 7111ffbdafd..40302f5c18d 100644
--- a/yt/yt/core/misc/proc.h
+++ b/yt/yt/core/misc/proc.h
@@ -10,6 +10,8 @@
#include <yt/yt/core/misc/fs.h>
+#include <vector>
+
namespace NYT {
////////////////////////////////////////////////////////////////////////////////
@@ -378,6 +380,11 @@ TFile MemfdCreate(const TString& name);
////////////////////////////////////////////////////////////////////////////////
const TString& GetLinuxKernelVersion();
+std::vector<int> ParseLinuxKernelVersion();
+
+////////////////////////////////////////////////////////////////////////////////
+
+bool IsUringEnabled();
////////////////////////////////////////////////////////////////////////////////