From: Hugh Dickins <hughd@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>,
"Alex Xu (Hello71)" <alex_y_xu@yahoo.ca>,
Vineeth Pillai <vpillai@digitalocean.com>,
Kelley Nielsen <kelleynnn@gmail.com>,
Rik van Riel <riel@surriel.com>,
Huang Ying <ying.huang@intel.com>,
Hugh Dickins <hughd@google.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH 3/4] mm: swapoff: take notice of completion sooner
Date: Mon, 8 Apr 2019 12:59:32 -0700 (PDT) [thread overview]
Message-ID: <alpine.LSU.2.11.1904081258200.1523@eggly.anvils> (raw)
In-Reply-To: <alpine.LSU.2.11.1904081249370.1523@eggly.anvils>
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.
Fixes: b56a2d8af914 ("mm: rid swapoff of quadratic complexity")
Signed-off-by: Hugh Dickins <hughd@google.com>
---
mm/swapfile.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
--- 5.1-rc4/mm/swapfile.c 2019-04-07 19:15:01.269054187 -0700
+++ linux/mm/swapfile.c 2019-04-07 19:17:13.291957539 -0700
@@ -2051,11 +2051,9 @@ retry:
spin_lock(&mmlist_lock);
p = &init_mm.mmlist;
- while ((p = p->next) != &init_mm.mmlist) {
- if (signal_pending(current)) {
- retval = -EINTR;
- break;
- }
+ while (si->inuse_pages &&
+ !signal_pending(current) &&
+ (p = p->next) != &init_mm.mmlist) {
mm = list_entry(p, struct mm_struct, mmlist);
if (!mmget_not_zero(mm))
@@ -2082,7 +2080,9 @@ retry:
mmput(prev_mm);
i = 0;
- while ((i = find_next_to_unuse(si, i, frontswap)) != 0) {
+ while (si->inuse_pages &&
+ !signal_pending(current) &&
+ (i = find_next_to_unuse(si, i, frontswap)) != 0) {
entry = swp_entry(type, i);
page = find_get_page(swap_address_space(entry), i);
@@ -2123,8 +2123,11 @@ retry:
* separate lists, and wait for those lists to be emptied; but it's
* easier and more robust (though cpu-intensive) just to keep retrying.
*/
- if (si->inuse_pages)
- goto retry;
+ if (si->inuse_pages) {
+ if (!signal_pending(current))
+ goto retry;
+ retval = -EINTR;
+ }
out:
return (retval == FRONTSWAP_PAGES_UNUSED) ? 0 : retval;
}
next prev parent reply other threads:[~2019-04-08 19:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-08 19:53 [PATCH 0/4] mm: swapoff: fixes for 5.1-rc Hugh Dickins
2019-04-08 19:56 ` [PATCH 1/4] mm: swapoff: shmem_find_swap_entries() filter out other types Hugh Dickins
2019-04-08 19:58 ` [PATCH 2/4] mm: swapoff: remove too limiting SWAP_UNUSE_MAX_TRIES Hugh Dickins
2019-04-08 19:59 ` Hugh Dickins [this message]
2019-04-08 20:01 ` [PATCH 4/4] mm: swapoff: shmem_unuse() stop eviction without igrab() Hugh Dickins
2019-04-09 7:50 ` Konstantin Khlebnikov
2019-04-09 18:43 ` Hugh Dickins
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LSU.2.11.1904081258200.1523@eggly.anvils \
--to=hughd@google.com \
--cc=akpm@linux-foundation.org \
--cc=alex_y_xu@yahoo.ca \
--cc=kelleynnn@gmail.com \
--cc=khlebnikov@yandex-team.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=riel@surriel.com \
--cc=vpillai@digitalocean.com \
--cc=ying.huang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox