Commit 506a86c5 authored by Johannes Weiner's avatar Johannes Weiner Committed by Andrew Morton

mm: zswap: function ordering: public lru api

The zswap entry section sits awkwardly in the middle of LRU-related
functions. Group the external LRU API functions first.

Link: https://lkml.kernel.org/r/20240130014208.565554-15-hannes@cmpxchg.orgSigned-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Reviewed-by: default avatarNhat Pham <nphamcs@gmail.com>
Cc: Chengming Zhou <zhouchengming@bytedance.com>
Cc: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent abca07c0
...@@ -746,6 +746,10 @@ static int zswap_enabled_param_set(const char *val, ...@@ -746,6 +746,10 @@ static int zswap_enabled_param_set(const char *val,
return ret; return ret;
} }
/*********************************
* lru functions
**********************************/
/* should be called under RCU */ /* should be called under RCU */
#ifdef CONFIG_MEMCG #ifdef CONFIG_MEMCG
static inline struct mem_cgroup *mem_cgroup_from_entry(struct zswap_entry *entry) static inline struct mem_cgroup *mem_cgroup_from_entry(struct zswap_entry *entry)
...@@ -764,6 +768,21 @@ static inline int entry_to_nid(struct zswap_entry *entry) ...@@ -764,6 +768,21 @@ static inline int entry_to_nid(struct zswap_entry *entry)
return page_to_nid(virt_to_page(entry)); return page_to_nid(virt_to_page(entry));
} }
void zswap_lruvec_state_init(struct lruvec *lruvec)
{
atomic_long_set(&lruvec->zswap_lruvec_state.nr_zswap_protected, 0);
}
void zswap_folio_swapin(struct folio *folio)
{
struct lruvec *lruvec;
if (folio) {
lruvec = folio_lruvec(folio);
atomic_long_inc(&lruvec->zswap_lruvec_state.nr_zswap_protected);
}
}
void zswap_memcg_offline_cleanup(struct mem_cgroup *memcg) void zswap_memcg_offline_cleanup(struct mem_cgroup *memcg)
{ {
struct zswap_pool *pool; struct zswap_pool *pool;
...@@ -798,23 +817,6 @@ static void zswap_entry_cache_free(struct zswap_entry *entry) ...@@ -798,23 +817,6 @@ static void zswap_entry_cache_free(struct zswap_entry *entry)
kmem_cache_free(zswap_entry_cache, entry); kmem_cache_free(zswap_entry_cache, entry);
} }
/*********************************
* zswap lruvec functions
**********************************/
void zswap_lruvec_state_init(struct lruvec *lruvec)
{
atomic_long_set(&lruvec->zswap_lruvec_state.nr_zswap_protected, 0);
}
void zswap_folio_swapin(struct folio *folio)
{
struct lruvec *lruvec;
VM_WARN_ON_ONCE(!folio_test_locked(folio));
lruvec = folio_lruvec(folio);
atomic_long_inc(&lruvec->zswap_lruvec_state.nr_zswap_protected);
}
/********************************* /*********************************
* lru functions * lru functions
**********************************/ **********************************/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment