Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp572910rwd; Wed, 7 Jun 2023 04:14:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ633KPEdS/eKbthpOEipICW6mbIvtzSianhp7McxhnJSYypG3e2xZpk/6xUhk9/XWKes/yB X-Received: by 2002:a05:6830:1249:b0:6b2:9c7f:bcc5 with SMTP id s9-20020a056830124900b006b29c7fbcc5mr3847439otp.22.1686136467261; Wed, 07 Jun 2023 04:14:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686136467; cv=none; d=google.com; s=arc-20160816; b=BSQVzgAkx+mGIjkPAZDW+XFOeDQClZd2+Z6wlSBFTcalxLaeZTs0IKQ9vNEQPYZ7/5 /RqSSRxN4VnTUxhHBrDXcwpKX2ZnoDv9/3ADOVLNLrVU/QgxxbbQ2ch5OUSIKXcSlvDa JxStfLcegBbjqSn8tZoEMUwBAzLhVxsEbNFWCHD2N05R29LhEfFs9mkTec86F55Q2uOV oYlZ4cZhROVb3FZoQQ58HQAJf/ZAES2JLQsjB6TfgU1km9zxYYUkR6wyNfLkkH3cV4Nj XUyEVrkfOcV38Ctc9KItPbaD2BeAxA5/WezA+XszUe1YQ23YdzLFmDgxHo82UtTql3I7 ljsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=CaF8PzEF9e7LF8fr6u7QZMgwza+QflistAgrP9nL8qA=; b=jrglmZDl2TORCTCDoXqfRdWQ+1ORWYItT4VU6VJ1t6jCK+1MeMAjkjxsd96NOx6ye3 yaWRBfOUxF2oAwsau4HQXCfk2oXxHt3cVzHZQhqX3V4+O/p4f6ecUNcPuxmfE5zBBL14 GYYuH8GcpTwbtaB7VyMzyjbneDZ3mlYLwU2atBtDhDuReMz/G4UgPGU/KyMO9nS6cafo VVhh9gXsjgaFWoOfkaqrHBArxC2n9ADdaZCKhonXBV8bno4c8R7PnZb41+kpj876KW/f esXLwgGVS1Yx77z0RY2L4SsKASlmtOqXQzkfCtK/xUBTBT888mSdg0dMdcsqEBW/j1Cv dpWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="lmh6X/88"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=aiGs2NwC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y11-20020aa79aeb000000b00652a45240d5si8796624pfp.47.2023.06.07.04.14.14; Wed, 07 Jun 2023 04:14:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="lmh6X/88"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=aiGs2NwC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239886AbjFGKxS (ORCPT + 99 others); Wed, 7 Jun 2023 06:53:18 -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: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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/c45c06d4ae63a0714efbfa435c5a8f64a5f35b9b 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/resctrl/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 kernfs_node *kn) } } +static void rdtgroup_kn_get(struct rdtgroup *rdtgrp, struct kernfs_node *kn) +{ + atomic_inc(&rdtgrp->waitcount); + kernfs_break_active_protection(kn); +} + +static void rdtgroup_kn_put(struct rdtgroup *rdtgrp, struct kernfs_node *kn) +{ + if (atomic_dec_and_test(&rdtgrp->waitcount) && + (rdtgrp->flags & RDT_DELETED)) { + if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP || + rdtgrp->mode == 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 = kernfs_to_rdtgroup(kn); @@ -2312,8 +2332,7 @@ struct rdtgroup *rdtgroup_kn_lock_live(struct kernfs_node *kn) if (!rdtgrp) return NULL; - atomic_inc(&rdtgrp->waitcount); - kernfs_break_active_protection(kn); + rdtgroup_kn_get(rdtgrp, kn); mutex_lock(&rdtgroup_mutex); @@ -2332,17 +2351,7 @@ void rdtgroup_kn_unlock(struct kernfs_node *kn) return; mutex_unlock(&rdtgroup_mutex); - - if (atomic_dec_and_test(&rdtgrp->waitcount) && - (rdtgrp->flags & RDT_DELETED)) { - if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP || - rdtgrp->mode == 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); } static int mkdir_mondata_all(struct kernfs_node *parent_kn,