Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1763758rda; Tue, 24 Oct 2023 02:29:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDUn8YtGSkyz9itTgJ8/z99iSjCrHDHcDVZ4z+acGWinWMqsFx0rq1HLylI4gb5dsIx4dO X-Received: by 2002:a05:6870:b10:b0:1e9:8e4f:30dd with SMTP id lh16-20020a0568700b1000b001e98e4f30ddmr12825197oab.6.1698139782542; Tue, 24 Oct 2023 02:29:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698139782; cv=none; d=google.com; s=arc-20160816; b=ZkCyEGwSqqfw0ruYLZUvyqN53la0Nh2hQtPfawj0F15qMO1IlkwifHgnESVdUCOMZ2 3VQF2yTmZZaub3wlDfyPcOh9xJlqUVEjvvxSStiAEOanhtves1AHrES/pIgiBYpVszvS FeAL8pCFcXinD8rS3vk7IBzvopTUkL40n49Zg2AcG+hJck6G1XaPIj6q3BPv526/D8sK YN3on6yfGhI58DOUkzvkNPWVJbswRQJ/MJESFUaZQyeR2/zytWu1dcSH65bWmcGP+s8c yO2jKe8Q4BaHJjX4dxgy7hJRfT+MGD2kyrRLXB+biclZzAAe2desqAgOV4V82R2IyyKQ PeHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xZf6SFbjJFrWttcjIOgs5F34vcyDhJ6oqo0tLlfAacQ=; fh=gPQ6jqLSfsDb5bE3yrtO+AlT5R4d75RXkjC5xckz7Dk=; b=kkVvRU75+B/yEohKGLu6IyMFXXm75SBGvo3+QWVXIaZ1NyvzjUNkdtwQH6GXy5Tys1 2BMf/Jc7qEIR+laun9Y8uNHHDsxxTNoEk6203zfMUoMhkCuNi0E3Le12xa6/qYJDdskm HvrBWDKDCBCDPH25X/pesZVHCgGpalPqEGIcGsaMpNr1RBdXXp0yQ9ywNPu+lGBdr22+ 5o9r4/puGUX54k51s5oVxBJ49eAee9iogcJ6p2Jnj5EBj2cFcd4I/HaOgQPp2zD0grgA pCvzrpdnosUA7lAoDEp3I7XKvBnwHud/C935Stbq8P/2Iz+Qe2E1pRcHX8QDR9LAS0Ju 5iEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HB2EnfV3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id n1-20020a632701000000b0055c8fd5fe00si7919843pgn.886.2023.10.24.02.29.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 02:29:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HB2EnfV3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A725680309F6; Tue, 24 Oct 2023 02:29:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234317AbjJXJ3d (ORCPT + 99 others); Tue, 24 Oct 2023 05:29:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234134AbjJXJ3H (ORCPT ); Tue, 24 Oct 2023 05:29:07 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE2B81FC1; Tue, 24 Oct 2023 02:28:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698139709; x=1729675709; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CwVbuYCXjjmS1wYgCO7ZGGdahtlDKGYkkf8/AfncZ54=; b=HB2EnfV3CRcRQ3WcLzJJ/TUGJKZK4Ccxx3yMN4HcovuhVIUDTyd9vzh4 VlF7gma3NuLTB6+JNbLdsjaS4a7WA4RndDHw0EcJWCAezWgKKVVUUZdH3 fpoW7ZU/mjrLIP8kPEMcCA6N9iPLyvuwwZBryKfsOPmf6VqBXptfMfPFB h/D5oY5SxzedlzuaKLjOETpYpDs6BltDmfrXEzciKimgtmSlOyxIj/6JT C30HMOPL6NMJihXyK8s/62liOcCoI2KI1hEPvXhqQf3qP4zzBWfzTtVph cbXUJFstPHQd9t1P1sGmKA0jGNWA5aF3KGW2SsG6CMfZBhYfT2hE5E1sW Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10872"; a="386829566" X-IronPort-AV: E=Sophos;i="6.03,247,1694761200"; d="scan'208";a="386829566" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2023 02:28:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10872"; a="828754682" X-IronPort-AV: E=Sophos;i="6.03,247,1694761200"; d="scan'208";a="828754682" Received: from hprosing-mobl.ger.corp.intel.com (HELO localhost) ([10.249.40.219]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2023 02:28:25 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Shaopeng Tan , =?UTF-8?q?Maciej=20Wiecz=C3=B3r-Retman?= , Fenghua Yu Cc: linux-kernel@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH 12/24] selftests/resctrl: Improve perf init Date: Tue, 24 Oct 2023 12:26:22 +0300 Message-Id: <20231024092634.7122-13-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231024092634.7122-1-ilpo.jarvinen@linux.intel.com> References: <20231024092634.7122-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 24 Oct 2023 02:29:41 -0700 (PDT) struct perf_event_attr initialization is spread into perf_event_initialize() and perf_event_attr_initialize() and setting ->config is hardcoded by the deepest level. perf_event_attr init belongs to perf_event_attr_initialize() so move it entirely there. Rename the other function perf_event_initialized_read_format(). Call each init function directly from the test as they will take different parameters (especially tue after the perf related global variables are moved to local variables). Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/cache.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/resctrl/cache.c b/tools/testing/selftests/resctrl/cache.c index a70ace82e76e..a84679a4ac0c 100644 --- a/tools/testing/selftests/resctrl/cache.c +++ b/tools/testing/selftests/resctrl/cache.c @@ -15,8 +15,9 @@ static struct perf_event_read pe_read; static int pe_fd; char llc_occup_path[1024]; -static void perf_event_attr_initialize(void) +static void perf_event_attr_initialize(__u64 config) { + memset(&pea_llc_miss, 0, sizeof(struct perf_event_attr)); pea_llc_miss.type = PERF_TYPE_HARDWARE; pea_llc_miss.size = sizeof(struct perf_event_attr); pea_llc_miss.read_format = PERF_FORMAT_GROUP; @@ -27,18 +28,12 @@ static void perf_event_attr_initialize(void) pea_llc_miss.inherit = 1; pea_llc_miss.exclude_guest = 1; pea_llc_miss.disabled = 1; + pea_llc_miss.config = config; } -static void perf_event_initialize(void) +static void perf_event_initialize_read_format(void) { - memset(&pea_llc_miss, 0, sizeof(struct perf_event_attr)); memset(&pe_read, 0, sizeof(struct perf_event_read)); - - /* Initialize perf_event_attr structures for HW_CACHE_MISSES */ - perf_event_attr_initialize(); - - pea_llc_miss.config = PERF_COUNT_HW_CACHE_MISSES; - pe_read.nr = 1; } @@ -192,7 +187,8 @@ int cat_val(struct resctrl_val_param *param, size_t span) if (ret) return ret; - perf_event_initialize(); + perf_event_attr_initialize(PERF_COUNT_HW_CACHE_MISSES); + perf_event_initialize_read_format(); /* Test runs until the callback setup() tells the test to stop. */ while (1) { -- 2.30.2