Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp17224lqp; Fri, 12 Apr 2024 09:17:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVZTfY4WmVFxkkBwLfG1psP5PVJbU9ZSPCGNc5u2sf6QoJGVohqyQJ/pRi4P8rn1fdlZ5eSap8uHyBfnLB98W3X5gaBb/7EPiDQb+Hb4w== X-Google-Smtp-Source: AGHT+IGPLQUEhubpND6ZSqYwsYnvpvi6AgaXgxypKGf9YwnrxwtyJppYivOLYvYyc1/XvkL7AP/Y X-Received: by 2002:a17:90b:b0c:b0:2a2:97ce:24f5 with SMTP id bf12-20020a17090b0b0c00b002a297ce24f5mr3202203pjb.35.1712938671562; Fri, 12 Apr 2024 09:17:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712938671; cv=pass; d=google.com; s=arc-20160816; b=cgWpVdZYqt3W/eXI5XUxRTlMNybwHaoqRZrz0W5I9IqkxaKYwQwCJimmdeuwpTPL4K PFWw3J7U0MGqFDrOX7Y60HcapM3V8zMXfGITYfMsl3vYY2ULuk42vBRLNLASLdGOB/EY KA7ynE+EWTRYC4EUY+hLPUnJ+sAEQaEOkzOUX6KZJpuhLnSwJLV1iCEtEFWohlLzaIJR wGB23hXCPYUQDPbEhBRLDBMAuQQeJpOYCcLM5KO7vaMYK+tRyLapag4rone9wBp8z75k LcWoMV7QpNQmoq3YwDkqNf3zRTnUHXVRo/aW2U1pNsiiWcjN/FiPCgYnlXHyzNjxI/8G 1HNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=sZzuBntDOU8t/oNdMokHfJunvKAYI2xcEShsn+LJiwY=; fh=QpfXcl1MWRNwK/PrSFDaf8vyLNOqSjtq+qtJ/l97qlo=; b=nrSmeyTFE7Yzuw675c8lt+DR6MqYkDHx6puWTPGaCBLSlDLmVGbHRnTrV38AN202Fw haiAeaZWOYn46rcn+2Mrb1nOs2CmAwS+iocQcQIaAZy31897e1JxDpWBey8akuLo2Kx8 pR9RAQW1P5P4X+Y0QtO5Wlhwz9Ak9zmzc5reD4ncAOIHCb4tpDa7dxxt67mzyM/HSeSv V/Ou3shAuRJYVgB6+i33bVZ3X52XIW5683x8bEMwg9naeCj8hUX82ul1SZPBXL2Nwink Y6+NjJdp4TkYalVP4vzw+2hWXhLbSI+xJuPYJX+nIoFJM83tppTLAhLx95GTkjLfNcY0 9UBg==; 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-143041-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143041-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id z135-20020a63338d000000b005dbec216167si3466096pgz.614.2024.04.12.09.17.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 09:17:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-143041-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; 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-143041-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143041-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 3E722281987 for ; Fri, 12 Apr 2024 16:17:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 834BD149DEC; Fri, 12 Apr 2024 16:16:49 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 80BAC14882F for ; Fri, 12 Apr 2024 16:16:45 +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=1712938608; cv=none; b=FVLpbP3icqSUqPvWuXuHAQ+dQKRw4cMAd7h13mb7D1i4QYRPwd29N/8Cl49TiPHdk8RmEgqpBbFzzPrrxaoMivhLh7Y3SOup/ttn8Wz1xyQ/c8UC8qxJouzM3iMgOM59PoTZTIIvJObQhdiXhvPqRU+o2/TEPRwn7exP9Io9MpM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712938608; c=relaxed/simple; bh=iT8fIFzg5vFMvUBl82Bb1L7n2kIu+6n9K237w+bQp8k=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EAmdXS42LT/hvi55u5uxt04jHVqkZXiumOh70ffjJP3CFCfL7NerFzpKuIpr7bVaLOX852YzMeJUYNdtnEtfqzQI+V0vx3whPKcfhVID8qUnu/HfkVnFsR7tJvXYKq3qbtaveOEQPJ3Xj+3QU8hkWEQL2kANqy/ZhAtkUhwQJ1k= 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 A4F4D339; Fri, 12 Apr 2024 09:17:13 -0700 (PDT) Received: from e133380.arm.com (e133380.arm.com [10.1.197.52]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ACECF3F64C; Fri, 12 Apr 2024 09:16:41 -0700 (PDT) Date: Fri, 12 Apr 2024 17:16:39 +0100 From: Dave Martin To: Reinette Chatre Cc: James Morse , x86@kernel.org, linux-kernel@vger.kernel.org, Fenghua Yu , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Babu Moger , shameerali.kolothum.thodi@huawei.com, D Scott Phillips OS , carl@os.amperecomputing.com, lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com, baolin.wang@linux.alibaba.com, Jamie Iles , Xin Hao , peternewman@google.com, dfustini@baylibre.com, amitsinght@marvell.com, David Hildenbrand , Rex Nie Subject: Re: [PATCH v1 03/31] x86/resctrl: Move ctrlval string parsing policy away from the arch code Message-ID: References: <20240321165106.31602-1-james.morse@arm.com> <20240321165106.31602-4-james.morse@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Apr 08, 2024 at 08:14:47PM -0700, Reinette Chatre wrote: > Hi James, > > On 3/21/2024 9:50 AM, James Morse wrote: > > The policy for parsing the configuration values as a string from > > user-space is specified by a function pointer the arch code specifies. > > > > These strings are part of resctrl's ABI, and the functions and their > > caller both live in the same file. Exporting the parsing functions and > > allowing the architecture to choose how a schema is parsed allows an > > architecture to get this wrong. > > > > Keep this all in the flesystem parts of resctrl. This should prevent any > > flesystem -> filesystem Noted, thanks. > > architecture's string-parsing behaviour from varying without core code > > changes. Use the fflags to spot caches and bandwidth resources, and use > > the appropriate helper. > > > > Signed-off-by: James Morse > > --- > > .. > > > @@ -195,6 +204,14 @@ int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s, > > return 0; > > } > > > > +static ctrlval_parser_t *get_parser(struct rdt_resource *res) > > +{ > > + if (res->fflags & RFTYPE_RES_CACHE) > > + return &parse_cbm; > > + else > > + return &parse_bw; > > +} > > This is borderline ... at minimum it expands what fflags means and how it > is intended to be used and that needs to be documented because it reads: > > * @fflags: flags to choose base and info files > > I am curious why you picked fflags instead of an explicit check against > rid? > > Reinette Is fflags already somewhat overloaded? There seem to be a mix of things that are independent Boolean flags, while other things seem mutually exclusive or enum-like. Do we expect RFTYPE_RES_CACHE | RFTYPE_RES_MB ever to make sense, as David points out? With MPAM, we could in theory have cache population control and egress memory bandwidth controls on a single interconnect component. If that would always be represented through resctrl as two components with the MB controls considered one level out from the CACHE controls, then I guess these control types remain mutually exclusive from resctrl's point of view. Allowing a single rdt_resource to sprout multiple control types looks more invasive in the code, even if it logically makes sense in terms of the hardware. (I'm guessing that may have already been ruled out? Apologies if I seem to be questioning things that were decided already. That's not my intention, and James will already have thought about this in any case...) Anyway, for this patch, there seem to be a couple of assumptions: a) get_parser() doesn't get called except for rdt_resources that represent resource controls (so, fflags = RFTYPE_RES_foo for some "foo", with no other flags set), and b) there are exactly two kinds of "foo", so whatever isn't a CACHE is a BW. These assumptions seem to hold today (?) But the semantics of fflags already look a bit complicated, so I can see why it might be best to avoid anything that may add more complexity. If the main aim is to avoid silly copy-paste errors when coding up resources for a new arch, would it make sense to go for a more low- tech approach and just bundle up related fields in a macro? E.g., something like: #define RDT_RESOURCE_MB_DEFAULTS \ .format_str = "%d=%*u", \ .fflags = RFTYPE_RES_MB, \ .parse_ctrlval = parse_bw #define RDT_RESOURCE_CACHE_DEFAULTS \ .format_str = "%d=%0*x", \ .fflags = RFTYPE_RES_CACHE, \ .parse_ctrlval = parse_cbm This isn't particularly pretty, but would at least help avoid accidents and reduce the amount of explicit boilerplate in the resource definitions. Thoughts? Cheers ---Dave