From: Sebastian Andrzej Siewior <[email protected]>

commit 7365bbf5b570044ffbb66bc31af6cd5442b96cea linux-rt-devel.

This is an all-on-one change to align the state of the patch with what
has been submit upstream. This includes the following patches:

  [PATCH 1/2] mm/compaction: Really limit compact_unevictable_allowed to 0…1
  [PATCH 2/2 v5] mm/compaction: Disable compact_unevictable_allowed on RT

Signed-off-by: Sebastian Andrzej Siewior <[email protected]>
Signed-off-by: Paul Gortmaker <[email protected]>
---
 Documentation/admin-guide/sysctl/vm.rst |  3 +++
 kernel/sysctl.c                         | 32 +++++++++++++++++++++++++++++---
 mm/compaction.c                         |  2 +-
 3 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/Documentation/admin-guide/sysctl/vm.rst 
b/Documentation/admin-guide/sysctl/vm.rst
index 64aeee1009ca..0329a4d3fa9e 100644
--- a/Documentation/admin-guide/sysctl/vm.rst
+++ b/Documentation/admin-guide/sysctl/vm.rst
@@ -128,6 +128,9 @@ allowed to examine the unevictable lru (mlocked pages) for 
pages to compact.
 This should be used on systems where stalls for minor page faults are an
 acceptable trade for large contiguous free memory.  Set to 0 to prevent
 compaction from moving pages that are unevictable.  Default value is 1.
+On CONFIG_PREEMPT_RT the default value is 0 in order to avoid a page fault, due
+to compaction, which would block the task from becomming active until the fault
+is resolved.
 
 
 dirty_background_bytes
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index d08bd51a0fbc..8221219d65c3 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -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
@@ -1488,17 +1493,16 @@ static struct ctl_table vm_table[] = {
                .extra1         = &min_extfrag_threshold,
                .extra2         = &max_extfrag_threshold,
        },
-#ifndef CONFIG_PREEMPT_RT
        {
                .procname       = "compact_unevictable_allowed",
                .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,
        },
-#endif
+
 #endif /* CONFIG_COMPACTION */
        {
                .procname       = "min_free_kbytes",
@@ -2582,6 +2586,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
diff --git a/mm/compaction.c b/mm/compaction.c
index 83cc3d1e5df7..31e6e103f38b 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -1591,7 +1591,7 @@ typedef enum {
  * compactable pages.
  */
 #ifdef CONFIG_PREEMPT_RT
-#define sysctl_compact_unevictable_allowed 0
+int sysctl_compact_unevictable_allowed __read_mostly = 0;
 #else
 int sysctl_compact_unevictable_allowed __read_mostly = 1;
 #endif
-- 
2.7.4

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#8697): 
https://lists.yoctoproject.org/g/linux-yocto/message/8697
Mute This Topic: https://lists.yoctoproject.org/mt/74332647/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub  
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to