aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-05-12 15:20:52 -0400
committerThomas Gleixner <tglx@linutronix.de>2008-05-23 15:07:49 -0400
commit36dfe9252bd4c9b55e8454363fb7e444c92c5030 (patch)
treeed25ba387bc8b27484b93f4acf402ccc622a293f /kernel/trace/trace.c
parentc7078de1aaf562a31b20984409c38cc1b40fa8a3 (diff)
ftrace: make use of tracing_cpumask
Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r--kernel/trace/trace.c95
1 files changed, 64 insertions, 31 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 18f0ab88ca85..3ae17e254fc3 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -70,23 +70,6 @@ static DECLARE_WAIT_QUEUE_HEAD(trace_wait);
70 70
71unsigned long trace_flags = TRACE_ITER_PRINT_PARENT; 71unsigned long trace_flags = TRACE_ITER_PRINT_PARENT;
72 72
73/*
74 * Only trace on a CPU if the bitmask is set:
75 */
76static cpumask_t tracing_cpumask __read_mostly = CPU_MASK_ALL;
77
78/*
79 * The tracer itself will not take this lock, but still we want
80 * to provide a consistent cpumask to user-space:
81 */
82static DEFINE_MUTEX(tracing_cpumask_update_lock);
83
84/*
85 * Temporary storage for the character representation of the
86 * CPU bitmask:
87 */
88static char mask_str[NR_CPUS];
89
90void trace_wake_up(void) 73void trace_wake_up(void)
91{ 74{
92 /* 75 /*
@@ -1776,19 +1759,46 @@ static struct file_operations show_traces_fops = {
1776 .release = seq_release, 1759 .release = seq_release,
1777}; 1760};
1778 1761
1762/*
1763 * Only trace on a CPU if the bitmask is set:
1764 */
1765static cpumask_t tracing_cpumask = CPU_MASK_ALL;
1766
1767/*
1768 * When tracing/tracing_cpu_mask is modified then this holds
1769 * the new bitmask we are about to install:
1770 */
1771static cpumask_t tracing_cpumask_new;
1772
1773/*
1774 * The tracer itself will not take this lock, but still we want
1775 * to provide a consistent cpumask to user-space:
1776 */
1777static DEFINE_MUTEX(tracing_cpumask_update_lock);
1778
1779/*
1780 * Temporary storage for the character representation of the
1781 * CPU bitmask (and one more byte for the newline):
1782 */
1783static char mask_str[NR_CPUS + 1];
1784
1779static ssize_t 1785static ssize_t
1780tracing_cpumask_read(struct file *filp, char __user *ubuf, 1786tracing_cpumask_read(struct file *filp, char __user *ubuf,
1781 size_t count, loff_t *ppos) 1787 size_t count, loff_t *ppos)
1782{ 1788{
1783 int err; 1789 int len;
1784
1785 count = min(count, (size_t)NR_CPUS);
1786 1790
1787 mutex_lock(&tracing_cpumask_update_lock); 1791 mutex_lock(&tracing_cpumask_update_lock);
1788 cpumask_scnprintf(mask_str, NR_CPUS, tracing_cpumask); 1792
1789 err = copy_to_user(ubuf, mask_str, count); 1793 len = cpumask_scnprintf(mask_str, count, tracing_cpumask);
1790 if (err) 1794 if (count - len < 2) {
1791 count = -EFAULT; 1795 count = -EINVAL;
1796 goto out_err;
1797 }
1798 len += sprintf(mask_str + len, "\n");
1799 count = simple_read_from_buffer(ubuf, count, ppos, mask_str, NR_CPUS+1);
1800
1801out_err:
1792 mutex_unlock(&tracing_cpumask_update_lock); 1802 mutex_unlock(&tracing_cpumask_update_lock);
1793 1803
1794 return count; 1804 return count;
@@ -1798,16 +1808,40 @@ static ssize_t
1798tracing_cpumask_write(struct file *filp, const char __user *ubuf, 1808tracing_cpumask_write(struct file *filp, const char __user *ubuf,
1799 size_t count, loff_t *ppos) 1809 size_t count, loff_t *ppos)
1800{ 1810{
1801 int err; 1811 int err, cpu;
1802 1812
1803 mutex_lock(&tracing_cpumask_update_lock); 1813 mutex_lock(&tracing_cpumask_update_lock);
1804 err = cpumask_parse_user(ubuf, count, tracing_cpumask); 1814 err = cpumask_parse_user(ubuf, count, tracing_cpumask_new);
1805 mutex_unlock(&tracing_cpumask_update_lock);
1806
1807 if (err) 1815 if (err)
1808 return err; 1816 goto err_unlock;
1817
1818 spin_lock_irq(&ftrace_max_lock);
1819 for_each_possible_cpu(cpu) {
1820 /*
1821 * Increase/decrease the disabled counter if we are
1822 * about to flip a bit in the cpumask:
1823 */
1824 if (cpu_isset(cpu, tracing_cpumask) &&
1825 !cpu_isset(cpu, tracing_cpumask_new)) {
1826 atomic_inc(&global_trace.data[cpu]->disabled);
1827 }
1828 if (!cpu_isset(cpu, tracing_cpumask) &&
1829 cpu_isset(cpu, tracing_cpumask_new)) {
1830 atomic_dec(&global_trace.data[cpu]->disabled);
1831 }
1832 }
1833 spin_unlock_irq(&ftrace_max_lock);
1834
1835 tracing_cpumask = tracing_cpumask_new;
1836
1837 mutex_unlock(&tracing_cpumask_update_lock);
1809 1838
1810 return count; 1839 return count;
1840
1841err_unlock:
1842 mutex_unlock(&tracing_cpumask_update_lock);
1843
1844 return err;
1811} 1845}
1812 1846
1813static struct file_operations tracing_cpumask_fops = { 1847static struct file_operations tracing_cpumask_fops = {
@@ -1846,8 +1880,7 @@ tracing_iter_ctrl_read(struct file *filp, char __user *ubuf,
1846 r += sprintf(buf + r, "\n"); 1880 r += sprintf(buf + r, "\n");
1847 WARN_ON(r >= len + 2); 1881 WARN_ON(r >= len + 2);
1848 1882
1849 r = simple_read_from_buffer(ubuf, cnt, ppos, 1883 r = simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
1850 buf, r);
1851 1884
1852 kfree(buf); 1885 kfree(buf);
1853 1886