Enable an io-uring build
There exists a bug where calls that we previously thought were
non-blocking, actually do block when used with hwmon or filesystem fds.
This causes high latencies on the dbus interfaces when lots of sensors
are used in a single daemon, as is the case in PSUSensor.
This patchset moves the PSUSensor code over to using io-uring, through
boost asio, using the random_access_file class. This helps with
performance in a number of ways, the largest of which being that sensor
reads are no longer blocking.
Tested:
Booted the sensor system on Tyan S7106; dbus-monitor shows sensors
scanning normally.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I654eafcfab5a24b65b89c204ab43d81c7ae064cf
diff --git a/include/PSUSensor.hpp b/include/PSUSensor.hpp
index 9e32138..4d7aaba 100644
--- a/include/PSUSensor.hpp
+++ b/include/PSUSensor.hpp
@@ -2,10 +2,11 @@
#include <PwmSensor.hpp>
#include <Thresholds.hpp>
-#include <boost/asio/streambuf.hpp>
+#include <boost/asio/random_access_file.hpp>
#include <sdbusplus/asio/object_server.hpp>
#include <sensor.hpp>
+#include <array>
#include <memory>
#include <string>
#include <utility>
@@ -26,15 +27,19 @@
void setupRead(void);
private:
+ // Note, this buffer is a shared_ptr because during a read, its lifetime
+ // might have to outlive the PSUSensor class if the object gets destroyed
+ // while in the middle of a read operation
+ std::shared_ptr<std::array<char, 128>> buffer;
sdbusplus::asio::object_server& objServer;
- boost::asio::posix::stream_descriptor inputDev;
+ boost::asio::random_access_file inputDev;
boost::asio::deadline_timer waitTimer;
std::string path;
unsigned int sensorFactor;
double sensorOffset;
thresholds::ThresholdTimer thresholdTimer;
void restartRead();
- void handleResponse(const boost::system::error_code& err);
+ void handleResponse(const boost::system::error_code& err, size_t bytesRead);
void checkThresholds(void) override;
unsigned int sensorPollMs = defaultSensorPollMs;