From f9d21ae77239647093e15c0239dd9c381cd090a8 Mon Sep 17 00:00:00 2001 From: Anton Blanchard Date: Sun, 1 Aug 2004 20:09:24 -0700 Subject: [PATCH] sched: use for_each_cpu The per cpu schedule counters need to be summed up over all possible cpus. When testing hotplug cpu remove I saw the sum of the online cpu count for nr_uninterruptible go negative which made the load average go nuts. Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- kernel/sched.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'kernel') diff --git a/kernel/sched.c b/kernel/sched.c index c279ba227145..3e8897919924 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -1095,7 +1095,7 @@ unsigned long nr_uninterruptible(void) { unsigned long i, sum = 0; - for_each_online_cpu(i) + for_each_cpu(i) sum += cpu_rq(i)->nr_uninterruptible; return sum; @@ -1105,7 +1105,7 @@ unsigned long long nr_context_switches(void) { unsigned long long i, sum = 0; - for_each_online_cpu(i) + for_each_cpu(i) sum += cpu_rq(i)->nr_switches; return sum; @@ -1115,7 +1115,7 @@ unsigned long nr_iowait(void) { unsigned long i, sum = 0; - for_each_online_cpu(i) + for_each_cpu(i) sum += atomic_read(&cpu_rq(i)->nr_iowait); return sum; -- cgit v1.2.3 From 357fbac90d6c0755ce7fab16d64bf3c8f8077940 Mon Sep 17 00:00:00 2001 From: Tim Schmielau Date: Sun, 1 Aug 2004 20:09:36 -0700 Subject: [PATCH] Fix BSD accounting cross-platform compatibility BSD accounting cross-platform compatibility is a new feature of 2.6.8 and thus not crucial, but it'd be nice not to have kernels writing wrong file formats out in the wild. The endianness detection logic I wanted to suppose for userspace turned out to be bogus. So just do it the simple way and store endianness info together with the version number. Signed-off-by: Tim Schmielau Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/acct.h | 8 +++++++- kernel/acct.c | 5 ++--- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'kernel') diff --git a/include/linux/acct.h b/include/linux/acct.h index 6c2bd56773f0..b46ce1ac1c6a 100644 --- a/include/linux/acct.h +++ b/include/linux/acct.h @@ -17,6 +17,7 @@ #include #include +#include /* * comp_t is a 16-bit "floating" point number with a 3-bit base 8 @@ -104,7 +105,12 @@ struct acct_v3 #define ACOMPAT 0x04 /* ... used compatibility mode (VAX only not used) */ #define ACORE 0x08 /* ... dumped core */ #define AXSIG 0x10 /* ... was killed by a signal */ -#define ABYTESEX 0x80 /* always set, allows to detect byteorder */ + +#ifdef __BIG_ENDIAN +#define ACCT_BYTEORDER 0x80 /* accounting file is big endian */ +#else +#define ACCT_BYTEORDER 0x00 /* accounting file is little endian */ +#endif #ifdef __KERNEL__ diff --git a/kernel/acct.c b/kernel/acct.c index e55e7bba861e..daf23c4efab4 100644 --- a/kernel/acct.c +++ b/kernel/acct.c @@ -398,7 +398,7 @@ static void do_acct_process(long exitcode, struct file *file) */ memset((caddr_t)&ac, 0, sizeof(acct_t)); - ac.ac_version = ACCT_VERSION; + ac.ac_version = ACCT_VERSION | ACCT_BYTEORDER; strlcpy(ac.ac_comm, current->comm, sizeof(ac.ac_comm)); elapsed = jiffies_64_to_AHZ(get_jiffies_64() - current->start_time); @@ -441,8 +441,7 @@ static void do_acct_process(long exitcode, struct file *file) old_encode_dev(tty_devnum(current->signal->tty)) : 0; read_unlock(&tasklist_lock); - /* ABYTESEX is always set to allow byte order detection */ - ac.ac_flag = ABYTESEX; + ac.ac_flag = 0; if (current->flags & PF_FORKNOEXEC) ac.ac_flag |= AFORK; if (current->flags & PF_SUPERPRIV) -- cgit v1.2.3 From db386bbe60bb3e36e1ffa9e805302c1c5436d5ee Mon Sep 17 00:00:00 2001 From: Brian Gerst Date: Sun, 1 Aug 2004 20:15:07 -0700 Subject: [PATCH] Remove symbol_is() Remove the unused symbol_is() macro. Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- kernel/module.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'kernel') diff --git a/kernel/module.c b/kernel/module.c index 858b34f4c33b..dfe295ecf2f1 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -51,9 +51,6 @@ /* If this is set, the section belongs in the init part of the module */ #define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1)) -#define symbol_is(literal, string) \ - (strcmp(MODULE_SYMBOL_PREFIX literal, (string)) == 0) - /* Protects module list */ static spinlock_t modlist_lock = SPIN_LOCK_UNLOCKED; -- cgit v1.2.3 From 81fd00e2e58911325c794b6f98d683ecb7db2b04 Mon Sep 17 00:00:00 2001 From: Michael Kerrisk Date: Sun, 1 Aug 2004 20:31:12 -0700 Subject: [PATCH] Off-by-one error for SIGXCPU / RLIMIT_CPU checking There is a lonstanding off-by-one error that results from an incorrect comparison when checking whether a process has consumed CPU time in excess of its RLIMIT_CPU limits. This means, for example, that if we use setrlimit() to set the soft CPU limit (rlim_cur) to 5 seconds and the hard limit (rlim_max) to 10 seconds, then the process only receives a SIGXCPU signal after consuming 6 seconds of CPU time, and, if it continues consuming CPU after handling that signal, only receives SIGKILL after consuming 11 seconds of CPU time. The fix is trivial. Signed-off-by: Linus Torvalds --- kernel/timer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'kernel') diff --git a/kernel/timer.c b/kernel/timer.c index 56b315bc53cf..4850abbeacdc 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -792,12 +792,12 @@ static inline void do_process_times(struct task_struct *p, psecs = (p->utime += user); psecs += (p->stime += system); - if (psecs / HZ > p->rlim[RLIMIT_CPU].rlim_cur) { + if (psecs / HZ >= p->rlim[RLIMIT_CPU].rlim_cur) { /* Send SIGXCPU every second.. */ if (!(psecs % HZ)) send_sig(SIGXCPU, p, 1); /* and SIGKILL when we go over max.. */ - if (psecs / HZ > p->rlim[RLIMIT_CPU].rlim_max) + if (psecs / HZ >= p->rlim[RLIMIT_CPU].rlim_max) send_sig(SIGKILL, p, 1); } } -- cgit v1.2.3