From: Minchan Kim <minchan@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Mel Gorman <mgorman@suse.de>, Rik van Riel <riel@redhat.com>,
Hugh Dickins <hughd@google.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@suse.cz>, Minchan Kim <minchan@kernel.org>
Subject: [PATCH v3 1/3] mm: Don't hide spin_lock in swap_info_get internal
Date: Wed, 2 Jul 2014 09:13:47 +0900 [thread overview]
Message-ID: <1404260029-11525-2-git-send-email-minchan@kernel.org> (raw)
In-Reply-To: <1404260029-11525-1-git-send-email-minchan@kernel.org>
Now, swap_info_get hides lock holding by doing it internally
but releasing the lock so caller should release the lock.
Normally, it's not a good pattern and I need to handle lock
from caller in next patchset.
Signed-off-by: Minchan Kim <minchan@kernel.org>
---
mm/swapfile.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 8798b2e0ac59..ec2ce926ea5f 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -740,7 +740,6 @@ static struct swap_info_struct *swap_info_get(swp_entry_t entry)
goto bad_offset;
if (!p->swap_map[offset])
goto bad_free;
- spin_lock(&p->lock);
return p;
bad_free:
@@ -835,6 +834,7 @@ void swap_free(swp_entry_t entry)
p = swap_info_get(entry);
if (p) {
+ spin_lock(&p->lock);
swap_entry_free(p, entry, 1);
spin_unlock(&p->lock);
}
@@ -849,6 +849,7 @@ void swapcache_free(swp_entry_t entry)
p = swap_info_get(entry);
if (p) {
+ spin_lock(&p->lock);
swap_entry_free(p, entry, SWAP_HAS_CACHE);
spin_unlock(&p->lock);
}
@@ -868,6 +869,7 @@ int page_swapcount(struct page *page)
entry.val = page_private(page);
p = swap_info_get(entry);
if (p) {
+ spin_lock(&p->lock);
count = swap_count(p->swap_map[swp_offset(entry)]);
spin_unlock(&p->lock);
}
@@ -950,6 +952,7 @@ int free_swap_and_cache(swp_entry_t entry)
p = swap_info_get(entry);
if (p) {
+ spin_lock(&p->lock);
if (swap_entry_free(p, entry, 1) == SWAP_HAS_CACHE) {
page = find_get_page(swap_address_space(entry),
entry.val);
@@ -2763,6 +2766,7 @@ int add_swap_count_continuation(swp_entry_t entry, gfp_t gfp_mask)
goto outer;
}
+ spin_lock(&si->lock);
offset = swp_offset(entry);
count = si->swap_map[offset] & ~SWAP_HAS_CACHE;
--
2.0.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2014-07-02 0:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-02 0:13 [PATCH v3 0/3] free reclaimed pages by paging out instantly Minchan Kim
2014-07-02 0:13 ` Minchan Kim [this message]
2014-07-02 0:13 ` [PATCH v3 2/3] mm: Introduce atomic_remove_mapping Minchan Kim
2014-07-02 0:13 ` [PATCH v3 3/3] mm: Free reclaimed pages indepdent of next reclaim Minchan Kim
2014-07-02 20:42 ` [PATCH v3 0/3] free reclaimed pages by paging out instantly Andrew Morton
2014-07-03 0:59 ` Minchan Kim
2014-07-07 19:13 ` Andrew Morton
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=1404260029-11525-2-git-send-email-minchan@kernel.org \
--to=minchan@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.cz \
--cc=riel@redhat.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;
as well as URLs for NNTP newsgroup(s).