From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-we0-x234.google.com (mail-we0-x234.google.com [IPv6:2a00:1450:400c:c03::234]) by dpdk.org (Postfix) with ESMTP id B62C44BFE for ; Wed, 20 Mar 2013 17:08:07 +0100 (CET) Received: by mail-we0-f180.google.com with SMTP id k14so1520840wer.11 for ; Wed, 20 Mar 2013 09:07:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references:x-gm-message-state; bh=T1nebdULQTqz6P4tAzqW6geEwt8qt2otQP6ZwrKJ5mw=; b=IlqgecpRwSQNc/y4hscCpqZ7xfOJRxtjkEQxcPmiKaegWXwxs34+1l7UW4TkMRJx8+ 30SzO8xqGZF8YncsLMpC1WpGxUAQJFDn8hyzZO4cLePPRs8Mlu1/eMozMyYaxoqc1A3e NU+CM08IsO40IuR3tTYy/1baqgIRlpn1ayJVy6xrlTw4a2o9nWTZpG7rtBVt/+t5u9fn xbARqrztgpBMuE40e7XBDpvc/ynrgFwc0ieossKHtRXIj0Rf99f+gOMvd+4PyHYCaqYl jNPSWBqZxDu8dknI3EVWcQgdx8f26ZEYTCBuzeSwOYvcXDJSZXaX8C6PE4kFNSmPkVUX yxrg== X-Received: by 10.194.5.4 with SMTP id o4mr11581254wjo.40.1363795628704; Wed, 20 Mar 2013 09:07:08 -0700 (PDT) Received: from 6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPS id bj9sm7744785wib.4.2013.03.20.09.07.06 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 20 Mar 2013 09:07:07 -0700 (PDT) Received: by 6wind.com (sSMTP sendmail emulation); Wed, 20 Mar 2013 17:07:06 +0100 From: Thomas Monjalon To: dev@dpdk.org Date: Wed, 20 Mar 2013 17:05:04 +0100 Message-Id: <0b5c378689ddbf21bd1abb63ea5e30217eb27fac.1363795499.git.thomas.monjalon@6wind.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQlsf4n29Xz0IzRq/7NRbcVeuO/8YyKBdfJEQVg+Nobik+zMxUwdkZXPZ5fv6kEt9ygE/V+E Subject: [dpdk-dev] [PATCH 16/22] timer: check TSC reliability X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Mar 2013 16:08:08 -0000 From: Ivan Boule Read flags from /proc/cpuinfo and warn if constant_tsc or nonstop_tsc is not found. Acked-by: Ivan Boule Signed-off-by: Thomas Monjalon --- lib/librte_eal/linuxapp/eal/eal_hpet.c | 37 ++++++++++++++++++++++++++++++++ 1 files changed, 37 insertions(+), 0 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_hpet.c b/lib/librte_eal/linuxapp/eal/eal_hpet.c index aa686b1..de05151 100644 --- a/lib/librte_eal/linuxapp/eal/eal_hpet.c +++ b/lib/librte_eal/linuxapp/eal/eal_hpet.c @@ -2,6 +2,7 @@ * BSD LICENSE * * Copyright(c) 2010-2012 Intel Corporation. All rights reserved. + * Copyright(c) 2012-2013 6WIND. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -140,6 +141,41 @@ set_rdtsc_freq(void) ((1.0 / eal_hpet_resolution_hz) / 1e-15); } +static void +check_tsc_flags(void) +{ + char line[512]; + FILE *stream; + + stream = fopen("/proc/cpuinfo", "r"); + if (!stream) { + RTE_LOG(WARNING, EAL, "WARNING: Unable to open /proc/cpuinfo\n"); + return; + } + + while (fgets(line, sizeof line, stream)) { + char *constant_tsc; + char *nonstop_tsc; + + if (strncmp(line, "flags", 5) != 0) + continue; + + constant_tsc = strstr(line, "constant_tsc"); + nonstop_tsc = strstr(line, "nonstop_tsc"); + if (!constant_tsc || !nonstop_tsc) + RTE_LOG(WARNING, EAL, + "WARNING: cpu flags " + "constant_tsc=%s " + "nonstop_tsc=%s " + "-> using unreliable clock cycles !\n", + constant_tsc ? "yes":"no", + nonstop_tsc ? "yes":"no"); + break; + } + + fclose(stream); +} + /* * Open and mmap /dev/hpet (high precision event timer) that will * provide our time reference. @@ -192,6 +228,7 @@ rte_eal_hpet_init(void) use_rdtsc: internal_config.no_hpet = 1; set_rdtsc_freq(); + check_tsc_flags(); return 0; } -- 1.7.2.5