ccw_timeout_log [S390]
                        See Documentation/s390/common_io.rst for details.
 
-       cgroup_disable= [KNL] Disable a particular controller
-                       Format: {name of the controller(s) to disable}
+       cgroup_disable= [KNL] Disable a particular controller or optional feature
+                       Format: {name of the controller(s) or feature(s) to disable}
                        The effects of cgroup_disable=foo are:
                        - foo isn't auto-mounted if you mount all cgroups in
                          a single hierarchy
                        - foo isn't visible as an individually mountable
                          subsystem
+                       - if foo is an optional feature then the feature is
+                         disabled and corresponding cgroup files are not
+                         created
                        {Currently only "memory" controller deal with this and
                        cut the overhead, others just disable the usage. So
                        only cgroup_disable=memory is actually worthy}
+                       Specifying "pressure" disables per-cgroup pressure
+                       stall information accounting feature
 
        cgroup_no_v1=   [KNL] Disable cgroup controllers and named hierarchies in v1
                        Format: { { controller | "all" | "named" }
 
 static struct file_system_type cgroup2_fs_type;
 static struct cftype cgroup_base_files[];
 
+/* cgroup optional features */
+enum cgroup_opt_features {
+#ifdef CONFIG_PSI
+       OPT_FEATURE_PRESSURE,
+#endif
+       OPT_FEATURE_COUNT
+};
+
+static const char *cgroup_opt_feature_names[OPT_FEATURE_COUNT] = {
+#ifdef CONFIG_PSI
+       "pressure",
+#endif
+};
+
+static u16 cgroup_feature_disable_mask __read_mostly;
+
 static int cgroup_apply_control(struct cgroup *cgrp);
 static void cgroup_finalize_control(struct cgroup *cgrp, int ret);
 static void css_task_iter_skip(struct css_task_iter *it,
 {
        psi_trigger_replace(&of->priv, NULL);
 }
+
+bool cgroup_psi_enabled(void)
+{
+       return (cgroup_feature_disable_mask & (1 << OPT_FEATURE_PRESSURE)) == 0;
+}
+
+#else /* CONFIG_PSI */
+bool cgroup_psi_enabled(void)
+{
+       return false;
+}
+
 #endif /* CONFIG_PSI */
 
 static int cgroup_freeze_show(struct seq_file *seq, void *v)
 restart:
        for (cft = cfts; cft != cft_end && cft->name[0] != '\0'; cft++) {
                /* does cft->flags tell us to skip this file on @cgrp? */
+               if ((cft->flags & CFTYPE_PRESSURE) && !cgroup_psi_enabled())
+                       continue;
                if ((cft->flags & __CFTYPE_ONLY_ON_DFL) && !cgroup_on_dfl(cgrp))
                        continue;
                if ((cft->flags & __CFTYPE_NOT_ON_DFL) && cgroup_on_dfl(cgrp))
 
                WARN_ON(cft->ss || cft->kf_ops);
 
+               if ((cft->flags & CFTYPE_PRESSURE) && !cgroup_psi_enabled())
+                       continue;
+
                if (cft->seq_start)
                        kf_ops = &cgroup_kf_ops;
                else
 #ifdef CONFIG_PSI
        {
                .name = "io.pressure",
+               .flags = CFTYPE_PRESSURE,
                .seq_show = cgroup_io_pressure_show,
                .write = cgroup_io_pressure_write,
                .poll = cgroup_pressure_poll,
        },
        {
                .name = "memory.pressure",
+               .flags = CFTYPE_PRESSURE,
                .seq_show = cgroup_memory_pressure_show,
                .write = cgroup_memory_pressure_write,
                .poll = cgroup_pressure_poll,
        },
        {
                .name = "cpu.pressure",
+               .flags = CFTYPE_PRESSURE,
                .seq_show = cgroup_cpu_pressure_show,
                .write = cgroup_cpu_pressure_write,
                .poll = cgroup_pressure_poll,
                        pr_info("Disabling %s control group subsystem\n",
                                ss->name);
                }
+
+               for (i = 0; i < OPT_FEATURE_COUNT; i++) {
+                       if (strcmp(token, cgroup_opt_feature_names[i]))
+                               continue;
+                       cgroup_feature_disable_mask |= 1 << i;
+                       pr_info("Disabling %s control group feature\n",
+                               cgroup_opt_feature_names[i]);
+                       break;
+               }
        }
        return 1;
 }
                if (!(cft->flags & CFTYPE_NS_DELEGATABLE))
                        continue;
 
+               if ((cft->flags & CFTYPE_PRESSURE) && !cgroup_psi_enabled())
+                       continue;
+
                if (prefix)
                        ret += snprintf(buf + ret, size - ret, "%s.", prefix);
 
 
 static int psi_bug __read_mostly;
 
 DEFINE_STATIC_KEY_FALSE(psi_disabled);
+DEFINE_STATIC_KEY_TRUE(psi_cgroups_enabled);
 
 #ifdef CONFIG_PSI_DEFAULT_DISABLED
 static bool psi_enable;
                return;
        }
 
+       if (!cgroup_psi_enabled())
+               static_branch_disable(&psi_cgroups_enabled);
+
        psi_period = jiffies_to_nsecs(PSI_FREQ);
        group_init(&psi_system);
 }
 
 static struct psi_group *iterate_groups(struct task_struct *task, void **iter)
 {
+       if (*iter == &psi_system)
+               return NULL;
+
 #ifdef CONFIG_CGROUPS
-       struct cgroup *cgroup = NULL;
+       if (static_branch_likely(&psi_cgroups_enabled)) {
+               struct cgroup *cgroup = NULL;
 
-       if (!*iter)
-               cgroup = task->cgroups->dfl_cgrp;
-       else if (*iter == &psi_system)
-               return NULL;
-       else
-               cgroup = cgroup_parent(*iter);
+               if (!*iter)
+                       cgroup = task->cgroups->dfl_cgrp;
+               else
+                       cgroup = cgroup_parent(*iter);
 
-       if (cgroup && cgroup_parent(cgroup)) {
-               *iter = cgroup;
-               return cgroup_psi(cgroup);
+               if (cgroup && cgroup_parent(cgroup)) {
+                       *iter = cgroup;
+                       return cgroup_psi(cgroup);
+               }
        }
-#else
-       if (*iter)
-               return NULL;
 #endif
        *iter = &psi_system;
        return &psi_system;