History

mm: swapoff: take notice of completion sooner

The old try_to_unuse() implementation was driven by find_next_to_unuse(), which terminated as soon as all the swap had been freed. Add inuse_pages checks now (alongside signal_pending()) to stop scanning mms and swap_map once finished. The same ought to be done in shmem_unuse() too, but never was before, and needs a different interface: so leave it as is for now.

Hugh Dickins committed 7 years ago

Commit 64165b11 parent dd862de1 file · +11 −8Browse files

Unified · Split

mm/swapfile.c+11−8
@@ -2051,11 +2051,9 @@ retry: · 2050 unmodified lines
20512051
20522052 spin_lock(&mmlist_lock);
20532053 p = &init_mm.mmlist;
2054− while ((p = p->next) != &init_mm.mmlist) {
2055− if (signal_pending(current)) {
2056− retval = -EINTR;
2057− break;
2058− }
2054+ while (si->inuse_pages &&
2055+ !signal_pending(current) &&
2056+ (p = p->next) != &init_mm.mmlist) {
20592057
20602058 mm = list_entry(p, struct mm_struct, mmlist);
20612059 if (!mmget_not_zero(mm))
@@ -2082,7 +2080,9 @@ retry: · 20 unmodified lines
20822080 mmput(prev_mm);
20832081
20842082 i = 0;
2085− while ((i = find_next_to_unuse(si, i, frontswap)) != 0) {
2083+ while (si->inuse_pages &&
2084+ !signal_pending(current) &&
2085+ (i = find_next_to_unuse(si, i, frontswap)) != 0) {
20862086
20872087 entry = swp_entry(type, i);
20882088 page = find_get_page(swap_address_space(entry), i);
@@ -2123,8 +2123,11 @@ retry: · 34 unmodified lines
21232123 * separate lists, and wait for those lists to be emptied; but it's
21242124 * easier and more robust (though cpu-intensive) just to keep retrying.
21252125 */
2126− if (si->inuse_pages)
2127− goto retry;
2126+ if (si->inuse_pages) {
2127+ if (!signal_pending(current))
2128+ goto retry;
2129+ retval = -EINTR;
2130+ }
21282131 out:
21292132 return (retval == FRONTSWAP_PAGES_UNUSED) ? 0 : retval;
21302133 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t