All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Jens Axboe <axboe@kernel.dk>, Alasdair Kergon <agk@redhat.com>,
	Mike Snitzer <snitzer@redhat.com>,
	dm-devel@redhat.com, "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Felipe Balbi <balbi@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Tejun Heo <tj@kernel.org>, Zefan Li <lizefan.x@bytedance.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Jason Wessel <jason.wessel@windriver.com>,
	Daniel Thompson <daniel.thompson@linaro.org>,
	Douglas Anderson <dianders@chromium.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Pavel Machek <pavel@ucw.cz>, Will Deacon <will@kernel.org>,
	Waiman Long <longman@redhat.com>,
	Boqun Feng <boqun.feng@gmail.com>,
	Oleg Nesterov <oleg@redhat.com>,
	Davidlohr Bueso <dave@stgolabs.net>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Josh Triplett <josh@joshtriplett.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	Joel Fernandes <joel@joelfernandes.org>,
	John Stultz <john.stultz@linaro.org>,
	Stephen Boyd <sboyd@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
	netdev@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, cgroups@vger.kernel.org,
	kgdb-bugreport@lists.sourceforge.net,
	linux-perf-users@vger.kernel.org, linux-pm@vger.kernel.org,
	rcu@vger.kernel.org, linux-mm@kvack.org, kvm@vger.kernel.org
Subject: [PATCH 4/6] sched: Add get_current_state()
Date: Wed, 02 Jun 2021 15:12:29 +0200	[thread overview]
Message-ID: <20210602133040.461908001@infradead.org> (raw)
In-Reply-To: <20210602131225.336600299@infradead.org>

Remove yet another few p->state accesses.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 block/blk-mq.c        |    2 +-
 include/linux/sched.h |    2 ++
 kernel/freezer.c      |    2 +-
 kernel/sched/core.c   |    6 +++---
 4 files changed, 7 insertions(+), 5 deletions(-)

