Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp926876ybl; Wed, 8 Jan 2020 08:09:25 -0800 (PST) X-Google-Smtp-Source: APXvYqxXJpCqIFbYdCZwmN7c/Df5IICylOrb5suss3PXVAjpzpkIi8u6XrgZ8tMMHxRN+rPKnvO9 X-Received: by 2002:a05:6830:109a:: with SMTP id y26mr4331957oto.227.1578499765844; Wed, 08 Jan 2020 08:09:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578499765; cv=none; d=google.com; s=arc-20160816; b=ly645XRPkm60yygSYb3jprEJptrCsJpba6YBgXmdl5GT178SJ+sb7jORDbmoVyqoxQ PrUKAKkeWSrSKpkvM8u8vILoew2rsSE2AUSpI6gDrRAdQa/myURTk1821OBSWp2+ucVc OUzdqwiX28HA9ejLDf6vMiV6OV7KG6t3g0DUwjUJJ7EONy6hGKjIne99iLzB5X+GWYp7 WhLmzWxoXx7lXb2iyur5VZTHVFvI4JTkxM06Xu6ymz0IaMi3tRcKHi4DoLNK6UL84bwC 169wGMFqswChQ/+gabAgEzm+QE8J36i0f0cFxLD1FscmLEsQ1sIE5e4PIS1AEEChne+Q nsHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=3m0oUz0IrQpsO/JsrB3kIfcnhO9xdLGhoMXxPRfSyXs=; b=VtHVVvUIwLqkSqLBL6I+S5Qr2R6RBATf3r9WmGUTtpEAGLX4PVFhuEIB3SUa/24/wj FPw611J48xQ5aqQKdNqec49uMX2eDG+h/WJ7v1eWLsboO5NmgchLEQrjv/9W64mj9eQN VK8mq3FwxALJ4s5y6ab1oIz5B3kDbYV54o96cPZIYkmWSDs1rsrM+M3vQMXYeUAEkUUR gay33IbjotYtMxBAoIV+bsIzIYBqvOMt2K+oZ5rrhRtGdaAz8jtqbZs0YEUkAf5VaofU aTe2aeRWz/OvIuEa2BjQOSEYgZBjLImy85gRtIeDh8CtXlaTlarfkwyZbJgxzQQfYQc/ 6uww== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r1si2062310otq.298.2020.01.08.08.08.56; Wed, 08 Jan 2020 08:09:25 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728904AbgAHPpD (ORCPT + 99 others); Wed, 8 Jan 2020 10:45:03 -0500 Received: from mga12.intel.com ([192.55.52.136]:42398 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726757AbgAHPpC (ORCPT ); Wed, 8 Jan 2020 10:45:02 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jan 2020 07:45:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,410,1571727600"; d="scan'208";a="246375213" Received: from xshen14-linux.bj.intel.com ([10.238.155.105]) by fmsmga004.fm.intel.com with ESMTP; 08 Jan 2020 07:44:59 -0800 From: Xiaochen Shen To: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, tony.luck@intel.com, fenghua.yu@intel.com, reinette.chatre@intel.com Cc: x86@kernel.org, linux-kernel@vger.kernel.org, pei.p.jia@intel.com, xiaochen.shen@intel.com Subject: [PATCH] x86/resctrl: Take care of PF_EXITING task in callback Date: Thu, 9 Jan 2020 00:13:46 +0800 Message-Id: <1578500026-21152-1-git-send-email-xiaochen.shen@intel.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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() then move_myself() still calls resctrl_sched_in() since the task status is not currently considered. When a task is exiting then the data structure of the task itself will be freed soon, calling resctrl_sched_in() to write the register that control's 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. Signed-off-by: Xiaochen Shen Reviewed-by: Reinette Chatre --- 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 2e3b06d6bbc6..205925d802d8 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); } -- 1.8.3.1