linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] sched: make struct task_struct::state 32-bit
@ 2021-02-06 15:18 Alexey Dobriyan
  2021-02-06 15:20 ` [PATCH 2/5] sched: make nr_running() return 32-bit Alexey Dobriyan
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Alexey Dobriyan @ 2021-02-06 15:18 UTC (permalink / raw)
  To: mingo, peterz; +Cc: linux-kernel

32-bit accesses are shorter than 64-bit accesses on x86_64.
Nothing uses 64-bitness of struct task_struct::state.

Propagate 32-bitness to other variables and functions.

Silently delete "extern" from prototypes.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 block/blk-mq.c               |    2 +-
 drivers/md/dm.c              |    6 +++---
 fs/userfaultfd.c             |    4 ++--
 include/linux/sched.h        |    6 +++---
 include/linux/sched/debug.h  |    2 +-
 include/linux/sched/signal.h |    2 +-
 kernel/freezer.c             |    2 +-
 kernel/kthread.c             |    4 ++--
 kernel/locking/mutex.c       |    6 +++---
 kernel/locking/semaphore.c   |    2 +-
 kernel/rcu/rcutorture.c      |    4 ++--
 kernel/rcu/tree_stall.h      |    6 +++---
 kernel/sched/core.c          |   10 +++++-----
 lib/syscall.c                |    2 +-
 14 files changed, 29 insertions(+), 29 deletions(-)

--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -3841,7 +3841,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;
+	int state;
 
 	if (!blk_qc_t_valid(cookie) ||
 	    !test_bit(QUEUE_FLAG_POLL, &q->queue_flags))
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -2253,7 +2253,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, int task_state)
 {
 	int r = 0;
 	DEFINE_WAIT(wait);
@@ -2276,7 +2276,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, int task_state)
 {
 	int r = 0;
 
@@ -2403,7 +2403,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, int task_state,
 			int dmf_suspended_flag)
 {
 	bool do_lockfs = suspend_flags & DM_SUSPEND_LOCKFS_FLAG;
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -339,7 +339,7 @@ static inline bool userfaultfd_must_wait(struct userfaultfd_ctx *ctx,
 	return ret;
 }
 
-static inline long userfaultfd_get_blocking_state(unsigned int flags)
+static inline int userfaultfd_get_blocking_state(unsigned int flags)
 {
 	if (flags & FAULT_FLAG_INTERRUPTIBLE)
 		return TASK_INTERRUPTIBLE;
@@ -372,7 +372,7 @@ vm_fault_t handle_userfault(struct vm_fault *vmf, unsigned long reason)
 	struct userfaultfd_wait_queue uwq;
 	vm_fault_t ret = VM_FAULT_SIGBUS;
 	bool must_wait;
-	long blocking_state;
+	int blocking_state;
 
 	/*
 	 * We don't do userfault handling for the final child pid update.
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -655,7 +655,7 @@ struct task_struct {
 	struct thread_info		thread_info;
 #endif
 	/* -1 unrunnable, 0 runnable, >0 stopped: */
-	volatile long			state;
+	volatile int			state;
 
 	/*
 	 * This begins the randomizable portion of task_struct. Only
@@ -1806,10 +1806,10 @@ static __always_inline void scheduler_ipi(void)
 	 */
 	preempt_fold_need_resched();
 }
-extern unsigned long wait_task_inactive(struct task_struct *, long match_state);
+unsigned long wait_task_inactive(struct task_struct *, int match_state);
 #else
 static inline void scheduler_ipi(void) { }
-static inline unsigned long wait_task_inactive(struct task_struct *p, long match_state)
+static inline unsigned long wait_task_inactive(struct task_struct *p, int match_state)
 {
 	return 1;
 }
--- a/include/linux/sched/debug.h
+++ b/include/linux/sched/debug.h
@@ -14,7 +14,7 @@ extern void dump_cpu_task(int cpu);
 /*
  * Only dump TASK_* tasks. (0 for all tasks)
  */
-extern void show_state_filter(unsigned long state_filter);
+void show_state_filter(unsigned int state_filter);
 
 static inline void show_state(void)
 {
--- a/include/linux/sched/signal.h
+++ b/include/linux/sched/signal.h
@@ -381,7 +381,7 @@ static inline int fatal_signal_pending(struct task_struct *p)
 	return task_sigpending(p) && __fatal_signal_pending(p);
 }
 
-static inline int signal_pending_state(long state, struct task_struct *p)
+static inline int signal_pending_state(int state, struct task_struct *p)
 {
 	if (!(state & (TASK_INTERRUPTIBLE | TASK_WAKEKILL)))
 		return 0;
--- 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;
+	int save = current->state;
 
 	pr_debug("%s entered refrigerator\n", current->comm);
 
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -430,7 +430,7 @@ struct task_struct *kthread_create_on_node(int (*threadfn)(void *data),
 }
 EXPORT_SYMBOL(kthread_create_on_node);
 
-static void __kthread_bind_mask(struct task_struct *p, const struct cpumask *mask, long state)
+static void __kthread_bind_mask(struct task_struct *p, const struct cpumask *mask, int state)
 {
 	unsigned long flags;
 
@@ -446,7 +446,7 @@ static void __kthread_bind_mask(struct task_struct *p, const struct cpumask *mas
 	raw_spin_unlock_irqrestore(&p->pi_lock, flags);
 }
 
-static void __kthread_bind(struct task_struct *p, unsigned int cpu, long state)
+static void __kthread_bind(struct task_struct *p, unsigned int cpu, int state)
 {
 	__kthread_bind_mask(p, cpumask_of(cpu), state);
 }
--- a/kernel/locking/mutex.c
+++ b/kernel/locking/mutex.c
@@ -923,7 +923,7 @@ __ww_mutex_add_waiter(struct mutex_waiter *waiter,
  * Lock a mutex (possibly interruptible), slowpath:
  */
 static __always_inline int __sched
-__mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
+__mutex_lock_common(struct mutex *lock, int state, unsigned int subclass,
 		    struct lockdep_map *nest_lock, unsigned long ip,
 		    struct ww_acquire_ctx *ww_ctx, const bool use_ww_ctx)
 {
@@ -1097,14 +1097,14 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
 }
 
 static int __sched
-__mutex_lock(struct mutex *lock, long state, unsigned int subclass,
+__mutex_lock(struct mutex *lock, int state, unsigned int subclass,
 	     struct lockdep_map *nest_lock, unsigned long ip)
 {
 	return __mutex_lock_common(lock, state, subclass, nest_lock, ip, NULL, false);
 }
 
 static int __sched
-__ww_mutex_lock(struct mutex *lock, long state, unsigned int subclass,
+__ww_mutex_lock(struct mutex *lock, int state, unsigned int subclass,
 		struct lockdep_map *nest_lock, unsigned long ip,
 		struct ww_acquire_ctx *ww_ctx)
 {
--- a/kernel/locking/semaphore.c
+++ b/kernel/locking/semaphore.c
@@ -201,7 +201,7 @@ struct semaphore_waiter {
  * constant, and thus optimised away by the compiler.  Likewise the
  * 'timeout' parameter for the cases without timeouts.
  */
-static inline int __sched __down_common(struct semaphore *sem, long state,
+static inline int __sched __down_common(struct semaphore *sem, int state,
 								long timeout)
 {
 	struct semaphore_waiter waiter;
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -1600,10 +1600,10 @@ rcu_torture_stats_print(void)
 		srcutorture_get_gp_data(cur_ops->ttype, srcu_ctlp,
 					&flags, &gp_seq);
 		wtp = READ_ONCE(writer_task);
-		pr_alert("??? Writer stall state %s(%d) g%lu f%#x ->state %#lx cpu %d\n",
+		pr_alert("??? Writer stall state %s(%d) g%lu f%#x ->state %#x cpu %d\n",
 			 rcu_torture_writer_state_getname(),
 			 rcu_torture_writer_state, gp_seq, flags,
-			 wtp == NULL ? ~0UL : wtp->state,
+			 wtp == NULL ? ~0U : wtp->state,
 			 wtp == NULL ? -1 : (int)task_cpu(wtp));
 		if (!splatted && wtp) {
 			sched_show_task(wtp);
--- a/kernel/rcu/tree_stall.h
+++ b/kernel/rcu/tree_stall.h
@@ -453,7 +453,7 @@ static void rcu_check_gp_kthread_starvation(void)
 	unsigned long j;
 
 	if (rcu_is_gp_kthread_starving(&j)) {
-		pr_err("%s kthread starved for %ld jiffies! g%ld f%#x %s(%d) ->state=%#lx ->cpu=%d\n",
+		pr_err("%s kthread starved for %ld jiffies! g%ld f%#x %s(%d) ->state=%#x ->cpu=%d\n",
 		       rcu_state.name, j,
 		       (long)rcu_seq_current(&rcu_state.gp_seq),
 		       data_race(rcu_state.gp_flags),
@@ -679,9 +679,9 @@ void show_rcu_gp_kthreads(void)
 	ja = j - data_race(rcu_state.gp_activity);
 	jr = j - data_race(rcu_state.gp_req_activity);
 	jw = j - data_race(rcu_state.gp_wake_time);
-	pr_info("%s: wait state: %s(%d) ->state: %#lx delta ->gp_activity %lu ->gp_req_activity %lu ->gp_wake_time %lu ->gp_wake_seq %ld ->gp_seq %ld ->gp_seq_needed %ld ->gp_flags %#x\n",
+	pr_info("%s: wait state: %s(%d) ->state: %#x delta ->gp_activity %lu ->gp_req_activity %lu ->gp_wake_time %lu ->gp_wake_seq %ld ->gp_seq %ld ->gp_seq_needed %ld ->gp_flags %#x\n",
 		rcu_state.name, gp_state_getname(rcu_state.gp_state),
-		rcu_state.gp_state, t ? t->state : 0x1ffffL,
+		rcu_state.gp_state, t ? t->state : 0x1ffff,
 		ja, jr, jw, (long)data_race(rcu_state.gp_wake_seq),
 		(long)data_race(rcu_state.gp_seq),
 		(long)data_race(rcu_get_root()->gp_seq_needed),
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2589,7 +2589,7 @@ int migrate_swap(struct task_struct *cur, struct task_struct *p,
  * smp_call_function() if an IPI is sent by the same process we are
  * waiting to become inactive.
  */
-unsigned long wait_task_inactive(struct task_struct *p, long match_state)
+unsigned long wait_task_inactive(struct task_struct *p, int match_state)
 {
 	int running, queued;
 	struct rq_flags rf;
@@ -4960,7 +4960,7 @@ static void __sched notrace __schedule(bool preempt)
 {
 	struct task_struct *prev, *next;
 	unsigned long *switch_count;
-	unsigned long prev_state;
+	int prev_state;
 	struct rq_flags rf;
 	struct rq *rq;
 	int cpu;
@@ -7011,7 +7011,7 @@ void sched_show_task(struct task_struct *p)
 EXPORT_SYMBOL_GPL(sched_show_task);
 
 static inline bool
-state_filter_match(unsigned long state_filter, struct task_struct *p)
+state_filter_match(unsigned int state_filter, struct task_struct *p)
 {
 	/* no filter, everything matches */
 	if (!state_filter)
@@ -7032,7 +7032,7 @@ state_filter_match(unsigned long state_filter, struct task_struct *p)
 }
 
 
-void show_state_filter(unsigned long state_filter)
+void show_state_filter(unsigned int state_filter)
 {
 	struct task_struct *g, *p;
 
@@ -7912,7 +7912,7 @@ void __might_sleep(const char *file, int line, int preempt_offset)
 	 */
 	WARN_ONCE(current->state != TASK_RUNNING && current->task_state_change,
 			"do not call blocking ops when !TASK_RUNNING; "
-			"state=%lx set at [<%p>] %pS\n",
+			"state=%x set at [<%p>] %pS\n",
 			current->state,
 			(void *)current->task_state_change,
 			(void *)current->task_state_change);
--- a/lib/syscall.c
+++ b/lib/syscall.c
@@ -68,7 +68,7 @@ static int collect_syscall(struct task_struct *target, struct syscall_info *info
  */
 int task_current_syscall(struct task_struct *target, struct syscall_info *info)
 {
-	long state;
+	int state;
 	unsigned long ncsw;
 
 	if (target == current)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 2/5] sched: make nr_running() return 32-bit
  2021-02-06 15:18 [PATCH 1/5] sched: make struct task_struct::state 32-bit Alexey Dobriyan
@ 2021-02-06 15:20 ` Alexey Dobriyan
  2021-02-06 15:22 ` [PATCH 3/5] sched: make nr_iowait() return 32-bit value Alexey Dobriyan
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Alexey Dobriyan @ 2021-02-06 15:20 UTC (permalink / raw)
  To: mingo, peterz; +Cc: linux-kernel

Creating 2**32 tasks to run is impossible due to futex pid limits
and wasteful anyway. Nobody have done it.

Bring nr_running() into 32-bit world to save on REX prefixes.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 fs/proc/loadavg.c          |    2 +-
 fs/proc/stat.c             |    2 +-
 include/linux/sched/stat.h |    2 +-
 kernel/sched/core.c        |    4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)

--- a/fs/proc/loadavg.c
+++ b/fs/proc/loadavg.c
@@ -16,7 +16,7 @@ static int loadavg_proc_show(struct seq_file *m, void *v)
 
 	get_avenrun(avnrun, FIXED_1/200, 0);
 
-	seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
+	seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %d/%d %d\n",
 		LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
 		LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
 		LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
--- a/fs/proc/stat.c
+++ b/fs/proc/stat.c
@@ -200,7 +200,7 @@ static int show_stat(struct seq_file *p, void *v)
 		"\nctxt %llu\n"
 		"btime %llu\n"
 		"processes %lu\n"
-		"procs_running %lu\n"
+		"procs_running %u\n"
 		"procs_blocked %lu\n",
 		nr_context_switches(),
 		(unsigned long long)boottime.tv_sec,
--- a/include/linux/sched/stat.h
+++ b/include/linux/sched/stat.h
@@ -16,7 +16,7 @@ extern unsigned long total_forks;
 extern int nr_threads;
 DECLARE_PER_CPU(unsigned long, process_counts);
 extern int nr_processes(void);
-extern unsigned long nr_running(void);
+unsigned int nr_running(void);
 extern bool single_task_running(void);
 extern unsigned long nr_iowait(void);
 extern unsigned long nr_iowait_cpu(int cpu);
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4336,9 +4336,9 @@ context_switch(struct rq *rq, struct task_struct *prev,
  * externally visible scheduler statistics: current number of runnable
  * threads, total number of context switches performed since bootup.
  */
-unsigned long nr_running(void)
+unsigned int nr_running(void)
 {
-	unsigned long i, sum = 0;
+	unsigned int i, sum = 0;
 
 	for_each_online_cpu(i)
 		sum += cpu_rq(i)->nr_running;

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 3/5] sched: make nr_iowait() return 32-bit value
  2021-02-06 15:18 [PATCH 1/5] sched: make struct task_struct::state 32-bit Alexey Dobriyan
  2021-02-06 15:20 ` [PATCH 2/5] sched: make nr_running() return 32-bit Alexey Dobriyan
