Add one second timer to save POST codes to file
A lot of POST codes are sent to BMC from BIC
in a short time.
In BMC, there is an ipmi handler to get POST codes
and upload to dbus property.
The xyz.openbmc_project.State.Boot@.PostCode service
listens the PropertiesChanged signal and saves to POST
codes history file.
The xyz.openbmc_project.State.Boot@.PostCode service
is hanged if there are too many POST codes in a short time.
At this time, the memory usage of dbus-broker increases,
and the out-of-memory(OOM) issue happens.
The processes are killed when OOM happens,
and BMC may reset unexpected.
Test Case:
Check the frequency for post code file getting larger
Signed-off-by: Bonnie Lo <Bonnie_Lo@wiwynn.com>
Change-Id: Ic5a397cfa7f053e196cc3d0eeae3e2b2fa5089b7
diff --git a/inc/post_code.hpp b/inc/post_code.hpp
index 3ae58d8..53aa320 100644
--- a/inc/post_code.hpp
+++ b/inc/post_code.hpp
@@ -19,6 +19,7 @@
#include <unistd.h>
#include <phosphor-logging/elog-errors.hpp>
+#include <sdbusplus/timer.hpp>
#include <xyz/openbmc_project/Collection/DeleteAll/server.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
#include <xyz/openbmc_project/State/Boot/PostCode/server.hpp>
@@ -62,9 +63,10 @@
struct PostCode : sdbusplus::server::object_t<post_code, delete_all>
{
- PostCode(sdbusplus::bus_t& bus, const char* path, int nodeIndex) :
- sdbusplus::server::object_t<post_code, delete_all>(bus, path), bus(bus),
- node(nodeIndex),
+ PostCode(sdbusplus::bus_t& bus, const char* path, EventPtr& event,
+ int nodeIndex) :
+ sdbusplus::server::object_t<post_code, delete_all>(bus, path),
+ bus(bus), event(event), node(nodeIndex),
postCodeListPath(PostCodeListPathPrefix + std::to_string(node)),
propertiesChangedSignalRaw(
bus,
@@ -137,7 +139,9 @@
void incrBootCycle();
uint16_t getBootNum(const uint16_t index) const;
+ std::unique_ptr<phosphor::Timer> timer;
sdbusplus::bus_t& bus;
+ EventPtr& event;
int node;
std::chrono::time_point<std::chrono::steady_clock> firstPostCodeTimeSteady;
uint64_t firstPostCodeUsSinceEpoch;