Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1902536rdb; Tue, 20 Feb 2024 10:15:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXIs8VcECm5mtAGxhL3QOEjzYWDMsuLXL+h/EYOyKoGrG6avBc+ghXHSTLzEcOxkhK8xFRQGQUKiasZf5fb5i1v5odjn045sGle/eoK/g== X-Google-Smtp-Source: AGHT+IG4l83EyHZDie5jy8XYh0xobuZpB3UklGpHjW3Cv3h8Y2By3OpNRDIViO4m4KGfrJ518Fx7 X-Received: by 2002:a17:906:528d:b0:a3e:cab2:f776 with SMTP id c13-20020a170906528d00b00a3ecab2f776mr4057070ejm.15.1708452900651; Tue, 20 Feb 2024 10:15:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708452900; cv=pass; d=google.com; s=arc-20160816; b=oCR8/B4biv1uNrIKOBorJ2s1RNOk4uDgAQjvQKwoq4VPkjDfXFq2OL1WwganOEw4kQ V93wyBUXaKqUbvVzmZAWxKVrwd8CvX6uMMipDjBnXWjdJryr60OMdHW96GyGHKWMYxt0 k2Hf9Whh6PVieu+xsoPYLkY32IAJNNZNKqXg3CWylB9djCCyQYTeom2ZO8XO8Cu0CPUf i+sziFQCGfyiatLTL0A2gx/np4Hflq82DLJ12VGM5epc6p1UEccAB0/DnojERFuJGCZK 5kpRaDKOgOaX+k1KrSNcBSGa8TTotgd+67GRjmepXDHGb6w+X429KmX3SwV1ZZ95gcVn BUCw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=3DwGY1HIMqlGtH7PSwKVaTgkFw5t2pIsy/NMWk8How8=; fh=JJNKnh+rM/T2q5SCuskpu1HOXgMHKQDcbKx0Fl5m8bc=; b=DKYeY0BxJdckp4TlMio8ykjRAJxrPJT6iTwbKTzSajyjnYUds2/34S4KCTe1BfgyWq cCbF1ewbjYfs6A/JR3ebNkwraGCM26I1qPWm0JSK943b6mqIPHaOugaj9jrvgJDhusbs pZ0KsrMl7LTcOjmICEnQOTdauASZT55CkgQcm4H6DK8jqRcNVGaz/bZO6FCmLSdSXNV4 ndZwZaqP7kvgy6wmlIjZSn766IWfzwVgdtd1JU3UJztdck188jKEkge/GcLbspIYieBG 4hwDkWzHmXQx29u2WfoXyGUgCMPoGo3B0cSSdIMjgs6WcoFQ4DMsBFez+mn/Ha7D1Cli aZuw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-73493-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73493-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id k16-20020a17090627d000b00a3e5de68f28si2677030ejc.855.2024.02.20.10.15.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 10:15:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73493-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-73493-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73493-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6800A1F21F67 for ; Tue, 20 Feb 2024 18:15:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4503D78667; Tue, 20 Feb 2024 18:14:52 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C157A762EC; Tue, 20 Feb 2024 18:14:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708452891; cv=none; b=q3H/pQDkC5UkczWeV2PRCXU9Hvy0NuWTlpFZ515r6BjJiUHUTvgZRQf1oSArPIZLDx6vJVMqXHsWYnqJGgB1+DaNWfqh8e6NZcELRuitsu4JIFombZ4HH7NujBSIRLmyKZiHgym8SfezL+7IPe79pomS3UuNJ0CnKuSTALwbWWs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708452891; c=relaxed/simple; bh=OEt8B9xfdY+l+e2STF/QjTUr6oMjKAKUVGw4y91xUL0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=N0TpMPE/ZdSfiprRKCUbABvc8nXPmlW2EC0ZNPXdxgkwVk+TJqMe1lRUtEkiEuaVlusqUG3H1+qmZsTrOUIfZOvmlRHnDfyMu9DH2oElQCa9DyCFvp5qz2+dJ739mcdYubGNg+KGlrGPyQ6SEkS+JCVixfjMj0fjHNVO7VAHiOo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ACC56FEC; Tue, 20 Feb 2024 10:15:27 -0800 (PST) Received: from [10.1.197.60] (eglon.cambridge.arm.com [10.1.197.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 408FB3F762; Tue, 20 Feb 2024 10:14:42 -0800 (PST) Message-ID: <5ad6f627-45c6-4c2b-b761-c74f0fe85f6c@arm.com> Date: Tue, 20 Feb 2024 18:14:40 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 06/17] x86/resctrl: Introduce interface to display number of ABMC counters Content-Language: en-GB To: Babu Moger , corbet@lwn.net, fenghua.yu@intel.com, reinette.chatre@intel.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com Cc: x86@kernel.org, hpa@zytor.com, paulmck@kernel.org, rdunlap@infradead.org, tj@kernel.org, peterz@infradead.org, yanjiewtw@gmail.com, kim.phillips@amd.com, lukas.bulwahn@gmail.com, seanjc@google.com, jmattson@google.com, leitao@debian.org, jpoimboe@kernel.org, rick.p.edgecombe@intel.com, kirill.shutemov@linux.intel.com, jithu.joseph@intel.com, kai.huang@intel.com, kan.liang@linux.intel.com, daniel.sneddon@linux.intel.com, pbonzini@redhat.com, sandipan.das@amd.com, ilpo.jarvinen@linux.intel.com, peternewman@google.com, maciej.wieczor-retman@intel.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, eranian@google.com References: <20231201005720.235639-1-babu.moger@amd.com> From: James Morse In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Babu, On 19/01/2024 18:22, Babu Moger wrote: > The ABMC feature provides an option to the user to pin (or assign) the > RMID to the hardware counter and monitor the bandwidth for a longer > duration. There are only a limited number of hardware counters. > > Provide the interface to display the number of ABMC counters supported. > diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c > index a6c336b6de61..fa492ea820f0 100644 > --- a/arch/x86/kernel/cpu/resctrl/monitor.c > +++ b/arch/x86/kernel/cpu/resctrl/monitor.c > @@ -823,6 +823,10 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r) > resctrl_file_fflags_init("mbm_local_bytes_config", > RFTYPE_MON_INFO | RFTYPE_RES_CACHE); > } > + > + if (rdt_cpu_has(X86_FEATURE_ABMC)) Please put this in a header and calling it something like resctrl_arch_has_assignable_counters(). These X86 feature definition macros aren't available on other architectures! > + resctrl_file_fflags_init("mbm_assignable_counters", > + RFTYPE_MON_INFO); > } > > l3_mon_evt_init(r); > diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c > index 3e233251e7ed..53be5cd1c28e 100644 > --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c > +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c > @@ -811,6 +811,17 @@ static int rdtgroup_rmid_show(struct kernfs_open_file *of, > return ret; > } > > +static int rdtgroup_mbm_assignable_counters_show(struct kernfs_open_file *of, > + struct seq_file *s, void *v) > +{ > + struct rdt_resource *r = of->kn->parent->priv; > + struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r); (After the move out to /fs/ the resctrl_to_arch_res() macro is private to the arch code. Needing to do this when providing a value to user-space is the indication that the value should be in struct rdt_resource instead!) > + seq_printf(s, "%d\n", hw_res->mbm_assignable_counters); > + > + return 0; > +} > + > #ifdef CONFIG_PROC_CPU_RESCTRL > > /* Thanks, James