Skip to content

Commit 0ff67f9

Browse files
ryncsnakpm00
authored andcommitted
mm, swap: remove swap slot cache
Slot cache is no longer needed now, removing it and all related code. - vm-scalability with: `usemem --init-time -O -y -x -R -31 1G`, 12G memory cgroup using simulated pmem as SWAP (32G pmem, 32 CPUs), 16 test runs for each case, measuring the total throughput: Before (KB/s) (stdev) After (KB/s) (stdev) Random (4K): 424907.60 (24410.78) 414745.92 (34554.78) Random (64K): 163308.82 (11635.72) 167314.50 (18434.99) Sequential (4K, !-R): 6150056.79 (103205.90) 6321469.06 (115878.16) The performance changes are below noise level. - Build linux kernel with make -j96, using 4K folio with 1.5G memory cgroup limit and 64K folio with 2G memory cgroup limit, on top of tmpfs, 12 test runs, measuring the system time: Before (s) (stdev) After (s) (stdev) make -j96 (4K): 6445.69 (61.95) 6408.80 (69.46) make -j96 (64K): 6841.71 (409.04) 6437.99 (435.55) Similar to above, 64k mTHP case showed a slight improvement. Link: https://lkml.kernel.org/r/20250313165935.63303-7-ryncsn@gmail.com Signed-off-by: Kairui Song <kasong@tencent.com> Reviewed-by: Baoquan He <bhe@redhat.com> Cc: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Barry Song <v-songbaohua@oppo.com> Cc: Chris Li <chrisl@kernel.org> Cc: "Huang, Ying" <ying.huang@linux.alibaba.com> Cc: Hugh Dickins <hughd@google.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Kalesh Singh <kaleshsingh@google.com> Cc: Matthew Wilcow (Oracle) <willy@infradead.org> Cc: Nhat Pham <nphamcs@gmail.com> Cc: Yosry Ahmed <yosryahmed@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 1b7e900 commit 0ff67f9

File tree

6 files changed

+67
-463
lines changed

6 files changed

+67
-463
lines changed

include/linux/swap.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,6 @@ void free_pages_and_swap_cache(struct encoded_page **, int);
465465
extern atomic_long_t nr_swap_pages;
466466
extern long total_swap_pages;
467467
extern atomic_t nr_rotate_swap;
468-
extern bool has_usable_swap(void);
469468

470469
/* Swap 50% full? Release swapcache more aggressively.. */
471470
static inline bool vm_swap_full(void)
@@ -483,13 +482,11 @@ swp_entry_t folio_alloc_swap(struct folio *folio);
483482
bool folio_free_swap(struct folio *folio);
484483
void put_swap_folio(struct folio *folio, swp_entry_t entry);
485484
extern swp_entry_t get_swap_page_of_type(int);
486-
extern int get_swap_pages(int n, swp_entry_t swp_entries[], int order);
487485
extern int add_swap_count_continuation(swp_entry_t, gfp_t);
488486
extern void swap_shmem_alloc(swp_entry_t, int);
489487
extern int swap_duplicate(swp_entry_t);
490488
extern int swapcache_prepare(swp_entry_t entry, int nr);
491489
extern void swap_free_nr(swp_entry_t entry, int nr_pages);
492-
extern void swapcache_free_entries(swp_entry_t *entries, int n);
493490
extern void free_swap_and_cache_nr(swp_entry_t entry, int nr);
494491
int swap_type_of(dev_t device, sector_t offset);
495492
int find_first_swap(dev_t *device);

include/linux/swap_slots.h

Lines changed: 0 additions & 28 deletions
This file was deleted.

mm/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ ifdef CONFIG_MMU
7575
obj-$(CONFIG_ADVISE_SYSCALLS) += madvise.o
7676
endif
7777

78-
obj-$(CONFIG_SWAP) += page_io.o swap_state.o swapfile.o swap_slots.o
78+
obj-$(CONFIG_SWAP) += page_io.o swap_state.o swapfile.o
7979
obj-$(CONFIG_ZSWAP) += zswap.o
8080
obj-$(CONFIG_HAS_DMA) += dmapool.o
8181
obj-$(CONFIG_HUGETLBFS) += hugetlb.o

mm/swap_slots.c

Lines changed: 0 additions & 295 deletions
This file was deleted.

mm/swap_state.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <linux/blkdev.h>
2121
#include <linux/migrate.h>
2222
#include <linux/vmalloc.h>
23-
#include <linux/swap_slots.h>
2423
#include <linux/huge_mm.h>
2524
#include <linux/shmem_fs.h>
2625
#include "internal.h"
@@ -447,13 +446,8 @@ struct folio *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
447446

448447
/*
449448
* Just skip read ahead for unused swap slot.
450-
* During swap_off when swap_slot_cache is disabled,
451-
* we have to handle the race between putting
452-
* swap entry in swap cache and marking swap slot
453-
* as SWAP_HAS_CACHE. That's done in later part of code or
454-
* else swap_off will be aborted if we return NULL.
455449
*/
456-
if (!swap_entry_swapped(si, entry) && swap_slot_cache_enabled)
450+
if (!swap_entry_swapped(si, entry))
457451
goto put_and_return;
458452

459453
/*

0 commit comments

Comments
 (0)