public inbox for [email protected]
 help / color / mirror / Atom feed
From: Jens Axboe <[email protected]>
To: [email protected]
Cc: [email protected], [email protected],
	[email protected], [email protected], [email protected],
	Jens Axboe <[email protected]>
Subject: [PATCH 1/2] kernel: don't include PF_IO_WORKERs as part of same_thread_group()
Date: Thu, 25 Mar 2021 10:43:42 -0600	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

Don't pretend that the IO threads are in the same thread group, the only
case where that seems to be desired is for accounting purposes. Add
a special accounting function for that and make the scheduler side use it.

For signals and ptrace, we don't allow them to be treated as threads
anyway.

Reported-by: Stefan Metzmacher <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
---
 include/linux/sched/signal.h | 9 ++++++++-
 kernel/sched/cputime.c       | 2 +-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h
index 3f6a0fcaa10c..4f621e386abf 100644
--- a/include/linux/sched/signal.h
+++ b/include/linux/sched/signal.h
@@ -668,11 +668,18 @@ static inline bool thread_group_leader(struct task_struct *p)
 }
 
 static inline
-bool same_thread_group(struct task_struct *p1, struct task_struct *p2)
+bool same_thread_group_account(struct task_struct *p1, struct task_struct *p2)
 {
 	return p1->signal == p2->signal;
 }
 
+static inline
+bool same_thread_group(struct task_struct *p1, struct task_struct *p2)
+{
+	return same_thread_group_account(p1, p2) &&
+			!((p1->flags | p2->flags) & PF_IO_WORKER);
+}
+
 static inline struct task_struct *next_thread(const struct task_struct *p)
 {
 	return list_entry_rcu(p->thread_group.next,
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 5f611658eeab..625110cacc2a 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -307,7 +307,7 @@ void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times)
 	 * those pending times and rely only on values updated on tick or
 	 * other scheduler action.
 	 */
-	if (same_thread_group(current, tsk))
+	if (same_thread_group_account(current, tsk))
 		(void) task_sched_runtime(current);
 
 	rcu_read_lock();
-- 
2.31.0


  reply	other threads:[~2021-03-25 16:44 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-25 16:43 [PATCH 0/2] Don't show PF_IO_WORKER in /proc/<pid>/task/ Jens Axboe
2021-03-25 16:43 ` Jens Axboe [this message]
2021-03-25 16:43 ` [PATCH 2/2] proc: don't show PF_IO_WORKER threads as threads " Jens Axboe
2021-03-25 19:33 ` [PATCH 0/2] Don't show PF_IO_WORKER " Eric W. Biederman
2021-03-25 19:38   ` Linus Torvalds
2021-03-25 19:40     ` Jens Axboe
2021-03-25 19:42     ` Linus Torvalds
2021-03-25 19:46       ` Jens Axboe
2021-03-25 20:21         ` Eric W. Biederman
2021-03-25 20:40           ` Oleg Nesterov
2021-03-25 20:43             ` Jens Axboe
2021-03-25 20:48             ` Eric W. Biederman
2021-03-25 20:42           ` Jens Axboe
2021-03-25 20:12       ` Linus Torvalds
2021-03-25 20:40         ` Jens Axboe
2021-03-25 21:44           ` Jens Axboe
2021-03-25 21:57             ` Stefan Metzmacher
2021-03-26  0:11               ` Jens Axboe
2021-03-26 11:59                 ` Stefan Metzmacher
2021-04-01 14:40                   ` Stefan Metzmacher
2021-03-25 22:37             ` Linus Torvalds
2021-03-26  0:08               ` Jens Axboe
2021-03-25 20:43         ` Eric W. Biederman
2021-03-25 21:50           ` Jens Axboe
2021-03-25 20:44         ` Oleg Nesterov
2021-03-25 20:55           ` Eric W. Biederman
2021-03-25 21:20             ` Stefan Metzmacher
2021-03-25 21:48               ` Stefan Metzmacher
2021-03-25 19:40   ` Jens Axboe
2021-03-25 20:32     ` Oleg Nesterov

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 \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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