From patchwork Wed Feb 21 10:29:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 10231819 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A793360209 for ; Wed, 21 Feb 2018 10:30:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9327E28B10 for ; Wed, 21 Feb 2018 10:30:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8312028BE9; Wed, 21 Feb 2018 10:30:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A6FE228B62 for ; Wed, 21 Feb 2018 10:30:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B32106E5C1; Wed, 21 Feb 2018 10:30:08 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id D07CF6E5C1 for ; Wed, 21 Feb 2018 10:30:07 +0000 (UTC) Received: by mail-wr0-x244.google.com with SMTP id f14so2960813wre.8 for ; Wed, 21 Feb 2018 02:30:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ursulin-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=WNetLlglMNVrYAvoiNzILdXXvZmPNik5evMxwhLsD3k=; b=uZKcQ5GNbeja5OlkPRqi+/N3UU6ZenHqjMbeyGy4lWS7BxvMlxYAmaqdHH/O6RkEwv htPHO3pdWdDVeDBMLnKr4ggFCQrXpaSztIOXNMawlhlIjS7yQhsBbmDBk9ZDBLyP2HqY wuNJN4RDAWCpq/L1mDtH3DvR4ehrraBjfRFQtvmJTtPimqIFDRoQPJlX+tNahWvxJVFn iGlv38Vm1eNArGmMWdRiViQ3HGwvRlctByKBjftTMDj0ml4i+ZuXmSh7CuNXSVG51GYv 0+igInPvBvH/7IvMkQgeTKCTXw5t0UnbnSPKyL2rxs49kkfuY/7BGZvkKTp16PGvIQgA XWZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=WNetLlglMNVrYAvoiNzILdXXvZmPNik5evMxwhLsD3k=; b=BbUCyUXsGKwtO3gHYdE+4uW7sfi3CHNZXBTZyro0ajfVvG7M/ySlDRD7uqrTEVsTl8 9E2Dwq3tWtGzKm47vutHQ8NkSKLczsSrgNXN/ufi8C66fe4SEjtmmn4XiSL6qqQrRPez +AogzO61/VklIXGzuBjlk1B3XcCNDeZcsos8+N/Zddi+ul3d0umxDQUGh75sW9Jr3mVv vP/Ohp+/7rTKBRdsi3ky0YzbwuzaQbfvbKirW4QmjSIdLJWhKPKH5BJFW0vmEWtXda09 7sQ3ASyO9XZrzbQdLWaF/2KJVn/jBSpwD9Za66YekQNo594RlAIAuEqKX/oicnJXcyct 0W2w== X-Gm-Message-State: APf1xPB+nZ8Gu7hBKaTYaDXkgHbhl2mZYGU2LjD1jVaRQ3Zlls3pGVpJ iEKQqmKjhZXniSr2V0K7ovH249zC X-Google-Smtp-Source: AH8x227tV86B0nDREderJozUriv9x9lMdvUAP84uIuF+r51Uk743D5ErzhXKK55BIUB+OcFsuLYF6A== X-Received: by 10.28.238.132 with SMTP id j4mr1673080wmi.73.1519209006288; Wed, 21 Feb 2018 02:30:06 -0800 (PST) Received: from localhost.localdomain ([95.146.144.186]) by smtp.gmail.com with ESMTPSA id 128sm3768592wmi.20.2018.02.21.02.30.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Feb 2018 02:30:05 -0800 (PST) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Wed, 21 Feb 2018 10:29:57 +0000 Message-Id: <20180221102957.6334-1-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.14.1 Subject: [Intel-gfx] [PATCH i-g-t] lib/igt_perf: Find active perf CPU X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Intel-gfx@lists.freedesktop.org MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Tvrtko Ursulin Instead of assuming PMU runs on CPU0, try all possible CPUs if that is not the case. This makes the callers handle fallout from broken tests better, as well as sysadmin interventions where callers are not tests. Signed-off-by: Tvrtko Ursulin Cc: Chris Wilson Reviewed-by: Chris Wilson --- lib/igt_perf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/igt_perf.c b/lib/igt_perf.c index 0221461e918f..99d82ea51c9b 100644 --- a/lib/igt_perf.c +++ b/lib/igt_perf.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "igt_perf.h" @@ -31,6 +32,8 @@ static int _perf_open(uint64_t type, uint64_t config, int group, uint64_t format) { struct perf_event_attr attr = { }; + int nr_cpus = get_nprocs_conf(); + int cpu = 0, ret; attr.type = type; if (attr.type == 0) @@ -42,7 +45,11 @@ _perf_open(uint64_t type, uint64_t config, int group, uint64_t format) attr.read_format = format; attr.config = config; - return perf_event_open(&attr, -1, 0, group, 0); + do { + ret = perf_event_open(&attr, -1, cpu++, group, 0); + } while ((ret < 0 && errno == EINVAL) && (cpu < nr_cpus)); + + return ret; } int perf_i915_open(uint64_t config)