[v2,2/2] timer: don't check tsc flags in secondary processes

Message ID 156595695619.7484.7837232961573133745.stgit@jrharri1-skx (mailing list archive)
State Superseded, archived
Headers
Series [v2,1/2] timer: use rte_mp_msg to pass TSC hz to secondary procs |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Harris, James R Aug. 16, 2019, 12:02 p.m. UTC
  check_tsc_flags() parses /proc/cpuinfo and prints
warning messages if any cores don't have constant_tsc
and nonstop_tsc.  It has no functional meaning.
This consumes a noticeable amount of time in
secondary processes - on my test system, it consumes
21ms out of the 66ms total execution time for
rte_eal_init().

So let's just skip checking these flags in secondary
processes.  Since the primary process is already
parsing the entirety of /proc/cpuinfo, the warning
printed in the primary process should be sufficient.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
---
 lib/librte_eal/linux/eal/eal_timer.c |    9 +++++++++
 1 file changed, 9 insertions(+)
  

Patch

diff --git a/lib/librte_eal/linux/eal/eal_timer.c b/lib/librte_eal/linux/eal/eal_timer.c
index 76ec17034..ce447d43b 100644
--- a/lib/librte_eal/linux/eal/eal_timer.c
+++ b/lib/librte_eal/linux/eal/eal_timer.c
@@ -198,6 +198,15 @@  check_tsc_flags(void)
 	char line[512];
 	FILE *stream;
 
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		/* This function just prints warnings if TSC is not constant
+		 * and has no functional meaning.  It also checks *all* cores
+		 * on the system, not just the ones configured for this process.
+		 * So don't bother rechecking again in secondary processes.
+		 */
+		return;
+	}
+
 	stream = fopen("/proc/cpuinfo", "r");
 	if (!stream) {
 		RTE_LOG(WARNING, EAL, "WARNING: Unable to open /proc/cpuinfo\n");