From nobody Sun Feb 8 14:57:26 2026 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E3A611CAE for ; Mon, 4 Mar 2024 06:52:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709535179; cv=none; b=d98eXMfZzZIFglga/rHY0XRRRnWTcIhsj+XD5ZMruX405cCTFlXD9U9t4RdKk+/zuJe74aoZvkFY5UG9hyEZp5e6bsxno1YUOIIfasmemEFyJggJdphm10Un0gI6oMWDGE47ldOKyUwE9RmWFme5A+OQgczg02gt0Rwcvu3gBvI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709535179; c=relaxed/simple; bh=MA0DxG8bRrDPES7N5MFpH/L+LhBYNxe9zPtGQO6dSek=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b/rmX/qSCaTf6zbRwPibTRbIrNlIHq33M2iB4aAwfMph+3rFe3xnILNt5iLILXSQp+C+ehKfNX769jOWnohXIAvrm/b6qUCVXowRxwzq57vPml7PpJENUZmg+hQ/XD6WIzjR+DFWBDO5PXvcfsUWJMJ3HRbzsXSKl4R3+jutFGM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com; spf=pass smtp.mailfrom=shopee.com; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b=ATPZWgAh; arc=none smtp.client-ip=209.85.210.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shopee.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b="ATPZWgAh" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-6de3141f041so2581359b3a.0 for ; Sun, 03 Mar 2024 22:52:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopee.com; s=shopee.com; t=1709535177; x=1710139977; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gfomRvH8ULPC5eeUCXao/k9/srrLuDto1N2pX2K7uu0=; b=ATPZWgAh3Zoh1ScahENVK7XPylXN2KJ0nzdLbOKo7Tu4+Sn5FvteqW06nvepzL9eYZ i5sZN8IK0JBgnBpDUbaoeSEh4cCedm/uC0kEHX0Sr8xB3xQiT+VAAQ+A8GolC4WdfoZL cRLHEAXPGLit/nggWrsxb1QBLHCiyXEmZToeAIVcNFpw/bf58CkXTQVLJ+Sgiz930xGP gNvcZNY/NneSA5Bh/YGefLsMwYFc1fYpqz7zPv0gRhKAwVu8MbX26vXdfl4AFSnaur5K vJcT6hS3dp+tiqnDwUmoa1D462+zyUo6+zXaFT70ryGEdneD1CFWDQFY6kXxYlnRYCRm JVpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709535177; x=1710139977; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gfomRvH8ULPC5eeUCXao/k9/srrLuDto1N2pX2K7uu0=; b=Bk9L5ybyK+U5yevNcuZMQa8/pgUbewnCiZGylJ2pmvSrAzyftwCxIs+vMHulUqrryc ohiiyHbWI88EZOmu7T5r4CI6+Qcd7WBvKWDUPB/eOqL5jvC99MhPqMK/a+IA46Ol7bmQ G7Ia+gio9H14vWODD5CvglVX8XCa4/yNflMjQoFY/W3y07VILWxrKTvgE3Z2ZFH8sGNV ppCdSfTRGpVDtvbiu9j9ZNqOeVQcb2PSqB5/tidtxkh+dzlRusreRTAV3DpQVypg5jkX pZcQcVjtYSPPhXOrcuu4GakNToHxDUrkUYPyjPJWASQ+b4JYLCQyNfxxhVUYLLRhxOCC arqA== X-Forwarded-Encrypted: i=1; AJvYcCUFJhA1Ebp4hrIng76GstPxiq+k+zCRvPk75iWjqIOkRihzG2Cjyv/LTvn4y1IWuXSwzQj2xxDZbRzzy3UB7I/3C6WiUejXv9XOGNNp X-Gm-Message-State: AOJu0YzwJwRf8k8FJn1/MLuCY6yzIBZkyg42y51ZTsVdEHXL7SyaP3R2 20h5r5yI3fsI934VubY0P7V2rwX2wTK/PEDTrdnHzuMKBm0UvVa5fXGoCLuUF9E= X-Google-Smtp-Source: AGHT+IHq01yhFcxM+Ys+burCeKb/S2tHJ4gorNVk0H6QB7243MKMLmukDxVUF1XzQYYwFrfXJt3Fdw== X-Received: by 2002:a05:6a00:9294:b0:6e5:56b5:606a with SMTP id jw20-20020a056a00929400b006e556b5606amr9211060pfb.11.1709535176943; Sun, 03 Mar 2024 22:52:56 -0800 (PST) Received: from seacloud.vm ([143.92.64.20]) by smtp.gmail.com with ESMTPSA id o26-20020a056a001b5a00b006e4766d31bcsm6554740pfv.184.2024.03.03.22.52.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Mar 2024 22:52:56 -0800 (PST) From: Haifeng Xu To: reinette.chatre@intel.com, james.morse@arm.com Cc: fenghua.yu@intel.com, babu.moger@amd.com, peternewman@google.com, x86@kernel.org, linux-kernel@vger.kernel.org, Haifeng Xu Subject: [PATCH v4 1/2] x86/resctrl: Rename pseudo_lock_event.h to trace.h Date: Mon, 4 Mar 2024 14:52:35 +0800 Message-Id: <20240304065236.281877-2-haifeng.xu@shopee.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240304065236.281877-1-haifeng.xu@shopee.com> References: <20240304065236.281877-1-haifeng.xu@shopee.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now only pseudo-locking part uses tracepoints to do event tracking, but other parts of resctrl may need new tracepoints. It is unnecessary to create separate header files and define CREATE_TRACE_POINTS in different c files which fragments the resctrl tracing. Therefore, give the resctrl tracepoint header file a generic name to support its use for tracepoints that are not specific to pseudo-locking. No functional change. Signed-off-by: Haifeng Xu Suggested-by: Reinette Chatre --- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 2 +- .../x86/kernel/cpu/resctrl/{pseudo_lock_event.h =3D> trace.h} | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) rename arch/x86/kernel/cpu/resctrl/{pseudo_lock_event.h =3D> trace.h} (88%) diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c b/arch/x86/kernel/cp= u/resctrl/pseudo_lock.c index 884b88e25141..492c8e28c4ce 100644 --- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c +++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c @@ -31,7 +31,7 @@ #include "internal.h" =20 #define CREATE_TRACE_POINTS -#include "pseudo_lock_event.h" +#include "trace.h" =20 /* * The bits needed to disable hardware prefetching varies based on the diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock_event.h b/arch/x86/ker= nel/cpu/resctrl/trace.h similarity index 88% rename from arch/x86/kernel/cpu/resctrl/pseudo_lock_event.h rename to arch/x86/kernel/cpu/resctrl/trace.h index 428ebbd4270b..ed5c66b8ab0b 100644 --- a/arch/x86/kernel/cpu/resctrl/pseudo_lock_event.h +++ b/arch/x86/kernel/cpu/resctrl/trace.h @@ -2,7 +2,7 @@ #undef TRACE_SYSTEM #define TRACE_SYSTEM resctrl =20 -#if !defined(_TRACE_PSEUDO_LOCK_H) || defined(TRACE_HEADER_MULTI_READ) +#if !defined(_TRACE_RESCTRL_H) || defined(TRACE_HEADER_MULTI_READ) #define _TRACE_PSEUDO_LOCK_H =20 #include @@ -35,9 +35,9 @@ TRACE_EVENT(pseudo_lock_l3, TP_printk("hits=3D%llu miss=3D%llu", __entry->l3_hits, __entry->l3_miss)); =20 -#endif /* _TRACE_PSEUDO_LOCK_H */ +#endif /* _TRACE_RESCTRL_H */ =20 #undef TRACE_INCLUDE_PATH #define TRACE_INCLUDE_PATH . -#define TRACE_INCLUDE_FILE pseudo_lock_event +#define TRACE_INCLUDE_FILE trace #include --=20 2.25.1 From nobody Sun Feb 8 14:57:26 2026 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0CC0125B7 for ; Mon, 4 Mar 2024 06:53:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709535182; cv=none; b=g89wCxREDMHRgBoNF4aw4axE90jcrnl09QCAkgXGsOyRHE0uymYgNR3nNejA3ffKSz0W3LI/OEC/nT0WzskgOHRcLqFyY8U7ktLtYmXTPQ5fTKBJc9uHoll4VAWZPYnSdViY6BwQ0UzmF0UQezUI8CuWFOV4NcrsxdehocyjDiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709535182; c=relaxed/simple; bh=Aey2x/rUGCSiWROvyFZizw1j1BOYN6tFEPW7hjLZbQk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hoTFk/YNyeLjCe2QI2A8TASmP/DCuOtBcrQwdbDJnkEeo8RfEeFLjkZDAKOcSdw/RhrGMYeaLT3sV3JFY60a8OX9Z95c049eK4RvUcbm3v+mFbIEdo71mxRSKICz7j2ofVZRxPiPKMQjBX4PAKEM7Sz7HAIrK+AAVjZAjq37xwE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com; spf=pass smtp.mailfrom=shopee.com; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b=AjeIpzkT; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shopee.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b="AjeIpzkT" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-6de3141f041so2581390b3a.0 for ; Sun, 03 Mar 2024 22:53:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopee.com; s=shopee.com; t=1709535180; x=1710139980; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cc+akXbOIA4nrC6QlU/+zOxMss2MQbVBlurGWMYKMdo=; b=AjeIpzkTb2mlqnQbqzK6u/2sY+2/kotjmgwAaBhFl/eISXEOHD0FJ3txGyhHs9Nsrg 9YmuO346/TVlf5Xe3CiiHdhe00RrRrrZRrK+9oKWmQY2dVHEN2pVkZeDdUKFN0GMy2/w 9HuXIzlHbjtR44sSR8dp7udYz96ZY7gCV+3oyVcpzjFdeHlxeGBWD3uBZVZMiDcFPvz/ 0It0+u0N2aKydhU3tl+QDuFd05KNmZ6LVtA0bTvQoyCH5d82kpjCwLxruKqxFKHVu9DU KhVKcASNY3ucsADBAcdUr1Y7IuqYcw4IUH63ibk6LfqFVyBIL5c+WxnwRQodaU/t+JOc suuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709535180; x=1710139980; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cc+akXbOIA4nrC6QlU/+zOxMss2MQbVBlurGWMYKMdo=; b=DqFFYYdQEgtxWfq0pilluwcwbwsVyrWb2ufbwqkY8ULREmktuFrqOtSOl4sJlZdceM FDz3RfvjzCj4B4ofGZnUGqc8wngl+Um4/MsjbvgvKjIkyVd/wgDbrW6mTXkB32SLKk0h comrNRP3X04cQE/O6f6aQMcChWpOjFs9qBMk2RtIeS4FDpjpFITmBQzGviTaXH+ZH7JB u25ZxdbpdPpcbxrw5L6Dn9d44gvnDmximpEZYpPGyTgj4JDisY3KWsoawDxHgHaTRn3B 6kFQs3Nyj3sFpkdAbr77Xlhrst5dBiicYovwJ6LRN0TD4uA9uhYx6MkzlgXhTSLngQWY 0Aeg== X-Forwarded-Encrypted: i=1; AJvYcCWy/l6WLGixr4XD/L2N7dIkVHkg/dkBORTkWSXhttAYFqlBFXAY4JTey7UMHFanZ1SndUqWdjkDbc6gUgcFebvhUHRzhbP7gYKjlyDo X-Gm-Message-State: AOJu0YwmGCh6Ot89Zi80X493C85TBlidgTlmPS1V4mHmDkqbGxKjPoR2 c46SrokEnZCuhT2KcNOsW0Mds6swHqOmA0Sv4gAMSpA227dsMCmgWAOD7dpO/gI= X-Google-Smtp-Source: AGHT+IHLiExh9oImBud++i4oYMjchZ/644AAxWBTcSKZ+4o7NBR6WesFQRVGwl8UjoUBs5lFmde/Dg== X-Received: by 2002:a05:6a20:8f0c:b0:1a1:4e6b:185f with SMTP id b12-20020a056a208f0c00b001a14e6b185fmr1709400pzk.25.1709535180207; Sun, 03 Mar 2024 22:53:00 -0800 (PST) Received: from seacloud.vm ([143.92.64.20]) by smtp.gmail.com with ESMTPSA id o26-20020a056a001b5a00b006e4766d31bcsm6554740pfv.184.2024.03.03.22.52.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Mar 2024 22:53:00 -0800 (PST) From: Haifeng Xu To: reinette.chatre@intel.com, james.morse@arm.com Cc: fenghua.yu@intel.com, babu.moger@amd.com, peternewman@google.com, x86@kernel.org, linux-kernel@vger.kernel.org, Haifeng Xu Subject: [PATCH v4 2/2] x86/resctrl: Add tracepoint for llc_occupancy tracking Date: Mon, 4 Mar 2024 14:52:36 +0800 Message-Id: <20240304065236.281877-3-haifeng.xu@shopee.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240304065236.281877-1-haifeng.xu@shopee.com> References: <20240304065236.281877-1-haifeng.xu@shopee.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In our production environment, after removing monitor groups, those unused RMIDs get stuck in the limbo list forever because their llc_occupancy are always larger than the threshold. But the unused RMIDs can be successfully freed by turning up the threshold. In order to know how much the threshold should be, perf can be used to acquire the llc_occupancy of RMIDs in each rdt domain. Instead of using perf tool to track llc_occupancy and filter the log manually, it is more convenient for users to use tracepoint to do this work. So add a new tracepoint that shows the llc_occupancy of busy RMIDs when scanning the limbo list. Signed-off-by: Haifeng Xu Suggested-by: Reinette Chatre Suggested-by: James Morse --- Documentation/arch/x86/resctrl.rst | 8 ++++++++ arch/x86/kernel/cpu/resctrl/monitor.c | 9 +++++++++ arch/x86/kernel/cpu/resctrl/trace.h | 16 ++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index a6279df64a9d..dd3507dc765c 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -478,6 +478,14 @@ if non-contiguous 1s value is supported. On a system w= ith a 20-bit mask each bit represents 5% of the capacity of the cache. You could partition the cache into four equal parts with masks: 0x1f, 0x3e0, 0x7c00, 0xf8000. =20 +Tracepoint - mon_llc_occupancy_limbo +------------------------------------ +This tracepoint gives you the precise occupancy values for a subset of RMID +that are not immediately available for allocation. This can't be relied on +to produce output every second, it may be necessary to attempt to create an +empty monitor group to force an update. Output may only be produced if cre= ation +of a control or monitor group fails. + Memory bandwidth Allocation and monitoring =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index c34a35ec0f03..60b6a29a9e29 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -24,6 +24,7 @@ #include =20 #include "internal.h" +#include "trace.h" =20 /** * struct rmid_entry - dirty tracking for all RMID. @@ -354,6 +355,14 @@ void __check_limbo(struct rdt_domain *d, bool force_fr= ee) rmid_dirty =3D true; } else { rmid_dirty =3D (val >=3D resctrl_rmid_realloc_threshold); + + /* x86's CLOSID and RMID are independent numbers, so the entry's + * closid is a invalid CLOSID. But on arm64, the RMID value isn't + * a unique number for each CLOSID. It's necessary to track both + * CLOSID and RMID because there may be dependencies between each + * other on some architectures. + */ + trace_mon_llc_occupancy_limbo(entry->closid, entry->rmid, d->id, val); } =20 if (force_free || !rmid_dirty) { diff --git a/arch/x86/kernel/cpu/resctrl/trace.h b/arch/x86/kernel/cpu/resc= trl/trace.h index ed5c66b8ab0b..b310b4985b94 100644 --- a/arch/x86/kernel/cpu/resctrl/trace.h +++ b/arch/x86/kernel/cpu/resctrl/trace.h @@ -35,6 +35,22 @@ TRACE_EVENT(pseudo_lock_l3, TP_printk("hits=3D%llu miss=3D%llu", __entry->l3_hits, __entry->l3_miss)); =20 +TRACE_EVENT(mon_llc_occupancy_limbo, + TP_PROTO(u32 ctrl_hw_id, u32 mon_hw_id, int domain_id, u64 llc_occupa= ncy_bytes), + TP_ARGS(ctrl_hw_id, mon_hw_id, domain_id, llc_occupancy_bytes), + TP_STRUCT__entry(__field(u32, ctrl_hw_id) + __field(u32, mon_hw_id) + __field(int, domain_id) + __field(u64, llc_occupancy_bytes)), + TP_fast_assign(__entry->ctrl_hw_id =3D ctrl_hw_id; + __entry->mon_hw_id =3D mon_hw_id; + __entry->domain_id =3D domain_id; + __entry->llc_occupancy_bytes =3D llc_occupancy_bytes;), + TP_printk("ctrl_hw_id=3D%u mon_hw_id=3D%u domain_d=3D%d llc_occupancy= _bytes=3D%llu", + __entry->ctrl_hw_id, __entry->mon_hw_id, __entry->domain_id, + __entry->llc_occupancy_bytes) + ); + #endif /* _TRACE_RESCTRL_H */ =20 #undef TRACE_INCLUDE_PATH --=20 2.25.1