Received: by 2002:ab2:1c04:0:b0:1f7:53ba:1ebe with SMTP id f4csp42739lqg; Fri, 26 Apr 2024 08:17:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUF0Ucnlt+fH9iwvfrGkD3QUIBWUXTsqef/OJOvBqGr69WZugfF6OgciLwRpT8dOqryenUmE5GeQoiEBixpzuzhD29/tTJ9dmea3alUJg== X-Google-Smtp-Source: AGHT+IH3+fbj6g6mCDkWcmbJsP9qW2nbLiGrluoFUOHv0XM19yU80fiw/5UMa04r5NMdcHl1Wac6 X-Received: by 2002:a17:90a:5ac3:b0:2a2:97cd:9c94 with SMTP id n61-20020a17090a5ac300b002a297cd9c94mr3397774pji.40.1714144659777; Fri, 26 Apr 2024 08:17:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714144659; cv=pass; d=google.com; s=arc-20160816; b=0lgq/8gVuW4s37azRnfad5tTDb4Maxn/CqlOmn3/G9IOQEOG86vy4G0UjpeGOXSuwU 0docrBCabo5hKt3GgftL7fnarVGJifAm48ezKWeGi5GgBDJYBYdTPs9ZInFfFk8aiu/p R15HICX8kFi+TXO1DDrKwF2W8CEUEVloYDdGjchpqPIzms+AP0rRp3MvjhxOYzhnzPt6 tKGlHiSlhOiwIAijQusjiZlG7Fd15jrGYbJ+nw2vibU+MJACrSik9dTIO+L41BT2qRnM A3+9Ktgjigq6N8tazO8kWYlLYZ1EIOpAIMFekCAGzh79OnWMMWAADzxGKZZranpH990p jZXw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=FGT9UrnqOKESZPtpGTHdDi1ZYLB9nG6QtTlR8jI0kwA=; fh=Vo4MxA0u7CmSKYL/GjcyKHwusyvU+nKR43bqJem+vcY=; b=s95dS+Lngwpu4bt8bRoREUFkjkhj7xPzdgmRRmcl+Dgy6vP5G01HY/m3OGRzRx/AtA GJOdO5kDsMB8RQZisrWt8KSPOg5z9I2PnxRSRzhW5G5XwdKjGi58sxYVo3KH7Vd46utS 7vBfk1Edla559iEwmpK90sM+EP2jMGldnfhASUzmYl3/Vpd8bQF8HULKOLpormljZyG5 momnAJ729o+rEK1peoOAqcQWuws7xFDi4tMXY5nmOH4p1YgEbgBs/UnF9W1ExNCuO3ao U+mFWpQRWjMTcGmW9+nNMA0+IoMsQ975nfQ08qDYSRZ4bILpxWNVk1cIp5Uet42gB3Cl T+Fw==; 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-160221-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160221-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id me4-20020a17090b17c400b002ab379b4c55si4344904pjb.11.2024.04.26.08.17.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 08:17:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160221-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::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-160221-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160221-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D3810B21484 for ; Fri, 26 Apr 2024 15:10:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DC16A14D6E5; Fri, 26 Apr 2024 15:09:29 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DACCE14D433 for ; Fri, 26 Apr 2024 15:09:27 +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=1714144169; cv=none; b=Bt+m+oj/9xm3+qNAeFockWYfjOAm0MuRh+Bd+4JHnleEW/QDFWxzM+OMBYXUPaiQ4lH+diWso9bCt2nZjI2b8ivsxZdGcRFDiYtlB/A3sgK5UX7KGKP2TScPrVN9mUdBMK2EGM1KPyA9cdF0xFe62zv45tC/pTN+xbBk/NhjS3w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714144169; c=relaxed/simple; bh=HbqD7eD5D3lOAmxZJi41qbuG3jApi5xHkc7gcwXKeMQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KTY/zoeU2SrWW6h6Yc7JxN5ZupjW5t1G3cpg+JElvGKrNGVrBKfnyKDfyq8fR5CRIPQfNLSkXFXqL5HIjaajPXQYh9xaFfEK3w9b6ojdz3KBnGTfc11M8ZrVq9tDGg0l15WvgQ/bOaHBeK3F+W8F2kg1nWAskUxB9CF2w3acpu4= 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 5FA281688; Fri, 26 Apr 2024 08:09:55 -0700 (PDT) Received: from e133380.cambridge.arm.com (e133380.arm.com [10.1.197.52]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7BE0F3F73F; Fri, 26 Apr 2024 08:09:24 -0700 (PDT) From: Dave Martin To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: James Morse , Fenghua Yu , Reinette Chatre , 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, "Shaopeng Tan (Fujitsu)" , baolin.wang@linux.alibaba.com, Jamie Iles , Xin Hao , Peter Newman , dfustini@baylibre.com, amitsinght@marvell.com, David Hildenbrand , Rex Nie Subject: [PATCH v2 05/35] x86/resctrl: Remove rdtgroup from update_cpu_closid_rmid() Date: Fri, 26 Apr 2024 16:08:34 +0100 Message-Id: <20240426150904.8854-5-Dave.Martin@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240426150904.8854-1-Dave.Martin@arm.com> References: <20240426150537.8094-1-Dave.Martin@arm.com> <20240426150904.8854-1-Dave.Martin@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: James Morse update_cpu_closid_rmid() takes a struct rdtgroup as an argument, which it uses to update the local CPUs default pqr values. This is a problem once the resctrl parts move out to /fs/, as the arch code cannot poke around inside struct rdtgroup. Rename update_cpu_closid_rmid() as resctrl_arch_sync_cpus_defaults() to be used as the target of an IPI, and pass the effective CLOSID and RMID in a new struct. Signed-off-by: James Morse Signed-off-by: Dave Martin --- Changes in v2: * To clarify the meanings of the new helper and struct: Rename resctrl_arch_sync_cpu_default() to resctrl_arch_sync_cpu_closid_rmid(); Rename struct resctrl_cpu_sync to struct resctrl_cpu_defaults; Flesh out the comment block in . No functional change. --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 17 +++++++++++++---- include/linux/resctrl.h | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 98c051ac848d..871b59c2c886 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -341,13 +341,13 @@ static int rdtgroup_cpus_show(struct kernfs_open_file *of, * from update_closid_rmid() is protected against __switch_to() because * preemption is disabled. */ -static void update_cpu_closid_rmid(void *info) +void resctrl_arch_sync_cpu_closid_rmid(void *info) { - struct rdtgroup *r = info; + struct resctrl_cpu_defaults *r = info; if (r) { this_cpu_write(pqr_state.default_closid, r->closid); - this_cpu_write(pqr_state.default_rmid, r->mon.rmid); + this_cpu_write(pqr_state.default_rmid, r->rmid); } /* @@ -362,11 +362,20 @@ static void update_cpu_closid_rmid(void *info) * Update the PGR_ASSOC MSR on all cpus in @cpu_mask, * * Per task closids/rmids must have been set up before calling this function. + * @r may be NULL. */ static void update_closid_rmid(const struct cpumask *cpu_mask, struct rdtgroup *r) { - on_each_cpu_mask(cpu_mask, update_cpu_closid_rmid, r, 1); + struct resctrl_cpu_defaults defaults, *p = NULL; + + if (r) { + defaults.closid = r->closid; + defaults.rmid = r->mon.rmid; + p = &defaults; + } + + on_each_cpu_mask(cpu_mask, resctrl_arch_sync_cpu_closid_rmid, p, 1); } static int cpus_mon_write(struct rdtgroup *rdtgrp, cpumask_var_t newmask, diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 6e87bc95f5ea..bf736ec22f71 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -220,6 +220,28 @@ struct resctrl_schema { u32 num_closid; }; +struct resctrl_cpu_defaults { + u32 closid; + u32 rmid; +}; + +/** + * resctrl_arch_sync_cpu_closid_rmid() - Refresh this CPU's CLOSID and RMID. + * Call via IPI. + * @info: If non-NULL, a pointer to a struct resctrl_cpu_defaults + * specifying the new CLOSID and RMID for tasks in the default + * resctrl ctrl and mon group when running on this CPU. If NULL, + * this CPU is not re-assigned to a different default group. + * + * Propagates reassignment of CPUs and/or tasks to different resctrl groups + * when requested by the resctrl core code. + * + * This function records the per-cpu defaults specified by @info (if any), + * and then reconfigures the CPU's hardware CLOSID and RMID for subsequent + * execution based on @current, in the same way as during a task switch. + */ +void resctrl_arch_sync_cpu_closid_rmid(void *info); + /* The number of closid supported by this resource regardless of CDP */ u32 resctrl_arch_get_num_closid(struct rdt_resource *r); int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid); -- 2.34.1