Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp22908pxb; Fri, 15 Jan 2021 04:58:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJxeifRUP0A+B1n0GRqX0tCZMToHPjQ5rcm/RwzuIvyxyqaJyxobd7jL0/LhkQMXJ/soQg5X X-Received: by 2002:a17:906:a106:: with SMTP id t6mr8942081ejy.63.1610715484718; Fri, 15 Jan 2021 04:58:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610715484; cv=none; d=google.com; s=arc-20160816; b=Bv/1bNorb2Su0PaDHaOfizux2JJcc2wr6ALIkB2DvzYN0kSQrCoyntxlv0mzOalR0o ziSCBDWNj6xPqoqrWY9gy4KZCUC8giwxoW4oPzFCoouHl6qJHOeW/+WwQj4hTMdaR2au mARGjKlr4Di3OF8IRXkdsujybpnD3K03Gdm5C5XHF6JRX3sj7RuobBwmuCP6hbme8aNm b8o57u5P6DXt605cAh2BGxz0/YKr1ZQI7G2sYBUBPtECIDEhtAp2qvsFkhG17XicSRC6 8/vo+I3WCske//LQHzcfPl0KZpYRFxJVZWbTwVjjj70B7CTgNsaz85b71Vvuqu/wTbQ+ Cqww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=k7cHms9keb3Tjy73oD6AWmkPnlJbU6LpaJNHCc1kgaA=; b=fR0Hv3j+xSA1YwCgMlVdx0hgd0c24GHYEwI2KYZBtQPwxGoSqKfP8wpqdQf9XkbC6P Z87jpMV27nItSLVqL5BLRWGfeVWPL3xwVQ+/QrjrmyyMfBwNvGq/2tQkPGUf/XWwCvSO ZcRHCexEcJ+MWYEtQBaEPYuUh/xXdExMVV7mKoh8dPIQiumPgeIIwvsMleSLBogANWnx mQw0NFRNtTeWO3euTwmDidaG62cUbQXBQoPyzyyhLrh2an4G//1GuLNESBdRYD2EOQY9 U2d3XsDXAr1zXK3MPU4vLYa0OmvtU9Yb/Rd0gRVaZKI3tegDQbrMA10iWMPMXB8JWwlV 9dQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=12ht4WfZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qc8si3661435ejb.346.2021.01.15.04.57.41; Fri, 15 Jan 2021 04:58:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=12ht4WfZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387723AbhAOM4F (ORCPT + 99 others); Fri, 15 Jan 2021 07:56:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:41940 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387552AbhAOMe7 (ORCPT ); Fri, 15 Jan 2021 07:34:59 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6F0F0235F9; Fri, 15 Jan 2021 12:34:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610714058; bh=Yc2Cx4Cs0jYWHCPDiwsTGl/dGXIh1X6W1zdM4ZZuelE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=12ht4WfZMc9WWzaKrkpgG4d/zf5Uw1dVLN4wrxpiDpf5lNo22L4qJvEg6nYehJBJj H3NVWxisjOx9O/7iGwYu8bnrWdF34Xpm7dyW363RwdsRgcHHHGtRfdL8cpwa0pY/do 3+s6Bm+svA83zZS+Dolo1h8tjBRmfpLlvMSBvymo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shakeel Butt , Fenghua Yu , Reinette Chatre , Borislav Petkov , Tony Luck Subject: [PATCH 5.4 28/62] x86/resctrl: Dont move a task to the same resource group Date: Fri, 15 Jan 2021 13:27:50 +0100 Message-Id: <20210115121959.764359870@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210115121958.391610178@linuxfoundation.org> References: <20210115121958.391610178@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fenghua Yu commit a0195f314a25582b38993bf30db11c300f4f4611 upstream Shakeel Butt reported in [1] that a user can request a task to be moved to a resource group even if the task is already in the group. It just wastes time to do the move operation which could be costly to send IPI to a different CPU. Add a sanity check to ensure that the move operation only happens when the task is not already in the resource group. [1] https://lore.kernel.org/lkml/CALvZod7E9zzHwenzf7objzGKsdBmVwTgEJ0nPgs0LUFU3SN5Pw@mail.gmail.com/ Fixes: e02737d5b826 ("x86/intel_rdt: Add tasks files") Reported-by: Shakeel Butt Signed-off-by: Fenghua Yu Signed-off-by: Reinette Chatre Signed-off-by: Borislav Petkov Reviewed-by: Tony Luck Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/962ede65d8e95be793cb61102cca37f7bb018e66.1608243147.git.reinette.chatre@intel.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -546,6 +546,13 @@ static void update_task_closid_rmid(stru static int __rdtgroup_move_task(struct task_struct *tsk, struct rdtgroup *rdtgrp) { + /* If the task is already in rdtgrp, no need to move the task. */ + if ((rdtgrp->type == RDTCTRL_GROUP && tsk->closid == rdtgrp->closid && + tsk->rmid == rdtgrp->mon.rmid) || + (rdtgrp->type == RDTMON_GROUP && tsk->rmid == rdtgrp->mon.rmid && + tsk->closid == rdtgrp->mon.parent->closid)) + return 0; + /* * Set the task's closid/rmid before the PQR_ASSOC MSR can be * updated by them.