From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeelb@google.com>,
Muchun Song <muchun.song@linux.dev>,
cgroups@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH 3/4] memcg: Use a folio in get_mctgt_type
Date: Thu, 11 Jan 2024 18:12:18 +0000 [thread overview]
Message-ID: <20240111181219.3462852-4-willy@infradead.org> (raw)
In-Reply-To: <20240111181219.3462852-1-willy@infradead.org>
Replace seven calls to compound_head() with one. We still use the
page as page_mapped() is different from folio_mapped().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
mm/memcontrol.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d14fe0740b37..b6096c34b3e4 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -6076,6 +6076,7 @@ static enum mc_target_type get_mctgt_type(struct vm_area_struct *vma,
unsigned long addr, pte_t ptent, union mc_target *target)
{
struct page *page = NULL;
+ struct folio *folio;
enum mc_target_type ret = MC_TARGET_NONE;
swp_entry_t ent = { .val = 0 };
@@ -6090,9 +6091,11 @@ static enum mc_target_type get_mctgt_type(struct vm_area_struct *vma,
else if (is_swap_pte(ptent))
page = mc_handle_swap_pte(vma, ptent, &ent);
+ if (page)
+ folio = page_folio(page);
if (target && page) {
- if (!trylock_page(page)) {
- put_page(page);
+ if (!folio_trylock(folio)) {
+ folio_put(folio);
return ret;
}
/*
@@ -6107,8 +6110,8 @@ static enum mc_target_type get_mctgt_type(struct vm_area_struct *vma,
* Alas, skip moving the page in this case.
*/
if (!pte_present(ptent) && page_mapped(page)) {
- unlock_page(page);
- put_page(page);
+ folio_unlock(folio);
+ folio_put(folio);
return ret;
}
}
@@ -6121,18 +6124,18 @@ static enum mc_target_type get_mctgt_type(struct vm_area_struct *vma,
* mem_cgroup_move_account() checks the page is valid or
* not under LRU exclusion.
*/
- if (page_memcg(page) == mc.from) {
+ if (folio_memcg(folio) == mc.from) {
ret = MC_TARGET_PAGE;
- if (is_device_private_page(page) ||
- is_device_coherent_page(page))
+ if (folio_is_device_private(folio) ||
+ folio_is_device_coherent(folio))
ret = MC_TARGET_DEVICE;
if (target)
- target->folio = page_folio(page);
+ target->folio = folio;
}
if (!ret || !target) {
if (target)
- unlock_page(page);
- put_page(page);
+ folio_unlock(folio);
+ folio_put(folio);
}
}
/*
--
2.43.0
next prev parent reply other threads:[~2024-01-11 18:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-11 18:12 [PATCH 0/4] Convert memcontrol charge moving to use folios Matthew Wilcox (Oracle)
2024-01-11 18:12 ` [PATCH 1/4] memcg: Convert mem_cgroup_move_charge_pte_range() to use a folio Matthew Wilcox (Oracle)
2024-01-15 8:03 ` Muchun Song
2024-01-11 18:12 ` [PATCH 2/4] memcg: Return the folio in union mc_target Matthew Wilcox (Oracle)
2024-01-15 3:49 ` Muchun Song
2024-01-11 18:12 ` Matthew Wilcox (Oracle) [this message]
2024-01-11 19:34 ` [PATCH 3/4] memcg: Use a folio in get_mctgt_type Johannes Weiner
2024-01-15 3:48 ` Muchun Song
2024-01-11 18:12 ` [PATCH 4/4] memcg: Use a folio in get_mctgt_type_thp Matthew Wilcox (Oracle)
2024-01-12 1:57 ` Roman Gushchin
2024-01-15 3:47 ` Muchun Song
2024-01-26 17:57 ` [PATCH 0/4] Convert memcontrol charge moving to use folios Shakeel Butt
2024-02-21 7:48 ` Michal Hocko
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=20240111181219.3462852-4-willy@infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeelb@google.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