Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4690372rdb; Tue, 12 Dec 2023 06:53:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQe5uHyExCzgvdfLkjjceGg4cXBvtJWTAbGk/E6z17R4BPIA8fYvJhDwMiXiI9cs8e6zil X-Received: by 2002:a17:903:22c7:b0:1d0:6ffe:1e7f with SMTP id y7-20020a17090322c700b001d06ffe1e7fmr3110696plg.98.1702392827915; Tue, 12 Dec 2023 06:53:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702392827; cv=none; d=google.com; s=arc-20160816; b=BzmAmU02+dDRXe/sLf0YwbZ5Y6ZTp3cIijO9a30sfsOJqXcTgZen8vPOt+1MAd2y59 Yr6BDez81bhDNexXWrWRC0JapG64CHYLt6AmOHIgpx1AtnwMh0bB8y6wVpzcFd93xq9G Vn7xWrGjTt5goYPBJeh6RBC6+ZDRg3MEV8OWYI6NGibQOa2bLq1x1jKHVRt1kNDaFULr 92AOHFTTwM5Bt7n6XO64W7kJRE7kNZ229jEbQ/v/A2Hfj5aY5NH7kuqEuQfX84r7bjfE NzRQOXzVdzi4r1sUOxPPCa39qErIoX6bUz1OELX31ZamwSnJbHIHhBh54QjKgfStFz1c 1pzQ== 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=7P/aUBAzLwnIqxyJafmMKx5DpnAfqZ0Sl4o0lTQflt4=; fh=/pACME0x50g4vorTSG5vEdNwgU981WFvy8LGbk4DPBk=; b=UMjfK/94zPHtHk34LKQ8A3U6HdgJxU/ES6rKpcTdDEt+b1qOJM8Yz9i9u+jYGSPnIB 7PcBHua/lVABx5cuf1MKacWMaAqhPlhR9eq2RaVlIUCUdt5Az8+NsNPUME5oNypItpns OXU/OrGh4hDI8IRQdjG/ygjeK5iyJEywu1y6js2Xq78JEMiJQainw5pPKU3NtP4akQ7O BElMJzNa/GSTsGO0L9I0mK+bePjizGq+7JjZ+LMdXU4655N3SFDayUQIoiB9DZYOFGbq vi3crBPbYwNqL8v4xVMuYSD6+33ru15BodmGVYAwi8L8/DGx4oSsJrmvZVNXG2mO8rDl 8gIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=APKBhwtq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id e8-20020a170902744800b001d0b78ea7a2si7901509plt.516.2023.12.12.06.53.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 06:53:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=APKBhwtq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 7A1B18026DA1; Tue, 12 Dec 2023 06:53:45 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376998AbjLLOxT (ORCPT + 99 others); Tue, 12 Dec 2023 09:53:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376969AbjLLOxS (ORCPT ); Tue, 12 Dec 2023 09:53:18 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3784EB; Tue, 12 Dec 2023 06:53:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702392803; x=1733928803; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Qo202yzdW9FjkslWfPMmIkndsLvL+V5BLV3JStn7eyw=; b=APKBhwtqjI+K6C+Q6mkeiVnM/jaC47UDxSp3G/yoQe73ubc26YAjLRuT az7ZQTqaa9MP8EwdDtWKMssKBWT00ghyXzrbAWXnMDePFOY1gd4VUF/IW wyhLRVmQJ+plx2NFoX2DQsqkdlsdv83jhlREFAda9mZlsxv59zA5P4v8n EoTfv/Ab2BDC8F+dIIo6E7PDeU9AdYGgHxDJel7Pk6gJBiDUl2kVwxZaw Ny5XQh9qn4DAE/Wq0oqCc8g1OvE8MJ//wfLZWR9EKeOz+zxQGrioRJure oaJSehEYVZU+V+JOAEr4QNhhK/yUEHprsobLoUbev4oDn0p54AzAVvseL Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10922"; a="481014340" X-IronPort-AV: E=Sophos;i="6.04,270,1695711600"; d="scan'208";a="481014340" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Dec 2023 06:53:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,270,1695711600"; d="scan'208";a="15023957" Received: from mdabrows-mobl1.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.5.65]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Dec 2023 06:53:21 -0800 From: Maciej Wieczor-Retman To: Fenghua Yu , Reinette Chatre , Shuah Khan Cc: ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 2/4] selftests/resctrl: Add helpers for the non-contiguous test Date: Tue, 12 Dec 2023 15:52:52 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email 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 (pete.vger.email [0.0.0.0]); Tue, 12 Dec 2023 06:53:45 -0800 (PST) The CAT non-contiguous selftests have to read the file responsible for reporting support of non-contiguous CBMs in Intel CAT. Then the test compares if that information matches what is reported by CPUID output. Add a generic helper function to read a chosen functionality support information. Signed-off-by: Maciej Wieczor-Retman --- Changelog v2: - Added this patch. tools/testing/selftests/resctrl/resctrl.h | 1 + tools/testing/selftests/resctrl/resctrlfs.c | 25 +++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 739e16d08a7b..8f72d94b9cbe 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -161,6 +161,7 @@ unsigned int count_contiguous_bits(unsigned long val, unsigned int *start); int get_full_cbm(const char *cache_type, unsigned long *mask); int get_mask_no_shareable(const char *cache_type, unsigned long *mask); int get_cache_size(int cpu_no, const char *cache_type, unsigned long *cache_size); +int read_info_res_file(const char *resource, const char *filename); void ctrlc_handler(int signum, siginfo_t *info, void *ptr); int signal_handler_register(void); void signal_handler_unregister(void); diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 0e97036a64b8..70333440ff2f 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -249,6 +249,31 @@ static int get_bit_mask(const char *filename, unsigned long *mask) return 0; } +int read_info_res_file(const char *resource, const char *filename) +{ + char file_path[PATH_MAX]; + FILE *fp; + int ret; + + snprintf(file_path, sizeof(file_path), "%s/%s/%s", INFO_PATH, resource, + filename); + + fp = fopen(file_path, "r"); + if (!fp) { + perror("Error in opening sparse_masks file\n"); + return -1; + } + + if (fscanf(fp, "%u", &ret) <= 0) { + perror("Could not get sparse_masks contents\n"); + fclose(fp); + return -1; + } + + fclose(fp); + return ret; +} + /* * create_bit_mask- Create bit mask from start, len pair * @start: LSB of the mask -- 2.43.0