Merge master.kernel.org:/pub/scm/linux/kernel/git/herbert/crypto-2.6
[linux-drm-fsl-dcu.git] / arch / ia64 / kernel / perfmon.c
index aa94f60fa8e7724ee04f83e665e9b762c97540ca..e7191ca30b165806d1cf28a49c88ca89f99d2512 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/interrupt.h>
-#include <linux/smp_lock.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/init.h>
  * in UP:
  *     - we need to protect against PMU overflow interrupts (local_irq_disable)
  *
- * spin_lock_irqsave()/spin_lock_irqrestore():
+ * spin_lock_irqsave()/spin_unlock_irqrestore():
  *     in SMP: local_irq_disable + spin_lock
  *     in UP : local_irq_disable
  *
@@ -521,19 +520,57 @@ pfm_sysctl_t pfm_sysctl;
 EXPORT_SYMBOL(pfm_sysctl);
 
 static ctl_table pfm_ctl_table[]={
-       {1, "debug", &pfm_sysctl.debug, sizeof(int), 0666, NULL, &proc_dointvec, NULL,},
-       {2, "debug_ovfl", &pfm_sysctl.debug_ovfl, sizeof(int), 0666, NULL, &proc_dointvec, NULL,},
-       {3, "fastctxsw", &pfm_sysctl.fastctxsw, sizeof(int), 0600, NULL, &proc_dointvec, NULL,},
-       {4, "expert_mode", &pfm_sysctl.expert_mode, sizeof(int), 0600, NULL, &proc_dointvec, NULL,},
-       { 0, },
+       {
+               .ctl_name       = CTL_UNNUMBERED,
+               .procname       = "debug",
+               .data           = &pfm_sysctl.debug,
+               .maxlen         = sizeof(int),
+               .mode           = 0666,
+               .proc_handler   = &proc_dointvec,
+       },
+       {
+               .ctl_name       = CTL_UNNUMBERED,
+               .procname       = "debug_ovfl",
+               .data           = &pfm_sysctl.debug_ovfl,
+               .maxlen         = sizeof(int),
+               .mode           = 0666,
+               .proc_handler   = &proc_dointvec,
+       },
+       {
+               .ctl_name       = CTL_UNNUMBERED,
+               .procname       = "fastctxsw",
+               .data           = &pfm_sysctl.fastctxsw,
+               .maxlen         = sizeof(int),
+               .mode           = 0600,
+               .proc_handler   =  &proc_dointvec,
+       },
+       {
+               .ctl_name       = CTL_UNNUMBERED,
+               .procname       = "expert_mode",
+               .data           = &pfm_sysctl.expert_mode,
+               .maxlen         = sizeof(int),
+               .mode           = 0600,
+               .proc_handler   = &proc_dointvec,
+       },
+       {}
 };
 static ctl_table pfm_sysctl_dir[] = {
-       {1, "perfmon", NULL, 0, 0755, pfm_ctl_table, },
-       {0,},
+       {
+               .ctl_name       = CTL_UNNUMBERED,
+               .procname       = "perfmon",
+               .mode           = 0755,
+               .child          = pfm_ctl_table,
+       },
+       {}
 };
 static ctl_table pfm_sysctl_root[] = {
-       {1, "kernel", NULL, 0, 0755, pfm_sysctl_dir, },
-       {0,},
+       {
+               .ctl_name       = CTL_KERN,
+               .procname       = "kernel",
+               .mode           = 0755,
+               .child          = pfm_sysctl_dir,
+       },
+       {}
 };
 static struct ctl_table_header *pfm_sysctl_header;
 
@@ -621,7 +658,7 @@ EXPORT_PER_CPU_SYMBOL_GPL(pfm_syst_info);
 
 
 /* forward declaration */
