From: Mikael Pettersson <mikpe@csd.uu.se>

- perfctr_{init,exit}() don't need to be global: mark them static
- add comment to vperfctr_alloc() as to why an entire page is
  claimed and reserved (mmap())
- add printk_ratelimit() to __vperfctr_set_cpus_allowed()
- add task_lock() new usage comment to <linux/sched.h>

Signed-off-by: Mikael Pettersson <mikpe@csd.uu.se>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/drivers/perfctr/init.c    |    4 ++--
 25-akpm/drivers/perfctr/virtual.c |    9 ++++++---
 25-akpm/include/linux/sched.h     |    3 +++
 3 files changed, 11 insertions(+), 5 deletions(-)

diff -puN drivers/perfctr/init.c~perfctr-update-6-6-misc-minor-cleanups drivers/perfctr/init.c
--- 25/drivers/perfctr/init.c~perfctr-update-6-6-misc-minor-cleanups	2004-06-30 11:04:16.887366016 -0700
+++ 25-akpm/drivers/perfctr/init.c	2004-06-30 11:04:16.894364952 -0700
@@ -68,7 +68,7 @@ asmlinkage long sys_perfctr_info(struct 
 	return 0;
 }
 
-int __init perfctr_init(void)
+static int __init perfctr_init(void)
 {
 	int err;
 
@@ -87,7 +87,7 @@ int __init perfctr_init(void)
 	return 0;
 }
 
-void __exit perfctr_exit(void)
+static void __exit perfctr_exit(void)
 {
 	vperfctr_exit();
 	perfctr_cpu_exit();
diff -puN drivers/perfctr/virtual.c~perfctr-update-6-6-misc-minor-cleanups drivers/perfctr/virtual.c
--- 25/drivers/perfctr/virtual.c~perfctr-update-6-6-misc-minor-cleanups	2004-06-30 11:04:16.889365712 -0700
+++ 25-akpm/drivers/perfctr/virtual.c	2004-06-30 11:04:16.895364800 -0700
@@ -145,6 +145,8 @@ static void dec_nrctrs(void)
 	spin_unlock(&nrctrs_lock);
 }
 
+/* Allocate a `struct vperfctr'. Claim and reserve
+   an entire page so that it can be mmap():ed. */
 static struct vperfctr *vperfctr_alloc(void)
 {
 	unsigned long page;
@@ -369,9 +371,10 @@ void __vperfctr_set_cpus_allowed(struct 
 	cpus_and(tmp, new_mask, perfctr_cpus_forbidden_mask);
 	if (!cpus_empty(tmp)) {
 		atomic_set(&perfctr->bad_cpus_allowed, 1);
-		printk(KERN_WARNING "perfctr: process %d (comm %s) issued unsafe"
-		       " set_cpus_allowed() on process %d (comm %s)\n",
-		       current->pid, current->comm, owner->pid, owner->comm);
+		if (printk_ratelimit())
+			printk(KERN_WARNING "perfctr: process %d (comm %s) issued unsafe"
+			       " set_cpus_allowed() on process %d (comm %s)\n",
+			       current->pid, current->comm, owner->pid, owner->comm);
 	} else
 		atomic_set(&perfctr->bad_cpus_allowed, 0);
 }
diff -puN include/linux/sched.h~perfctr-update-6-6-misc-minor-cleanups include/linux/sched.h
--- 25/include/linux/sched.h~perfctr-update-6-6-misc-minor-cleanups	2004-06-30 11:04:16.890365560 -0700
+++ 25-akpm/include/linux/sched.h	2004-06-30 11:04:16.896364648 -0700
@@ -934,6 +934,9 @@ extern void unhash_process(struct task_s
  * Protects ->fs, ->files, ->mm, ->ptrace, ->group_info and synchronises with
  * wait4().
  *
+ * Synchronises set_cpus_allowed(), unlink, and creat of ->thread.perfctr.
+ * [if CONFIG_PERFCTR_VIRTUAL]
+ *
  * Nests both inside and outside of read_lock(&tasklist_lock).
  * It must not be nested with write_lock_irq(&tasklist_lock),
  * neither inside nor outside.
_