From patchwork Tue Dec 11 12:04:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 205187 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 5400E2C0080 for ; Tue, 11 Dec 2012 23:04:15 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1TiOZK-0003OF-4K; Tue, 11 Dec 2012 12:04:14 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1TiOZE-0003Lu-8c for fwts-devel@lists.ubuntu.com; Tue, 11 Dec 2012 12:04:08 +0000 Received: from cpc3-craw6-2-0-cust180.croy.cable.virginmedia.com ([77.100.248.181] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1TiOZE-0004tr-5q for fwts-devel@lists.ubuntu.com; Tue, 11 Dec 2012 12:04:08 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH 3/4] acpi: cstates: use new fwts_cpu_performance() helper function Date: Tue, 11 Dec 2012 12:04:05 +0000 Message-Id: <1355227446-14380-4-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1355227446-14380-1-git-send-email-colin.king@canonical.com> References: <1355227446-14380-1-git-send-email-colin.king@canonical.com> X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: fwts-devel-bounces@lists.ubuntu.com Errors-To: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King Remove duplicated code by using fwts_cpu_performance() Signed-off-by: Colin Ian King Acked-by: Keng-Yu Lin Acked-by: Ivan Hu --- src/acpi/cstates/cstates.c | 55 +++++++++------------------------------------- 1 file changed, 10 insertions(+), 45 deletions(-) diff --git a/src/acpi/cstates/cstates.c b/src/acpi/cstates/cstates.c index 26cf2e6..79170df 100644 --- a/src/acpi/cstates/cstates.c +++ b/src/acpi/cstates/cstates.c @@ -34,9 +34,6 @@ #include #include #include -#include -#include -#include #include #define MIN_CSTATE 1 @@ -51,46 +48,6 @@ typedef struct { static int statecount = -1; static int firstcpu = -1; -static void keep_busy_for_one_second(int cpu) -{ - cpu_set_t mask, oldset; - time_t current; - unsigned long loopcount = 0; - - /* First, go to the right cpu */ - - sched_getaffinity(0, sizeof(oldset), &oldset); - - CPU_ZERO(&mask); - CPU_SET(cpu, &mask); - sched_setaffinity(0, sizeof(mask), &mask); - current = time(NULL); - - do { - double A, B; - int i; - A = 1.234567; - B = 3.121213; - for (i=0; i<100; i++) { - A = A * B; - B = A * A; - A = A - B + sqrt(A); - A = A * B; - B = A * A; - A = A - B + sqrt(A); - A = A * B; - B = A * A; - A = A - B + sqrt(A); - A = A * B; - B = A * A; - A = A - B + sqrt(A); - } - loopcount++; - } while (current == time(NULL)); - - sched_setaffinity(0, sizeof(oldset), &oldset); -} - static void get_cstates(char *path, fwts_cstates *state) { struct dirent *entry; @@ -167,8 +124,16 @@ static void do_cpu(fwts_framework *fw, int nth, int cpus, int cpu, char *path) if ((i & 7) < 4) sleep(1); - else - keep_busy_for_one_second(cpu); + else { + uint64_t loop_count; + + if (fwts_cpu_performance(fw, cpu, &loop_count) != FWTS_OK) { + fwts_failed(fw, LOG_LEVEL_HIGH, "CPUFailedPerformance", + "Could not determine the CPU performance, this " + "may be due to not being able to get or set the " + "CPU affinity for CPU %i.", cpu); + } + } get_cstates(path, ¤t);