perf metricgroup: Delay events string creation
[linux-2.6-microblaze.git] / kernel / sysctl.c
index ad5b88a..8a176d8 100644 (file)
@@ -212,6 +212,11 @@ static int proc_do_cad_pid(struct ctl_table *table, int write,
                  void __user *buffer, size_t *lenp, loff_t *ppos);
 static int proc_taint(struct ctl_table *table, int write,
                               void __user *buffer, size_t *lenp, loff_t *ppos);
+#ifdef CONFIG_COMPACTION
+static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
+                                              int write, void __user *buffer,
+                                              size_t *lenp, loff_t *ppos);
+#endif
 #endif
 
 #ifdef CONFIG_PRINTK
@@ -229,25 +234,8 @@ static int proc_dopipe_max_size(struct ctl_table *table, int write,
                void __user *buffer, size_t *lenp, loff_t *ppos);
 
 #ifdef CONFIG_MAGIC_SYSRQ
-/* Note: sysrq code uses its own private copy */
-static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
-
 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
-                               void __user *buffer, size_t *lenp,
-                               loff_t *ppos)
-{
-       int error;
-
-       error = proc_dointvec(table, write, buffer, lenp, ppos);
-       if (error)
-               return error;
-
-       if (write)
-               sysrq_toggle_support(__sysrq_enabled);
-
-       return 0;
-}
-
+                       void __user *buffer, size_t *lenp, loff_t *ppos);
 #endif
 
 static struct ctl_table kern_table[];
@@ -747,7 +735,7 @@ static struct ctl_table kern_table[] = {
 #ifdef CONFIG_MAGIC_SYSRQ
        {
                .procname       = "sysrq",
-               .data           = &__sysrq_enabled,
+               .data           = NULL,
                .maxlen         = sizeof (int),
                .mode           = 0644,
                .proc_handler   = sysrq_sysctl_handler,
@@ -1484,7 +1472,7 @@ static struct ctl_table vm_table[] = {
                .data           = &sysctl_compact_unevictable_allowed,
                .maxlen         = sizeof(int),
                .mode           = 0644,
-               .proc_handler   = proc_dointvec,
+               .proc_handler   = proc_dointvec_minmax_warn_RT_change,
                .extra1         = SYSCTL_ZERO,
                .extra2         = SYSCTL_ONE,
        },
@@ -2572,6 +2560,28 @@ int proc_dointvec(struct ctl_table *table, int write,
        return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
 }
 
+#ifdef CONFIG_COMPACTION
+static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
+                                              int write, void __user *buffer,
+                                              size_t *lenp, loff_t *ppos)
+{
+       int ret, old;
+
+       if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write)
+               return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
+
+       old = *(int *)table->data;
+       ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
+       if (ret)
+               return ret;
+       if (old != *(int *)table->data)
+               pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
+                            table->procname, current->comm,
+                            task_pid_nr(current));
+       return ret;
+}
+#endif
+
 /**
  * proc_douintvec - read a vector of unsigned integers
  * @table: the sysctl table
@@ -2835,6 +2845,26 @@ static int proc_dostring_coredump(struct ctl_table *table, int write,
 }
 #endif
 
+#ifdef CONFIG_MAGIC_SYSRQ
+static int sysrq_sysctl_handler(struct ctl_table *table, int write,
+                               void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+       int tmp, ret;
+
+       tmp = sysrq_mask();
+
+       ret = __do_proc_dointvec(&tmp, table, write, buffer,
+                              lenp, ppos, NULL, NULL);
+       if (ret || !write)
+               return ret;
+
+       if (write)
+               sysrq_toggle_support(tmp);
+
+       return 0;
+}
+#endif
+
 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
                                     void __user *buffer,
                                     size_t *lenp, loff_t *ppos,