From patchwork Tue Aug 6 02:23:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: alexs@kernel.org X-Patchwork-Id: 13754338 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB6CBC3DA4A for ; Tue, 6 Aug 2024 02:19:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB5BE6B00BC; Mon, 5 Aug 2024 22:19:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A164C6B00BD; Mon, 5 Aug 2024 22:19:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8908E6B00BE; Mon, 5 Aug 2024 22:19:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 699AF6B00BC for ; Mon, 5 Aug 2024 22:19:16 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2D64E161D54 for ; Tue, 6 Aug 2024 02:19:16 +0000 (UTC) X-FDA: 82420213512.13.58E9F35 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf22.hostedemail.com (Postfix) with ESMTP id 77B1DC001E for ; Tue, 6 Aug 2024 02:19:14 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fHD0Nind; spf=pass (imf22.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722910705; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=vqM7Gkcszhk+4w/7mI0miJdp8Uy77XWXHsMSi6m4afQ=; b=7/h02sTZ7vpezVa8WEVVWKNOGmZk0giFf9Bom4yYKPoiu2qMoT3MEbSVJ8QK4uX9RCGfOg s+/Xu9KBa3UDCU8nndPXc0PFwqsafuZx32fCFHdrJ2Z/zttemhm/fj9od+rzOOj3v3SuKH L+Uiqfaxza/l4iOw0zCXAosa3ukcGDU= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fHD0Nind; spf=pass (imf22.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722910705; a=rsa-sha256; cv=none; b=QVOEJZgnuIG8+TD8ZLDrhSWEhfphmyUCphPO/Ru4cGHAbO1Y4N3QHrm2G6ZfKAi6Pq7U4v 3c+COan6i1dApzSHnWW6tMNckkwUR4fL0V3s/nVTbkQ0E7oz7exeLZRkF9BKYhzlopdsqP bfB85k6ZcQeYFcw0cr/pmXjRirU0uF0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id AC50860E00; Tue, 6 Aug 2024 02:19:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BEC0C4AF11; Tue, 6 Aug 2024 02:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722910753; bh=8EJ/o5yp3ZapndwWQeMuiNEuMIoUNdxMr4p7pDAhjMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fHD0NindhMQW6QUkJ2u9oDL3HNMi/H8qnJWxEJrGbwtH1YlIb2amxcYwVifocYTdU S4LnhS1E+vxEX5IUdJBshGvy/4Dkn7bBOdoq6v4vqZpYCkKdW+tzpO/HAsF430o7YK iCQpenKaRCiHhk+pkrD9d6b1W7PAfmGD87rWCRlLrvfE8NInQwIObWeiw3kX9eifcF H/PzSqlHXVcXLUFXOgsJxQfLjOW1W40R4RhUgtvXZDEalOqqkVePdXSRBv33b1YYmV i6P2PWItaOhhBbbw2/aX1FW7p0MeXuJp6GEMv+4xwNRv0u7yh3UTkHwfIBgu1KrIoI QmZak2SKy6ucg== From: alexs@kernel.org To: Vitaly Wool , Miaohe Lin , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, minchan@kernel.org, willy@infradead.org, senozhatsky@chromium.org, david@redhat.com, 42.hyeyoo@gmail.com, Yosry Ahmed , nphamcs@gmail.com Cc: Alex Shi Subject: [PATCH v5 21/21] mm/zsmalloc: update comments for page->zpdesc changes Date: Tue, 6 Aug 2024 10:23:08 +0800 Message-ID: <20240806022311.3924442-22-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240806022311.3924442-1-alexs@kernel.org> References: <20240806022143.3924396-1-alexs@kernel.org> <20240806022311.3924442-1-alexs@kernel.org> MIME-Version: 1.0 X-Stat-Signature: wswp1m1t5azgmaxizg634tay7r3ib3eu X-Rspam-User: X-Rspamd-Queue-Id: 77B1DC001E X-Rspamd-Server: rspam02 X-HE-Tag: 1722910754-187473 X-HE-Meta: U2FsdGVkX19qM9oCxyO5HSn7zSREP3YvU2IS8mOLz9RlHl90g6RfY2GB9yR20VKexMuGCcefpA6cRCwF6mfAvLcznvaeZUv1Cc1pdq4Rl0HU+JqTgMGMRf8QF6dCDY2f3X6COBha11WDYq9K5BFavrxlsRp+yGD5soORUnx6FjjeH4ZHKmOejGSbD8c9GE6BEUcWkvjOculBzVVZz/qHQcIzhqnEtvnUrqkBI4zYmEyG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ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi After the page to zpdesc conversion, there still left few comments or function named with page not zpdesc, let's update the comments and rename function create_page_chain() as create_zpdesc_chain(). Signed-off-by: Alex Shi --- mm/zsmalloc.c | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index e92451c6b69c..a3d9431d29ec 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -17,14 +17,16 @@ * * Usage of struct zpdesc fields: * zpdesc->zspage: points to zspage - * zpdesc->next: links together all component pages of a zspage + * zpdesc->next: links together all component zpdescs of a zspage * For the huge page, this is always 0, so we use this field * to store handle. * zpdesc->first_obj_offset: PG_zsmalloc, lower 16 bit locate the first * object offset in a subpage of a zspage * * Usage of struct zpdesc(page) flags: - * PG_private: identifies the first component page + * PG_private: identifies the first component zpdesc + * PG_lock: lock all component zpdescs for a zspage free, serialize with + * migration */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt @@ -191,7 +193,10 @@ struct size_class { */ int size; int objs_per_zspage; - /* Number of PAGE_SIZE sized pages to combine to form a 'zspage' */ + /* + * Number of PAGE_SIZE sized zpdescs/pages to combine to + * form a 'zspage' + */ int pages_per_zspage; unsigned int index; @@ -893,7 +898,7 @@ static void free_zspage(struct zs_pool *pool, struct size_class *class, /* * Since zs_free couldn't be sleepable, this function cannot call - * lock_page. The page locks trylock_zspage got will be released + * lock_page. The zpdesc locks trylock_zspage got will be released * by __free_zspage. */ if (!trylock_zspage(zspage)) { @@ -950,7 +955,7 @@ static void init_zspage(struct size_class *class, struct zspage *zspage) set_freeobj(zspage, 0); } -static void create_page_chain(struct size_class *class, struct zspage *zspage, +static void create_zpdesc_chain(struct size_class *class, struct zspage *zspage, struct zpdesc *zpdescs[]) { int i; @@ -959,9 +964,9 @@ static void create_page_chain(struct size_class *class, struct zspage *zspage, int nr_zpdescs = class->pages_per_zspage; /* - * Allocate individual pages and link them together as: - * 1. all pages are linked together using zpdesc->next - * 2. each sub-page point to zspage using zpdesc->zspage + * Allocate individual zpdescs and link them together as: + * 1. all zpdescs are linked together using zpdesc->next + * 2. each sub-zpdesc point to zspage using zpdesc->zspage * * we set PG_private to identify the first zpdesc (i.e. no other zpdesc * has this flag set). @@ -1019,7 +1024,7 @@ static struct zspage *alloc_zspage(struct zs_pool *pool, zpdescs[i] = zpdesc; } - create_page_chain(class, zspage, zpdescs); + create_zpdesc_chain(class, zspage, zpdescs); init_zspage(class, zspage); zspage->pool = pool; zspage->class = class->index; @@ -1346,7 +1351,7 @@ static unsigned long obj_malloc(struct zs_pool *pool, /* record handle in the header of allocated chunk */ link->handle = handle | OBJ_ALLOCATED_TAG; else - /* record handle to page->index */ + /* record handle to zpdesc->handle */ zspage->first_zpdesc->handle = handle | OBJ_ALLOCATED_TAG; kunmap_atomic(vaddr); @@ -1679,19 +1684,19 @@ static int putback_zspage(struct size_class *class, struct zspage *zspage) #ifdef CONFIG_COMPACTION /* * To prevent zspage destroy during migration, zspage freeing should - * hold locks of all pages in the zspage. + * hold locks of all component zpdesc in the zspage. */ static void lock_zspage(struct zspage *zspage) { struct zpdesc *curr_zpdesc, *zpdesc; /* - * Pages we haven't locked yet can be migrated off the list while we're + * Zpdesc 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(). + * lock each zpdesc under migrate_read_lock(). Otherwise, the zpdesc we + * lock may no longer belong to the zspage. This means that we may wait + * for the wrong zpdesc to unlock, so we must take a reference to the + * zpdesc prior to waiting for it to unlock outside migrate_read_lock(). */ while (1) { migrate_read_lock(zspage); @@ -1766,7 +1771,7 @@ static void replace_sub_page(struct size_class *class, struct zspage *zspage, idx++; } while ((zpdesc = get_next_zpdesc(zpdesc)) != NULL); - create_page_chain(class, zspage, zpdescs); + create_zpdesc_chain(class, zspage, zpdescs); first_obj_offset = get_first_obj_offset(oldzpdesc); set_first_obj_offset(newzpdesc, first_obj_offset); if (unlikely(ZsHugePage(zspage))) @@ -1777,8 +1782,8 @@ 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. + * Page/zpdesc is locked so zspage couldn't be destroyed. For detail, + * look at lock_zspage in free_zspage. */ VM_BUG_ON_PAGE(PageIsolated(page), page); @@ -1805,7 +1810,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, /* We're committed, tell the world that this is a Zsmalloc page. */ __zpdesc_set_zsmalloc(newzpdesc); - /* The page is locked, so this pointer must remain valid */ + /* The zpdesc/page is locked, so this pointer must remain valid */ zspage = get_zspage(zpdesc); pool = zspage->pool; @@ -1878,7 +1883,7 @@ static const struct movable_operations zsmalloc_mops = { }; /* - * Caller should hold page_lock of all pages in the zspage + * Caller should hold zpdesc locks of all in the zspage * In here, we cannot use zspage meta data. */ static void async_free_zspage(struct work_struct *work)