--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -3891,7 +3891,7 @@ int blk_poll(struct request_queue *q, bl
 
 	hctx->poll_considered++;
 
-	state = current->state;
+	state = get_current_state();
 	do {
 		int ret;
 
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -212,6 +212,8 @@ struct task_group;
 
 #endif
 
+#define get_current_state()	READ_ONCE(current->state)
+
 /* Task command name length: */
 #define TASK_COMM_LEN			16
 
--- a/kernel/freezer.c
+++ b/kernel/freezer.c
@@ -58,7 +58,7 @@ bool __refrigerator(bool check_kthr_stop
 	/* Hmm, should we be allowed to suspend when there are realtime
 	   processes around? */
 	bool was_frozen = false;
-	long save = current->state;
+	unsigned int save = get_current_state();
 
 	pr_debug("%s entered refrigerator\n", current->comm);
 
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -8273,15 +8273,15 @@ static inline int preempt_count_equals(i
 
 void __might_sleep(const char *file, int line, int preempt_offset)
 {
+	unsigned int state = get_current_state();
 	/*
 	 * Blocking primitives will set (and therefore destroy) current->state,
 	 * since we will exit with TASK_RUNNING make sure we enter with it,
 	 * otherwise we will destroy state.
 	 */
-	WARN_ONCE(current->state != TASK_RUNNING && current->task_state_change,
+	WARN_ONCE(state != TASK_RUNNING && current->task_state_change,
 			"do not call blocking ops when !TASK_RUNNING; "
-			"state=%lx set at [<%p>] %pS\n",
-			current->state,
+			"state=%x set at [<%p>] %pS\n", state,
 			(void *)current->task_state_change,
 			(void *)current->task_state_change);
 



WARNING: multiple messages have this Message-ID
From: Peter Zijlstra <peterz@infradead.org>
To: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>,  Mel Gorman <mgorman@suse.de>,
	Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>, Pavel Machek <pavel@ucw.cz>,
	Mike Snitzer <snitzer@redhat.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	kgdb-bugreport@lists.sourceforge.net,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	Oleg Nesterov <oleg@redhat.com>,
	linux-mm@kvack.org, dm-devel@redhat.com,
	Paolo Bonzini <pbonzini@redhat.com>,
	Zefan Li <lizefan.x@bytedance.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Joel Fernandes <joel@joelfernandes.org>,
	netdev@vger.kernel.org, Jiri Olsa <jolsa@redhat.com>,
	Alasdair Kergon <agk@redhat.com>,
	Daniel Thompson <daniel.thompson@linaro.org>,
	Davidlohr Bueso <dave@stgolabs.net>,
	kvm@vger.kernel.org, Will Deacon <will@kernel.org>,
	cgroups@vger.kernel.org, x86@kernel.org,
	Jakub Kicinski <kuba@kernel.org>,
	John Stultz <john.stultz@linaro.org>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	linux-pm@vger.kernel.org, Boqun Feng <boqun.feng@gmail.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Josh Triplett <josh@joshtriplett.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Borislav Petkov <bp@alien8.de>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Waiman Long <longman@redhat.com>,
	Namhyung Kim <namhyung@kernel.org>, Jens Axboe <axboe@kernel.dk>,
	Felipe Balbi <balbi@kernel.org>, Stephen Boyd <sboyd@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Douglas Anderson <dianders@chromium.org>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Jason Wessel <jason.wessel@windriver.com>,
	Tejun Heo <tj@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	rcu@vger.kernel.org, "David S. Miller" <davem@davemloft.net>
Subject: [dm-devel] [PATCH 4/6] sched: Add get_current_state()
Date: Wed, 02 Jun 2021 15:12:29 +0200	[thread overview]
Message-ID: <20210602133040.461908001@infradead.org> (raw)
In-Reply-To: <20210602131225.336600299@infradead.org>

Remove yet another few p->state accesses.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 block/blk-mq.c        |    2 +-
 include/linux/sched.h |    2 ++
 kernel/freezer.c      |    2 +-
 kernel/sched/core.c   |    6 +++---
 4 files changed, 7 insertions(+), 5 deletions(-)

--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -3891,7 +3891,7 @@ int blk_poll(struct request_queue *q, bl
 
 	hctx->poll_considered++;
 
-	state = current->state;
+	state = get_current_state();
 	do {
 		int ret;
 
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -212,6 +212,8 @@ struct task_group;
 
 #endif
 
+#define get_current_state()	READ_ONCE(current->state)
+
 /* Task command name length: */
 #define TASK_COMM_LEN			16
 
--- a/kernel/freezer.c
+++ b/kernel/freezer.c
@@ -58,7 +58,7 @@ bool __refrigerator(bool check_kthr_stop
 	/* Hmm, should we be allowed to suspend when there are realtime
 	   processes around? */
 	bool was_frozen = false;
-	long save = current->state;
+	unsigned int save = get_current_state();
 
 	pr_debug("%s entered refrigerator\n", current->comm);
 
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -8273,15 +8273,15 @@ static inline int preempt_count_equals(i
 
 void __might_sleep(const char *file, int line, int preempt_offset)
 {
+	unsigned int state = get_current_state();
 	/*
 	 * Blocking primitives will set (and therefore destroy) current->state,
 	 * since we will exit with TASK_RUNNING make sure we enter with it,
 	 * otherwise we will destroy state.
 	 */
-	WARN_ONCE(current->state != TASK_RUNNING && current->task_state_change,
+	WARN_ONCE(state != TASK_RUNNING && current->task_state_change,
 			"do not call blocking ops when !TASK_RUNNING; "
-			"state=%lx set at [<%p>] %pS\n",
-			current->state,
+			"state=%x set at [<%p>] %pS\n", state,
 			(void *)current->task_state_change,
 			(void *)current->task_state_change);
 


--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


  parent reply	other threads:[~2021-06-02 13:31 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02 13:12 [PATCH 0/6] sched: Cleanup task_struct::state Peter Zijlstra
2021-06-02 13:12 ` [dm-devel] " Peter Zijlstra
2021-06-02 13:12 ` [PATCH 1/6] sched: Unbreak wakeups Peter Zijlstra
2021-06-02 13:12   ` [dm-devel] " Peter Zijlstra
2021-06-02 13:58   ` Greg Kroah-Hartman
2021-06-02 13:58     ` [dm-devel] " Greg Kroah-Hartman
2021-06-02 14:47   ` Will Deacon
2021-06-02 14:47     ` [dm-devel] " Will Deacon
2021-06-02 19:43   ` Davidlohr Bueso
2021-06-02 19:43     ` [dm-devel] " Davidlohr Bueso
2021-06-02 13:12 ` [PATCH 2/6] sched: Introduce task_is_running() Peter Zijlstra
2021-06-02 13:12   ` [dm-devel] " Peter Zijlstra
2021-06-02 14:59   ` Will Deacon
2021-06-02 14:59     ` [dm-devel] " Will Deacon
2021-06-02 16:46     ` Peter Zijlstra
2021-06-02 16:46       ` [dm-devel] " Peter Zijlstra
2021-06-02 23:15   ` Davidlohr Bueso
2021-06-02 23:15     ` [dm-devel] " Davidlohr Bueso
2021-06-02 13:12 ` [PATCH 3/6] sched,perf,kvm: Fix preemption condition Peter Zijlstra
2021-06-02 13:12   ` [dm-devel] " Peter Zijlstra
2021-06-02 13:59   ` Mathieu Desnoyers
2021-06-02 13:59     ` [dm-devel] [PATCH 3/6] sched, perf, kvm: " Mathieu Desnoyers
2021-06-02 13:59     ` [PATCH 3/6] sched,perf,kvm: " Mathieu Desnoyers
2021-06-02 14:10     ` Peter Zijlstra
2021-06-02 14:10       ` [dm-devel] [PATCH 3/6] sched, perf, kvm: " Peter Zijlstra
2021-06-02 14:30       ` [PATCH 3/6] sched,perf,kvm: " Mark Rutland
2021-06-02 14:30         ` [dm-devel] [PATCH 3/6] sched, perf, kvm: " Mark Rutland
2021-06-02 14:15   ` [PATCH 3/6] sched,perf,kvm: " Mathieu Desnoyers
2021-06-02 14:15     ` [dm-devel] [PATCH 3/6] sched, perf, kvm: " Mathieu Desnoyers
2021-06-02 14:15     ` [PATCH 3/6] sched,perf,kvm: " Mathieu Desnoyers
2021-06-02 14:23     ` Peter Zijlstra
2021-06-02 14:23       ` [dm-devel] [PATCH 3/6] sched, perf, kvm: " Peter Zijlstra
2021-06-02 13:12 ` Peter Zijlstra [this message]
2021-06-02 13:12   ` [dm-devel] [PATCH 4/6] sched: Add get_current_state() Peter Zijlstra
2021-06-02 14:01   ` Mathieu Desnoyers
2021-06-02 14:01     ` [dm-devel] " Mathieu Desnoyers
2021-06-02 14:01     ` Mathieu Desnoyers
2021-06-02 14:12     ` Peter Zijlstra
2021-06-02 14:12       ` [dm-devel] " Peter Zijlstra
2021-06-02 15:02   ` Will Deacon
2021-06-02 15:02     ` [dm-devel] " Will Deacon
2021-06-02 13:12 ` [PATCH 5/6] sched,timer: Use __set_current_state() Peter Zijlstra
2021-06-02 13:12   ` [dm-devel] " Peter Zijlstra
2021-06-02 15:06   ` Will Deacon
2021-06-02 15:06     ` [dm-devel] " Will Deacon
2021-06-02 19:54   ` Davidlohr Bueso
2021-06-02 19:54     ` [dm-devel] " Davidlohr Bueso
2021-06-03  6:39     ` Peter Zijlstra
2021-06-03  6:39       ` [dm-devel] " Peter Zijlstra
2021-06-18 20:42   ` Thomas Gleixner
2021-06-18 20:42     ` [dm-devel] " Thomas Gleixner
2021-06-02 13:12 ` [PATCH 6/6] sched: Change task_struct::state Peter Zijlstra
2021-06-02 13:12   ` [dm-devel] " Peter Zijlstra
2021-06-02 14:06   ` Mathieu Desnoyers
2021-06-02 14:06     ` [dm-devel] " Mathieu Desnoyers
2021-06-02 14:06     ` Mathieu Desnoyers
2021-06-02 14:20     ` Peter Zijlstra
2021-06-02 14:20       ` [dm-devel] " Peter Zijlstra
2021-06-02 15:10   ` Will Deacon
2021-06-02 15:10     ` [dm-devel] " Will Deacon
2021-06-07 10:45   ` Daniel Thompson
2021-06-07 10:45     ` [dm-devel] " Daniel Thompson
2021-06-07 11:10     ` Peter Zijlstra
2021-06-07 11:10       ` [dm-devel] " Peter Zijlstra

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=20210602133040.461908001@infradead.org \
    --to=peterz@infradead.org \
    --cc=acme@kernel.org \
    --cc=agk@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=axboe@kernel.dk \
    --cc=balbi@kernel.org \
    --cc=boqun.feng@gmail.com \
    --cc=bp@alien8.de \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=cgroups@vger.kernel.org \
    --cc=daniel.thompson@linaro.org \
    --cc=dave@stgolabs.net \
    --cc=davem@davemloft.net \
    --cc=dianders@chromium.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=dm-devel@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=hpa@zytor.com \
    --cc=jason.wessel@windriver.com \
    --cc=jiangshanlai@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=john.stultz@linaro.org \
    --cc=jolsa@redhat.com \
    --cc=josh@joshtriplett.org \
    --cc=juri.lelli@redhat.com \
    --cc=kgdb-bugreport@lists.sourceforge.net \
    --cc=kuba@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=lizefan.x@bytedance.com \
    --cc=longman@redhat.com \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=paulmck@kernel.org \
    --cc=pavel@ucw.cz \
    --cc=pbonzini@redhat.com \
    --cc=rcu@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=rostedt@goodmis.org \
    --cc=sboyd@kernel.org \
    --cc=snitzer@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    --subject='Re: [PATCH 4/6] sched: Add get_current_state()' \
    /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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.