@ 2021-02-06 15:22 ` Alexey Dobriyan
  2021-02-06 15:24 ` [PATCH 4/5] sched: make nr_iowait_cpu() return 32-bit Alexey Dobriyan
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Alexey Dobriyan @ 2021-02-06 15:22 UTC (permalink / raw)
  To: mingo, peterz; +Cc: linux-kernel

Creating 2**32 tasks to wait in D-state is impossible and wasteful.

Return "unsigned int" and save on REX prefixes.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 fs/proc/stat.c             |    2 +-
 include/linux/sched/stat.h |    2 +-
 kernel/sched/core.c        |    4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

--- a/fs/proc/stat.c
+++ b/fs/proc/stat.c
@@ -201,7 +201,7 @@ static int show_stat(struct seq_file *p, void *v)
 		"btime %llu\n"
 		"processes %lu\n"
 		"procs_running %u\n"
-		"procs_blocked %lu\n",
+		"procs_blocked %u\n",
 		nr_context_switches(),
 		(unsigned long long)boottime.tv_sec,
 		total_forks,
--- a/include/linux/sched/stat.h
+++ b/include/linux/sched/stat.h
@@ -18,7 +18,7 @@ DECLARE_PER_CPU(unsigned long, process_counts);
 extern int nr_processes(void);
 unsigned int nr_running(void);
 extern bool single_task_running(void);
