Commit 423284ee authored by William Lee Irwin III's avatar William Lee Irwin III Committed by Linus Torvalds

[PATCH] consolidate prof_cpu_mask

Handling of prof_cpu_mask is grossly inconsistent.  Some arches have it as a
cpumask_t, others unsigned long, and even within arches it's treated
inconsistently.  This makes it cpumask_t across the board, and consolidates
the handling in kernel/profile.c
Signed-off-by: default avatarWilliam Irwin <wli@holomorphy.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f0fd8a8d
......@@ -288,31 +288,6 @@ irq_affinity_write_proc(struct file *file, const char __user *buffer,
return full_count;
}
static int
prof_cpu_mask_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len = cpumask_scnprintf(page, count, *(cpumask_t *)data);
if (count - len < 2)
return -EINVAL;
len += sprintf(page + len, "\n");
return len;
}
static int
prof_cpu_mask_write_proc(struct file *file, const char __user *buffer,
unsigned long count, void *data)
{
unsigned long full_count = count, err;
cpumask_t new_value, *mask = (cpumask_t *)data;
err = cpumask_parse(buffer, count, new_value);
if (err)
return err;
*mask = new_value;
return full_count;
}
#endif /* CONFIG_SMP */
#define MAX_NAMELEN 10
......@@ -350,8 +325,6 @@ register_irq_proc (unsigned int irq)
#endif
}
unsigned long prof_cpu_mask = ~0UL;
void
init_irq_proc (void)
{
......@@ -365,12 +338,7 @@ init_irq_proc (void)
#ifdef CONFIG_SMP
/* create /proc/irq/prof_cpu_mask */
entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir);
entry->nlink = 1;
entry->data = (void *)&prof_cpu_mask;
entry->read_proc = prof_cpu_mask_read_proc;
entry->write_proc = prof_cpu_mask_write_proc;
create_prof_cpu_mask(root_irq_dir);
#endif
/*
......
......@@ -41,8 +41,6 @@ extern void init_i8259a_irqs(void);
extern void handle_irq(int irq, struct pt_regs * regs);
extern unsigned long prof_cpu_mask;
static inline void
alpha_do_profile(unsigned long pc)
{
......@@ -55,7 +53,7 @@ alpha_do_profile(unsigned long pc)
* Only measure the CPUs specified by /proc/irq/prof_cpu_mask.
* (default is all CPUs.)
*/
if (!((1<<smp_processor_id()) & prof_cpu_mask))
if (!cpu_isset(smp_processor_id(), prof_cpu_mask))
return;
pc -= (unsigned long) &_stext;
......
......@@ -1025,32 +1025,6 @@ static int irq_affinity_write_proc(struct file *file, const char __user *buffer,
}
#endif
static int prof_cpu_mask_read_proc (char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len = cpumask_scnprintf(page, count, *(cpumask_t *)data);
if (count - len < 2)
return -EINVAL;
len += sprintf(page + len, "\n");
return len;
}
static int prof_cpu_mask_write_proc (struct file *file, const char __user *buffer,
unsigned long count, void *data)
{
cpumask_t *mask = (cpumask_t *)data;
unsigned long full_count = count, err;
cpumask_t new_value;
err = cpumask_parse(buffer, count, new_value);
if (err)
return err;
*mask = new_value;
return full_count;
}
#define MAX_NAMELEN 10
static void register_irq_proc (unsigned int irq)
......@@ -1086,27 +1060,13 @@ static void register_irq_proc (unsigned int irq)
#endif
}
unsigned long prof_cpu_mask = -1;
void init_irq_proc (void)
{
struct proc_dir_entry *entry;
int i;
/* create /proc/irq */
root_irq_dir = proc_mkdir("irq", NULL);
/* create /proc/irq/prof_cpu_mask */
entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir);
if (!entry)
return;
entry->nlink = 1;
entry->data = (void *)&prof_cpu_mask;
entry->read_proc = prof_cpu_mask_read_proc;
entry->write_proc = prof_cpu_mask_write_proc;
create_prof_cpu_mask(root_irq_dir);
/*
* Create entries for all existing IRQs.
*/
......
......@@ -1137,31 +1137,6 @@ void fixup_irqs(void)
}
#endif
static int prof_cpu_mask_read_proc (char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len = cpumask_scnprintf(page, count, *(cpumask_t *)data);
if (count - len < 2)
return -EINVAL;
len += sprintf(page + len, "\n");
return len;
}
static int prof_cpu_mask_write_proc (struct file *file, const char *buffer,
unsigned long count, void *data)
{
cpumask_t *mask = (cpumask_t *)data;
unsigned long full_count = count, err;
cpumask_t new_value;
err = cpumask_parse(buffer, count, new_value);
if (err)
return err;
*mask = new_value;
return full_count;
}
#define MAX_NAMELEN 10
static void register_irq_proc (unsigned int irq)
......@@ -1196,26 +1171,15 @@ static void register_irq_proc (unsigned int irq)
#endif
}
cpumask_t prof_cpu_mask = CPU_MASK_ALL;
void init_irq_proc (void)
{
struct proc_dir_entry *entry;
int i;
/* create /proc/irq */
root_irq_dir = proc_mkdir("irq", 0);
/* create /proc/irq/prof_cpu_mask */
entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir);
if (!entry)
return;
entry->nlink = 1;
entry->data = (void *)&prof_cpu_mask;
entry->read_proc = prof_cpu_mask_read_proc;
entry->write_proc = prof_cpu_mask_write_proc;
create_prof_cpu_mask(root_irq_dir);
/*
* Create entries for all existing IRQs.
......
......@@ -196,7 +196,6 @@ static inline void
ia64_do_profile (struct pt_regs * regs)
{
unsigned long ip, slot;
extern cpumask_t prof_cpu_mask;
profile_hook(regs);
......
......@@ -872,30 +872,6 @@ static int irq_affinity_write_proc (struct file *file, const char *buffer,
#endif
static int prof_cpu_mask_read_proc (char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len = cpumask_scnprintf(page, count, *(cpumask_t *)data);
if (count - len < 2)
return -EINVAL;
len += sprintf(page + len, "\n");
return len;
}
static int prof_cpu_mask_write_proc (struct file *file, const char *buffer,
unsigned long count, void *data)
{
cpumask_t *mask = (cpumask_t *)data, new_value;
unsigned long full_count = count, err;
err = cpumask_parse(buffer, count, new_value);
if (err)
return err;
*mask = new_value;
return full_count;
}
#define MAX_NAMELEN 10
static void register_irq_proc (unsigned int irq)
......@@ -931,26 +907,15 @@ static void register_irq_proc (unsigned int irq)
#endif
}
unsigned long prof_cpu_mask = -1;
void init_irq_proc (void)
{
struct proc_dir_entry *entry;
int i;
/* create /proc/irq */
root_irq_dir = proc_mkdir("irq", 0);
/* create /proc/irq/prof_cpu_mask */
entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir);
if (!entry)
return;
entry->nlink = 1;
entry->data = (void *)&prof_cpu_mask;
entry->read_proc = prof_cpu_mask_read_proc;
entry->write_proc = prof_cpu_mask_write_proc;
create_prof_cpu_mask(root_irq_dir);
/*
* Create entries for all existing IRQs.
......
......@@ -51,9 +51,6 @@ static inline void
parisc_do_profile(struct pt_regs *regs)
{
unsigned long pc = regs->iaoq[0];
#if 0
extern unsigned long prof_cpu_mask;
#endif
extern char _stext;
profile_hook(regs);
......@@ -69,7 +66,7 @@ parisc_do_profile(struct pt_regs *regs)
* only look at the cpus specified in this mask
*/
if (!((1 << smp_processor_id()) & prof_cpu_mask))
if (!cpu_isset(smp_processor_id(), prof_cpu_mask))
return;
#endif
......
......@@ -620,32 +620,6 @@ static int irq_affinity_write_proc (struct file *file, const char __user *buffer
return full_count;
}
static int prof_cpu_mask_read_proc (char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len = cpumask_scnprintf(page, count, *(cpumask_t *)data);
if (count - len < 2)
return -EINVAL;
len += sprintf(page + len, "\n");
return len;
}
static int prof_cpu_mask_write_proc (struct file *file, const char __user *buffer,
unsigned long count, void *data)
{
int err;
int full_count = count;
cpumask_t *mask = (cpumask_t *)data;
cpumask_t new_value;
err = cpumask_parse(buffer, count, new_value);
if (err)
return err;
*mask = new_value;
return full_count;
}
#define MAX_NAMELEN 10
static void register_irq_proc (unsigned int irq)
......@@ -673,23 +647,14 @@ static void register_irq_proc (unsigned int irq)
smp_affinity_entry[irq] = entry;
}
unsigned long prof_cpu_mask = -1;
void init_irq_proc (void)
{
struct proc_dir_entry *entry;
int i;
/* create /proc/irq */
root_irq_dir = proc_mkdir("irq", NULL);
/* create /proc/irq/prof_cpu_mask */
entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir);
entry->nlink = 1;
entry->data = (void *)&prof_cpu_mask;
entry->read_proc = prof_cpu_mask_read_proc;
entry->write_proc = prof_cpu_mask_write_proc;
create_prof_cpu_mask(root_irq_dir);
/*
* Create entries for all existing IRQs.
......
......@@ -113,7 +113,6 @@ extern char _stext;
static inline void ppc_do_profile (struct pt_regs *regs)
{
unsigned long nip;
extern unsigned long prof_cpu_mask;
profile_hook(regs);
......@@ -129,7 +128,7 @@ static inline void ppc_do_profile (struct pt_regs *regs)
* Only measure the CPUs specified by /proc/irq/prof_cpu_mask.
* (default is all CPUs.)
*/
if (!((1<<smp_processor_id()) & prof_cpu_mask))
if (!cpu_isset(smp_processor_id(), prof_cpu_mask))
return;
nip -= (unsigned long) &_stext;
......
......@@ -758,44 +758,6 @@ static int irq_affinity_write_proc (struct file *file, const char __user *buffer
return ret;
}
static int prof_cpu_mask_read_proc (char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len = cpumask_scnprintf(page, count, *(cpumask_t *)data);
if (count - len < 2)
return -EINVAL;
len += sprintf(page + len, "\n");
return len;
}
static int prof_cpu_mask_write_proc (struct file *file, const char __user *buffer,
unsigned long count, void *data)
{
cpumask_t *mask = (cpumask_t *)data;
unsigned long full_count = count, err;
cpumask_t new_value;
err = cpumask_parse(buffer, count, new_value);
if (err)
return err;
*mask = new_value;
#ifdef CONFIG_PPC_ISERIES
{
unsigned i;
for (i=0; i<NR_CPUS; ++i) {
if ( paca[i].prof_buffer && cpu_isset(i, new_value) )
paca[i].prof_enabled = 1;
else
paca[i].prof_enabled = 0;
}
}
#endif
return full_count;
}
#define MAX_NAMELEN 10
static void register_irq_proc (unsigned int irq)
......@@ -825,26 +787,15 @@ static void register_irq_proc (unsigned int irq)
smp_affinity_entry[irq] = entry;
}
unsigned long prof_cpu_mask = -1;
void init_irq_proc (void)
{
struct proc_dir_entry *entry;
int i;
/* create /proc/irq */
root_irq_dir = proc_mkdir("irq", NULL);
/* create /proc/irq/prof_cpu_mask */
entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir);
if (!entry)
return;
entry->nlink = 1;
entry->data = (void *)&prof_cpu_mask;
entry->read_proc = prof_cpu_mask_read_proc;
entry->write_proc = prof_cpu_mask_write_proc;
create_prof_cpu_mask(root_irq_dir);
/*
* Create entries for all existing IRQs.
......
......@@ -117,7 +117,6 @@ static unsigned adjusting_time = 0;
static inline void ppc64_do_profile(struct pt_regs *regs)
{
unsigned long nip;
extern unsigned long prof_cpu_mask;
profile_hook(regs);
......@@ -133,7 +132,7 @@ static inline void ppc64_do_profile(struct pt_regs *regs)
* Only measure the CPUs specified by /proc/irq/prof_cpu_mask.
* (default is all CPUs.)
*/
if (!((1<<smp_processor_id()) & prof_cpu_mask))
if (!cpu_isset(smp_processor_id(), prof_cpu_mask))
return;
nip -= (unsigned long)_stext;
......
......@@ -9,49 +9,11 @@
static struct proc_dir_entry * root_irq_dir;
static int prof_cpu_mask_read_proc (char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len = cpumask_scnprintf(page, count, *(cpumask_t *)data);
if (count - len < 2)
return -EINVAL;
len += sprintf(page + len, "\n");
return len;
}
static int prof_cpu_mask_write_proc (struct file *file,
const char __user *buffer,
unsigned long count, void *data)
{
cpumask_t *mask = (cpumask_t *)data;
unsigned long full_count = count, err;
cpumask_t new_value;
err = cpumask_parse(buffer, count, new_value);
if (err)
return err;
*mask = new_value;
return full_count;
}
cpumask_t prof_cpu_mask = CPU_MASK_ALL;
void init_irq_proc(void)
{
struct proc_dir_entry *entry;
/* create /proc/irq */
root_irq_dir = proc_mkdir("irq", 0);
/* create /proc/irq/prof_cpu_mask */
entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir);
if (!entry)
return;
entry->nlink = 1;
entry->data = (void *)&prof_cpu_mask;
entry->read_proc = prof_cpu_mask_read_proc;
entry->write_proc = prof_cpu_mask_write_proc;
create_prof_cpu_mask(root_irq_dir);
}
......@@ -185,7 +185,6 @@ extern char _stext, _etext;
static inline void s390_do_profile(struct pt_regs * regs)
{
unsigned long eip;
extern cpumask_t prof_cpu_mask;
profile_hook(regs);
......
......@@ -251,7 +251,6 @@ EXPORT_SYMBOL(do_settimeofday);
static long last_rtc_update;
/* Profiling definitions */
extern unsigned long prof_cpu_mask;
extern unsigned int * prof_buffer;
extern unsigned long prof_len;
extern unsigned long prof_shift;
......
......@@ -610,30 +610,6 @@ static int irq_affinity_write_proc (struct file *file, const char *buffer,
return full_count;
}
static int prof_cpu_mask_read_proc (char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len = cpumask_scnprintf(page, count, *(cpumask_t *)data);
if (count - len < 2)
return -EINVAL;
len += sprintf(page + len, "\n");
return len;
}
static int prof_cpu_mask_write_proc (struct file *file, const char *buffer,
unsigned long count, void *data)
{
cpumask_t *mask = (cpumask_t *)data, new_value;
unsigned long full_count = count, err;
err = cpumask_parse(buffer, count, new_value);
if (err)
return err;
*mask = new_value;
return full_count;
}
#define MAX_NAMELEN 10
static void register_irq_proc (unsigned int irq)
......@@ -662,24 +638,15 @@ static void register_irq_proc (unsigned int irq)
smp_affinity_entry[irq] = entry;
}
/* Read and written as a long */
cpumask_t prof_cpu_mask = CPU_MASK_ALL;
void __init init_irq_proc (void)
{
struct proc_dir_entry *entry;
int i;
/* create /proc/irq */
root_irq_dir = proc_mkdir("irq", 0);
/* create /proc/irq/prof_cpu_mask */
entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir);
entry->nlink = 1;
entry->data = (void *)&prof_cpu_mask;
entry->read_proc = prof_cpu_mask_read_proc;
entry->write_proc = prof_cpu_mask_write_proc;
create_prof_cpu_mask(root_irq_dir);
/*
* Create entries for all existing IRQs.
......
......@@ -862,31 +862,6 @@ static int irq_affinity_write_proc (struct file *file,
#endif
static int prof_cpu_mask_read_proc (char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len = cpumask_scnprintf(page, count, *(cpumask_t *)data);
if (count - len < 2)
return -EINVAL;
len += sprintf(page + len, "\n");
return len;
}
static int prof_cpu_mask_write_proc (struct file *file,
const char __user *buffer,
unsigned long count, void *data)
{
unsigned long full_count = count, err;
cpumask_t new_value, *mask = (cpumask_t *)data;
err = cpumask_parse(buffer, count, new_value);
if (err)
return err;
*mask = new_value;
return full_count;
}
#define MAX_NAMELEN 10
static void register_irq_proc (unsigned int irq)
......@@ -922,26 +897,15 @@ static void register_irq_proc (unsigned int irq)
#endif
}
unsigned long prof_cpu_mask = -1;
void init_irq_proc (void)
{
struct proc_dir_entry *entry;
int i;
/* create /proc/irq */
root_irq_dir = proc_mkdir("irq", NULL);
/* create /proc/irq/prof_cpu_mask */
entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir);
if (!entry)
return;
entry->nlink = 1;
entry->data = (void *)&prof_cpu_mask;
entry->read_proc = prof_cpu_mask_read_proc;
entry->write_proc = prof_cpu_mask_write_proc;
create_prof_cpu_mask(root_irq_dir);
/*
* Create entries for all existing IRQs.
......@@ -949,4 +913,3 @@ void init_irq_proc (void)
for (i = 0; i < NR_IRQS; i++)
register_irq_proc(i);
}
......@@ -70,8 +70,6 @@ extern atomic_t irq_mis_count;
static inline void __do_profile(unsigned long eip)
{
extern unsigned long prof_cpu_mask;
if (!prof_buffer)
return;
......@@ -79,7 +77,7 @@ static inline void __do_profile(unsigned long eip)
* Only measure the CPUs specified by /proc/irq/prof_cpu_mask.
* (default is all CPUs.)
*/
if (!((1<<smp_processor_id()) & prof_cpu_mask))
if (!cpu_isset(smp_processor_id(), prof_cpu_mask))
return;
eip -= (unsigned long)_stext;
......
......@@ -132,7 +132,6 @@ __asm__( \
static inline void x86_do_profile (struct pt_regs *regs)
{
unsigned long rip;
extern unsigned long prof_cpu_mask;
extern char _stext[];
profile_hook(regs);
......@@ -148,7 +147,7 @@ static inline void x86_do_profile (struct pt_regs *regs)
* Only measure the CPUs specified by /proc/irq/prof_cpu_mask.
* (default is all CPUs.)
*/
if (!((1<<smp_processor_id()) & prof_cpu_mask))
if (!cpu_isset(smp_processor_id(), prof_cpu_mask))
return;
rip -= (unsigned long) &_stext;
......
......@@ -6,18 +6,23 @@
#include <linux/kernel.h>
#include <linux/config.h>
#include <linux/init.h>
#include <linux/cpumask.h>
#include <asm/errno.h>
struct proc_dir_entry;
/* parse command line */
int __init profile_setup(char * str);
/* init basic kernel profiler */
void __init profile_init(void);
void create_prof_cpu_mask(struct proc_dir_entry *);
extern unsigned int * prof_buffer;
extern unsigned long prof_len;
extern unsigned long prof_shift;
extern int prof_on;
extern cpumask_t prof_cpu_mask;
enum profile_type {
......
......@@ -8,12 +8,14 @@
#include <linux/bootmem.h>
#include <linux/notifier.h>
#include <linux/mm.h>
#include <linux/cpumask.h>
#include <asm/sections.h>
unsigned int * prof_buffer;
unsigned long prof_len;
unsigned long prof_shift;
int prof_on;
cpumask_t prof_cpu_mask = CPU_MASK_ALL;
int __init profile_setup(char * str)
{
......@@ -163,3 +165,46 @@ EXPORT_SYMBOL_GPL(unregister_profile_notifier);
EXPORT_SYMBOL_GPL(profile_event_register);
EXPORT_SYMBOL_GPL(profile_event_unregister);
#ifdef CONFIG_PROC_FS
#include <linux/proc_fs.h>
#include <asm/uaccess.h>
static int prof_cpu_mask_read_proc (char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len = cpumask_scnprintf(page, count, *(cpumask_t *)data);
if (count - len < 2)
return -EINVAL;
len += sprintf(page + len, "\n");
return len;
}
static int prof_cpu_mask_write_proc (struct file *file, const char __user *buffer,
unsigned long count, void *data)
{
cpumask_t *mask = (cpumask_t *)data;
unsigned long full_count = count, err;
cpumask_t new_value;
err = cpumask_parse(buffer, count, new_value);
if (err)
return err;
*mask = new_value;
return full_count;
}
void create_prof_cpu_mask(struct proc_dir_entry *root_irq_dir)
{
struct proc_dir_entry *entry;
/* create /proc/irq/prof_cpu_mask */
if (!(entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir)))
return;
entry->nlink = 1;
entry->data = (void *)&prof_cpu_mask;
entry->read_proc = prof_cpu_mask_read_proc;
entry->write_proc = prof_cpu_mask_write_proc;
}
#endif /* CONFIG_PROC_FS */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment