From: Chengming Zhou <zhouchengming@bytedance.com>
To: yosryahmed@google.com,
Sergey Senozhatsky <senozhatsky@chromium.org>,
hannes@cmpxchg.org, nphamcs@gmail.com,
Andrew Morton <akpm@linux-foundation.org>,
Minchan Kim <minchan@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Chengming Zhou <zhouchengming@bytedance.com>
Subject: [PATCH 2/2] mm/zsmalloc: remove the deferred free mechanism
Date: Tue, 27 Feb 2024 03:02:55 +0000 [thread overview]
Message-ID: <20240226-zsmalloc-zspage-rcu-v1-2-456b0ef1a89d@bytedance.com> (raw)
In-Reply-To: <20240226-zsmalloc-zspage-rcu-v1-0-456b0ef1a89d@bytedance.com>
Since the only user of kick_deferred_free() has gone, remove all the
deferred mechanism related code.
Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
---
mm/zsmalloc.c | 109 ----------------------------------------------------------
1 file changed, 109 deletions(-)
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index b153f2e5fc0f..1a044690b389 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -232,9 +232,6 @@ struct zs_pool {
#ifdef CONFIG_ZSMALLOC_STAT
struct dentry *stat_dentry;
-#endif
-#ifdef CONFIG_COMPACTION
- struct work_struct free_work;
#endif
spinlock_t lock;
atomic_t compaction_in_progress;
@@ -281,12 +278,8 @@ static void migrate_write_lock(struct zspage *zspage);
static void migrate_write_unlock(struct zspage *zspage);
#ifdef CONFIG_COMPACTION
-static void kick_deferred_free(struct zs_pool *pool);
-static void init_deferred_free(struct zs_pool *pool);
static void SetZsPageMovable(struct zs_pool *pool, struct zspage *zspage);
#else
-static void kick_deferred_free(struct zs_pool *pool) {}
-static void init_deferred_free(struct zs_pool *pool) {}
static void SetZsPageMovable(struct zs_pool *pool, struct zspage *zspage) {}
#endif
@@ -1632,50 +1625,6 @@ static int putback_zspage(struct size_class *class, struct zspage *zspage)
return fullness;
}
-#ifdef CONFIG_COMPACTION
-/*
- * To prevent zspage destroy during migration, zspage freeing should
- * hold locks of all pages in the zspage.
- */
-static void lock_zspage(struct zspage *zspage)
-{
- struct page *curr_page, *page;
-
- /*
- * Pages we haven't locked yet can be migrated off the list while we're
- * trying to lock them, so we need to be careful and only attempt to
- * lock each page under migrate_read_lock(). Otherwise, the page we lock
- * may no longer belong to the zspage. This means that we may wait for
- * the wrong page to unlock, so we must take a reference to the page
- * prior to waiting for it to unlock outside migrate_read_lock().
- */
- while (1) {
- migrate_read_lock(zspage);
- page = get_first_page(zspage);
- if (trylock_page(page))
- break;
- get_page(page);
- migrate_read_unlock(zspage);
- wait_on_page_locked(page);
- put_page(page);
- }
-
- curr_page = page;
- while ((page = get_next_page(curr_page))) {
- if (trylock_page(page)) {
- curr_page = page;
- } else {
- get_page(page);
- migrate_read_unlock(zspage);
- wait_on_page_locked(page);
- put_page(page);
- migrate_read_lock(zspage);
- }
- }
- migrate_read_unlock(zspage);
-}
-#endif /* CONFIG_COMPACTION */
-
static void migrate_lock_init(struct zspage *zspage)
{
rwlock_init(&zspage->lock);
@@ -1730,10 +1679,6 @@ static void replace_sub_page(struct size_class *class, struct zspage *zspage,
static bool zs_page_isolate(struct page *page, isolate_mode_t mode)
{
- /*
- * Page is locked so zspage couldn't be destroyed. For detail, look at
- * lock_zspage in free_zspage.
- */
VM_BUG_ON_PAGE(PageIsolated(page), page);
return true;
@@ -1848,56 +1793,6 @@ static const struct movable_operations zsmalloc_mops = {
.putback_page = zs_page_putback,
};
-/*
- * Caller should hold page_lock of all pages in the zspage
- * In here, we cannot use zspage meta data.
- */
-static void async_free_zspage(struct work_struct *work)
-{
- int i;
- struct size_class *class;
- struct zspage *zspage, *tmp;
- LIST_HEAD(free_pages);
- struct zs_pool *pool = container_of(work, struct zs_pool,
- free_work);
-
- for (i = 0; i < ZS_SIZE_CLASSES; i++) {
- class = pool->size_class[i];
- if (class->index != i)
- continue;
-
- spin_lock(&pool->lock);
- list_splice_init(&class->fullness_list[ZS_INUSE_RATIO_0],
- &free_pages);
- spin_unlock(&pool->lock);
- }
-
- list_for_each_entry_safe(zspage, tmp, &free_pages, list) {
- list_del(&zspage->list);
- lock_zspage(zspage);
-
- spin_lock(&pool->lock);
- class = zspage_class(pool, zspage);
- __free_zspage(pool, class, zspage);
- spin_unlock(&pool->lock);
- }
-};
-
-static void kick_deferred_free(struct zs_pool *pool)
-{
- schedule_work(&pool->free_work);
-}
-
-static void zs_flush_migration(struct zs_pool *pool)
-{
- flush_work(&pool->free_work);
-}
-
-static void init_deferred_free(struct zs_pool *pool)
-{
- INIT_WORK(&pool->free_work, async_free_zspage);
-}
-
static void SetZsPageMovable(struct zs_pool *pool, struct zspage *zspage)
{
struct page *page = get_first_page(zspage);
@@ -1908,8 +1803,6 @@ static void SetZsPageMovable(struct zs_pool *pool, struct zspage *zspage)
unlock_page(page);
} while ((page = get_next_page(page)) != NULL);
}
-#else
-static inline void zs_flush_migration(struct zs_pool *pool) { }
#endif
/*
@@ -2121,7 +2014,6 @@ struct zs_pool *zs_create_pool(const char *name)
if (!pool)
return NULL;
- init_deferred_free(pool);
spin_lock_init(&pool->lock);
atomic_set(&pool->compaction_in_progress, 0);
@@ -2229,7 +2121,6 @@ void zs_destroy_pool(struct zs_pool *pool)
int i;
zs_unregister_shrinker(pool);
- zs_flush_migration(pool);
zs_pool_stat_destroy(pool);
for (i = 0; i < ZS_SIZE_CLASSES; i++) {
--
b4 0.10.1
next prev parent reply other threads:[~2024-02-27 3:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-27 3:02 [PATCH 0/2] mm/zsmalloc: simplify synchronization between zs_page_migrate() and free_zspage() Chengming Zhou
2024-02-27 3:02 ` [PATCH 1/2] mm/zsmalloc: don't hold locks of all pages when free_zspage() Chengming Zhou
2024-02-28 4:33 ` Sergey Senozhatsky
2024-02-28 5:14 ` Chengming Zhou
2024-02-28 5:29 ` Sergey Senozhatsky
2024-02-28 5:42 ` Chengming Zhou
2024-02-28 6:07 ` Sergey Senozhatsky
2024-02-28 6:01 ` Sergey Senozhatsky
2024-02-28 6:44 ` Chengming Zhou
2024-02-28 6:14 ` Sergey Senozhatsky
2024-02-28 6:49 ` Chengming Zhou
2024-02-27 3:02 ` Chengming Zhou [this message]
2024-02-28 1:57 ` [PATCH 0/2] mm/zsmalloc: simplify synchronization between zs_page_migrate() and free_zspage() Sergey Senozhatsky
2024-02-28 2:22 ` [External] " Chengming Zhou
2024-02-28 3:54 ` Sergey Senozhatsky
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=20240226-zsmalloc-zspage-rcu-v1-2-456b0ef1a89d@bytedance.com \
--to=zhouchengming@bytedance.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=nphamcs@gmail.com \
--cc=senozhatsky@chromium.org \
--cc=yosryahmed@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