Skip to contentSkip to conversation

mm: tlb swap entries batch async release

PATCH Superseded Zhiguo Jiang 4 participants 12 messages Jul 30, 2024 – Aug 1, 2024

Subsystems (7)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover mm: tlb swap entries batch async release

The main reasons for the prolonged exit of a background process is the time-consuming release of its swap entries. The proportion of swap memory occupied by the background process increases with its duration in the background, and after a period of time, this value can reach 60% or more. Additionally, the relatively lengthy path for releasing swap entries further contributes to the longer time required for the background process to release its swap entries.

In the multiple background applications scenario, when launching a large memory application such as a camera, system may enter a low memory state, which will triggers the killing of multiple background processes at the same time. Due to multiple exiting processes occupying multiple CPUs for concurrent execution, the current foreground application's CPU resources are tight and may cause issues such as lagging.

To solve this problem, we have introduced the multiple exiting process asynchronous swap memory release mechanism, which isolates and caches swap entries occupied by multiple exit processes, and hands them over to an asynchronous kworker to complete the release. This allows the exiting processes to complete quickly and release CPU resources. We have validated this modification on the products and achieved the expected benefits.

It offers several benefits:
1. Alleviate the high system cpu load caused by multiple exiting processes running simultaneously.
2. Reduce lock competition in swap entry free path by an asynchronous kworker instead of multiple exiting processes parallel execution.
3. Release memory occupied by exiting processes more efficiently.

Zhiguo Jiang (2):
mm: move task_is_dying to h headfile
mm: tlb: multiple exiting processes's swap entries async release

 include/asm-generic/tlb.h |  50 +++++++
 include/linux/mm_types.h  |  58 ++++++++
 include/linux/oom.h       |   6 +
 mm/memcontrol.c           |   6 -
 mm/memory.c               |   3 +-
 mm/mmu_gather.c           | 297 ++++++++++++++++++++++++++++++++++++++
 6 files changed, 413 insertions(+), 7 deletions(-)
 mode change 100644 => 100755 include/asm-generic/tlb.h
 mode change 100644 => 100755 include/linux/mm_types.h
 mode change 100644 => 100755 include/linux/oom.h
 mode change 100644 => 100755 mm/memcontrol.c
 mode change 100644 => 100755 mm/memory.c
 mode change 100644 => 100755 mm/mmu_gather.c
Signature · 1 line
2.39.0
#1 lore raw

PATCH 1/2 mm: move task_is_dying to h headfile

Move task_is_dying() to include/linux/oom.h so that it can be referenced elsewhere.

---
 include/linux/oom.h | 6 ++++++
 mm/memcontrol.c     | 6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)
include/linux/oom.h +6 -0
index 7d0c9c48a0c5..a3a58463c0d5
@@ -77,6 +77,12 @@ static inline bool tsk_is_oom_victim(struct task_struct * tsk)
 	return tsk->signal->oom_mm;
 }
 
+static inline bool task_is_dying(void)
+{
+	return tsk_is_oom_victim(current) || fatal_signal_pending(current) ||
+		(current->flags & PF_EXITING);
+}
+
 /*
  * Checks whether a page fault on the given mm is still reliable.
  * This is no longer true if the oom reaper started to reap the
mm/memcontrol.c +0 -6
index 9b3ef3a70833..c54a8aea19b0
@@ -98,12 +98,6 @@ static DECLARE_WAIT_QUEUE_HEAD(memcg_cgwb_frn_waitq);
 #define THRESHOLDS_EVENTS_TARGET 128
 #define SOFTLIMIT_EVENTS_TARGET 1024
 
-static inline bool task_is_dying(void)
-{
-	return tsk_is_oom_victim(current) || fatal_signal_pending(current) ||
-		(current->flags & PF_EXITING);
-}
-
 /* Some nice accessors for the vmpressure. */
 struct vmpressure *memcg_to_vmpressure(struct mem_cgroup *memcg)
 {
Signature · 1 line
2.39.0
#2 lore raw

PATCH 2/2 mm: tlb: add tlb swap entries batch async release

In reply to Zhiguo Jiang

The main reasons for the prolonged exit of a background process is the time-consuming release of its swap entries. The proportion of swap memory occupied by the background process increases with its duration in the background, and after a period of time, this value can reach 60% or more. Additionally, the relatively lengthy path for releasing swap entries further contributes to the longer time required for the background process to release its swap entries.

In the multiple background applications scenario, when launching a large memory application such as a camera, system may enter a low memory state, which will triggers the killing of multiple background processes at the same time. Due to multiple exiting processes occupying multiple CPUs for concurrent execution, the current foreground application's CPU resources are tight and may cause issues such as lagging.

To solve this problem, we have introduced the multiple exiting process asynchronous swap memory release mechanism, which isolates and caches swap entries occupied by multiple exit processes, and hands them over to an asynchronous kworker to complete the release. This allows the exiting processes to complete quickly and release CPU resources. We have validated this modification on the products and achieved the expected benefits.

It offers several benefits:
1. Alleviate the high system cpu load caused by multiple exiting processes running simultaneously.
2. Reduce lock competition in swap entry free path by an asynchronous kworker instead of multiple exiting processes parallel execution.
3. Release memory occupied by exiting processes more efficiently.

---
 include/asm-generic/tlb.h |  50 +++++++
 include/linux/mm_types.h  |  58 ++++++++
 mm/memory.c               |   3 +-
 mm/mmu_gather.c           | 297 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 407 insertions(+), 1 deletion(-)
include/asm-generic/tlb.h +50 -0
index 709830274b75..aab43f1cf97f
@@ -294,6 +294,43 @@ extern void tlb_flush_rmaps(struct mmu_gather *tlb, struct vm_area_struct *vma);
 static inline void tlb_flush_rmaps(struct mmu_gather *tlb, struct vm_area_struct *vma) { }
 #endif
 
+#ifndef CONFIG_MMU_GATHER_NO_GATHER
+struct mmu_swap_batch {
+	struct mmu_swap_batch *next;
+	unsigned int nr;
+	unsigned int max;
+	encoded_swpentry_t encoded_entrys[];
+};
+
+#define MAX_SWAP_GATHER_BATCH	\
+	((PAGE_SIZE - sizeof(struct mmu_swap_batch)) / sizeof(void *))
+
+#define MAX_SWAP_GATHER_BATCH_COUNT	(10000UL / MAX_SWAP_GATHER_BATCH)
+
+struct mmu_swap_gather {
+	/*
+	 * the asynchronous kworker to batch
+	 * release swap entries
+	 */
+	struct work_struct free_work;
+
+	/* batch cache swap entries */
+	unsigned int batch_count;
+	struct mmu_swap_batch *active;
+	struct mmu_swap_batch local;
+	encoded_swpentry_t __encoded_entrys[MMU_GATHER_BUNDLE];
+};
+
+extern bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
+		swp_entry_t entry, int nr);
+#else
+bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
+		swp_entry_t entry, int nr)
+{
+	return false;
+}
+#endif
+
 /*
  * struct mmu_gather is an opaque type used by the mm code for passing around
  * any data needed by arch specific code for tlb_remove_page.
@@ -343,6 +380,18 @@ struct mmu_gather {
 	unsigned int		vma_exec : 1;
 	unsigned int		vma_huge : 1;
 	unsigned int		vma_pfn  : 1;
+#ifndef CONFIG_MMU_GATHER_NO_GATHER
+	/*
+	 * Two states of releasing swap entries
+	 * asynchronously:
+	 * swp_freeable - have opportunity to
+	 * release asynchronously future
+	 * swp_freeing - be releasing asynchronously.
+	 */
+	unsigned int		swp_freeable : 1;
+	unsigned int		swp_freeing : 1;
+	unsigned int		swp_disable : 1;
+#endif
 
 	unsigned int		batch_count;
 