-extern unsigned long nr_iowait(void);
+unsigned int nr_iowait(void);
 extern unsigned long nr_iowait_cpu(int cpu);
 
 static inline int sched_info_on(void)
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4418,9 +4418,9 @@ unsigned long nr_iowait_cpu(int cpu)
  * Task CPU affinities can make all that even more 'interesting'.
  */
 
-unsigned long nr_iowait(void)
+unsigned int nr_iowait(void)
 {
-	unsigned long i, sum = 0;
+	unsigned int i, sum = 0;
 
 	for_each_possible_cpu(i)
 		sum += nr_iowait_cpu(i);

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 4/5] sched: make nr_iowait_cpu() return 32-bit
  2021-02-06 15:18 [PATCH 1/5] sched: make struct task_struct::state 32-bit Alexey Dobriyan
  2021-02-06 15:20 ` [PATCH 2/5] sched: make nr_running() return 32-bit Alexey Dobriyan
  2021-02-06 15:22 ` [PATCH 3/5] sched: make nr_iowait() return 32-bit value Alexey Dobriyan
@ 2021-02-06 15:24 ` Alexey Dobriyan
  2021-02-06 15:30 ` [PATCH 5/5] sched: make multiple runqueue task counters 32-bit Alexey Dobriyan
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Alexey Dobriyan @ 2021-02-06 15:24 UTC (permalink / raw)
  To: mingo, peterz; +Cc: linux-kernel

