Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3934598ybl; Mon, 13 Jan 2020 05:16:20 -0800 (PST) X-Google-Smtp-Source: APXvYqws7nRUdngRqJ6NwnqQ8ilSfuHmM8yINSeR7CuUZ54hTtds8pzP78LfO4LyO5PFzXve0pfL X-Received: by 2002:aca:55cc:: with SMTP id j195mr12730609oib.22.1578921380114; Mon, 13 Jan 2020 05:16:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578921380; cv=none; d=google.com; s=arc-20160816; b=ZxdrFU909JbAOFWB42d2JnjuySuvvr8TxSfozjKxls4dSrp3R1ecADLxn9Q+boF3HR Y+aUj7SQSzE6DWdF14of4ZtHJvnIsGFcdlDb+s4GHizW1QfwRTstKxTWLarJmvshMmF9 /FlULcloRqb0XFWyWowZDtVwJpgajQ2hl43YtkwaEIojE8qRGdd3/hTWT/8jMQVIqkQh siNNUwh1Hppy0+iDjljBNVR+K0NcUAS6en1/Gx8X6VSQh95DoSmLAM9iRieT832bAfnO VB8cjQzcw1KVjPThieUeJaZLUUnW5iPiDPXmA7K9Q4d3r/TrmGSROwb0OYTLkGOeiofL PeaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=YdaDfnzztcKQPUFJnEeU4N4qpFHkZxX19G/Spry4hzg=; b=v36j615N/hSYXEdTL6VYaLhyT6D4cY7PZE5VUDqC/eCHGwAQ29/6OWIlwRfTqxHix4 fePLK00FugXdY3dFZ3BbGT0tDNwvh8mE5JVJs596EWw9SJnTdwvIiGskBmoPMAn7C1WK i1fTNz6muamAHlq4xnA0o17gjhg+RM43YCOvA80VByvSAQI0puKBRsBBh1o3p+dcXjsH 7RFhJuH1Ic8BZ48pbel4QK1Lb2Ig4o9F2FjZ4wSrAGtqqkl+ZsmxqdLyhkDfskBiS2lx XVp1mP4EFiZrMCAx1SikLHL8WQfAIC+SVfSOFXsEcEdxi6b96lbmVvtFzgdw4LF3kv73 0lcw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k19si6602212otr.52.2020.01.13.05.16.06; Mon, 13 Jan 2020 05:16:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726985AbgAMNPC (ORCPT + 99 others); Mon, 13 Jan 2020 08:15:02 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:38503 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726480AbgAMNPC (ORCPT ); Mon, 13 Jan 2020 08:15:02 -0500 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iqzYT-0000SU-1u; Mon, 13 Jan 2020 14:14:53 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id A42C51C18BC; Mon, 13 Jan 2020 14:14:52 +0100 (CET) Date: Mon, 13 Jan 2020 13:14:52 -0000 From: "tip-bot2 for Xiaochen Shen" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/cache] x86/resctrl: Do not reconfigure exiting tasks Cc: Xiaochen Shen , Borislav Petkov , Reinette Chatre , x86 , LKML In-Reply-To: <1578500026-21152-1-git-send-email-xiaochen.shen@intel.com> References: <1578500026-21152-1-git-send-email-xiaochen.shen@intel.com> MIME-Version: 1.0 Message-ID: <157892129247.19145.17833326698641017024.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org 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: dc433797c6f639e46824585bbf943578f13d54bf Gitweb: https://git.kernel.org/tip/dc433797c6f639e46824585bbf943578f13d54bf Author: Xiaochen Shen AuthorDate: Thu, 09 Jan 2020 00:13:46 +08:00 Committer: Borislav Petkov CommitterDate: Mon, 13 Jan 2020 14:10:21 +01:00 x86/resctrl: Do not reconfigure exiting tasks When writing a pid to file "tasks", a callback function move_myself() is queued to this task to be called when the task returns from kernel mode or exits. The purpose of move_myself() is to activate the newly assigned closid and/or rmid associated with this task. This activation is done by calling resctrl_sched_in() from move_myself(), the same function that is called when switching to this task. If this work is successfully queued but then the task enters PF_EXITING status (e.g., receiving signal SIGKILL, SIGTERM) prior to the execution of the callback move_myself(), move_myself() still calls resctrl_sched_in() since the task status is not currently considered. When a task is exiting, the data structure of the task itself will be freed soon. Calling resctrl_sched_in() to write the register that controls the task's resources is unnecessary and it implies extra performance overhead. Add check on task status in move_myself() and return immediately if the task is PF_EXITING. [ bp: Massage. ] Signed-off-by: Xiaochen Shen Signed-off-by: Borislav Petkov Reviewed-by: Reinette Chatre Link: https://lkml.kernel.org/r/1578500026-21152-1-git-send-email-xiaochen.shen@intel.com --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 2e3b06d..205925d 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -532,11 +532,15 @@ static void move_myself(struct callback_head *head) kfree(rdtgrp); } + if (unlikely(current->flags & PF_EXITING)) + goto out; + preempt_disable(); /* update PQR_ASSOC MSR to make resource group go into effect */ resctrl_sched_in(); preempt_enable(); +out: kfree(callback); }