-static struct file_operations pfm_file_ops;
+static const struct file_operations pfm_file_ops;
 
 /*
  * forward declarations
@@ -2126,7 +2163,7 @@ pfm_no_open(struct inode *irrelevant, struct file *dontcare)
 
 
 
-static struct file_operations pfm_file_ops = {
+static const struct file_operations pfm_file_ops = {
        .llseek   = no_llseek,
        .read     = pfm_read,
        .write    = pfm_write,
@@ -2261,7 +2298,7 @@ pfm_remap_buffer(struct vm_area_struct *vma, unsigned long buf, unsigned long ad
  * allocate a sampling buffer and remaps it into the user address space of the task
  */
 static int
-pfm_smpl_buffer_alloc(struct task_struct *task, pfm_context_t *ctx, unsigned long rsize, void **user_vaddr)
+pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_t *ctx, unsigned long rsize, void **user_vaddr)
 {
        struct mm_struct *mm = task->mm;
        struct vm_area_struct *vma = NULL;
@@ -2301,17 +2338,17 @@ pfm_smpl_buffer_alloc(struct task_struct *task, pfm_context_t *ctx, unsigned lon
        DPRINT(("smpl_buf @%p\n", smpl_buf));
 
        /* allocate vma */
-       vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
+       vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
        if (!vma) {
                DPRINT(("Cannot allocate vma\n"));
                goto error_kmem;
        }
-       memset(vma, 0, sizeof(*vma));
 
        /*
         * partially initialize the vma for the sampling buffer
         */
        vma->vm_mm           = mm;
+       vma->vm_file         = filp;
        vma->vm_flags        = VM_READ| VM_MAYREAD |VM_RESERVED;
        vma->vm_page_prot    = PAGE_READONLY; /* XXX may need to change */
 
@@ -2350,6 +2387,8 @@ pfm_smpl_buffer_alloc(struct task_struct *task, pfm_context_t *ctx, unsigned lon
                goto error;
        }
 
+       get_file(filp);
+
        /*
         * now insert the vma in the vm list for the process, must be
         * done with mmap lock held
@@ -2427,7 +2466,7 @@ pfarg_is_sane(struct task_struct *task, pfarg_context_t *pfx)
 }
 
 static int
-pfm_setup_buffer_fmt(struct task_struct *task, pfm_context_t *ctx, unsigned int ctx_flags,
+pfm_setup_buffer_fmt(struct task_struct *task, struct file *filp, pfm_context_t *ctx, unsigned int ctx_flags,
                     unsigned int cpu, pfarg_context_t *arg)
 {
        pfm_buffer_fmt_t *fmt = NULL;
@@ -2468,7 +2507,7 @@ pfm_setup_buffer_fmt(struct task_struct *task, pfm_context_t *ctx, unsigned int
                /*
                 * buffer is always remapped into the caller's address space
                 */
-               ret = pfm_smpl_buffer_alloc(current, ctx, size, &uaddr);
+               ret = pfm_smpl_buffer_alloc(current, filp, ctx, size, &uaddr);
                if (ret) goto error;
 
                /* keep track of user address of buffer */
@@ -2679,7 +2718,7 @@ pfm_context_create(pfm_context_t *ctx, void *arg, int count, struct pt_regs *reg
         * does the user want to sample?
         */
        if (pfm_uuid_cmp(req->ctx_smpl_buf_id, pfm_null_uuid)) {
-               ret = pfm_setup_buffer_fmt(current, ctx, ctx_flags, 0, req);
+               ret = pfm_setup_buffer_fmt(current, filp, ctx, ctx_flags, 0, req);
                if (ret) goto buffer_error;
        }
 
@@ -6597,7 +6636,7 @@ found:
        return 0;
 }
 
-static struct file_operations pfm_proc_fops = {
+static const struct file_operations pfm_proc_fops = {
        .open           = pfm_proc_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
@@ -6689,7 +6728,7 @@ pfm_init(void)
        /*
         * create /proc/sys/kernel/perfmon (for debugging purposes)
         */
-       pfm_sysctl_header = register_sysctl_table(pfm_sysctl_root, 0);
+       pfm_sysctl_header = register_sysctl_table(pfm_sysctl_root);
 
        /*
         * initialize all our spinlocks