Runqueue ->nr_iowait counters are 32-bit anyway.

Propagate 32-bitness into other code, but don't try too hard.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 drivers/cpuidle/governors/menu.c |    6 +++---
 include/linux/sched/stat.h       |    2 +-
 kernel/sched/core.c              |    2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -117,7 +117,7 @@ struct menu_device {
 	int		interval_ptr;
 };
 
-static inline int which_bucket(u64 duration_ns, unsigned long nr_iowaiters)
+static inline int which_bucket(u64 duration_ns, unsigned int nr_iowaiters)
 {
 	int bucket = 0;
 
@@ -150,7 +150,7 @@ static inline int which_bucket(u64 duration_ns, unsigned long nr_iowaiters)
  * to be, the higher this multiplier, and thus the higher
  * the barrier to go to an expensive C state.
  */
-static inline int performance_multiplier(unsigned long nr_iowaiters)
+static inline int performance_multiplier(unsigned int nr_iowaiters)
 {
 	/* for IO wait tasks (per cpu!) we add 10x each */
 	return 1 + 10 * nr_iowaiters;
@@ -270,7 +270,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
 	unsigned int predicted_us;
 	u64 predicted_ns;
 	u64 interactivity_req;
-	unsigned long nr_iowaiters;
+	unsigned int nr_iowaiters;
 	ktime_t delta_next;
 	int i, idx;
 
--- a/include/linux/sched/stat.h
+++ b/include/linux/sched/stat.h
@@ -19,7 +19,7 @@ extern int nr_processes(void);
 unsigned int nr_running(void);
 extern bool single_task_running(void);
 unsigned int nr_iowait(void);
-extern unsigned long nr_iowait_cpu(int cpu);
+unsigned int nr_iowait_cpu(int cpu);
 
 static inline int sched_info_on(void)
 {
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4383,7 +4383,7 @@ unsigned long long nr_context_switches(void)
  * it does become runnable.
  */
 
-unsigned long nr_iowait_cpu(int cpu)
+unsigned int nr_iowait_cpu(int cpu)
 {
 	return atomic_read(&cpu_rq(cpu)->nr_iowait);
 }

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 5/5] sched: make multiple runqueue task counters 32-bit
  2021-02-06 15:18 [PATCH 1/5] sched: make struct task_struct::state 32-bit Alexey Dobriyan
                   ` (2 preceding siblings ...)
  2021-02-06 15:24 ` [PATCH 4/5] sched: make nr_iowait_cpu() return 32-bit Alexey Dobriyan
@ 2021-02-06 15:30 ` Alexey Dobriyan
  2021-02-08 10:34 ` [PATCH 1/5] sched: make struct task_struct::state 32-bit Peter Zijlstra
  2021-02-08 10:39 ` Peter Zijlstra
  5 siblings, 0 replies; 12+ messages in thread
From: Alexey Dobriyan @ 2021-02-06 15:30 UTC (permalink / raw)
  To: mingo, peterz; +Cc: linux-kernel, juri.lelli, rostedt, bristot

Make

	struct dl_rq::dl_nr_migratory
	struct dl_rq::dl_nr_running

	struct rt_rq::rt_nr_boosted
	struct rt_rq::rt_nr_migratory
	struct rt_rq::rt_nr_total

	struct rq::nr_uninterruptible

32-bit.

If total number of tasks can't exceed 2**32 (and less due to futex pid
limits), then per-runqueue counters can't as well.

This patchset has been sponsored by REX Prefix Eradication Society.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 kernel/sched/loadavg.c |    2 +-
 kernel/sched/sched.h   |   12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

--- a/kernel/sched/loadavg.c
+++ b/kernel/sched/loadavg.c
@@ -81,7 +81,7 @@ long calc_load_fold_active(struct rq *this_rq, long adjust)
 	long nr_active, delta = 0;
 
 	nr_active = this_rq->nr_running - adjust;
-	nr_active += (long)this_rq->nr_uninterruptible;
+	nr_active += (int)this_rq->nr_uninterruptible;
 
 	if (nr_active != this_rq->calc_load_active) {
 		delta = nr_active - this_rq->calc_load_active;
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -622,8 +622,8 @@ struct rt_rq {
 	} highest_prio;
 #endif
 #ifdef CONFIG_SMP
-	unsigned long		rt_nr_migratory;
-	unsigned long		rt_nr_total;
+	unsigned int		rt_nr_migratory;
+	unsigned int		rt_nr_total;
 	int			overloaded;
 	struct plist_head	pushable_tasks;
 
@@ -637,7 +637,7 @@ struct rt_rq {
 	raw_spinlock_t		rt_runtime_lock;
 
 #ifdef CONFIG_RT_GROUP_SCHED
-	unsigned long		rt_nr_boosted;
+	unsigned int		rt_nr_boosted;
 
 	struct rq		*rq;
 	struct task_group	*tg;
@@ -654,7 +654,7 @@ struct dl_rq {
 	/* runqueue is an rbtree, ordered by deadline */
 	struct rb_root_cached	root;
 
-	unsigned long		dl_nr_running;
+	unsigned int		dl_nr_running;
 
 #ifdef CONFIG_SMP
 	/*
@@ -668,7 +668,7 @@ struct dl_rq {
 		u64		next;
 	} earliest_dl;
 
-	unsigned long		dl_nr_migratory;
+	unsigned int		dl_nr_migratory;
 	int			overloaded;
 
 	/*
@@ -946,7 +946,7 @@ struct rq {
 	 * one CPU and if it got migrated afterwards it may decrease
 	 * it on another CPU. Always updated under the runqueue lock:
 	 */
-	unsigned long		nr_uninterruptible;
+	unsigned int		nr_uninterruptible;
 
 	struct task_struct __rcu	*curr;
 	struct task_struct	*idle;

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/5] sched: make struct task_struct::state 32-bit
  2021-02-06 15:18 [PATCH 1/5] sched: make struct task_struct::state 32-bit Alexey Dobriyan
                   ` (3 preceding siblings ...)
  2021-02-06 15:30 ` [PATCH 5/5] sched: make multiple runqueue task counters 32-bit Alexey Dobriyan
@ 2021-02-08 10:34 ` Peter Zijlstra
  2021-02-08 14:30   ` Alexey Dobriyan
  2021-02-08 10:39 ` Peter Zijlstra
  5 siblings, 1 reply; 12+ messages in thread
From: Peter Zijlstra @ 2021-02-08 10:34 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: mingo, linux-kernel

On Sat, Feb 06, 2021 at 06:18:32PM +0300, Alexey Dobriyan wrote:

> Silently delete "extern" from prototypes.

NAK, extern is right.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/5] sched: make struct task_struct::state 32-bit
  2021-02-06 15:18 [PATCH 1/5] sched: make struct task_struct::state 32-bit Alexey Dobriyan
                   ` (4 preceding siblings ...)
  2021-02-08 10:34 ` [PATCH 1/5] sched: make struct task_struct::state 32-bit Peter Zijlstra
@ 2021-02-08 10:39 ` Peter Zijlstra
  2021-02-08 14:33   ` Alexey Dobriyan
  5 siblings, 1 reply; 12+ messages in thread
From: Peter Zijlstra @ 2021-02-08 10:39 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: mingo, linux-kernel

On Sat, Feb 06, 2021 at 06:18:32PM +0300, Alexey Dobriyan wrote:
> 32-bit accesses are shorter than 64-bit accesses on x86_64.
> Nothing uses 64-bitness of struct task_struct::state.
> 
> Propagate 32-bitness to other variables and functions.

You're saving a handful of bytes, why?

> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -655,7 +655,7 @@ struct task_struct {
>  	struct thread_info		thread_info;
>  #endif
>  	/* -1 unrunnable, 0 runnable, >0 stopped: */
> -	volatile long			state;
> +	volatile int			state;

A much larger, but probably more useful cleanup would be to get rid of
that volatile.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/5] sched: make struct task_struct::state 32-bit
  2021-02-08 10:34 ` [PATCH 1/5] sched: make struct task_struct::state 32-bit Peter Zijlstra
@ 2021-02-08 14:30   ` Alexey Dobriyan
  2021-02-08 14:52     ` Alexey Dobriyan
  0 siblings, 1 reply; 12+ messages in thread
From: Alexey Dobriyan @ 2021-02-08 14:30 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: mingo, linux-kernel

On Mon, Feb 08, 2021 at 11:34:18AM +0100, Peter Zijlstra wrote:
> On Sat, Feb 06, 2021 at 06:18:32PM +0300, Alexey Dobriyan wrote:
> 
> > Silently delete "extern" from prototypes.
> 
> NAK, extern is right.

Extern is only necessary for variables.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/5] sched: make struct task_struct::state 32-bit
  2021-02-08 10:39 ` Peter Zijlstra
@ 2021-02-08 14:33   ` Alexey Dobriyan
  0 siblings, 0 replies; 12+ messages in thread
From: Alexey Dobriyan @ 2021-02-08 14:33 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: mingo, linux-kernel

On Mon, Feb 08, 2021 at 11:39:25AM +0100, Peter Zijlstra wrote:
> On Sat, Feb 06, 2021 at 06:18:32PM +0300, Alexey Dobriyan wrote:
> > 32-bit accesses are shorter than 64-bit accesses on x86_64.
> > Nothing uses 64-bitness of struct task_struct::state.
> > 
> > Propagate 32-bitness to other variables and functions.
> 
> You're saving a handful of bytes, why?

Eeh? To save handful of bytes.

> > --- a/include/linux/sched.h
> > +++ b/include/linux/sched.h
> > @@ -655,7 +655,7 @@ struct task_struct {
> >  	struct thread_info		thread_info;
> >  #endif
> >  	/* -1 unrunnable, 0 runnable, >0 stopped: */
> > -	volatile long			state;
> > +	volatile int			state;
> 
> A much larger, but probably more useful cleanup would be to get rid of
> that volatile.

volatile is separate patch. It is independent of ->state type.
I didn't think about this specific volatile at all.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/5] sched: make struct task_struct::state 32-bit
  2021-02-08 14:30   ` Alexey Dobriyan
@ 2021-02-08 14:52     ` Alexey Dobriyan
  2021-02-08 15:25       ` Peter Zijlstra
  0 siblings, 1 reply; 12+ messages in thread
From: Alexey Dobriyan @ 2021-02-08 14:52 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: mingo, linux-kernel

On Mon, Feb 08, 2021 at 05:30:25PM +0300, Alexey Dobriyan wrote:
> On Mon, Feb 08, 2021 at 11:34:18AM +0100, Peter Zijlstra wrote:
> > On Sat, Feb 06, 2021 at 06:18:32PM +0300, Alexey Dobriyan wrote:
> > 
> > > Silently delete "extern" from prototypes.
> > 
> > NAK, extern is right.
> 
> Extern is only necessary for variables.

Specifically C17, 6.2.2 p5 (linkage of identifiers):

	if the declaration of an identifier for a function has no
	storage-class specifier, its linkage is determined exactly as if
	it were declared with the storage-class specifier "extern".

This is why nothing happens if "extern" is deleted.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/5] sched: make struct task_struct::state 32-bit
  2021-02-08 14:52     ` Alexey Dobriyan
@ 2021-02-08 15:25       ` Peter Zijlstra
  2021-02-08 16:45         ` Alexey Dobriyan
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Zijlstra @ 2021-02-08 15:25 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: mingo, linux-kernel

On Mon, Feb 08, 2021 at 05:52:45PM +0300, Alexey Dobriyan wrote:
> On Mon, Feb 08, 2021 at 05:30:25PM +0300, Alexey Dobriyan wrote:
> > On Mon, Feb 08, 2021 at 11:34:18AM +0100, Peter Zijlstra wrote:
> > > On Sat, Feb 06, 2021 at 06:18:32PM +0300, Alexey Dobriyan wrote:
> > > 
> > > > Silently delete "extern" from prototypes.
> > > 
> > > NAK, extern is right.
> > 
> > Extern is only necessary for variables.
> 
> Specifically C17, 6.2.2 p5 (linkage of identifiers):
> 
> 	if the declaration of an identifier for a function has no
> 	storage-class specifier, its linkage is determined exactly as if
> 	it were declared with the storage-class specifier "extern".
> 
> This is why nothing happens if "extern" is deleted.

I know, but I still very much like extern on the function declarations
too. It tells me the definition isn't to be found in this TU.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/5] sched: make struct task_struct::state 32-bit
  2021-02-08 15:25       ` Peter Zijlstra
