Skip to content

Commit

Permalink
Adjust log levels of /proc/cpuinfo parsing
Browse files Browse the repository at this point in the history
There are a few steps in our parsing logic where we skip lines that
don't match the expectations of the /proc/cpuinfo node. Reduce the log
level of these lines to 'debug', as these are not generally errors and
are noisy on systems that have unique cpuinfo key-value pairs.

When parsing logic encounters a higher-than-expected processor number,
increase the level to warning, to indicate that an error may have
occurred in the parsing step.
  • Loading branch information
prashanthswami committed Jan 6, 2024
1 parent 42bff7a commit 9104dce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/arm/linux/cpuinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ static bool parse_line(
}
/* Skip line if no ':' separator was found. */
if (separator == line_end) {
cpuinfo_log_info(
cpuinfo_log_debug(
"Line %.*s in /proc/cpuinfo is ignored: key/value separator ':' not found",
(int)(line_end - line_start),
line_start);
Expand All @@ -758,7 +758,7 @@ static bool parse_line(
}
/* Skip line if key contains nothing but spaces. */
if (key_end == line_start) {
cpuinfo_log_info(
cpuinfo_log_debug(
"Line %.*s in /proc/cpuinfo is ignored: key contains only spaces",
(int)(line_end - line_start),
line_start);
Expand All @@ -774,7 +774,7 @@ static bool parse_line(
}
/* Value part contains nothing but spaces. Skip line. */
if (value_start == line_end) {
cpuinfo_log_info(
cpuinfo_log_debug(
"Line %.*s in /proc/cpuinfo is ignored: value contains only spaces",
(int)(line_end - line_start),
line_start);
Expand Down Expand Up @@ -873,7 +873,7 @@ static bool parse_line(
} else if (memcmp(line_start, "Hardware", key_length) == 0) {
size_t value_length = value_end - value_start;
if (value_length > CPUINFO_HARDWARE_VALUE_MAX) {
cpuinfo_log_info(
cpuinfo_log_debug(
"length of Hardware value \"%.*s\" in /proc/cpuinfo exceeds limit (%d): truncating to the limit",
(int)value_length,
value_start,
Expand All @@ -888,7 +888,7 @@ static bool parse_line(
} else if (memcmp(line_start, "Revision", key_length) == 0) {
size_t value_length = value_end - value_start;
if (value_length > CPUINFO_REVISION_VALUE_MAX) {
cpuinfo_log_info(
cpuinfo_log_debug(
"length of Revision value \"%.*s\" in /proc/cpuinfo exceeds limit (%d): truncating to the limit",
(int)value_length,
value_start,
Expand Down Expand Up @@ -918,7 +918,7 @@ static bool parse_line(
} else if (new_processor_index > processor_index + 1) {
/* Strange, but common: skipped
* processor $(processor_index + 1) */
cpuinfo_log_info(
cpuinfo_log_warning(
"unexpectedly high processor number %" PRIu32
" following processor %" PRIu32 " in /proc/cpuinfo",
new_processor_index,
Expand Down
8 changes: 4 additions & 4 deletions src/x86/linux/cpuinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static bool parse_line(
}
/* Skip line if no ':' separator was found. */
if (separator == line_end) {
cpuinfo_log_info(
cpuinfo_log_debug(
"Line %.*s in /proc/cpuinfo is ignored: key/value separator ':' not found",
(int)(line_end - line_start),
line_start);
Expand All @@ -115,7 +115,7 @@ static bool parse_line(
}
/* Skip line if key contains nothing but spaces. */
if (key_end == line_start) {
cpuinfo_log_info(
cpuinfo_log_debug(
"Line %.*s in /proc/cpuinfo is ignored: key contains only spaces",
(int)(line_end - line_start),
line_start);
Expand All @@ -131,7 +131,7 @@ static bool parse_line(
}
/* Value part contains nothing but spaces. Skip line. */
if (value_start == line_end) {
cpuinfo_log_info(
cpuinfo_log_debug(
"Line %.*s in /proc/cpuinfo is ignored: value contains only spaces",
(int)(line_end - line_start),
line_start);
Expand Down Expand Up @@ -177,7 +177,7 @@ static bool parse_line(
} else if (new_processor_index > processor_index + 1) {
/* Strange, but common: skipped
* processor $(processor_index + 1) */
cpuinfo_log_info(
cpuinfo_log_warning(
"unexpectedly high processor number %" PRIu32
" following processor %" PRIu32 " in /proc/cpuinfo",
new_processor_index,
Expand Down

0 comments on commit 9104dce

Please sign in to comment.