Skip to content

Commit f328c1d

Browse files
Christoph Hellwigtorvalds
authored andcommitted
frontswap: simplify frontswap_register_ops
Given that frontswap_register_ops must be called from built-in code, there is no need to handle the case of swapfiles coming online before or during it, so delete the code that deals with that case. Link: https://lkml.kernel.org/r/20211224062246.1258487-11-hch@lst.de Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Juergen Gross <jgross@suse.com> Cc: Dan Streetman <ddstreet@ieee.org> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Hugh Dickins <hughd@google.com> Cc: Konrad Rzeszutek Wilk <Konrad.wilk@oracle.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Seth Jennings <sjenning@redhat.com> Cc: Vitaly Wool <vitaly.wool@konsulko.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent bd9cd52 commit f328c1d

File tree

1 file changed

+0
-41
lines changed

1 file changed

+0
-41
lines changed

mm/frontswap.c

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -99,25 +99,6 @@ static inline void inc_frontswap_invalidates(void) { }
9999
*/
100100
void frontswap_register_ops(struct frontswap_ops *ops)
101101
{
102-
DECLARE_BITMAP(a, MAX_SWAPFILES);
103-
DECLARE_BITMAP(b, MAX_SWAPFILES);
104-
struct swap_info_struct *si;
105-
unsigned int i;
106-
107-
bitmap_zero(a, MAX_SWAPFILES);
108-
bitmap_zero(b, MAX_SWAPFILES);
109-
110-
spin_lock(&swap_lock);
111-
plist_for_each_entry(si, &swap_active_head, list) {
112-
if (!WARN_ON(!si->frontswap_map))
113-
__set_bit(si->type, a);
114-
}
115-
spin_unlock(&swap_lock);
116-
117-
/* the new ops needs to know the currently active swap devices */
118-
for_each_set_bit(i, a, MAX_SWAPFILES)
119-
ops->init(i);
120-
121102
/*
122103
* Setting frontswap_ops must happen after the ops->init() calls
123104
* above; cmpxchg implies smp_mb() which will ensure the init is
@@ -128,28 +109,6 @@ void frontswap_register_ops(struct frontswap_ops *ops)
128109
} while (cmpxchg(&frontswap_ops, ops->next, ops) != ops->next);
129110

130111
static_branch_inc(&frontswap_enabled_key);
131-
132-
spin_lock(&swap_lock);
133-
plist_for_each_entry(si, &swap_active_head, list) {
134-
if (si->frontswap_map)
135-
__set_bit(si->type, b);
136-
}
137-
spin_unlock(&swap_lock);
138-
139-
/*
140-
* On the very unlikely chance that a swap device was added or
141-
* removed between setting the "a" list bits and the ops init
142-
* calls, we re-check and do init or invalidate for any changed
143-
* bits.
144-
*/
145-
if (unlikely(!bitmap_equal(a, b, MAX_SWAPFILES))) {
146-
for (i = 0; i < MAX_SWAPFILES; i++) {
147-
if (!test_bit(i, a) && test_bit(i, b))
148-
ops->init(i);
149-
else if (test_bit(i, a) && !test_bit(i, b))
150-
ops->invalidate_area(i);
151-
}
152-
}
153112
}
154113

155114
/*

0 commit comments

Comments
 (0)