@ 2021-02-08 16:45         ` Alexey Dobriyan
  0 siblings, 0 replies; 12+ messages in thread
From: Alexey Dobriyan @ 2021-02-08 16:45 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: mingo, linux-kernel

On Mon, Feb 08, 2021 at 04:25:35PM +0100, Peter Zijlstra wrote:
> On Mon, Feb 08, 2021 at 05:52:45PM +0300, Alexey Dobriyan wrote:
> > On Mon, Feb 08, 2021 at 05:30:25PM +0300, Alexey Dobriyan wrote:
> > > On Mon, Feb 08, 2021 at 11:34:18AM +0100, Peter Zijlstra wrote:
> > > > On Sat, Feb 06, 2021 at 06:18:32PM +0300, Alexey Dobriyan wrote:
> > > > 
> > > > > Silently delete "extern" from prototypes.
> > > > 
> > > > NAK, extern is right.
> > > 
> > > Extern is only necessary for variables.
> > 
> > Specifically C17, 6.2.2 p5 (linkage of identifiers):
> > 
> > 	if the declaration of an identifier for a function has no
> > 	storage-class specifier, its linkage is determined exactly as if
> > 	it were declared with the storage-class specifier "extern".
> > 
> > This is why nothing happens if "extern" is deleted.
> 
> I know, but I still very much like extern on the function declarations
> too. It tells me the definition isn't to be found in this TU.

What can I say. The absense of function body should tell that.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-02-08 18:43 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-06 15:18 [PATCH 1/5] sched: make struct task_struct::state 32-bit Alexey Dobriyan
2021-02-06 15:20 ` [PATCH 2/5] sched: make nr_running() return 32-bit Alexey Dobriyan
2021-02-06 15:22 ` [PATCH 3/5] sched: make nr_iowait() return 32-bit value Alexey Dobriyan
2021-02-06 15:24 ` [PATCH 4/5] sched: make nr_iowait_cpu() return 32-bit Alexey Dobriyan
2021-02-06 15:30 ` [PATCH 5/5] sched: make multiple runqueue task counters 32-bit Alexey Dobriyan
2021-02-08 10:34 ` [PATCH 1/5] sched: make struct task_struct::state 32-bit Peter Zijlstra
2021-02-08 14:30   ` Alexey Dobriyan
2021-02-08 14:52     ` Alexey Dobriyan
2021-02-08 15:25       ` Peter Zijlstra
2021-02-08 16:45         ` Alexey Dobriyan
2021-02-08 10:39 ` Peter Zijlstra
2021-02-08 14:33   ` Alexey Dobriyan

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).