Commit 2f064a59 authored by Peter Zijlstra's avatar Peter Zijlstra
Browse files

sched: Change task_struct::state



Change the type and name of task_struct::state. Drop the volatile and
shrink it to an 'unsigned int'. Rename it in order to find all uses
such that we can use READ_ONCE/WRITE_ONCE as appropriate.

Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarDaniel Bristot de Oliveira <bristot@redhat.com>
Acked-by: default avatarWill Deacon <will@kernel.org>
Acked-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
Link: https://lore.kernel.org/r/20210611082838.550736351@infradead.org
parent 7c3edd6d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1788,7 +1788,7 @@ format_mca_init_stack(void *mca_data, unsigned long offset,
	ti->task = p;
	ti->cpu = cpu;
	p->stack = ti;
	p->state = TASK_UNINTERRUPTIBLE;
	p->__state = TASK_UNINTERRUPTIBLE;
	cpumask_set_cpu(cpu, &p->cpus_mask);
	INIT_LIST_HEAD(&p->tasks);
	p->parent = p->real_parent = p->group_leader = p;
+4 −4
Original line number Diff line number Diff line
@@ -641,11 +641,11 @@ ptrace_attach_sync_user_rbs (struct task_struct *child)
	read_lock(&tasklist_lock);
	if (child->sighand) {
		spin_lock_irq(&child->sighand->siglock);
		if (child->state == TASK_STOPPED &&
		if (READ_ONCE(child->__state) == TASK_STOPPED &&
		    !test_and_set_tsk_thread_flag(child, TIF_RESTORE_RSE)) {
			set_notify_resume(child);

			child->state = TASK_TRACED;
			WRITE_ONCE(child->__state, TASK_TRACED);
			stopped = 1;
		}
		spin_unlock_irq(&child->sighand->siglock);
@@ -665,9 +665,9 @@ ptrace_attach_sync_user_rbs (struct task_struct *child)
	read_lock(&tasklist_lock);
	if (child->sighand) {
		spin_lock_irq(&child->sighand->siglock);
		if (child->state == TASK_TRACED &&
		if (READ_ONCE(child->__state) == TASK_TRACED &&
		    (child->signal->flags & SIGNAL_STOP_STOPPED)) {
			child->state = TASK_STOPPED;
			WRITE_ONCE(child->__state, TASK_STOPPED);
		}
		spin_unlock_irq(&child->sighand->siglock);
	}
+7 −6
Original line number Diff line number Diff line
@@ -3162,6 +3162,7 @@ memzcan(void)

static void show_task(struct task_struct *tsk)
{
	unsigned int p_state = READ_ONCE(tsk->__state);
	char state;

	/*
@@ -3169,14 +3170,14 @@ static void show_task(struct task_struct *tsk)
	 * appropriate for calling from xmon. This could be moved
	 * to a common, generic, routine used by both.
	 */
	state = (tsk->state == 0) ? 'R' :
		(tsk->state < 0) ? 'U' :
		(tsk->state & TASK_UNINTERRUPTIBLE) ? 'D' :
		(tsk->state & TASK_STOPPED) ? 'T' :
		(tsk->state & TASK_TRACED) ? 'C' :
	state = (p_state == 0) ? 'R' :
		(p_state < 0) ? 'U' :
		(p_state & TASK_UNINTERRUPTIBLE) ? 'D' :
		(p_state & TASK_STOPPED) ? 'T' :
		(p_state & TASK_TRACED) ? 'C' :
		(tsk->exit_state & EXIT_ZOMBIE) ? 'Z' :
		(tsk->exit_state & EXIT_DEAD) ? 'E' :
		(tsk->state & TASK_INTERRUPTIBLE) ? 'S' : '?';
		(p_state & TASK_INTERRUPTIBLE) ? 'S' : '?';

	printf("%16px %16lx %16px %6d %6d %c %2d %s\n", tsk,
		tsk->thread.ksp, tsk->thread.regs,
+1 −1
Original line number Diff line number Diff line
@@ -3886,7 +3886,7 @@ static bool blk_mq_poll_hybrid(struct request_queue *q,
int blk_poll(struct request_queue *q, blk_qc_t cookie, bool spin)
{
	struct blk_mq_hw_ctx *hctx;
	long state;
	unsigned int state;

	if (!blk_qc_t_valid(cookie) ||
	    !test_bit(QUEUE_FLAG_POLL, &q->queue_flags))
+3 −3
Original line number Diff line number Diff line
@@ -2328,7 +2328,7 @@ static bool md_in_flight_bios(struct mapped_device *md)
	return sum != 0;
}

static int dm_wait_for_bios_completion(struct mapped_device *md, long task_state)
static int dm_wait_for_bios_completion(struct mapped_device *md, unsigned int task_state)
{
	int r = 0;
	DEFINE_WAIT(wait);
@@ -2351,7 +2351,7 @@ static int dm_wait_for_bios_completion(struct mapped_device *md, long task_state
	return r;
}

static int dm_wait_for_completion(struct mapped_device *md, long task_state)
static int dm_wait_for_completion(struct mapped_device *md, unsigned int task_state)
{
	int r = 0;

@@ -2478,7 +2478,7 @@ static void unlock_fs(struct mapped_device *md)
 * are being added to md->deferred list.
 */
static int __dm_suspend(struct mapped_device *md, struct dm_table *map,
			unsigned suspend_flags, long task_state,
			unsigned suspend_flags, unsigned int task_state,
			int dmf_suspended_flag)
{
	bool do_lockfs = suspend_flags & DM_SUSPEND_LOCKFS_FLAG;
Loading