Skip to content

Commit 04ac684

Browse files
Matthew Wilcox (Oracle)opsiff
authored andcommitted
memory-failure: convert delete_from_lru_cache() to take a folio
mainline inclusion from mainline-v6.8-rc1 category: performance All three callers now have a folio; pass it in instead of the page. Saves five calls to compound_head(). Link: https://lkml.kernel.org/r/20231117161447.2461643-4-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Naoya Horiguchi <naoya.horiguchi@nec.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> (cherry picked from commit f709239) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent f578380 commit 04ac684

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

mm/memory-failure.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -925,26 +925,26 @@ static const char * const action_page_types[] = {
925925
* The page count will stop it from being freed by unpoison.
926926
* Stress tests should be aware of this memory leak problem.
927927
*/
928-
static int delete_from_lru_cache(struct page *p)
928+
static int delete_from_lru_cache(struct folio *folio)
929929
{
930-
if (isolate_lru_page(p)) {
930+
if (folio_isolate_lru(folio)) {
931931
/*
932932
* Clear sensible page flags, so that the buddy system won't
933-
* complain when the page is unpoison-and-freed.
933+
* complain when the folio is unpoison-and-freed.
934934
*/
935-
ClearPageActive(p);
936-
ClearPageUnevictable(p);
935+
folio_clear_active(folio);
936+
folio_clear_unevictable(folio);
937937

938938
/*
939939
* Poisoned page might never drop its ref count to 0 so we have
940940
* to uncharge it manually from its memcg.
941941
*/
942-
mem_cgroup_uncharge(page_folio(p));
942+
mem_cgroup_uncharge(folio);
943943

944944
/*
945-
* drop the page count elevated by isolate_lru_page()
945+
* drop the refcount elevated by folio_isolate_lru()
946946
*/
947-
put_page(p);
947+
folio_put(folio);
948948
return 0;
949949
}
950950
return -EIO;
@@ -1042,7 +1042,7 @@ static int me_pagecache_clean(struct page_state *ps, struct page *p)
10421042
struct address_space *mapping;
10431043
bool extra_pins;
10441044

1045-
delete_from_lru_cache(p);
1045+
delete_from_lru_cache(folio);
10461046

10471047
/*
10481048
* For anonymous folios the only reference left
@@ -1169,7 +1169,7 @@ static int me_swapcache_dirty(struct page_state *ps, struct page *p)
11691169
/* Trigger EIO in shmem: */
11701170
folio_clear_uptodate(folio);
11711171

1172-
ret = delete_from_lru_cache(p) ? MF_FAILED : MF_DELAYED;
1172+
ret = delete_from_lru_cache(folio) ? MF_FAILED : MF_DELAYED;
11731173
folio_unlock(folio);
11741174

11751175
if (ret == MF_DELAYED)
@@ -1188,7 +1188,7 @@ static int me_swapcache_clean(struct page_state *ps, struct page *p)
11881188

11891189
delete_from_swap_cache(folio);
11901190

1191-
ret = delete_from_lru_cache(p) ? MF_FAILED : MF_RECOVERED;
1191+
ret = delete_from_lru_cache(folio) ? MF_FAILED : MF_RECOVERED;
11921192
folio_unlock(folio);
11931193

11941194
if (has_extra_refcount(ps, p, false))

0 commit comments

Comments
 (0)