Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2136110rdb; Mon, 20 Nov 2023 03:08:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IE6cRzGQjFD9zlnTQBxFStB9ULDQfAtd5NbyoLuV+KKeyaaEiBsxazMqMsHoAFGUGyur4Zl X-Received: by 2002:a05:6a20:a11d:b0:187:d8d7:5f14 with SMTP id q29-20020a056a20a11d00b00187d8d75f14mr9341552pzk.39.1700478492036; Mon, 20 Nov 2023 03:08:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700478492; cv=none; d=google.com; s=arc-20160816; b=tDEih7PHhEF46MIK5WkUXZWtmLgOIvOiDWfWetemmE+1RPhXveERspZsGLZqBXfNr0 ID9N2w/+hupTxXfqvg/HP0of6gcy/AeX8p9ZBbYq/aNTzI0mO9zMUdmdk2z+amcbVH1a RHBm6QDri75ND2QXumeKiF+ViVultx/edJGn1yjcN8DOTN+bP3rlxG5TE4l1pgbWJkuo IDT3jtpPH5014s7XHR6ZdPIN77VI9jAJTougEYpBY8fvdSKJcEOgu3+3NTjzUwDYOXPD DZgcD7DJ1jtXbyJSmqevsNCRBwpwPvPOalEBBAG0HuESkhZ3b37pkE0au9EX+WP24omE 5w2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=ksT/tKiORBnBwI35//2FTiV7BcI7AFyfHkVN1wkjmKE=; fh=Cfx77l24RvhHW8iGoyiEiVQ4QSE1ZJ84mIS8hOxJpD0=; b=P5P19vCcRSkYPvtHCxqg2zUowj+AD8GTUDf0+SUKSNzlssLtUMxcXHMIIMOxCIq5tY uWqapKn6bkNMXWffwXTSbtZmW17qDssEDEDpqZetd71dRp2XVBgeDFY3NGemVxF7NQh7 xLwZu22o/XBFclcy4tYMsGEO0zWi4/+DeVhNhZxRTuvr71h4kUGYRr9lwngYWm4t73Y+ na3gj0tD7OIroNaEIryRxS4M36lMxICGkpe/yi9FGMIfXuvLkmaPJoAJnlW5v3CwBSJh uun0R8JcxSEVDDz471927VwMAGnWsQ6WFobjdj394szv1WlVqalnwev81Gi6qReE7F7W b/7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=l4XK5BYn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id m6-20020a656a06000000b00588fa0def2asi8340419pgu.778.2023.11.20.03.08.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 03:08:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=l4XK5BYn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id E348580B1226; Mon, 20 Nov 2023 03:08:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233134AbjKTLH4 (ORCPT + 99 others); Mon, 20 Nov 2023 06:07:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233227AbjKTLHt (ORCPT ); Mon, 20 Nov 2023 06:07:49 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54C0713E; Mon, 20 Nov 2023 03:07:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700478452; x=1732014452; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=+ENk/qI3aAhzoQvbdmTZGZGTHTjCD4Wz6VPEXQlwA/w=; b=l4XK5BYnxTgtAXfX1oiLZyqqJ5+g5cRc8YCYACJRU6rG8FGgyKiq9ZYy RZcHfwNUBWRpmT8/iM/AndcXUw13DTfZ5sd93gL1a+afLmknx83B2Bm34 jSfMprWOmh09dcNNwiASpq/aCxAip6FV31tQrY7PuZ+t1ACvSOt5ZZHOw PYTvAugqE3W/Nxkixk1TuM1DTZTQfnGJISqFpglTvzHvoaD+4RWDNxjCH q9x3RvDZzBg13vBdJj8XEma0LyK+d7wl5/3KQmYDj4J+vIVByge76a6EM kIWzmX4w6VD+s3dHKRLHqH9lfivVP5h0r6Z41sIOpqEMNdPLpG8MVj/lH w==; X-IronPort-AV: E=McAfee;i="6600,9927,10899"; a="477807962" X-IronPort-AV: E=Sophos;i="6.04,213,1695711600"; d="scan'208";a="477807962" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 03:07:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10899"; a="766247695" X-IronPort-AV: E=Sophos;i="6.04,213,1695711600"; d="scan'208";a="766247695" Received: from akeren-mobl.ger.corp.intel.com ([10.252.40.26]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 03:07:29 -0800 Date: Mon, 20 Nov 2023 13:07:26 +0200 (EET) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: =?ISO-8859-15?Q?Maciej_Wiecz=F3r-Retman?= cc: Fenghua Yu , Reinette Chatre , Shuah Khan , LKML , linux-kselftest@vger.kernel.org Subject: Re: [PATCH] selftests/resctrl: Add non-contiguous CBMs CAT test In-Reply-To: Message-ID: <1b7e4a12-f636-4722-a9c7-76f99c723ab@linux.intel.com> References: <20231109112847.432687-1-maciej.wieczor-retman@intel.com> <879955f-d2d4-017-6694-5a031ec7f2@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1441281498-1700478451=:2032" X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 20 Nov 2023 03:08:09 -0800 (PST) This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1441281498-1700478451=:2032 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8BIT On Mon, 20 Nov 2023, Maciej Wiecz?r-Retman wrote: > On 2023-11-17 at 14:55:54 +0200, Ilpo J?rvinen wrote: > >On Thu, 9 Nov 2023, Maciej Wieczor-Retman wrote: > > > >> Non-contiguous CBM support for Intel CAT has been merged into the kernel > >> with Commit 0e3cd31f6e90 ("x86/resctrl: Enable non-contiguous CBMs in > >> Intel CAT") but there is no selftest that would validate if this feature > >> works correctly. > >> > >> The selftest needs to verify if writing non-contiguous CBMs to the > >> schemata file behaves as expected in comparison to the information about > >> non-contiguous CBMs support. > >> > >> Add tests for both L2 and L3 CAT to verify if the return values > >> generated by writing non-contiguous CBMs don't contradict the > >> reported non-contiguous support information. > >> @@ -342,6 +342,87 @@ static int cat_run_test(const struct resctrl_test *test, const struct user_param > >> return ret; > >> } > >> > >> +static int noncont_cat_run_test(const struct resctrl_test *test, > >> + const struct user_params *uparams) > >> +{ > >> + unsigned long full_cache_mask, cont_mask, noncont_mask; > >> + unsigned int eax, ebx, ecx, edx, ret, sparse_masks; > >> + char res_path[PATH_MAX]; > >> + char schemata[64]; > >> + int bit_center; > >> + FILE *fp; > >> + > >> + /* Check to compare sparse_masks content to cpuid output. */ > >> + snprintf(res_path, sizeof(res_path), "%s/%s/%s", INFO_PATH, > >> + test->resource, "sparse_masks"); > >> + > >> + fp = fopen(res_path, "r"); > >> + if (!fp) { > >> + perror("# Error in opening file\n"); > >> + return errno; > >> + } > >> + > >> + if (fscanf(fp, "%u", &sparse_masks) <= 0) { > >> + perror("Could not get sparse_masks contents\n"); > >> + fclose(fp); > >> + return -1; > >> + } > >> + > >> + fclose(fp); > > > >Add a function to do this conversion into resctrlfs.c. > > By conversion do you mean the above calls to fopen, fscanf and fclose? Or did > you mean the below __cpuid_count? Since you mention making get_cache_level > non-static I assume the first is the case but just wanted to confirm. You convert the 0/1 read from a resctrl related file into (unsigned) int here. Create a helper function for that into resctrlfs.c that returns int (to be able to return also errors) and just call it from here with the feature string you're interested in, the helper should deal with the rest. > >> + return !ret == !sparse_masks; > >> +} > >> + > >> +static bool noncont_cat_feature_check(const struct resctrl_test *test) > >> +{ > >> + char res_path[PATH_MAX]; > >> + struct stat statbuf; > >> + > >> + snprintf(res_path, sizeof(res_path), "%s/%s/%s", INFO_PATH, > >> + test->resource, "sparse_masks"); > >> + > >> + if (stat(res_path, &statbuf)) > >> + return false; > > > >This looks generic enough that validate_resctrl_feature_request() should > >be somehow adapted to cover also these cases. Perhaps it would be best to > >just split validate_resctrl_feature_request() into multiple functions. > > As in conditionally call a function inside validate_resctrl_feature_request() > that would check for the existance of a particular file that would indicate if a > feature is supported or not? I meant that validate_resctrl_feature_request() should probably be split into 2 or 3 functions, each taking different arguments and one them checks mon_features, another presence of sparse_masks file (any file on the level actually). > Does implementing it as a new entry in resctrl_test struct that would hold the > desired filename seem reasonable? I'm not convinced it's useful to put it into the test structure. A simple function that calls into one or more of the functions provided in resctrlfs.c seems enough for me. > Or would it be better to pass it as a new function argument (similiar to > how "const char *feature" is used now)? I'd create a separate function in resctrlfs.c instead (IMO, a new function should be also done for those callers which currently use const char *feature). -- i. --8323329-1441281498-1700478451=:2032--