@@ -354,6 +403,7 @@ struct mmu_gather {
 #ifdef CONFIG_MMU_GATHER_PAGE_SIZE
 	unsigned int page_size;
 #endif
+	struct mmu_swap_gather *swp;
 #endif
 };
 
include/linux/mm_types.h +58 -0

64 lines not on this page · raw message

mm/memory.c +2 -1
index b9f5cc0db3eb..bfa1995558d2
@@ -1650,7 +1650,8 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb,
 			if (!should_zap_cows(details))
 				continue;
 			rss[MM_SWAPENTS] -= nr;
-			free_swap_and_cache_nr(entry, nr);
+			if (!__tlb_remove_swap_entries(tlb, entry, nr))
+				free_swap_and_cache_nr(entry, nr);
 		} else if (is_migration_entry(entry)) {
 			folio = pfn_swap_entry_folio(entry);
 			if (!should_zap_folio(details, folio))
mm/mmu_gather.c +297 -0

320 lines not on this page · raw message

Signature · 1 line
2.39.0
#3 lore raw

Re: [PATCH 2/2] mm: tlb: add tlb swap entries batch async release

kernel test robot noticed the following build errors:

Hi Zhiguo,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]

url:    https://github.com/intel-lab-lkp/linux/commits/Zhiguo-Jiang/mm-move-task_is_dying-to-h-headfile/20240730-215136
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20240730114426.511-3-justinjiang%40vivo.com
patch subject: [PATCH 2/2] mm: tlb: add tlb swap entries batch async release
config: s390-allnoconfig (https://download.01.org/0day-ci/archive/20240731/[email protected]/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project ccae7b461be339e717d02f99ac857cf0bc7d17fc)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240731/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All error/warnings (new ones prefixed by >>):

In file included from arch/s390/mm/init.c:17:
In file included from include/linux/ptrace.h:10:
In file included from include/linux/pid_namespace.h:7:
In file included from include/linux/mm.h:2234:
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]

     514 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   In file included from arch/s390/mm/init.c:25:
   In file included from include/linux/memblock.h:13:
   In file included from arch/s390/include/asm/dma.h:5:
   In file included from include/linux/io.h:14:
   In file included from arch/s390/include/asm/io.h:93:
   include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     548 |         val = __raw_readb(PCI_IOBASE + addr);
         |                           ~~~~~~~~~~ ^
   include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     561 |         val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
         |                                                           ^
   include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
     102 | #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
         |                                                      ^
   In file included from arch/s390/mm/init.c:25:
   In file included from include/linux/memblock.h:13:
   In file included from arch/s390/include/asm/dma.h:5:
   In file included from include/linux/io.h:14:
   In file included from arch/s390/include/asm/io.h:93:
   include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     574 |         val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
      35 | #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
         |                                                           ^
   include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
     115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
         |                                                      ^
   In file included from arch/s390/mm/init.c:25:
   In file included from include/linux/memblock.h:13:
   In file included from arch/s390/include/asm/dma.h:5:
   In file included from include/linux/io.h:14:
   In file included from arch/s390/include/asm/io.h:93:
   include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     585 |         __raw_writeb(value, PCI_IOBASE + addr);
         |                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     595 |         __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     605 |         __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:693:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     693 |         readsb(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:701:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     701 |         readsw(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:709:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     709 |         readsl(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:718:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     718 |         writesb(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:727:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     727 |         writesw(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:736:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     736 |         writesl(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   In file included from arch/s390/mm/init.c:42:
   In file included from arch/s390/include/asm/tlb.h:39:
>> include/asm-generic/tlb.h:327:6: warning: no previous prototype for function '__tlb_remove_swap_entries' [-Wmissing-prototypes]
     327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
         |      ^
   include/asm-generic/tlb.h:327:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
     327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
         | ^
         | static 

14 warnings generated.
--
In file included from arch/s390/mm/pgtable.c:11:
In file included from include/linux/mm.h:2234:
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]

     514 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   In file included from arch/s390/mm/pgtable.c:22:
   In file included from arch/s390/include/asm/tlb.h:39:
>> include/asm-generic/tlb.h:327:6: warning: no previous prototype for function '__tlb_remove_swap_entries' [-Wmissing-prototypes]
     327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
         |      ^
   include/asm-generic/tlb.h:327:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
     327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
         | ^
         | static 

2 warnings generated.
--
In file included from mm/memory.c:44:
In file included from include/linux/mm.h:2234:
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]

     514 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   In file included from mm/memory.c:45:
   include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
      47 |         __mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
         |                                    ~~~~~~~~~~~ ^ ~~~
   include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
      49 |                                 NR_ZONE_LRU_BASE + lru, nr_pages);
         |                                 ~~~~~~~~~~~~~~~~ ^ ~~~
   In file included from mm/memory.c:84:
   In file included from arch/s390/include/asm/io.h:93:
   include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     548 |         val = __raw_readb(PCI_IOBASE + addr);
         |                           ~~~~~~~~~~ ^
   include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     561 |         val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
         |                                                           ^
   include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
     102 | #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
         |                                                      ^
   In file included from mm/memory.c:84:
   In file included from arch/s390/include/asm/io.h:93:
   include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     574 |         val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
      35 | #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
         |                                                           ^
   include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
     115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
         |                                                      ^
   In file included from mm/memory.c:84:
   In file included from arch/s390/include/asm/io.h:93:
   include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     585 |         __raw_writeb(value, PCI_IOBASE + addr);
         |                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     595 |         __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     605 |         __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:693:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     693 |         readsb(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:701:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     701 |         readsw(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:709:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     709 |         readsl(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:718:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     718 |         writesb(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:727:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     727 |         writesw(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:736:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     736 |         writesl(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   In file included from mm/memory.c:88:
   In file included from arch/s390/include/asm/tlb.h:39:
>> include/asm-generic/tlb.h:327:6: warning: no previous prototype for function '__tlb_remove_swap_entries' [-Wmissing-prototypes]
     327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
         |      ^
   include/asm-generic/tlb.h:327:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
     327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
         | ^
         | static 

16 warnings generated.
--
In file included from mm/mmap.c:14:
In file included from include/linux/backing-dev.h:15:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/s390/include/asm/elf.h:181:
In file included from arch/s390/include/asm/mmu_context.h:11:
In file included from arch/s390/include/asm/pgalloc.h:18:
In file included from include/linux/mm.h:2234:
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]

     514 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   In file included from mm/mmap.c:16:
   include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
      47 |         __mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
         |                                    ~~~~~~~~~~~ ^ ~~~
   include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
      49 |                                 NR_ZONE_LRU_BASE + lru, nr_pages);
         |                                 ~~~~~~~~~~~~~~~~ ^ ~~~
   In file included from mm/mmap.c:53:
   In file included from arch/s390/include/asm/tlb.h:39:
>> include/asm-generic/tlb.h:327:6: warning: no previous prototype for function '__tlb_remove_swap_entries' [-Wmissing-prototypes]
     327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
         |      ^
   include/asm-generic/tlb.h:327:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
     327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
         | ^
         | static 

4 warnings generated.
--
In file included from mm/mremap.c:11:
In file included from include/linux/mm.h:2234:
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]

     514 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   In file included from mm/mremap.c:12:
   include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
      47 |         __mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
         |                                    ~~~~~~~~~~~ ^ ~~~
   include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
      49 |                                 NR_ZONE_LRU_BASE + lru, nr_pages);
         |                                 ~~~~~~~~~~~~~~~~ ^ ~~~
   In file included from mm/mremap.c:30:
   In file included from arch/s390/include/asm/tlb.h:39:
>> include/asm-generic/tlb.h:327:6: warning: no previous prototype for function '__tlb_remove_swap_entries' [-Wmissing-prototypes]
     327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
         |      ^
   include/asm-generic/tlb.h:327:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
     327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
         | ^
         | static 

mm/mremap.c:228:20: warning: unused function 'arch_supports_page_table_move' [-Wunused-function]
228 | static inline bool arch_supports_page_table_move(void)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mm/mremap.c:227:39: note: expanded from macro 'arch_supports_page_table_move'
227 | #define arch_supports_page_table_move arch_supports_page_table_move
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 warnings generated.
--
In file included from kernel/sched/core.c:10:
In file included from include/linux/highmem.h:10:
In file included from include/linux/mm.h:2234:
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]

     514 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   In file included from kernel/sched/core.c:34:
   In file included from include/linux/sched/isolation.h:7:
   In file included from include/linux/tick.h:8:
   In file included from include/linux/clockchips.h:14:
   In file included from include/linux/clocksource.h:22:
   In file included from arch/s390/include/asm/io.h:93:
   include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     548 |         val = __raw_readb(PCI_IOBASE + addr);
         |                           ~~~~~~~~~~ ^
   include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     561 |         val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
         |                                                           ^
   include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
     102 | #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
         |                                                      ^
   In file included from kernel/sched/core.c:34:
   In file included from include/linux/sched/isolation.h:7:
   In file included from include/linux/tick.h:8:
   In file included from include/linux/clockchips.h:14:
   In file included from include/linux/clocksource.h:22:
   In file included from arch/s390/include/asm/io.h:93:
   include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     574 |         val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
      35 | #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
         |                                                           ^
   include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
     115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
         |                                                      ^
   In file included from kernel/sched/core.c:34:
   In file included from include/linux/sched/isolation.h:7:
   In file included from include/linux/tick.h:8:
   In file included from include/linux/clockchips.h:14:
   In file included from include/linux/clocksource.h:22:
   In file included from arch/s390/include/asm/io.h:93:
   include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     585 |         __raw_writeb(value, PCI_IOBASE + addr);
         |                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     595 |         __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     605 |         __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:693:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     693 |         readsb(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:701:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     701 |         readsw(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:709:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     709 |         readsl(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:718:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     718 |         writesb(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:727:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     727 |         writesw(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:736:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     736 |         writesl(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   In file included from kernel/sched/core.c:80:
   In file included from arch/s390/include/asm/tlb.h:39:
>> include/asm-generic/tlb.h:327:6: warning: no previous prototype for function '__tlb_remove_swap_entries' [-Wmissing-prototypes]
     327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
         |      ^
   include/asm-generic/tlb.h:327:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
     327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
         | ^
         | static 
   kernel/sched/core.c:6330:20: warning: unused function 'sched_core_cpu_deactivate' [-Wunused-function]
    6330 | static inline void sched_core_cpu_deactivate(unsigned int cpu) {}
         |                    ^~~~~~~~~~~~~~~~~~~~~~~~~

15 warnings generated.
..

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#4 lore raw

Re: [PATCH 2/2] mm: tlb: add tlb swap entries batch async release

Quoted 16 lines · kernel test robot

[Some people who received this message don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Hi Zhiguo,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]

url:    https://github.com/intel-lab-lkp/linux/commits/Zhiguo-Jiang/mm-move-task_is_dying-to-h-headfile/20240730-215136
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20240730114426.511-3-justinjiang%40vivo.com
patch subject: [PATCH 2/2] mm: tlb: add tlb swap entries batch async release
config: s390-allnoconfig (https://download.01.org/0day-ci/archive/20240731/[email protected]/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project ccae7b461be339e717d02f99ac857cf0bc7d17fc)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240731/[email protected]/reproduce)
Quoted 4 lines

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

Hi,

I have fixed the arch s390 config compilation warning in v2. Please kindly help to test again.
https://lore.kernel.org/linux-mm/[email protected]/T/#t

Thanks

Quoted 326 lines

All error/warnings (new ones prefixed by >>):

In file included from arch/s390/mm/init.c:17:
In file included from include/linux/ptrace.h:10:
In file included from include/linux/pid_namespace.h:7:
In file included from include/linux/mm.h:2234:
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
514 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
In file included from arch/s390/mm/init.c:25:
In file included from include/linux/memblock.h:13:
In file included from arch/s390/include/asm/dma.h:5:
In file included from include/linux/io.h:14:
In file included from arch/s390/include/asm/io.h:93:
include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
548 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
561 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
| ^
include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
102 | #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
| ^
In file included from arch/s390/mm/init.c:25:
In file included from include/linux/memblock.h:13:
In file included from arch/s390/include/asm/dma.h:5:
In file included from include/linux/io.h:14:
In file included from arch/s390/include/asm/io.h:93:
include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
574 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
| ^
include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
| ^
In file included from arch/s390/mm/init.c:25:
In file included from include/linux/memblock.h:13:
In file included from arch/s390/include/asm/dma.h:5:
In file included from include/linux/io.h:14:
In file included from arch/s390/include/asm/io.h:93:
include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
585 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
595 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
605 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:693:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
693 | readsb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:701:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
701 | readsw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:709:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
709 | readsl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:718:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
718 | writesb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:727:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
727 | writesw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:736:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
736 | writesl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
In file included from arch/s390/mm/init.c:42:
In file included from arch/s390/include/asm/tlb.h:39:

Quoted 1 line
Quoted 1 line

include/asm-generic/tlb.h:327:6: warning: no previous prototype for function '__tlb_remove_swap_entries' [-Wmissing-prototypes]

327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
| ^
include/asm-generic/tlb.h:327:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
| ^
| static
14 warnings generated.
--
In file included from arch/s390/mm/pgtable.c:11:
In file included from include/linux/mm.h:2234:
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
514 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
In file included from arch/s390/mm/pgtable.c:22:
In file included from arch/s390/include/asm/tlb.h:39:

Quoted 1 line
Quoted 1 line

include/asm-generic/tlb.h:327:6: warning: no previous prototype for function '__tlb_remove_swap_entries' [-Wmissing-prototypes]

327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
| ^
include/asm-generic/tlb.h:327:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
| ^
| static
2 warnings generated.
--
In file included from mm/memory.c:44:
In file included from include/linux/mm.h:2234:
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
514 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
In file included from mm/memory.c:45:
include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
47 | __mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~ ^ ~~~
include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
49 | NR_ZONE_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~~~~~~ ^ ~~~
In file included from mm/memory.c:84:
In file included from arch/s390/include/asm/io.h:93:
include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
548 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
561 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
| ^
include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
102 | #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
| ^
In file included from mm/memory.c:84:
In file included from arch/s390/include/asm/io.h:93:
include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
574 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
| ^
include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
| ^
In file included from mm/memory.c:84:
In file included from arch/s390/include/asm/io.h:93:
include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
585 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
595 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
605 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:693:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
693 | readsb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:701:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
701 | readsw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:709:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
709 | readsl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:718:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
718 | writesb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:727:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
727 | writesw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:736:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
736 | writesl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
In file included from mm/memory.c:88:
In file included from arch/s390/include/asm/tlb.h:39:

Quoted 1 line
Quoted 1 line

include/asm-generic/tlb.h:327:6: warning: no previous prototype for function '__tlb_remove_swap_entries' [-Wmissing-prototypes]

327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
| ^
include/asm-generic/tlb.h:327:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
| ^
| static
16 warnings generated.
--
In file included from mm/mmap.c:14:
In file included from include/linux/backing-dev.h:15:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/s390/include/asm/elf.h:181:
In file included from arch/s390/include/asm/mmu_context.h:11:
In file included from arch/s390/include/asm/pgalloc.h:18:
In file included from include/linux/mm.h:2234:
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
514 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
In file included from mm/mmap.c:16:
include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
47 | __mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~ ^ ~~~
include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
49 | NR_ZONE_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~~~~~~ ^ ~~~
In file included from mm/mmap.c:53:
In file included from arch/s390/include/asm/tlb.h:39:

Quoted 1 line
Quoted 1 line

include/asm-generic/tlb.h:327:6: warning: no previous prototype for function '__tlb_remove_swap_entries' [-Wmissing-prototypes]

327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
| ^
include/asm-generic/tlb.h:327:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
| ^
| static
4 warnings generated.
--
In file included from mm/mremap.c:11:
In file included from include/linux/mm.h:2234:
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
514 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
In file included from mm/mremap.c:12:
include/linux/mm_inline.h:47:41: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
47 | __mod_lruvec_state(lruvec, NR_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~ ^ ~~~
include/linux/mm_inline.h:49:22: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
49 | NR_ZONE_LRU_BASE + lru, nr_pages);
| ~~~~~~~~~~~~~~~~ ^ ~~~
In file included from mm/mremap.c:30:
In file included from arch/s390/include/asm/tlb.h:39:

Quoted 1 line
Quoted 1 line

include/asm-generic/tlb.h:327:6: warning: no previous prototype for function '__tlb_remove_swap_entries' [-Wmissing-prototypes]

327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
| ^
include/asm-generic/tlb.h:327:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
| ^
| static
mm/mremap.c:228:20: warning: unused function 'arch_supports_page_table_move' [-Wunused-function]
228 | static inline bool arch_supports_page_table_move(void)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mm/mremap.c:227:39: note: expanded from macro 'arch_supports_page_table_move'
227 | #define arch_supports_page_table_move arch_supports_page_table_move
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 warnings generated.
--
In file included from kernel/sched/core.c:10:
In file included from include/linux/highmem.h:10:
In file included from include/linux/mm.h:2234:
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
514 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
In file included from kernel/sched/core.c:34:
In file included from include/linux/sched/isolation.h:7:
In file included from include/linux/tick.h:8:
In file included from include/linux/clockchips.h:14:
In file included from include/linux/clocksource.h:22:
In file included from arch/s390/include/asm/io.h:93:
include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
548 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
561 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
| ^
include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
102 | #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
| ^
In file included from kernel/sched/core.c:34:
In file included from include/linux/sched/isolation.h:7:
In file included from include/linux/tick.h:8:
In file included from include/linux/clockchips.h:14:
In file included from include/linux/clocksource.h:22:
In file included from arch/s390/include/asm/io.h:93:
include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
574 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
| ^
include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
| ^
In file included from kernel/sched/core.c:34:
In file included from include/linux/sched/isolation.h:7:
In file included from include/linux/tick.h:8:
In file included from include/linux/clockchips.h:14:
In file included from include/linux/clocksource.h:22:
In file included from arch/s390/include/asm/io.h:93:
include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
585 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
595 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
605 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:693:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
693 | readsb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:701:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
701 | readsw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:709:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
709 | readsl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:718:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
718 | writesb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:727:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
727 | writesw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:736:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
736 | writesl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
In file included from kernel/sched/core.c:80:
In file included from arch/s390/include/asm/tlb.h:39:

Quoted 1 line
Quoted 1 line

include/asm-generic/tlb.h:327:6: warning: no previous prototype for function '__tlb_remove_swap_entries' [-Wmissing-prototypes]

327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
| ^
include/asm-generic/tlb.h:327:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
| ^
| static
kernel/sched/core.c:6330:20: warning: unused function 'sched_core_cpu_deactivate' [-Wunused-function]
6330 | static inline void sched_core_cpu_deactivate(unsigned int cpu) {}
| ^~~~~~~~~~~~~~~~~~~~~~~~~
15 warnings generated.
..

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

#5 lore raw

Re: [PATCH 2/2] mm: tlb: add tlb swap entries batch async release

In reply to Zhiguo Jiang
kernel test robot noticed the following build warnings:

Hi Zhiguo,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]

url:    https://github.com/intel-lab-lkp/linux/commits/Zhiguo-Jiang/mm-move-task_is_dying-to-h-headfile/20240730-215136
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20240730114426.511-3-justinjiang%40vivo.com
patch subject: [PATCH 2/2] mm: tlb: add tlb swap entries batch async release
config: s390-allyesconfig (https://download.01.org/0day-ci/archive/20240731/[email protected]/config)
compiler: s390-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240731/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

In file included from arch/s390/include/asm/tlb.h:39,

                    from mm/oom_kill.c:49:
>> include/asm-generic/tlb.h:327:6: warning: no previous prototype for '__tlb_remove_swap_entries' [-Wmissing-prototypes]

327 | bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
| ^~~~~~~~~~~~~~~~~~~~~~~~~

vim +/__tlb_remove_swap_entries +327 include/asm-generic/tlb.h

323
324 extern bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
325 swp_entry_t entry, int nr);
326 #else

 > 327	bool __tlb_remove_swap_entries(struct mmu_gather *tlb,

328 swp_entry_t entry, int nr)
329 {
330 return false;
331 }
332 #endif
333

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
maintainer
#6 lore raw

Re: [PATCH 2/2] mm: tlb: add tlb swap entries batch async release

In reply to Zhiguo Jiang

include/asm-generic/tlb.h extern void tlb_flush_rmaps(struct mmu_gather *tlb, struct vm_area_struct *vma); · line 332

Quoted 11 lines · Zhiguo Jiang
include/asm-generic/tlb.h +11 -0
+
+
+extern bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
+		swp_entry_t entry, int nr);
+#else
+bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
+		swp_entry_t entry, int nr)
+{
+	return false;
+}
+#endif

To address the reported build regression, that function must be annotated as 'static inline'.

Arnd

#7 lore raw

Re: [PATCH 2/2] mm: tlb: add tlb swap entries batch async release

Quoted 16 lines · Arnd Bergmann

include/asm-generic/tlb.h extern void tlb_flush_rmaps(struct mmu_gather *tlb, struct vm_area_struct *vma); · line 332

Quoted 11 lines · Zhiguo Jiang
include/asm-generic/tlb.h +11 -0
+
+
+extern bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
+		swp_entry_t entry, int nr);
+#else
+bool __tlb_remove_swap_entries(struct mmu_gather *tlb,
+		swp_entry_t entry, int nr)
+{
+	return false;
+}
+#endif

To address the reported build regression, that function must be annotated as 'static inline'.

Quoted 1 line

Arnd

Hi Arnd,

I have added 'static inline' for __tlb_remove_swap_entries() in [PATCH v2 3/3]. Thanks for your nice guidance.
https://lore.kernel.org/linux-mm/[email protected]/T/#t

Thanks
Zhiguo

#8 lore raw

Re: [PATCH 2/2] mm: tlb: add tlb swap entries batch async release

In reply to Zhiguo Jiang
kernel test robot noticed the following build warnings:

Hi Zhiguo,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]

url:    https://github.com/intel-lab-lkp/linux/commits/Zhiguo-Jiang/mm-move-task_is_dying-to-h-headfile/20240730-215136
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20240730114426.511-3-justinjiang%40vivo.com
patch subject: [PATCH 2/2] mm: tlb: add tlb swap entries batch async release
config: i386-randconfig-061-20240731 (https://download.01.org/0day-ci/archive/20240801/[email protected]/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240801/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)

>> mm/mmu_gather.c:54:10: sparse: sparse: symbol 'nr_exiting_processes' was not declared. Should it be static?

mm/mmu_gather.c: note: in included file (through include/linux/mmzone.h, include/linux/gfp.h):
include/linux/page-flags.h:235:46: sparse: sparse: self-comparison always evaluates to false include/linux/page-flags.h:235:46: sparse: sparse: self-comparison always evaluates to false

vim +/nr_exiting_processes +54 mm/mmu_gather.c

    53	
  > 54	atomic_t nr_exiting_processes = ATOMIC_INIT(0);
    55	static struct kmem_cache *swap_gather_cachep;
    56	static struct workqueue_struct *swapfree_wq;
    57	static DEFINE_STATIC_KEY_TRUE(tlb_swap_asyncfree_disabled);
    58	
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#9 lore raw

Re: [PATCH 2/2] mm: tlb: add tlb swap entries batch async release

Quoted 14 lines · kernel test robot

Hi Zhiguo,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]

url:    https://github.com/intel-lab-lkp/linux/commits/Zhiguo-Jiang/mm-move-task_is_dying-to-h-headfile/20240730-215136
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20240730114426.511-3-justinjiang%40vivo.com
patch subject: [PATCH 2/2] mm: tlb: add tlb swap entries batch async release
config: i386-randconfig-061-20240731 (https://download.01.org/0day-ci/archive/20240801/[email protected]/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240801/[email protected]/reproduce)
Quoted 6 lines

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)

Hi,

I have fix this compilation warning issue in the bellow patch. Please kindly help to test with this patch.
https://lore.kernel.org/linux-mm/[email protected]/T/#u

Thanks
Zhiguo

Quoted 14 lines
Quoted 1 line
Quoted 1 line

mm/mmu_gather.c:54:10: sparse: sparse: symbol 'nr_exiting_processes' was not declared. Should it be static?

mm/mmu_gather.c: note: in included file (through include/linux/mmzone.h, include/linux/gfp.h):
include/linux/page-flags.h:235:46: sparse: sparse: self-comparison always evaluates to false include/linux/page-flags.h:235:46: sparse: sparse: self-comparison always evaluates to false

vim +/nr_exiting_processes +54 mm/mmu_gather.c

     53	
Quoted 1 line

54 atomic_t nr_exiting_processes = ATOMIC_INIT(0);

     55	static struct kmem_cache *swap_gather_cachep;
     56	static struct workqueue_struct *swapfree_wq;
     57	static DEFINE_STATIC_KEY_TRUE(tlb_swap_asyncfree_disabled);
     58	
#10 lore raw
In reply to Zhiguo Jiang
Quoted 5 lines · Zhiguo Jiang

The main reasons for the prolonged exit of a background process is the time-consuming release of its swap entries. The proportion of swap memory occupied by the background process increases with its duration in the background, and after a period of time, this value can reach 60% or more.

Do you know the reason? Could they be contending for a cluster lock or something?
Is there any perf data or flamegraph available here?

Quoted 19 lines

Additionally, the relatively lengthy path for releasing swap entries further contributes to the longer time required for the background process to release its swap entries.

In the multiple background applications scenario, when launching a large memory application such as a camera, system may enter a low memory state, which will triggers the killing of multiple background processes at the same time. Due to multiple exiting processes occupying multiple CPUs for concurrent execution, the current foreground application's CPU resources are tight and may cause issues such as lagging.

To solve this problem, we have introduced the multiple exiting process asynchronous swap memory release mechanism, which isolates and caches swap entries occupied by multiple exit processes, and hands them over to an asynchronous kworker to complete the release. This allows the exiting processes to complete quickly and release CPU resources. We have validated this modification on the products and achieved the expected benefits.

Quoted 4 lines

It offers several benefits:
1. Alleviate the high system cpu load caused by multiple exiting processes running simultaneously.
2. Reduce lock competition in swap entry free path by an asynchronous

Do you have data on which lock is affected? Could it be a cluster lock?

Quoted 7 lines

kworker instead of multiple exiting processes parallel execution.
3. Release memory occupied by exiting processes more efficiently.

Zhiguo Jiang (2):
mm: move task_is_dying to h headfile
mm: tlb: multiple exiting processes's swap entries async release

Quoted 13 lines
 include/asm-generic/tlb.h |  50 +++++++
 include/linux/mm_types.h  |  58 ++++++++
 include/linux/oom.h       |   6 +
 mm/memcontrol.c           |   6 -
 mm/memory.c               |   3 +-
 mm/mmu_gather.c           | 297 ++++++++++++++++++++++++++++++++++++++
 6 files changed, 413 insertions(+), 7 deletions(-)
 mode change 100644 => 100755 include/asm-generic/tlb.h
 mode change 100644 => 100755 include/linux/mm_types.h
 mode change 100644 => 100755 include/linux/oom.h
 mode change 100644 => 100755 mm/memcontrol.c
 mode change 100644 => 100755 mm/memory.c
 mode change 100644 => 100755 mm/mmu_gather.c

Can you check your local filesystem to determine why you're running the chmod command?

Quoted 4 lines

--
2.39.0

Thanks
Barry

#11 lore raw
Quoted 10 lines · Barry Song

[Some people who received this message don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Quoted 4 lines · Zhiguo Jiang

The main reasons for the prolonged exit of a background process is the time-consuming release of its swap entries. The proportion of swap memory occupied by the background process increases with its duration in the background, and after a period of time, this value can reach 60% or more.

Do you know the reason? Could they be contending for a cluster lock or something?
Is there any perf data or flamegraph available here?

Hi,

Testing datas of application occuping different physical memory sizes at different time points in the background:
Testing Platform: 8GB RAM
Testing procedure:
After booting up, start 15 applications first, and then observe the physical memory size occupied by the last launched application at different time points in the background.

foreground - abbreviation FG
background - abbreviation BG

The app launched last: com.qiyi.video app
|  memory type  | FG 5s  | BG 5s  | BG 1min | BG 3min | BG 5min | BG 10min | BG 15min |
---------------------------------------------------------------------------------------

|     VmRSS(KB) | 453832 | 252300 |  207724 |  206776 |  204364 | 199944   |  199748  |
|   RssAnon(KB) | 247348 |  99296 |   71816 |   71484 |   71268 | 67808    |   67660  |
|   RssFile(KB) | 205536 | 152020 |  134956 |  134340 |  132144 | 131184   |  131136  |
|  RssShmem(KB) |   1048 |    984 |     952 |     952 |     952 | 952      |     952  |
|    VmSwap(KB) | 202692 | 334852 |  362332 |  362664 |  362880 | 366340   |  366488  |
| Swap ratio(%) | 30.87% | 57.03% |  63.56% |  63.69% |  63.97% | 64.69%   |  64.72%  |

The app launched last: com.netease.sky.vivo
|  memory type  | FG 5s  | BG 5s  | BG 1min | BG 3min | BG 5min | BG 10min | BG 15min |
---------------------------------------------------------------------------------------

|     VmRSS(KB) | 435424 | 403564 |  403200 |  401688 |  402996 | 396372   |   396268 |
|   RssAnon(KB) | 151616 | 117252 |  117244 |  115888 |  117088 | 110780   |   110684 |
|   RssFile(KB) | 281672 | 284192 |  283836 |  283680 |  283788 | 283472   |   283464 |
|  RssShmem(KB) |   2136 |   2120 |    2120 |    2120 |    2120 | 2120     |     2120 |
|    VmSwap(KB) | 546584 | 559920 |  559928 |  561284 |  560084 | 566392   |   566488 |
| Swap ratio(%) | 55.66% | 58.11% |  58.14% |  58.29% |  58.16% | 58.83%   |   58.84% |

A background exiting process's perfedata:
|      interfaces              | cost(ms) | exe(ms) | average(ms) | run counts |
--------------------------------------------------------------------------------

| do_signal                    |  791.813 |   0     |     791.813 |     1      |
| get_signal                   |  791.813 |   0     |     791.813 |     1      |
| do_group_exit                |  791.813 |   0     |     791.813 |     1      |
| do_exit                      |  791.813 |   0.148 |     791.813 |     1      |
| exit_mm                      |  577.859 |   0     |     577.859 |     1      |
| __mmput                      |  577.859 |   0.202 |     577.859 |     1      |
| exit_mmap                    |  577.497 |   1.806 |     192.499 |     3      |
| __oom_reap_task_mm           |  562.869 |   2.695 |     562.869 |     1      |
| unmap_page_range             |  562.07  |   3.185 |      20.817 |    27      |
| zap_pte_range                |  558.645 | 123.958 |      15.518 |    36      |
| free_swap_and_cache          |  433.381 |  28.831 |       6.879 |    63      |
| free_swap_slot               |  403.568 |   4.876 |       4.248 |    95      |
| swapcache_free_entries       |  398.292 |   3.578 |       3.588 |   111      |
| swap_entry_free              |  393.863 |  13.953 |       3.176 |   124      |
| swap_range_free              |  372.602 | 202.478 |       1.791 |   208      |
| $x.204 [zram]                |  132.389 |   0.341 |       0.33 |   401      |
| zram_reset_device            |  131.888 |  22.376 |       0.326 |   405      |
| obj_free                     |   80.101 |  29.517 |       0.21 |   381      |
| zs_create_pool               |   29.381 |   2.772 |       0.124 |   237      |
| clear_shadow_from_swap_cache |   22.846 |  22.686 |       0.11 |   208      |
| __put_page                   |   19.317 |  10.088 |       0.105 |   184      |
| pr_memcg_info                |   13.038 |   1.181 |       0.11 |   118      |
| free_pcp_prepare             |    9.229 |   0.812 |       0.094 |    98      |
| xxx_memcg_out                |    9.223 |   4.746 |       0.098 |    94      |
| free_pgtables                |    8.813 |   3.302 |       8.813 |     1      |
| zs_compact                   |    8.617 |   8.43  |       0.097 |    89      |
| kmem_cache_free              |    7.483 |   4.595 |       0.084 |    89      |
| __mem_cgroup_uncharge_swap   |    6.348 |   3.03  |       0.086 |    74      |
| $x.178 [zsmalloc]            |    6.182 |   0.32  |       0.09 |    69      |
| $x.182 [zsmalloc]            |    5.019 |   0.08  |       0.088 |    57      |

cost - total time consumption.
exe - total actual execution time.

According to perfdata, we can observe that the main reason for the prolonged exit of a background process is the time-consuming release of its swap entries.

The reason for the time-consuming release of swap entries is not only due to cluster locks, but also swp_slots lock and swap_info lock, additionally zram and swapdisk free path time-consuming .

Quoted 20 lines
Quoted 20 lines

Additionally, the relatively lengthy path for releasing swap entries further contributes to the longer time required for the background process to release its swap entries.

In the multiple background applications scenario, when launching a large memory application such as a camera, system may enter a low memory state, which will triggers the killing of multiple background processes at the same time. Due to multiple exiting processes occupying multiple CPUs for concurrent execution, the current foreground application's CPU resources are tight and may cause issues such as lagging.

To solve this problem, we have introduced the multiple exiting process asynchronous swap memory release mechanism, which isolates and caches swap entries occupied by multiple exit processes, and hands them over to an asynchronous kworker to complete the release. This allows the exiting processes to complete quickly and release CPU resources. We have validated this modification on the products and achieved the expected benefits.

Quoted 5 lines
Quoted 4 lines

It offers several benefits:
1. Alleviate the high system cpu load caused by multiple exiting processes running simultaneously.
2. Reduce lock competition in swap entry free path by an asynchronous

Do you have data on which lock is affected? Could it be a cluster lock?

The reason for the time-consuming release of swap entries is not only due to cluster locks, but also swp_slots lock and swap_info lock, additionally zram and swapdisk free path time-consuming . In short, swap entry release path is relatively long compared to file and anonymous folio release path.

Quoted 21 lines
Quoted 15 lines

kworker instead of multiple exiting processes parallel execution.
3. Release memory occupied by exiting processes more efficiently.

Zhiguo Jiang (2):
mm: move task_is_dying to h headfile
mm: tlb: multiple exiting processes's swap entries async release

  include/asm-generic/tlb.h |  50 +++++++
  include/linux/mm_types.h  |  58 ++++++++
  include/linux/oom.h       |   6 +
  mm/memcontrol.c           |   6 -
  mm/memory.c               |   3 +-
  mm/mmu_gather.c           | 297 ++++++++++++++++++++++++++++++++++++++
  6 files changed, 413 insertions(+), 7 deletions(-)
Quoted 6 lines

mode change 100644 => 100755 include/asm-generic/tlb.h mode change 100644 => 100755 include/linux/mm_types.h mode change 100644 => 100755 include/linux/oom.h mode change 100644 => 100755 mm/memcontrol.c mode change 100644 => 100755 mm/memory.c
mode change 100644 => 100755 mm/mmu_gather.c

Quoted 2 lines

Can you check your local filesystem to determine why you're running the chmod command?

Ok, I will check it carefully.

Thanks
Zhiguo

Quoted 6 lines
Quoted 4 lines

--
2.39.0

Thanks
Barry