Skip to content

Commit 0b36444

Browse files
Christoph Hellwigtorvalds
authored andcommitted
frontswap: remove frontswap_shrink
frontswap_shrink is never called, so remove it. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Juergen Gross <[email protected]> Cc: Dan Streetman <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Konrad Rzeszutek Wilk <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Seth Jennings <[email protected]> Cc: Vitaly Wool <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 71024cb commit 0b36444

File tree

3 files changed

+0
-97
lines changed

3 files changed

+0
-97
lines changed

Documentation/vm/frontswap.rst

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -255,19 +255,6 @@ the old data and ensure that it is no longer accessible. Since the
255255
swap subsystem then writes the new data to the read swap device,
256256
this is the correct course of action to ensure coherency.
257257

258-
* What is frontswap_shrink for?
259-
260-
When the (non-frontswap) swap subsystem swaps out a page to a real
261-
swap device, that page is only taking up low-value pre-allocated disk
262-
space. But if frontswap has placed a page in transcendent memory, that
263-
page may be taking up valuable real estate. The frontswap_shrink
264-
routine allows code outside of the swap subsystem to force pages out
265-
of the memory managed by frontswap and back into kernel-addressable memory.
266-
For example, in RAMster, a "suction driver" thread will attempt
267-
to "repatriate" pages sent to a remote machine back to the local machine;
268-
this is driven using the frontswap_shrink mechanism when memory pressure
269-
subsides.
270-
271258
* Why does the frontswap patch create the new include file swapfile.h?
272259

273260
The frontswap code depends on some swap-subsystem-internal data

include/linux/frontswap.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ struct frontswap_ops {
2424
};
2525

2626
extern void frontswap_register_ops(struct frontswap_ops *ops);
27-
extern void frontswap_shrink(unsigned long);
2827
extern unsigned long frontswap_curr_pages(void);
2928

3029
extern bool __frontswap_test(struct swap_info_struct *, pgoff_t);

mm/frontswap.c

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -341,89 +341,6 @@ static unsigned long __frontswap_curr_pages(void)
341341
return totalpages;
342342
}
343343

344-
static int __frontswap_unuse_pages(unsigned long total, unsigned long *unused,
345-
int *swapid)
346-
{
347-
int ret = -EINVAL;
348-
struct swap_info_struct *si = NULL;
349-
int si_frontswap_pages;
350-
unsigned long total_pages_to_unuse = total;
351-
unsigned long pages = 0, pages_to_unuse = 0;
352-
353-
assert_spin_locked(&swap_lock);
354-
plist_for_each_entry(si, &swap_active_head, list) {
355-
si_frontswap_pages = atomic_read(&si->frontswap_pages);
356-
if (total_pages_to_unuse < si_frontswap_pages) {
357-
pages = pages_to_unuse = total_pages_to_unuse;
358-
} else {
359-
pages = si_frontswap_pages;
360-
pages_to_unuse = 0; /* unuse all */
361-
}
362-
/* ensure there is enough RAM to fetch pages from frontswap */
363-
if (security_vm_enough_memory_mm(current->mm, pages)) {
364-
ret = -ENOMEM;
365-
continue;
366-
}
367-
vm_unacct_memory(pages);
368-
*unused = pages_to_unuse;
369-
*swapid = si->type;
370-
ret = 0;
371-
break;
372-
}
373-
374-
return ret;
375-
}
376-
377-
/*
378-
* Used to check if it's necessary and feasible to unuse pages.
379-
* Return 1 when nothing to do, 0 when need to shrink pages,
380-
* error code when there is an error.
381-
*/
382-
static int __frontswap_shrink(unsigned long target_pages,
383-
unsigned long *pages_to_unuse,
384-
int *type)
385-
{
386-
unsigned long total_pages = 0, total_pages_to_unuse;
387-
388-
assert_spin_locked(&swap_lock);
389-
390-
total_pages = __frontswap_curr_pages();
391-
if (total_pages <= target_pages) {
392-
/* Nothing to do */
393-
*pages_to_unuse = 0;
394-
return 1;
395-
}
396-
total_pages_to_unuse = total_pages - target_pages;
397-
return __frontswap_unuse_pages(total_pages_to_unuse, pages_to_unuse, type);
398-
}
399-
400-
/*
401-
* Frontswap, like a true swap device, may unnecessarily retain pages
402-
* under certain circumstances; "shrink" frontswap is essentially a
403-
* "partial swapoff" and works by calling try_to_unuse to attempt to
404-
* unuse enough frontswap pages to attempt to -- subject to memory
405-
* constraints -- reduce the number of pages in frontswap to the
406-
* number given in the parameter target_pages.
407-
*/
408-
void frontswap_shrink(unsigned long target_pages)
409-
{
410-
unsigned long pages_to_unuse = 0;
411-
int type, ret;
412-
413-
/*
414-
* we don't want to hold swap_lock while doing a very
415-
* lengthy try_to_unuse, but swap_list may change
416-
* so restart scan from swap_active_head each time
417-
*/
418-
spin_lock(&swap_lock);
419-
ret = __frontswap_shrink(target_pages, &pages_to_unuse, &type);
420-
spin_unlock(&swap_lock);
421-
if (ret == 0)
422-
try_to_unuse(type, true, pages_to_unuse);
423-
return;
424-
}
425-
EXPORT_SYMBOL(frontswap_shrink);
426-
427344
/*
428345
* Count and return the number of frontswap pages across all
429346
* swap devices. This is exported so that backend drivers can

0 commit comments

Comments
 (0)