1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
From 1b01638d44ebb5d6163899775dea2fcc7e0715d6 Mon Sep 17 00:00:00 2001
From: Helen Huang <he.huang@intel.com>
Date: Mon, 31 May 2021 09:19:55 +0800
Subject: [PATCH] Add log count limitation to requestAdd()
To avoid log storm, add the log count limitation to
requestAdd().
Change-Id: I91894ff07fa252ed7746816535611a33b6f640ea
Signed-off-by: Helen Huang <he.huang@intel.com>
---
ipmbbridged.cpp | 44 ++++++++++++++++++++++++++++++++++++++------
ipmbbridged.hpp | 3 +++
2 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/ipmbbridged.cpp b/ipmbbridged.cpp
index 6d1be04..93f5b2f 100644
--- a/ipmbbridged.cpp
+++ b/ipmbbridged.cpp
@@ -916,12 +916,44 @@ std::tuple<int, uint8_t, uint8_t, uint8_t, uint8_t, std::vector<uint8_t>>
if (i2cRetryCnt == ipmbI2cNumberOfRetries)
{
- std::string msgToLog =
- "requestAdd: Sent to I2C failed after retries."
- " busId=" +
- std::to_string(ipmbBusId) + ", error=" + ec.message();
- phosphor::logging::log<phosphor::logging::level::INFO>(
- msgToLog.c_str());
+ if ((requestAddLogCount <= ipmbRequestAddLogLimit) ||
+ (!(requestAddLogCount % ipmbRequestAddLogInterval)) ||
+ (UINT_MAX == requestAddLogCount))
+ {
+ std::string msgToLog;
+ if (requestAddLogCount == ipmbRequestAddLogLimit)
+ {
+ msgToLog = "requestAdd: There are " +
+ std::to_string(ipmbRequestAddLogLimit - 1) +
+ " similiar logs."
+ " To avoid log storm, not all the logs for the "
+ "issue will be shown: ";
+ }
+ if (!(requestAddLogCount % ipmbRequestAddLogInterval) && (requestAddLogCount != 0))
+ {
+ msgToLog = "requestAdd: There are " +
+ std::to_string(requestAddLogCount) +
+ " similiar logs so far: ";
+ }
+ if (UINT_MAX == requestAddLogCount)
+ {
+ msgToLog = "requestAdd: There are " +
+ std::to_string(requestAddLogCount) +
+ " similiar logs,"
+ " The log count will be rolled back to zero: ";
+ }
+ msgToLog += "requestAdd: Sent to I2C failed after retries."
+ " busId=" +
+ std::to_string(ipmbBusId) +
+ ", error=" + ec.message();
+ phosphor::logging::log<phosphor::logging::level::INFO>(
+ msgToLog.c_str());
+ }
+ requestAddLogCount++;
+ }
+ else
+ {
+ requestAddLogCount = 0;
}
request->timer->expires_after(
diff --git a/ipmbbridged.hpp b/ipmbbridged.hpp
index c79ac63..eaba7ae 100644
--- a/ipmbbridged.hpp
+++ b/ipmbbridged.hpp
@@ -50,6 +50,8 @@ constexpr int ipmbMaxOutstandingRequestsCount = 64;
constexpr int ipmbNumberOfTries = 6;
constexpr uint64_t ipmbRequestRetryTimeout = 250; // ms
+constexpr int ipmbRequestAddLogLimit = 10;
+constexpr int ipmbRequestAddLogInterval = 100;
/**
* @brief Ipmb I2C communication
*/
@@ -313,6 +315,7 @@ class IpmbChannel
uint8_t ipmbBusId;
uint8_t channelIdx;
+ unsigned int requestAddLogCount = 0;
std::shared_ptr<IpmbCommandFilter> commandFilter;
// array storing outstanding requests
--
2.17.1
|