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 8, 2024
1 parent 42bff7a commit cc93df1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 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 @@ -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 cc93df1

Please sign in to comment.