From: Xiaochen Shen <xiaochen.shen@intel.com>
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 [thread overview]
Message-ID: <1578500026-21152-1-git-send-email-xiaochen.shen@intel.com> (raw)
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 <xiaochen.shen@intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@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 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
next reply other threads:[~2020-01-08 15:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-08 16:13 Xiaochen Shen [this message]
2020-01-13 13:14 ` [tip: x86/cache] x86/resctrl: Do not reconfigure exiting tasks tip-bot2 for Xiaochen Shen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1578500026-21152-1-git-send-email-xiaochen.shen@intel.com \
--to=xiaochen.shen@intel.com \
--cc=bp@alien8.de \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pei.p.jia@intel.com \
--cc=reinette.chatre@intel.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).