From nobody Mon Feb 9 00:02:30 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4A3FC7EE23 for ; Wed, 7 Jun 2023 10:53:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239875AbjFGKxT (ORCPT ); Wed, 7 Jun 2023 06:53:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239993AbjFGKxL (ORCPT ); Wed, 7 Jun 2023 06:53:11 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5025A1FC4; Wed, 7 Jun 2023 03:52:49 -0700 (PDT) Date: Wed, 07 Jun 2023 10:52:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686135128; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CaF8PzEF9e7LF8fr6u7QZMgwza+QflistAgrP9nL8qA=; b=lmh6X/88g1M+sYvlHUfTIKzfhXYEi8Kl9IguegOjysqxJjUh8uo2sRlnPJflSfbFF4CsMH 5+Lv3sSsxepYIo09QjNlyRfX6EScZSTgsUiy6Pq/wjIDJcr+6aB4BFBIKGyzNGoOo5yC3k odXZuM9WaDfrZLbrNeK5V9vol33SrN4Jh8FCxJHWhqZOpxZjaxlWO8OxvMgALMF+JrGhPc TE2s79Mef/q+CE4ocgOzcVcb6GlSruvMZVGlMjotDMAHNoLycX135bxLKrNiNwDPRZYvHK nB9cBsQm0cYN/cD7PDc1tsSBjqI56If4orfwyxHMhAgQLy2ANLmwQ9i+kedLgA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686135128; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CaF8PzEF9e7LF8fr6u7QZMgwza+QflistAgrP9nL8qA=; b=aiGs2NwCXiX6U9Ryx6M6W2bdGou1eLNgCDacVHU9pfRMYTPbt7jUIlEPtuFBiNq2CYnhjf DUgkdVhSZy81fjAg== From: "tip-bot2 for Peter Newman" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/cache] x86/resctrl: Factor rdtgroup lock for multi-file ops Cc: Peter Newman , "Borislav Petkov (AMD)" , Reinette Chatre , Babu Moger , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230419125015.693566-2-peternewman@google.com> References: <20230419125015.693566-2-peternewman@google.com> MIME-Version: 1.0 Message-ID: <168613512832.404.10934762057759711815.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/cache branch of tip: Commit-ID: c45c06d4ae63a0714efbfa435c5a8f64a5f35b9b Gitweb: https://git.kernel.org/tip/c45c06d4ae63a0714efbfa435c5a8f64a= 5f35b9b Author: Peter Newman AuthorDate: Wed, 19 Apr 2023 14:50:13 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Wed, 07 Jun 2023 12:15:18 +02:00 x86/resctrl: Factor rdtgroup lock for multi-file ops rdtgroup_kn_lock_live() can only release a kernfs reference for a single file before waiting on the rdtgroup_mutex, limiting its usefulness for operations on multiple files, such as rename. Factor the work needed to respectively break and unbreak active protection on an individual file into rdtgroup_kn_{get,put}(). No functional change. Signed-off-by: Peter Newman Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Reinette Chatre Tested-by: Babu Moger Link: https://lore.kernel.org/r/20230419125015.693566-2-peternewman@google.= com --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 35 +++++++++++++++---------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 61cdd9b..653d258 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2305,6 +2305,26 @@ static struct rdtgroup *kernfs_to_rdtgroup(struct ke= rnfs_node *kn) } } =20 +static void rdtgroup_kn_get(struct rdtgroup *rdtgrp, struct kernfs_node *k= n) +{ + atomic_inc(&rdtgrp->waitcount); + kernfs_break_active_protection(kn); +} + +static void rdtgroup_kn_put(struct rdtgroup *rdtgrp, struct kernfs_node *k= n) +{ + if (atomic_dec_and_test(&rdtgrp->waitcount) && + (rdtgrp->flags & RDT_DELETED)) { + if (rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKSETUP || + rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKED) + rdtgroup_pseudo_lock_remove(rdtgrp); + kernfs_unbreak_active_protection(kn); + rdtgroup_remove(rdtgrp); + } else { + kernfs_unbreak_active_protection(kn); + } +} + struct rdtgroup *rdtgroup_kn_lock_live(struct kernfs_node *kn) { struct rdtgroup *rdtgrp =3D kernfs_to_rdtgroup(kn); @@ -2312,8 +2332,7 @@ struct rdtgroup *rdtgroup_kn_lock_live(struct kernfs_= node *kn) if (!rdtgrp) return NULL; =20 - atomic_inc(&rdtgrp->waitcount); - kernfs_break_active_protection(kn); + rdtgroup_kn_get(rdtgrp, kn); =20 mutex_lock(&rdtgroup_mutex); =20 @@ -2332,17 +2351,7 @@ void rdtgroup_kn_unlock(struct kernfs_node *kn) return; =20 mutex_unlock(&rdtgroup_mutex); - - if (atomic_dec_and_test(&rdtgrp->waitcount) && - (rdtgrp->flags & RDT_DELETED)) { - if (rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKSETUP || - rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKED) - rdtgroup_pseudo_lock_remove(rdtgrp); - kernfs_unbreak_active_protection(kn); - rdtgroup_remove(rdtgrp); - } else { - kernfs_unbreak_active_protection(kn); - } + rdtgroup_kn_put(rdtgrp, kn); } =20 static int mkdir_mondata_all(struct kernfs_node *parent_kn,