From patchwork Mon Jul 29 11:25:13 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: 13744724 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 197E3C3DA4A for ; Mon, 29 Jul 2024 11:20:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 87CB76B008A; Mon, 29 Jul 2024 07:20:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 82BCB6B0092; Mon, 29 Jul 2024 07:20:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6CE4C6B0093; Mon, 29 Jul 2024 07:20:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 490506B008A for ; Mon, 29 Jul 2024 07:20:24 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 077B11C0C70 for ; Mon, 29 Jul 2024 11:20:24 +0000 (UTC) X-FDA: 82392546768.23.A6A46EF Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf06.hostedemail.com (Postfix) with ESMTP id 582F618000F for ; Mon, 29 Jul 2024 11:20:22 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=nBwIehPf; spf=pass (imf06.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=1722251996; 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=sZ0jCLUmrW4GgmKYMLUXM0xCC+YXy3CRY71rKqzqfw8=; b=0R8U0dLFJmsKZA++uHnMACoQRAHdrAe0jf0rnZAspt0zNCm/l9fY0qsHwAGf39vJmrYCSX OiiHK+HDbISiTgQ/RftWA+4kxVN8uIsQ3RFxgtj4Xi+5Ery6ZH6RCh3SAwSo+JcJ3jsPux UQkNHMsyZKnwiDUaUeNa8/UbfkMEKWY= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=nBwIehPf; spf=pass (imf06.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=1722251996; a=rsa-sha256; cv=none; b=PjmOcBkKHYQrnN/9+TSSHEnEswjq37Q4MO9igdzyNvXqj4xBc5gzXPUw81wZ0AGtBv304B vh4yJ77IJrtOJpBpIhbJSrKSDuK/Oef4PovMsf8NE1BLr9shWK8fuI+wINAeCXdWcw/lq+ tykA8S+5lMu+TpGlZDqQV1oYFZAM8Qc= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 513B4617B4; Mon, 29 Jul 2024 11:20:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51CFDC32786; Mon, 29 Jul 2024 11:20:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252021; bh=ZMy0HVEu+XzzoekAuFVehV3NQWY5KpoqAmg4pIiNEm0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nBwIehPfLpmA1kyjsm46mnAqNpzYgrAXYCZIcwst0anGWvE9xf0m0R8uFaRtIPafu t/td39zcrbnZCdeZ8Hng4wHXf3YwDD9eNyWYe7W/Im049pUfREJaRBDouTeuse56Oz 3mv1N7T6lkm9KCFwe/zaANt0mHEKazgD2gaWuOI+J0vIETg6lJKpHz3LCbsGPlWfnp XXVMKZHwtpMB3p6VUEVxW3PWo4gfcqwMrF5lSlgTSSYkDC1C5g1FF+UxfKElPkb7Fe dsSS/yGrJCevPh2RsZ/SVQbLQ1CIU9NGDRhATvT33AuoL53PAg2gwql7mm17WwLswY 6VhUZbMkF/G+g== 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 v4 01/22] mm/zsmalloc: add zpdesc memory descriptor for zswap.zpool Date: Mon, 29 Jul 2024 19:25:13 +0800 Message-ID: <20240729112534.3416707-2-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 582F618000F X-Stat-Signature: 8ia3yiewckopu4syfccsnq4kkp1cans9 X-HE-Tag: 1722252022-168063 X-HE-Meta: U2FsdGVkX18nVZ/f/m6W70jeyxXR3tWW70J7AOM7FC4QQxrfh5p4TCfrQ5r2If9Bd2737tnubsCcXDS4UmMVIvY5D6lZxlsbuOz9MmOSh1JqtUUdHsREZly+qgVcxInZaSM7rwz/O6Cwv9mA2sZho4wyMoKB6Fve+trnTmjLB4Ow2CsaOVLM5bGlGfHxy18ej9U0pKhmUFbKcxsmhxrnzMbXtUeI0qQVE7zFK7JWxLc0uKZKP/ya3jVyCbiNqx0UeFZB05u+1pmpMOyOBBZN6rMSayoBIdzmPSsXsNxWy0WtHAYPFqJL4VN1qaqBRO5qTJoFz1LtTVT5y4L3kXLI3pkXC9RCkuw6hXOngOtjyt878WUJCgpnCXfTwLlPNxWJytRtyt3xQzu1k0bnbT7+V93IyNZ5BoewSi3pnrTpW9yxiMHi/chIbhGTRhgR7nSrdiRUwQrvArU5hi3u9VD1hEHFCMvuZzPempOp3fXRE7MPSBA1sBlV02RUDUh3Id/39y36iBYLqDqLqprtl5q8Et64gXPC2HSa7u8J/GfJ+LArhCb888aX2a1buci1TvAFq1i0ZtnzKrkauXACRKPTWKUGO0jat2wSzLfzHAEeX2eBfM7JBfY0+/oBOzL4J433ZBRk7BWzojhGQUq6Rx2oRjqaC+5zXdUZ5VqFWgJeH2VnL3wsjKIS72BKbbeXsJH1C6HVV0+1W5+q+EI8De0CfwoIVtpGHAGJXtca+S+Q2uxJVDXDrDpwH1L+nIS6txixFBNBWe5k8tAHEK25AweDa2GpKU2YDY6+uHIDO8QWo7UBCHUdudghlbLZbSjIkyM4qIOHXS9b0GFO55r5xouNn0C3ku7A4COGvtyiwJahaLzEd6+uWL1x4HXcOY+ZiOodxlp1WkMW4sMKAQ9TUQ+P1Ik+SSQo2eKBJajAfzQy2olyJdhULt+JBonMgMCvcH6EdL1mugaqgiQCUUwEm1o PxdHsgDq +acLcG27idvS+WSo8LR0K4jXfzHYRXwdwS04AsPJV7LAz84KPh98oYBGP3+DhJM+KbDjfziWnf/f25weYHQDVGyFDKvmFE5IREpnsoSFfkL/RbcjWoLlKtVfD8Zg5zTIdggPMhx6T4cdqb+RVPk17zTVpK+1UfLL7Bio4oYEpJ+zwYKwGxwYnrk1MpRXjN5L6EQywF9XoVJ8OK+j8lVQaua1NNakm245cZp8tha+APifnb8du91NgaF38C8gcCSinikYODbI8+ihP1RX86y12WdZsINk3EE7nilyZiCMUSvb/CYWR/lxHU3oawY/JPSZK5B5mk/C77PV/3eA= X-Bogosity: 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 The 1st patch introduces new memory decriptor zpdesc and rename zspage.first_page to zspage.first_zpdesc, no functional change. We removed PG_owner_priv_1 since it was moved to zspage after commit a41ec880aa7b ("zsmalloc: move huge compressed obj from page to zspage"). And keep the memcg_data member, since as Yosry pointed out: "When the pages are freed, put_page() -> folio_put() -> __folio_put() will call mem_cgroup_uncharge(). The latter will call folio_memcg() (which reads folio->memcg_data) to figure out if uncharging needs to be done. There are also other similar code paths that will check folio->memcg_data. It is currently expected to be present for all folios. So until we have custom code paths per-folio type for allocation/freeing/etc, we need to keep folio->memcg_data present and properly initialized." Originally-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zpdesc.h | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ mm/zsmalloc.c | 21 ++++++++-------- 2 files changed, 76 insertions(+), 11 deletions(-) create mode 100644 mm/zpdesc.h diff --git a/mm/zpdesc.h b/mm/zpdesc.h new file mode 100644 index 000000000000..2dbef231f616 --- /dev/null +++ b/mm/zpdesc.h @@ -0,0 +1,66 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* zpdesc.h: zswap.zpool memory descriptor + * + * Written by Alex Shi + * Hyeonggon Yoo <42.hyeyoo@gmail.com> + */ +#ifndef __MM_ZPDESC_H__ +#define __MM_ZPDESC_H__ + +/* + * struct zpdesc - Memory descriptor for zpool memory, now is for zsmalloc + * @flags: Page flags, PG_private: identifies the first component page + * @lru: Indirectly used by page migration + * @mops: Used by page migration + * @next: Next zpdesc in a zspage in zsmalloc zpool + * @handle: For huge zspage in zsmalloc zpool + * @zspage: Pointer to zspage in zsmalloc + * @memcg_data: Memory Control Group data. + * + * This struct overlays struct page for now. Do not modify without a good + * understanding of the issues. + */ +struct zpdesc { + unsigned long flags; + struct list_head lru; + struct movable_operations *mops; + union { + /* Next zpdescs in a zspage in zsmalloc zpool */ + struct zpdesc *next; + /* For huge zspage in zsmalloc zpool */ + unsigned long handle; + }; + struct zspage *zspage; + unsigned long _zp_pad_1; +#ifdef CONFIG_MEMCG + unsigned long memcg_data; +#endif +}; +#define ZPDESC_MATCH(pg, zp) \ + static_assert(offsetof(struct page, pg) == offsetof(struct zpdesc, zp)) + +ZPDESC_MATCH(flags, flags); +ZPDESC_MATCH(lru, lru); +ZPDESC_MATCH(mapping, mops); +ZPDESC_MATCH(index, next); +ZPDESC_MATCH(index, handle); +ZPDESC_MATCH(private, zspage); +#ifdef CONFIG_MEMCG +ZPDESC_MATCH(memcg_data, memcg_data); +#endif +#undef ZPDESC_MATCH +static_assert(sizeof(struct zpdesc) <= sizeof(struct page)); + +#define zpdesc_page(zp) (_Generic((zp), \ + const struct zpdesc *: (const struct page *)(zp), \ + struct zpdesc *: (struct page *)(zp))) + +#define zpdesc_folio(zp) (_Generic((zp), \ + const struct zpdesc *: (const struct folio *)(zp), \ + struct zpdesc *: (struct folio *)(zp))) + +#define page_zpdesc(p) (_Generic((p), \ + const struct page *: (const struct zpdesc *)(p), \ + struct page *: (struct zpdesc *)(p))) + +#endif diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 5d6581ab7c07..a532851025f9 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -13,20 +13,18 @@ /* * Following is how we use various fields and flags of underlying - * struct page(s) to form a zspage. + * struct zpdesc(page) to form a zspage. * - * Usage of struct page fields: - * page->private: points to zspage - * page->index: links together all component pages of a zspage + * Usage of struct zpdesc fields: + * zpdesc->zspage: points to zspage + * zpdesc->next: links together all component pages of a zspage * For the huge page, this is always 0, so we use this field * to store handle. * page->page_type: PG_zsmalloc, lower 16 bit locate the first object * offset in a subpage of a zspage * - * Usage of struct page flags: + * Usage of struct zpdesc(page) flags: * PG_private: identifies the first component page - * PG_owner_priv_1: identifies the huge component page - * */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt @@ -64,6 +62,7 @@ #include #include #include +#include "zpdesc.h" #define ZSPAGE_MAGIC 0x58 @@ -253,7 +252,7 @@ struct zspage { }; unsigned int inuse; unsigned int freeobj; - struct page *first_page; + struct zpdesc *first_zpdesc; struct list_head list; /* fullness list */ struct zs_pool *pool; rwlock_t lock; @@ -448,7 +447,7 @@ static inline void mod_zspage_inuse(struct zspage *zspage, int val) static inline struct page *get_first_page(struct zspage *zspage) { - struct page *first_page = zspage->first_page; + struct page *first_page = zpdesc_page(zspage->first_zpdesc); VM_BUG_ON_PAGE(!is_first_page(first_page), first_page); return first_page; @@ -948,7 +947,7 @@ static void create_page_chain(struct size_class *class, struct zspage *zspage, set_page_private(page, (unsigned long)zspage); page->index = 0; if (i == 0) { - zspage->first_page = page; + zspage->first_zpdesc = page_zpdesc(page); SetPagePrivate(page); if (unlikely(class->objs_per_zspage == 1 && class->pages_per_zspage == 1)) @@ -1324,7 +1323,7 @@ static unsigned long obj_malloc(struct zs_pool *pool, link->handle = handle | OBJ_ALLOCATED_TAG; else /* record handle to page->index */ - zspage->first_page->index = handle | OBJ_ALLOCATED_TAG; + zspage->first_zpdesc->handle = handle | OBJ_ALLOCATED_TAG; kunmap_atomic(vaddr); mod_zspage_inuse(zspage, 1); From patchwork Mon Jul 29 11:25:14 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: 13744725 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 58800C3DA4A for ; Mon, 29 Jul 2024 11:20:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2B656B0093; Mon, 29 Jul 2024 07:20:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DD2496B0095; Mon, 29 Jul 2024 07:20:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C73C36B0096; Mon, 29 Jul 2024 07:20:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A47D76B0093 for ; Mon, 29 Jul 2024 07:20:27 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1CDC6C02A8 for ; Mon, 29 Jul 2024 11:20:27 +0000 (UTC) X-FDA: 82392546894.04.AC71985 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf14.hostedemail.com (Postfix) with ESMTP id 6E1B9100005 for ; Mon, 29 Jul 2024 11:20:25 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=SbdRtdLa; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf14.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722251982; a=rsa-sha256; cv=none; b=hAANAcUWfm+qU2kdBPZ5an0uDkGYlJFaK/chZfMx0Uiz++bBuyV/HaMjrwnoBmLdGdR0wS mCc9eR+/8cplAPGUJu36YqrtcBVDm+DtSyXw86JOJVijzzKuCTk17kUBNF9du2ymYgyz+H 0xOtKAAvOB5zzXVdfSG1LGIxTViBO60= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=SbdRtdLa; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf14.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722251982; 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=qzwgsEtyNjS3flm4YCFrLQ9ljo1JbYGAnII3x07Au/c=; b=Jys7GnMo3cu67JXWGm3WJqqRMwB5AIsjLr/7amGNt9rW+wW9Z5XMQm/vlMizzGpZ9Wk98s k7GldwjSRGxlsHqadomLt5WRubjc3LKDp03BhKC0yTEAtJzIdllUhGRysAXhEPRzrlVqYy 1+Rr7CPzr6H8eNgfASGvuvtLXAaHNkY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 87D79617AF; Mon, 29 Jul 2024 11:20:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93387C4AF0A; Mon, 29 Jul 2024 11:20:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252024; bh=L8DShu1UmY1Sg2Z983VpR54BaIaM2jEwz6eoX7cilko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SbdRtdLaduX5nsjwmdcLwtIXUdqB9/5/aj+4DgJZnt9EekflUIzv6SzENAzlwRCi9 bxzItDWLB6yhsPVpdvv8mnTXpf7D5SjuYrX9Tnl3TOBe8LwXBhKHftAIyo0EYV8hWr mnRISrYNV++OhSkCDDIhUuSDsFULCjGdsn4onyrDXtrhUBIN9bsSzY30N5F83xePIT 9SkVVPfAHjX/xlHXgxuaCPMA3feETv5Qa/fdcUUSBq9HHUpJ/1G3kLAROE9f+2yH/c D2RqzCjcFi4ArUlsgDblEBw56WCu1A2XmrSFk8+Z4f2QzAmKm7olzai1YNIquJJJB0 fcojyZZx5zzUA== 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 v4 02/22] mm/zsmalloc: use zpdesc in trylock_zspage/lock_zspage Date: Mon, 29 Jul 2024 19:25:14 +0800 Message-ID: <20240729112534.3416707-3-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 6E1B9100005 X-Stat-Signature: 3d84oqh966hfirghgm1z3gi1954d7e4b X-Rspam-User: X-HE-Tag: 1722252025-507758 X-HE-Meta: U2FsdGVkX18ThdZpNDXIHJm9Y2x4wqXmLbULhddqWSVh4Fq3GuBmKQsftlT4Ry84O7bsmpyGNtKXegAjqlDTU31CHII4y66N0X1/Uk+gJWOGcTXcUdxlBHCTUl/mxArUsBfkL5Ld/guSco5l5dxoT+DDVQTC8AG/pvCAgrJcgferScM0+1QWmiDv8zfPuXcKeiOLrUzvvYkJqD6dXPkLcGi6qoPt+HgIX3mKWYZa0mQypEvIaA2sTNoga8ei8ABVHqhM8t9jkJSwec7Obv+g47LjJeyWBtMbZ0Zi26C5pLnEfXKdVNMe4Iqm9Sba6L4CFYJgkucZHnE4VeuM8LXdqwnGKtc1vt0NLX1b/EKwH8IkBTXS/maiGqY0t++mbDgnR/sJ8oJuiXuLgVxY3GWsvICeD43QbLsY3pYfmjAoyZvCUWdG0YlPyge8AnTN5cs+9njIJtFtX5LLyPJofjw74Aduztdr5VSWNGp4Gi+QzvZ1uvXJ0DbfV1349Ws3b0HVTTCU01SoWyMK2FlZewEEmIHoMBC5K72wQgTqz20p4IgLRpjG2QuZG7oeRDp5ikQ7g7RGPrEGZ36BjuirgxocHfy4b9d3wteunzZ70fWy5EyLdkVpq9V87b1z7HtP1rQmMpN7TxdirMSp6kDhvZ0WwjEaQab6ujJugDW6r42zf1IcUsXYt4d71e32uGU8fzTDMHyzadkQaGoxYwHKfBZPtqPW1mCdDWYTMTiL8jJlJOM9jPy3XDVZUirY6jAxLwZqPLXfmv2ExKq5HR+ubmo6AxbW2dH0fOHrVpzxIfUCCDSy2M6njbyFSyJCohY6JRaHbfkPJfHk25NxMRZp3uYGKrqWVOUo9OcqmsNalmopXIHKrOBVQ3o2vE4oTtl8ULB31uhKqcnqk9HmqNxkZhqrjAgpOkLp4X5WuN6Dq4Pj+z58C+7IdK+zY4pGJmhS2/XcB/4q+eRhtFrtnYSjp+N RmYIHydd FgVdT7HyZffW6c7RAFpAqm2Wohc0GDUUl009hdvciMdZCcjhO5/kZR0z5BQTnKDZkThWH44oY4C7rhyUKMNw+R68ZdZWY0jNWtZLdMn1NTrFv+erZkMr/L2uedFeqrJakls/W32STKKnQpNk0Phm37RvMq7CnRlhn/WSjZf4h96B1Kk/99yCSDx4mmk9gb8oQ0cLXaHFxgBkXf8OHsjMe0nHGBG6PI0AIDeiOk1U2yqqSOkcqfqCVxDK6I9G/EdM88hXFQNPxh09i3BXN0rusBtwGpBse7YwmkC1WUB4KfF/HP6+Vi26PfNK2dyf8kmLuYfJ00FGaLR3olZ755izfsb3ee0ZGWYCelh46cUQcBOeZv9vfYSckJD221Ma6vp52+RHo X-Bogosity: 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 To use zpdesc in trylock_zspage/lock_zspage funcs, we add couple of helpers: zpdesc_lock/zpdesc_unlock/zpdesc_trylock/zpdesc_wait_locked and zpdesc_get/zpdesc_put for this purpose. Here we use the folio series func in guts for 2 reasons, one zswap.zpool only get single page, and use folio could save some compound_head checking; two, folio_put could bypass devmap checking that we don't need. Originally-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zpdesc.h | 30 ++++++++++++++++++++++++ mm/zsmalloc.c | 64 ++++++++++++++++++++++++++++++++++----------------- 2 files changed, 73 insertions(+), 21 deletions(-) diff --git a/mm/zpdesc.h b/mm/zpdesc.h index 2dbef231f616..3b04197cec9d 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -63,4 +63,34 @@ static_assert(sizeof(struct zpdesc) <= sizeof(struct page)); const struct page *: (const struct zpdesc *)(p), \ struct page *: (struct zpdesc *)(p))) +static inline void zpdesc_lock(struct zpdesc *zpdesc) +{ + folio_lock(zpdesc_folio(zpdesc)); +} + +static inline bool zpdesc_trylock(struct zpdesc *zpdesc) +{ + return folio_trylock(zpdesc_folio(zpdesc)); +} + +static inline void zpdesc_unlock(struct zpdesc *zpdesc) +{ + folio_unlock(zpdesc_folio(zpdesc)); +} + +static inline void zpdesc_wait_locked(struct zpdesc *zpdesc) +{ + folio_wait_locked(zpdesc_folio(zpdesc)); +} + +static inline void zpdesc_get(struct zpdesc *zpdesc) +{ + folio_get(zpdesc_folio(zpdesc)); +} + +static inline void zpdesc_put(struct zpdesc *zpdesc) +{ + folio_put(zpdesc_folio(zpdesc)); +} + #endif diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index a532851025f9..243677a9c6d2 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -433,13 +433,17 @@ static __maybe_unused int is_first_page(struct page *page) return PagePrivate(page); } +static int is_first_zpdesc(struct zpdesc *zpdesc) +{ + return PagePrivate(zpdesc_page(zpdesc)); +} + /* Protected by class->lock */ static inline int get_zspage_inuse(struct zspage *zspage) { return zspage->inuse; } - static inline void mod_zspage_inuse(struct zspage *zspage, int val) { zspage->inuse += val; @@ -453,6 +457,14 @@ static inline struct page *get_first_page(struct zspage *zspage) return first_page; } +static struct zpdesc *get_first_zpdesc(struct zspage *zspage) +{ + struct zpdesc *first_zpdesc = zspage->first_zpdesc; + + VM_BUG_ON_PAGE(!is_first_zpdesc(first_zpdesc), zpdesc_page(first_zpdesc)); + return first_zpdesc; +} + #define FIRST_OBJ_PAGE_TYPE_MASK 0xffff static inline void reset_first_obj_offset(struct page *page) @@ -745,6 +757,16 @@ static struct page *get_next_page(struct page *page) return (struct page *)page->index; } +static struct zpdesc *get_next_zpdesc(struct zpdesc *zpdesc) +{ + struct zspage *zspage = get_zspage(zpdesc_page(zpdesc)); + + if (unlikely(ZsHugePage(zspage))) + return NULL; + + return zpdesc->next; +} + /** * obj_to_location - get (, ) from encoded object value * @obj: the encoded object value @@ -815,11 +837,11 @@ static void reset_page(struct page *page) static int trylock_zspage(struct zspage *zspage) { - struct page *cursor, *fail; + struct zpdesc *cursor, *fail; - for (cursor = get_first_page(zspage); cursor != NULL; cursor = - get_next_page(cursor)) { - if (!trylock_page(cursor)) { + for (cursor = get_first_zpdesc(zspage); cursor != NULL; cursor = + get_next_zpdesc(cursor)) { + if (!zpdesc_trylock(cursor)) { fail = cursor; goto unlock; } @@ -827,9 +849,9 @@ static int trylock_zspage(struct zspage *zspage) return 1; unlock: - for (cursor = get_first_page(zspage); cursor != fail; cursor = - get_next_page(cursor)) - unlock_page(cursor); + for (cursor = get_first_zpdesc(zspage); cursor != fail; cursor = + get_next_zpdesc(cursor)) + zpdesc_unlock(cursor); return 0; } @@ -1658,7 +1680,7 @@ static int putback_zspage(struct size_class *class, struct zspage *zspage) */ static void lock_zspage(struct zspage *zspage) { - struct page *curr_page, *page; + struct zpdesc *curr_zpdesc, *zpdesc; /* * Pages we haven't locked yet can be migrated off the list while we're @@ -1670,24 +1692,24 @@ static void lock_zspage(struct zspage *zspage) */ while (1) { migrate_read_lock(zspage); - page = get_first_page(zspage); - if (trylock_page(page)) + zpdesc = get_first_zpdesc(zspage); + if (zpdesc_trylock(zpdesc)) break; - get_page(page); + zpdesc_get(zpdesc); migrate_read_unlock(zspage); - wait_on_page_locked(page); - put_page(page); + zpdesc_wait_locked(zpdesc); + zpdesc_put(zpdesc); } - curr_page = page; - while ((page = get_next_page(curr_page))) { - if (trylock_page(page)) { - curr_page = page; + curr_zpdesc = zpdesc; + while ((zpdesc = get_next_zpdesc(curr_zpdesc))) { + if (zpdesc_trylock(zpdesc)) { + curr_zpdesc = zpdesc; } else { - get_page(page); + zpdesc_get(zpdesc); migrate_read_unlock(zspage); - wait_on_page_locked(page); - put_page(page); + zpdesc_wait_locked(zpdesc); + zpdesc_put(zpdesc); migrate_read_lock(zspage); } } From patchwork Mon Jul 29 11:25:15 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: 13744726 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 941D1C3DA61 for ; Mon, 29 Jul 2024 11:20:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 239C86B0099; Mon, 29 Jul 2024 07:20:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1EAB26B0098; Mon, 29 Jul 2024 07:20:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 08BA26B0099; Mon, 29 Jul 2024 07:20:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id DB9066B0096 for ; Mon, 29 Jul 2024 07:20:30 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4BA541602BB for ; Mon, 29 Jul 2024 11:20:30 +0000 (UTC) X-FDA: 82392547020.17.98039E8 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id A216B80004 for ; Mon, 29 Jul 2024 11:20:28 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=mPBuc1PI; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf02.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722251969; 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=61ZUT7gO5pix+Syfo3H6V1v5+PP3SiTNV2KMQCafkgk=; b=KzD/Sm+aOJ4R11KlnZZnAmUYuZNGqiL32DTHJQrirmomLc8SMiGmixy5woSfJ6A51/1C9p bRnJ+XQURv7R3mXSJ3ne17d+1djKywzP5WZCuLi6n97emxUbXmaEa+0AnrTHZRq+UDZX5B iVihfR3dT9D8seQUO9OFsZsiXMEtQCo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722251969; a=rsa-sha256; cv=none; b=ZkPjMkYHtkAc+W2KIqZ3kYtLn0bNtW1QK9fcK1zSodtdasSFLWJxQGY2LiNrBuy3ePFNNd vwIzQ/swzsBaQCR67RZWhl9hEoLTz+9LbHvzG08Dcg9OOfRnYRxyOj0ivYKSBPVgNgxhGJ 6o1TGVS+CSvdcs3sMqRWs97A17WAsSk= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=mPBuc1PI; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf02.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id CF361617BD; Mon, 29 Jul 2024 11:20:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D32CFC4AF0A; Mon, 29 Jul 2024 11:20:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252027; bh=ezRZsoVNxvO9p/Es1oKbiCO8zRXU9uaLAm4pSSvGkg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mPBuc1PIJz8zxeEieUPstihcjHXEabomtxQv0t1FNmEjidfXx8YbWGSAUWn5iN7D7 DEyiE44MryR2s94k9jM8AXG6j1u5h/1k3RSSZAOfk3Y/EF+LxFI07oscV3CGh0J6ed B6cj5rJspAo6bNylOz4erxIr8aBwqP+bNW919IGYX/RCEGVxm5tx2i77vy+ZpHd3eT gGh2JRbA9G2mi9iKh2gmOKthWRciie29ZHJjBEseRwcP+hIxFTykM9M4wYVvG1xTBs r6o/CobB/cF4rZDnpSBwcspMXsRequ6xuCHD3GU91Cq49XYzsMeyHEKs66Twok2ApT mJcO8nA17CJeQ== 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 v4 03/22] mm/zsmalloc: convert __zs_map_object/__zs_unmap_object to use zpdesc Date: Mon, 29 Jul 2024 19:25:15 +0800 Message-ID: <20240729112534.3416707-4-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: A216B80004 X-Stat-Signature: hmd7bpoteasuqiu76b9pdhyphhwxtfgk X-Rspam-User: X-HE-Tag: 1722252028-711374 X-HE-Meta: U2FsdGVkX1/uzYVf+BDHWzmkqzhKzRje5VwqNjvRp4UmzQu/dDyS04sE5VYkLiD6ILQxjtrDleNLZOmDNVH2UXbl53qfjFEvSGc/PN0PsiG4Lf6i/6UDFkfxlZdfmBrsdVIuD60l3w0Pvus0ETzf6EStePIJei5rLaENElJIfgvTDu4contX6bJ1kFQE1/vmiyS7bal1+VnB6hJO/r05UHOgOkaNAkqwywSKRA15REP5WdIkoYqESvD2Sq/tXf1Rjf+PdNRBkdV8jP5Y92pNmaHu+sC4FzRGcDWVgnP7B1L3SrW8GMOcFdOfN/jXKfPRV9V6y6rOgrl3SXI1SnWX7rBXaUgZKXfZnswkX38vBPQgccqDDIuMOBOuE3TI2Terojv4Z/xehHZSP9YGeG78nYhU+8ExLtoDSTquCbi/cgOI0PgebTwnWjIeAjjj+SKjAoNVinRSsYfS0pba1yiC8OcytLKn+7uKpBPdrbbg1f1WohkKxDPgn9Afj0Djbec8hrPLiD3mzv0lIpkGWbrd0TYsCvWDQvuXnd2A6JUCvW7PfMh+DEfLn3AP1u/+ZM7P7OiWACAjSIi5Aj5UlMk1nkFhR9tpj1FOMaUfUwfDnq/nWo0hSKn2tT8xI3yrmoEcH90xu8zUPgEbJBws2am8IVrbLaq71ujxwZsNtWoNvaVXdiI5cPiD82xOv7nN5F9IZV5WuYMPB6UA86NcGXn/lYowFY5JEG+brazBrETaTILRRo3J9gcdyZ5f9GHPfvYiQsiFdbvAcmT0wbnAoquwiGwPEoREhet95JMcApqgoERRRxYTwGxavVjyhZKR9dVdUlU+9alTJJp+hSqw3lbuckXtBANtziOmpQbb4s1nD0bPXEcz8UKiYKHCoTyvfp6h9dHXI5qQFo4juoZi/XMb7pCUabugQzhynNbASBpCyUV41PMkGV2aIrVUmJES/K6M+LBLbRhpkBvQQ5AhNc5 tNYcXF94 5UhDivdgRdBdOq//qmMUv56WHfpbgt7nu96XrxSevnUEUeZkajm5x/+LAIOOQsKfbJVMm5lsfPIRCADTix9InMZGztELEglyj7dzdUi8o4Y45WUGbSSogWycHbKI5dyilwBlmFbMAjiYRTfVbeu/VNrKUBpgy+gs+lNiatHbcOeB2k9XNtuDVsG3XxEuzCf/m4x7Z7k8BtummbGUoyWop0/nmVGzJ4kJlEJWHwpMWcqFOTv6FOx1FNcOv1nTafozJ/E5xnjFcLmIzCERz+gLhHYZ9iexp4R/PPEMGQ9vFIveAdvqYYtnO8Rx94Ft6jwLd2RaSPCwHgd6ULqLEKIdRjZeockdbnz+5l7rIudX074g0vkao0QF2xSpZNc1yU2ahkfE5 X-Bogosity: 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: Hyeonggon Yoo <42.hyeyoo@gmail.com> These two functions take pointer to an array of struct page. Introduce zpdesc_kmap_atomic() and make __zs_{map,unmap}_object() take pointer to an array of zpdesc instead of page. Add silly type casting when calling them. Casting will be removed late. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 243677a9c6d2..68a39c233d34 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -243,6 +243,11 @@ struct zs_pool { atomic_t compaction_in_progress; }; +static inline void *zpdesc_kmap_atomic(struct zpdesc *zpdesc) +{ + return kmap_atomic(zpdesc_page(zpdesc)); +} + struct zspage { struct { unsigned int huge:HUGE_BITS; @@ -1061,7 +1066,7 @@ static inline void __zs_cpu_down(struct mapping_area *area) } static void *__zs_map_object(struct mapping_area *area, - struct page *pages[2], int off, int size) + struct zpdesc *zpdescs[2], int off, int size) { int sizes[2]; void *addr; @@ -1078,10 +1083,10 @@ static void *__zs_map_object(struct mapping_area *area, sizes[1] = size - sizes[0]; /* copy object to per-cpu buffer */ - addr = kmap_atomic(pages[0]); + addr = zpdesc_kmap_atomic(zpdescs[0]); memcpy(buf, addr + off, sizes[0]); kunmap_atomic(addr); - addr = kmap_atomic(pages[1]); + addr = zpdesc_kmap_atomic(zpdescs[1]); memcpy(buf + sizes[0], addr, sizes[1]); kunmap_atomic(addr); out: @@ -1089,7 +1094,7 @@ static void *__zs_map_object(struct mapping_area *area, } static void __zs_unmap_object(struct mapping_area *area, - struct page *pages[2], int off, int size) + struct zpdesc *zpdescs[2], int off, int size) { int sizes[2]; void *addr; @@ -1108,10 +1113,10 @@ static void __zs_unmap_object(struct mapping_area *area, sizes[1] = size - sizes[0]; /* copy per-cpu buffer to object */ - addr = kmap_atomic(pages[0]); + addr = zpdesc_kmap_atomic(zpdescs[0]); memcpy(addr + off, buf, sizes[0]); kunmap_atomic(addr); - addr = kmap_atomic(pages[1]); + addr = zpdesc_kmap_atomic(zpdescs[1]); memcpy(addr, buf + sizes[0], sizes[1]); kunmap_atomic(addr); @@ -1252,7 +1257,7 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle, pages[1] = get_next_page(page); BUG_ON(!pages[1]); - ret = __zs_map_object(area, pages, off, class->size); + ret = __zs_map_object(area, (struct zpdesc **)pages, off, class->size); out: if (likely(!ZsHugePage(zspage))) ret += ZS_HANDLE_SIZE; @@ -1287,7 +1292,7 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle) pages[1] = get_next_page(page); BUG_ON(!pages[1]); - __zs_unmap_object(area, pages, off, class->size); + __zs_unmap_object(area, (struct zpdesc **)pages, off, class->size); } local_unlock(&zs_map_area.lock); From patchwork Mon Jul 29 11:25:16 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: 13744727 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 E2005C3DA4A for ; Mon, 29 Jul 2024 11:20:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F50B6B0098; Mon, 29 Jul 2024 07:20:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A57F6B009A; Mon, 29 Jul 2024 07:20:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 520A86B009B; Mon, 29 Jul 2024 07:20:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 32FAA6B0098 for ; Mon, 29 Jul 2024 07:20:34 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id ABEB3802B6 for ; Mon, 29 Jul 2024 11:20:33 +0000 (UTC) X-FDA: 82392547146.30.0575BBF Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id E760914000C for ; Mon, 29 Jul 2024 11:20:31 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=toQpXt7a; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf23.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722251992; a=rsa-sha256; cv=none; b=45Z8kpYYn3rxa250VzyFALOmmML5Ak4zgEquurA9opLmXxo9TnaSNzAhREpATjjNkLm/yF PPyPI4qxAxKC3f6HvltgrdoZmb1sWtevCe+/Yw9g7iIbmx1O5td6gj1cVNxZ8hyOJRmVX7 aYbOoN+XLiwEN4OCTymqX9e+6yfLiIw= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=toQpXt7a; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf23.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722251992; 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=cvcxsTDbaHzPl8v7oNDOixyI9M+5C5Fmb/tzkdpqsbQ=; b=TW20jzgbhf3A2GInplvll7LF2V2thYy6PREUFskiHU63o7GxSveAQ3veG9CoGCMzdQz5oZ CqJ4oIRNApROVKuZncK/YDvOaVZLavQHERgid39LV81mPHL8CB/8DiBmfBPae+VzuIl8dI i5Xd172AKXPZ6qxCz9VFWPzhnFvi1h4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 12AB3617BB; Mon, 29 Jul 2024 11:20:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D765C32786; Mon, 29 Jul 2024 11:20:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252030; bh=L0Y7PVm5cpbz2IFM45IR0tDhRxs7uvign9JpFjcXT0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=toQpXt7a1O6odufEDjhGAzZYu3VuMAKim87S6w38HBpq3NyDrVubRh0vzjPWIoUq7 Kmp9LObgQS7DZcmOp8oE0SVc3ZgKc7hKBsyLCsSpkSfTj+7Jzd93aYoImSQntG4eF9 9QgWjRSpjW8+BrUmAgIZAHwJ9Zat1lil6FYLUCOmyAATd5uLdfLC+S5ohT3hKbPs7J mdBlovYhV6Wh/rF5+xEP4NsMbLYiNZ10tEhT7o5PrnGdBqESs3jpayId6AXUn4fFKf Ose/yAf/SYm5b9XQOOEUtSOwh7XiYz99icq5AyR8Dx5gENUdGpIq0Gj4h/sy3ExVyg N802hFeXmjcvA== 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 v4 04/22] mm/zsmalloc: add and use pfn/zpdesc seeking funcs Date: Mon, 29 Jul 2024 19:25:16 +0800 Message-ID: <20240729112534.3416707-5-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: E760914000C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: k7bpkzefhto1mqe547b6ah5ip5kmw87g X-HE-Tag: 1722252031-81909 X-HE-Meta: U2FsdGVkX1/nc02qIYRMOhU1J1YqrYNbKsXNhXTm8GQnmdFhNT5zokUiDG2Qua+MpYqgjsk7UKD/qxwWfv6CR8K2KDUD/immIHyKPWxbxLtG1+Ohx67tpbFW6EE4o+3HKvTIrGel3vW1XHrST7eyrW3K2HJmgYIgYxz8y4GDvsJEMjX4O6CJkH6a3PSMnQDnADLN+wB7+qySEdVVMkSymXsNKWHZpLlYFY+W4PDSzCc0abisOO7EDpxcJwg7bpk2jr0QhSbXfI1TOeAph7EyAy0vT3RTJqKIZDSWqDzPo43aQkV5y0defFkbe7FZU0EmfPL9ZsgUO3Ew1WcbErLoBHtoikIyFReXFn+6iegaQAjUhYqpB7iR5qaabVCNSSK9VRswbbRG8rHvMJF0iizOoyeUbOSc98/04JdLuD5RvCBmqGDqT3xiX4BV318o03aKHYR8hp5gTFqGUvoH9p0Tt5C9TfzhOnmOdWDFNSrhjCaW9kxTHohaw+7x7oDzhyDxzRrBPVP6VYbChjrPIvewp/BJTA+13qJDztaHuAcYrryHhcptil+qVIPpUA3ajD5QJw5a0Ala6jGzOFF7ml2vFiXATBrAf9t3CvwCgnOquJxtZLCYRudvKNYe9j0syjsZV791zX9VAeWNALwnn16sH6bTVQicOla/qU7Utcl6KZMnjExGUmdG1qxcojoDJWtDaNhl2osCyg6b074Nc4l7nxvQ6VSD1WLfyvaWSeYbfp7OZ/H85kIiWvs3LymvmnsorQVxlepnzkZBfoWU4JHthro5jCCXJhCh3f8pNEjdCwyATb2b7TeJuafowj7g5uBLsobjfxNrU2QChJQTGlkri8l4rQwxOtNGa0Ep7kBlP0pHQ02R3gzHbO90HJw1tyFiASCx7h4C/2GPoj0PGqEY+HTmSZdidD85dJfKNGrQe8g1li3LAANev0N6FlVCOZu1Cbd0nynG7IrbOJ6oOKp p76Xa33y bdGEhwO9h/aC6VNni6btqhnGMVX69WvmC6teL1RGw0wJQRjRZ5Trjmy+GTA5kUzlv3zPsu3r/ezh7c8KW+mg215suvbYI6eQgZhbNl/KvHctXA088zfJAoymY1MDc3OC9PC4BmZzanEOSJ/GNtPCdsOMgulYWX4dQVuVxpNyQ15GNbTj1tVMhBM2XJKKLX4MmMqcBtoeLqMErgNv4oMJbVYRT71Kxz0lgbggoXWphB72VpVEZgeRklJbxVygeeaJI2O5NUuFBN6IGmp+gaFbKWytUF83KOYd3LcXyJAPyleiU8fuj4DWRgJAijEeLeFbecMpRM3QpF2XsWPo= X-Bogosity: 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: Hyeonggon Yoo <42.hyeyoo@gmail.com> Add pfn_zpdesc conversion, convert obj_to_location() to take zpdesc and also convert its users to use zpdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zpdesc.h | 9 +++++++ mm/zsmalloc.c | 75 ++++++++++++++++++++++++++------------------------- 2 files changed, 47 insertions(+), 37 deletions(-) diff --git a/mm/zpdesc.h b/mm/zpdesc.h index 3b04197cec9d..79ec40b03956 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -93,4 +93,13 @@ static inline void zpdesc_put(struct zpdesc *zpdesc) folio_put(zpdesc_folio(zpdesc)); } +static inline unsigned long zpdesc_pfn(struct zpdesc *zpdesc) +{ + return page_to_pfn(zpdesc_page(zpdesc)); +} + +static inline struct zpdesc *pfn_zpdesc(unsigned long pfn) +{ + return page_zpdesc(pfn_to_page(pfn)); +} #endif diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 68a39c233d34..149fe2b332cb 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -773,15 +773,15 @@ static struct zpdesc *get_next_zpdesc(struct zpdesc *zpdesc) } /** - * obj_to_location - get (, ) from encoded object value + * obj_to_location - get (, ) from encoded object value * @obj: the encoded object value - * @page: page object resides in zspage + * @zpdesc: zpdesc object resides in zspage * @obj_idx: object index */ -static void obj_to_location(unsigned long obj, struct page **page, +static void obj_to_location(unsigned long obj, struct zpdesc **zpdesc, unsigned int *obj_idx) { - *page = pfn_to_page(obj >> OBJ_INDEX_BITS); + *zpdesc = pfn_zpdesc(obj >> OBJ_INDEX_BITS); *obj_idx = (obj & OBJ_INDEX_MASK); } @@ -1208,13 +1208,13 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle, enum zs_mapmode mm) { struct zspage *zspage; - struct page *page; + struct zpdesc *zpdesc; unsigned long obj, off; unsigned int obj_idx; struct size_class *class; struct mapping_area *area; - struct page *pages[2]; + struct zpdesc *zpdescs[2]; void *ret; /* @@ -1227,8 +1227,8 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle, /* It guarantees it can get zspage from handle safely */ read_lock(&pool->migrate_lock); obj = handle_to_obj(handle); - obj_to_location(obj, &page, &obj_idx); - zspage = get_zspage(page); + obj_to_location(obj, &zpdesc, &obj_idx); + zspage = get_zspage(zpdesc_page(zpdesc)); /* * migration cannot move any zpages in this zspage. Here, class->lock @@ -1247,17 +1247,17 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle, area->vm_mm = mm; if (off + class->size <= PAGE_SIZE) { /* this object is contained entirely within a page */ - area->vm_addr = kmap_atomic(page); + area->vm_addr = zpdesc_kmap_atomic(zpdesc); ret = area->vm_addr + off; goto out; } /* this object spans two pages */ - pages[0] = page; - pages[1] = get_next_page(page); - BUG_ON(!pages[1]); + zpdescs[0] = zpdesc; + zpdescs[1] = get_next_zpdesc(zpdesc); + BUG_ON(!zpdescs[1]); - ret = __zs_map_object(area, (struct zpdesc **)pages, off, class->size); + ret = __zs_map_object(area, zpdescs, off, class->size); out: if (likely(!ZsHugePage(zspage))) ret += ZS_HANDLE_SIZE; @@ -1269,7 +1269,7 @@ EXPORT_SYMBOL_GPL(zs_map_object); void zs_unmap_object(struct zs_pool *pool, unsigned long handle) { struct zspage *zspage; - struct page *page; + struct zpdesc *zpdesc; unsigned long obj, off; unsigned int obj_idx; @@ -1277,8 +1277,8 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle) struct mapping_area *area; obj = handle_to_obj(handle); - obj_to_location(obj, &page, &obj_idx); - zspage = get_zspage(page); + obj_to_location(obj, &zpdesc, &obj_idx); + zspage = get_zspage(zpdesc_page(zpdesc)); class = zspage_class(pool, zspage); off = offset_in_page(class->size * obj_idx); @@ -1286,13 +1286,13 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle) if (off + class->size <= PAGE_SIZE) kunmap_atomic(area->vm_addr); else { - struct page *pages[2]; + struct zpdesc *zpdescs[2]; - pages[0] = page; - pages[1] = get_next_page(page); - BUG_ON(!pages[1]); + zpdescs[0] = zpdesc; + zpdescs[1] = get_next_zpdesc(zpdesc); + BUG_ON(!zpdescs[1]); - __zs_unmap_object(area, (struct zpdesc **)pages, off, class->size); + __zs_unmap_object(area, zpdescs, off, class->size); } local_unlock(&zs_map_area.lock); @@ -1434,23 +1434,24 @@ static void obj_free(int class_size, unsigned long obj) { struct link_free *link; struct zspage *zspage; - struct page *f_page; + struct zpdesc *f_zpdesc; unsigned long f_offset; unsigned int f_objidx; void *vaddr; - obj_to_location(obj, &f_page, &f_objidx); + + obj_to_location(obj, &f_zpdesc, &f_objidx); f_offset = offset_in_page(class_size * f_objidx); - zspage = get_zspage(f_page); + zspage = get_zspage(zpdesc_page(f_zpdesc)); - vaddr = kmap_atomic(f_page); + vaddr = zpdesc_kmap_atomic(f_zpdesc); link = (struct link_free *)(vaddr + f_offset); /* Insert this object in containing zspage's freelist */ if (likely(!ZsHugePage(zspage))) link->next = get_freeobj(zspage) << OBJ_TAG_BITS; else - f_page->index = 0; + f_zpdesc->next = NULL; set_freeobj(zspage, f_objidx); kunmap_atomic(vaddr); @@ -1495,7 +1496,7 @@ EXPORT_SYMBOL_GPL(zs_free); static void zs_object_copy(struct size_class *class, unsigned long dst, unsigned long src) { - struct page *s_page, *d_page; + struct zpdesc *s_zpdesc, *d_zpdesc; unsigned int s_objidx, d_objidx; unsigned long s_off, d_off; void *s_addr, *d_addr; @@ -1504,8 +1505,8 @@ static void zs_object_copy(struct size_class *class, unsigned long dst, s_size = d_size = class->size; - obj_to_location(src, &s_page, &s_objidx); - obj_to_location(dst, &d_page, &d_objidx); + obj_to_location(src, &s_zpdesc, &s_objidx); + obj_to_location(dst, &d_zpdesc, &d_objidx); s_off = offset_in_page(class->size * s_objidx); d_off = offset_in_page(class->size * d_objidx); @@ -1516,8 +1517,8 @@ static void zs_object_copy(struct size_class *class, unsigned long dst, if (d_off + class->size > PAGE_SIZE) d_size = PAGE_SIZE - d_off; - s_addr = kmap_atomic(s_page); - d_addr = kmap_atomic(d_page); + s_addr = zpdesc_kmap_atomic(s_zpdesc); + d_addr = zpdesc_kmap_atomic(d_zpdesc); while (1) { size = min(s_size, d_size); @@ -1542,17 +1543,17 @@ static void zs_object_copy(struct size_class *class, unsigned long dst, if (s_off >= PAGE_SIZE) { kunmap_atomic(d_addr); kunmap_atomic(s_addr); - s_page = get_next_page(s_page); - s_addr = kmap_atomic(s_page); - d_addr = kmap_atomic(d_page); + s_zpdesc = get_next_zpdesc(s_zpdesc); + s_addr = zpdesc_kmap_atomic(s_zpdesc); + d_addr = zpdesc_kmap_atomic(d_zpdesc); s_size = class->size - written; s_off = 0; } if (d_off >= PAGE_SIZE) { kunmap_atomic(d_addr); - d_page = get_next_page(d_page); - d_addr = kmap_atomic(d_page); + d_zpdesc = get_next_zpdesc(d_zpdesc); + d_addr = zpdesc_kmap_atomic(d_zpdesc); d_size = class->size - written; d_off = 0; } @@ -1791,7 +1792,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, struct zs_pool *pool; struct size_class *class; struct zspage *zspage; - struct page *dummy; + struct zpdesc *dummy; void *s_addr, *d_addr, *addr; unsigned int offset; unsigned long handle; From patchwork Mon Jul 29 11:25:17 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: 13744728 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 9A936C3DA61 for ; Mon, 29 Jul 2024 11:20:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2FD916B009B; Mon, 29 Jul 2024 07:20:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 286CC6B009C; Mon, 29 Jul 2024 07:20:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 14F936B009D; Mon, 29 Jul 2024 07:20:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E88276B009B for ; Mon, 29 Jul 2024 07:20:36 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A9942A2922 for ; Mon, 29 Jul 2024 11:20:36 +0000 (UTC) X-FDA: 82392547272.01.3E101BD Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id 223DC80004 for ; Mon, 29 Jul 2024 11:20:34 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=N1dl0pOc; spf=pass (imf02.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=1722251982; 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=VMCQhHDdGJOKLu/KVq7ZZe30LH202MU5dyPStXWIX7Y=; b=G5/abDFOZ+miMTzfkK3B8adP1sjtwnqwIcPRUhocl8lzmrzjjYjls08GOXbMAeHWlOSNw+ WENkkhHyxa3d4rHSdSRhjDQEV47TZPymcXZX81P8J0XrJPHddphpMvvuB2hn36ZbDRRDXy 7+VUxOYHNwAbu5aHy1kEc6xYZkKVV0k= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722251982; a=rsa-sha256; cv=none; b=zckTsIquQISyc3/dsUd/ZowqjVrf8akGQHpekkZXxRRk+gV5JA6QA/v5eZz3Lsrwi1eU8g pJnOAjW/QtItnzu55SxkQg5esU0w2VWFeBM4h5GqVikZ6oJMJcCLEUG9fvNvm0Z+8bhNYj Wqfz997MXG2nQquc12Ax3AFrsUtFTVA= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=N1dl0pOc; spf=pass (imf02.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 51C83617AA; Mon, 29 Jul 2024 11:20:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F00FC32786; Mon, 29 Jul 2024 11:20:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252034; bh=OUw0L1+EEkxStexhrY6FwqktPPZ5HwiknqjqfzU6PXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N1dl0pOcTFgdmJMCVClV0yXxSZWm7Os6wsGJ8ws8QQxeG1j3yfc4V0ckuKv4YRMv/ N5hoiL5nFmBw9n5kMO//6XdEuvI1hUezsU07uTtuoLOWXZf9d7IUGz7qr8PrG7Ou9P oz3DyQNNb766EmVqx/Ph2tCIOxiJYm8TzWmi0nRSA3dytbAskWr3IWIfrIMpzw9y/D oVY3NFI/tP0Wjs+PVcxCpfRBSSKz1lDKt0FCv6Aznv+WWyn5nND3SBVMP8rLdaRzof H7D20CRe1/5dp+pGZF7Nyz3t615VHG60okruZFTRx/u9cA4QYBXyElY4tQZktkitMc /UvAS8vIlC8Bw== 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 v4 05/22] mm/zsmalloc: convert obj_malloc() to use zpdesc Date: Mon, 29 Jul 2024 19:25:17 +0800 Message-ID: <20240729112534.3416707-6-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 223DC80004 X-Stat-Signature: cq95prqcsf1ogw3xgryj7yb5fpzqgmtf X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1722252034-476712 X-HE-Meta: U2FsdGVkX18eTDe63AH5OQPZyNA9592LGChbaUyj61P90EGennwogoQ3/0TcvXoq5AlHx9YISyRUf/6Xt4BP40o94t7Ccr5otZ8hBzF4dT9YPqbLey9H/8iQ1RlWCFBKPu4T1jEgYGwrz09cTe1MEolM0CV2lcUBD5T6+uhmOrf0eD8uwT4Sff/G0EOfHvD7TWNskwpC6z1VtmblM5t4TpMtBjd8iscD4IMPqhTv+9qCDeKjQbgYO4lQNE8TT/YiSD14B75qrEXlrLoWWmtMrXtydaQAicy7rfwaDSEvxUmEd7nk2xhCmm5SXuWjOyAi9UukLiizfogNOAqukv5Rn5AU7ITIFzAaWInkP68VBLBv2vLyA5rIekfjsHwxnLyx3O8IfFbRI41jYjg0S1TD1OTIQ548feo69pWYMoD/pjorSLhchE91Iho3YxBfJMUA6WbsoPiFaS1NUhedxHJO+TBPnRvNO6TwRftwnGYtpMhEDxTCoKjeYzmKB84Wl3Ha3n+Wwl6lxvMZOkkMV4je1zsZDnx/hl3aGOLBHmD4QjX9mD5oU7HFjEGJOxd7e9fl/QC/Ku74OdQRB0B+gWOjq2KFgomKvyHiuGp9UIWbme5Aiawnfk1Z3itKbFjh91j453pfmNwlFK3ecq54WDlJxzN9Y/hXfsR9GDobyG2KAbw31xEsLBEycQxTOYDU7nVFiDZ39LEDpFzSuxMueXxob33Q8lgyWYxoexgfQU6m5j/bO2M/YJHhIgoeV8tv3UWw8nBNqqfBdik8NyAUJCi4+/o7t8+sTQttPljwS0JFgPrpqPhg9UBwCJLpfdeE68WNqK3e+q4fXzx6TaLE5fATIG+YLFAgP3wE5E3Le8FXoiTB2ZhgYlBUlTKK4jI3rPPb/C030ohlwCDYxHZIW6XAC0u8akL76Sf58IaYHArhDOV9oEhfOzc1PYNXZtUg9GUMCv4qvYBoTK6Zht+Co0/ lMTr6m13 A1epxj/Gm4xLZbaNO4uFBX0jGzXbkanbZBw38oDC03zeoYFj5d6otiR9WmIe+y8C4ScKh4P8z+efiu/grmToSViTR3K0Wqmzy7/j/+GSy51vNiENor8hMIgHvhLuY0r35TMejqPXjViA9/5EpYDuukwXr5InETSUKxvqZ3fTfvB3DIeChofTkRSdsakApDh7Dly2W9tCwguUp27o+CgHuxRT79KM0riLM+BoqDww7HxRaDvI+KjY+aT8410zypwodx9R5LRj2nQJuovNJWTGiRYDgaQQrANUQonFo136nwbR4rzqUsm6RjyC/hyrItSrkwAAvtYWW3DL7xZSZakmtHiSpsWYlRFizdxO93eYlRXtOi6MyBzNKhDlmC3BvYp0B3rDc X-Bogosity: 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: Hyeonggon Yoo <42.hyeyoo@gmail.com> Use get_first_zpdesc/get_next_zpdesc to replace get_first_page/get_next_page. no functional change. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 149fe2b332cb..bbc165cb587d 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1322,12 +1322,12 @@ EXPORT_SYMBOL_GPL(zs_huge_class_size); static unsigned long obj_malloc(struct zs_pool *pool, struct zspage *zspage, unsigned long handle) { - int i, nr_page, offset; + int i, nr_zpdesc, offset; unsigned long obj; struct link_free *link; struct size_class *class; - struct page *m_page; + struct zpdesc *m_zpdesc; unsigned long m_offset; void *vaddr; @@ -1335,14 +1335,14 @@ static unsigned long obj_malloc(struct zs_pool *pool, obj = get_freeobj(zspage); offset = obj * class->size; - nr_page = offset >> PAGE_SHIFT; + nr_zpdesc = offset >> PAGE_SHIFT; m_offset = offset_in_page(offset); - m_page = get_first_page(zspage); + m_zpdesc = get_first_zpdesc(zspage); - for (i = 0; i < nr_page; i++) - m_page = get_next_page(m_page); + for (i = 0; i < nr_zpdesc; i++) + m_zpdesc = get_next_zpdesc(m_zpdesc); - vaddr = kmap_atomic(m_page); + vaddr = zpdesc_kmap_atomic(m_zpdesc); link = (struct link_free *)vaddr + m_offset / sizeof(*link); set_freeobj(zspage, link->next >> OBJ_TAG_BITS); if (likely(!ZsHugePage(zspage))) @@ -1355,7 +1355,7 @@ static unsigned long obj_malloc(struct zs_pool *pool, kunmap_atomic(vaddr); mod_zspage_inuse(zspage, 1); - obj = location_to_obj(m_page, obj); + obj = location_to_obj(zpdesc_page(m_zpdesc), obj); record_obj(handle, obj); return obj; From patchwork Mon Jul 29 11:25:18 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: 13744729 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 1DA83C3DA61 for ; Mon, 29 Jul 2024 11:20:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA0206B009D; Mon, 29 Jul 2024 07:20:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A4FBF6B009E; Mon, 29 Jul 2024 07:20:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 917286B009F; Mon, 29 Jul 2024 07:20:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 70BEB6B009D for ; Mon, 29 Jul 2024 07:20:40 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 2BBEE4029B for ; Mon, 29 Jul 2024 11:20:40 +0000 (UTC) X-FDA: 82392547440.16.5C7FA21 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf03.hostedemail.com (Postfix) with ESMTP id 776F320011 for ; Mon, 29 Jul 2024 11:20:38 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=CHDQSHaQ; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf03.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722251979; 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=MXKib2VKKtWSPN2wud0WRC/YoxbugN+potuqXfgPPvA=; b=dR4D08CQ/HkUvx3iKeP29uqMgJIjPXa4t+pwrLKLdLKZl/OQoe7LAWDE1G4N5KRBQs4cgF nwUH9HKQB9Yw+ys2y4A7CzgoVyO6Td9TlDEFKhkTaTQf9NJ6H672Pzqwq6kLpDD5A4BaYr jqLPwflyP4+/wm3a7Nn0BYD9vgLKb+M= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722251979; a=rsa-sha256; cv=none; b=MUDYctTzoV7SHelak3cP0C5CfTka1EGY1QoL6N1e4hsGBBUHD6yxmB5j/yQ/FpO88hOHdY JkIsdpdQwIa01/ZDyu/M6vHAvGXEl7vidfCzxil0GbsLrIscD70Sjciab05U4jAMB4EIBx eYRM24eAMDH+Bez7zCrFgO9hYAPX2E0= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=CHDQSHaQ; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf03.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 92EAE617A5; Mon, 29 Jul 2024 11:20:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DF16C32786; Mon, 29 Jul 2024 11:20:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252037; bh=4GoIroOrsiTuTdQywHvfrAqEQ0msvRBa8bIywcf/abg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CHDQSHaQ7YakefYJHb5Fg8lwtzCCaRG0VB351O0fHGxYrATxRQrDZhI6rXJ3dYnNK Cs/mmOJEmxG2Aa1cu/6/PsIqH4iL7wmLNMzzgMSyyw6nxdlJ7TUkJefkCoFSJ2U4XS IMEeeC0++d0mDQXFOPSmTGpPyQZyQAKDz/oPl24dNOK4QRKxHMwM0ex8RFI3nGBYJw pknR9QDjYq8runDJIu6KXyqIB3Ocw+VmQeuFt5ONCeMIVGQmaQGQYkBstduSvvwdHA ncnyZj0t/SqxNDRf721evVt/lqIhGFRrvpfpJa6Vz1uJAWL6rzHStGwxIs063ARWFF exuUydPFMljvw== 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 v4 06/22] mm/zsmalloc: convert create_page_chain() and its users to use zpdesc Date: Mon, 29 Jul 2024 19:25:18 +0800 Message-ID: <20240729112534.3416707-7-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 776F320011 X-Stat-Signature: ap6iof9gugxbsp3z1neiiggd46ctjrxw X-Rspam-User: X-HE-Tag: 1722252038-310680 X-HE-Meta: U2FsdGVkX1+Lu0XNds0/DE3ZHCjCljg4uDmzsrTMOruvJszk2aH4yQw9U7AzpxN91X1rE8jyEa/iCpeANApj2kAAC1epl8jCxKdTot+ofwQFoAt1FG/9xnrM+u5BMb5q3u/sVg4m4qPNWyniwV9t6veBvA2lp+W+u9HrPZYqznE2tTAIxVb2SKgXNHbuqepjGDESsQJTmyRNiztoL7tY/cM8Qb+SsT00wmtKI2B7uTOYlTD3WBhDR0ppVbO5tJUgT4C2uj1yyMI7YP9zvSXvoN7IgWJ43wQlO7WK5wSQmZshDBIiFz/XN6O555BQGodiPP3z4iGCq524YO4P+MLXuL27NDfugT+icc44QYLGW6lqrIz3FydQ16LmNezfmoc7iWRt+2qO17H0NV3HgIkN+i9AEw9KnZ5CeucIQ7lvKXCyKRnV+puzHiCXpSEK7Motjneaa2fnQZMbt9WiLiDyHkKTgdevmZCQbxnvuI9+rfZFjcftvQoW0NPcEdkkH5wBhHBnth6oLX0RTVuCO+5nP9Utj4Onlu6HDN9TdBUafleAaL1czeTPE/1XyH7z5h5BI+iYskF30uQd/voyK/CPUxgJRfxPNpwwOQcNGgSz2McZ6vRBtHoOG6+VAg/dTsqE/f3sGWTXDh6ToDezFiPUHBpeaIDLl30zSxFLUEi8CecTazoPv0qjqDQFvhkflTaSQFYTML404/dWMVbS8dONFmtWFoLlML8arsUxlei7LyMUvWYI+szTX31CifMcq3+gLutkQ+slQw/r/LsjOyCwoNgGyEXAqZ2gtuNeLvk8WDTNNITAwue8bG5kpaOVePO9VjWe4oqskgAOCSu0CmUJEo0Esfghls4Mz/4veD4KRsp2KlEcTDcj0ih1skvfud33WPzbUqg4b1j2phxxtxuw/kUv2ocphg1BbN6OYFyyX1BgLiwaVCV72hfdfOPa5DaE33RpCOmiHhqhw4pLyeJ Zisa0rnt 3hvQatC7pEEY8t0XMCTqstJT6jtW4oI5o4dZSIWlXERnpECRNRkMf/yXEZCJh7iL94p9MjMKwFYoClShZzH8UqmOTIe1ved5/95PPohNTnMSa2dR989ZoSuxUB+WiLNt5l3ydLReXdixYS99x4mXAigucZ6NR61L9qrHLWWQ/TUB/tJqULCZCEyzlcILTiYyRMWVfe+OyINRckD+bY+Hgt3eNb85hvISOXnRETPancrxqsY4jmoigDTPcmgycpp/CGHhllm8rHDCDBndu3FrgrRXHUeosQn3Uo4M0gZ7WLCbe21X/h9ebzUCOZRPy8QMREdtjLZNhqJEtjfy1QWAktx+YkXxnTumaSM8FMy1FzAKPyWLR84pt0vM4JiCceIll6BuS X-Bogosity: 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 Introduce a few helper functions for conversion to convert create_page_chain() to use zpdesc, then use zpdesc in replace_sub_page() too. Originally-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zpdesc.h | 6 +++ mm/zsmalloc.c | 115 +++++++++++++++++++++++++++++++++----------------- 2 files changed, 82 insertions(+), 39 deletions(-) diff --git a/mm/zpdesc.h b/mm/zpdesc.h index 79ec40b03956..2293453f5d57 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -102,4 +102,10 @@ static inline struct zpdesc *pfn_zpdesc(unsigned long pfn) { return page_zpdesc(pfn_to_page(pfn)); } + +static inline void __zpdesc_set_movable(struct zpdesc *zpdesc, + const struct movable_operations *mops) +{ + __SetPageMovable(zpdesc_page(zpdesc), mops); +} #endif diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index bbc165cb587d..a8f390beeab8 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -248,6 +248,41 @@ static inline void *zpdesc_kmap_atomic(struct zpdesc *zpdesc) return kmap_atomic(zpdesc_page(zpdesc)); } +static inline void zpdesc_set_zspage(struct zpdesc *zpdesc, + struct zspage *zspage) +{ + zpdesc->zspage = zspage; +} + +static inline void zpdesc_set_first(struct zpdesc *zpdesc) +{ + SetPagePrivate(zpdesc_page(zpdesc)); +} + +static inline void zpdesc_inc_zone_page_state(struct zpdesc *zpdesc) +{ + inc_zone_page_state(zpdesc_page(zpdesc), NR_ZSPAGES); +} + +static inline void zpdesc_dec_zone_page_state(struct zpdesc *zpdesc) +{ + dec_zone_page_state(zpdesc_page(zpdesc), NR_ZSPAGES); +} + +static inline struct zpdesc *alloc_zpdesc(gfp_t gfp) +{ + struct page *page = alloc_page(gfp); + + return page_zpdesc(page); +} + +static inline void free_zpdesc(struct zpdesc *zpdesc) +{ + struct page *page = zpdesc_page(zpdesc); + + __free_page(page); +} + struct zspage { struct { unsigned int huge:HUGE_BITS; @@ -954,35 +989,35 @@ static void init_zspage(struct size_class *class, struct zspage *zspage) } static void create_page_chain(struct size_class *class, struct zspage *zspage, - struct page *pages[]) + struct zpdesc *zpdescs[]) { int i; - struct page *page; - struct page *prev_page = NULL; - int nr_pages = class->pages_per_zspage; + struct zpdesc *zpdesc; + struct zpdesc *prev_zpdesc = NULL; + int nr_zpdescs = class->pages_per_zspage; /* * Allocate individual pages and link them together as: - * 1. all pages are linked together using page->index - * 2. each sub-page point to zspage using page->private + * 1. all pages are linked together using zpdesc->next + * 2. each sub-page point to zspage using zpdesc->zspage * - * we set PG_private to identify the first page (i.e. no other sub-page + * we set PG_private to identify the first zpdesc (i.e. no other zpdesc * has this flag set). */ - for (i = 0; i < nr_pages; i++) { - page = pages[i]; - set_page_private(page, (unsigned long)zspage); - page->index = 0; + for (i = 0; i < nr_zpdescs; i++) { + zpdesc = zpdescs[i]; + zpdesc_set_zspage(zpdesc, zspage); + zpdesc->next = NULL; if (i == 0) { - zspage->first_zpdesc = page_zpdesc(page); - SetPagePrivate(page); + zspage->first_zpdesc = zpdesc; + zpdesc_set_first(zpdesc); if (unlikely(class->objs_per_zspage == 1 && class->pages_per_zspage == 1)) SetZsHugePage(zspage); } else { - prev_page->index = (unsigned long)page; + prev_zpdesc->next = zpdesc; } - prev_page = page; + prev_zpdesc = zpdesc; } } @@ -994,7 +1029,7 @@ static struct zspage *alloc_zspage(struct zs_pool *pool, gfp_t gfp) { int i; - struct page *pages[ZS_MAX_PAGES_PER_ZSPAGE]; + struct zpdesc *zpdescs[ZS_MAX_PAGES_PER_ZSPAGE]; struct zspage *zspage = cache_alloc_zspage(pool, gfp); if (!zspage) @@ -1004,25 +1039,25 @@ static struct zspage *alloc_zspage(struct zs_pool *pool, migrate_lock_init(zspage); for (i = 0; i < class->pages_per_zspage; i++) { - struct page *page; + struct zpdesc *zpdesc; - page = alloc_page(gfp); - if (!page) { + zpdesc = alloc_zpdesc(gfp); + if (!zpdesc) { while (--i >= 0) { - dec_zone_page_state(pages[i], NR_ZSPAGES); - __ClearPageZsmalloc(pages[i]); - __free_page(pages[i]); + zpdesc_dec_zone_page_state(zpdescs[i]); + __ClearPageZsmalloc(zpdesc_page(zpdescs[i])); + free_zpdesc(zpdescs[i]); } cache_free_zspage(pool, zspage); return NULL; } - __SetPageZsmalloc(page); + __SetPageZsmalloc(zpdesc_page(zpdesc)); - inc_zone_page_state(page, NR_ZSPAGES); - pages[i] = page; + zpdesc_inc_zone_page_state(zpdesc); + zpdescs[i] = zpdesc; } - create_page_chain(class, zspage, pages); + create_page_chain(class, zspage, zpdescs); init_zspage(class, zspage); zspage->pool = pool; zspage->class = class->index; @@ -1753,26 +1788,28 @@ static void migrate_write_unlock(struct zspage *zspage) static const struct movable_operations zsmalloc_mops; static void replace_sub_page(struct size_class *class, struct zspage *zspage, - struct page *newpage, struct page *oldpage) + struct zpdesc *newzpdesc, struct zpdesc *oldzpdesc) { - struct page *page; - struct page *pages[ZS_MAX_PAGES_PER_ZSPAGE] = {NULL, }; + struct zpdesc *zpdesc; + struct zpdesc *zpdescs[ZS_MAX_PAGES_PER_ZSPAGE] = {NULL, }; + unsigned int first_obj_offset; int idx = 0; - page = get_first_page(zspage); + zpdesc = get_first_zpdesc(zspage); do { - if (page == oldpage) - pages[idx] = newpage; + if (zpdesc == oldzpdesc) + zpdescs[idx] = newzpdesc; else - pages[idx] = page; + zpdescs[idx] = zpdesc; idx++; - } while ((page = get_next_page(page)) != NULL); + } while ((zpdesc = get_next_zpdesc(zpdesc)) != NULL); - create_page_chain(class, zspage, pages); - set_first_obj_offset(newpage, get_first_obj_offset(oldpage)); + create_page_chain(class, zspage, zpdescs); + first_obj_offset = get_first_obj_offset(zpdesc_page(oldzpdesc)); + set_first_obj_offset(zpdesc_page(newzpdesc), first_obj_offset); if (unlikely(ZsHugePage(zspage))) - newpage->index = oldpage->index; - __SetPageMovable(newpage, &zsmalloc_mops); + newzpdesc->handle = oldzpdesc->handle; + __zpdesc_set_movable(newzpdesc, &zsmalloc_mops); } static bool zs_page_isolate(struct page *page, isolate_mode_t mode) @@ -1845,7 +1882,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, } kunmap_atomic(s_addr); - replace_sub_page(class, zspage, newpage, page); + replace_sub_page(class, zspage, page_zpdesc(newpage), page_zpdesc(page)); /* * Since we complete the data copy and set up new zspage structure, * it's okay to release migration_lock. From patchwork Mon Jul 29 11:25:19 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: 13744730 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 5C548C3DA61 for ; Mon, 29 Jul 2024 11:20:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E6EB86B009F; Mon, 29 Jul 2024 07:20:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E1F396B00A0; Mon, 29 Jul 2024 07:20:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE6E36B00A1; Mon, 29 Jul 2024 07:20:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id ACB4B6B009F for ; Mon, 29 Jul 2024 07:20:48 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5D5578019D for ; Mon, 29 Jul 2024 11:20:48 +0000 (UTC) X-FDA: 82392547776.20.B5F858C Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf29.hostedemail.com (Postfix) with ESMTP id 05270120020 for ; Mon, 29 Jul 2024 11:20:45 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=kogUr8J+; spf=pass (imf29.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1722252020; 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=0SrS60HvLY/N6/E75A0QfavAHW7YWNFLHpW+OVguC9k=; b=tXmlh6aBiqjzktiDEi1+BhY03r3ycVWalagXpR3WBkFwWRv86CNYJzsCsy759Gtx4roI7f fT34HDZ3BgVwe+4cZa+7hgc8fBWEPdlhIhjovL/ii4uFksD2zbKmmHqNoPFdemGoZSnRsX XvaJZkrJuiJ9OWOTYXz15ekBfsZ5jKI= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=kogUr8J+; spf=pass (imf29.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1722252020; a=rsa-sha256; cv=none; b=V331OD/+2PBxUemaXojAQyfTcex4kc4w+sPum1lI4P7Il4sGwnh9au0Z86wZjKP/T9Sb/l 5m72+DC7R0jak2n7Esl5CNT8orxyJ6qXTrOxSUe13PXpw5qZF2MAYrldRJx1FeMLajysMV OMAw5I4CCQHPUoRDdJb5sdTWnkXTE64= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 03C80CE0ADC; Mon, 29 Jul 2024 11:20:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE9DCC4AF07; Mon, 29 Jul 2024 11:20:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252040; bh=82zz9HxUIo/V08TGVJ1E1ZkMfjqggCMIVYH80TRsdU8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kogUr8J+ASWDsTSUahBnjIKsYaKvi+MjsPcBvHhGeMdzD9/bY1wyw1uJjMFXqaZqa dbzYtQVeJrFawJPLm0Az6yN9N4HdL1MVHpK6luozdkWZsUBI0HDrA4b3KXItLrQxnt FMtVzoqoh1N2uK9Bv+aIKlt2fPU64fk92RzxzWQkEwNG+BtJhMhRhQmjjLweH2jQys o1NhJCqu93uTeCGJp77cZB5zYrqiDCLwwhIGCzsuyKh0QWkprw7eZWTRkq0VdpizXt oif7Tr3J8T6GX5EOfUt0ZLw+Egnrb/dD4h3giVED052va3Wk+2pYPUamRUWeo2rTld Hc9VV7OuD9jXA== 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 v4 07/22] mm/zsmalloc: convert obj_allocated() and related helpers to use zpdesc Date: Mon, 29 Jul 2024 19:25:19 +0800 Message-ID: <20240729112534.3416707-8-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 05270120020 X-Stat-Signature: qpjytjt197jzjqemmc51wz888fe1gf4s X-HE-Tag: 1722252045-992927 X-HE-Meta: U2FsdGVkX1+Rq7Eg2kcn/LTl4V9m2hPNe15Didu3B6RNtQexa7wTVTW1XArflHkx1GuQsBvH+XaY7M2AevBSkF6kvrOREmlxC1j8jh4gaNwDylgDJFrtkZWxgC0SeMND20jfkum91MT88Ws9g29b58ud9OJM1ex65fBD6fGIJCvd7SCDbAgAr3NYSzXkVji1cnSnDGui0uGH22Y4kLvPDSc3PlGqYCwM31blHGEYBpfcS9dhhHH0AjUnUYYjiiqbuhgsBhsBK3w4cueebtUTM0tGdLciHdsM96nhUYySDf9ZyBRmfJ5EvZBaoNiKp5FLXl/4ZbtvaosPUuAIkqSYyJDb7oIUe9/JYrZSqxKCyrx850C9QaIHDNW6GqBXO1WYRfu240/plhDzXR1yRSpaweX4x7fU0oorL8D/bxT8HceUQb0bat9vUr1A/43/OcYDNt5Fs6SbA+jQYgBMV9ijnsVSBAmIMlQ6UxHToshxXNCphwAPZ/sdiPdodOc4/5rUrJ6I/KT0LZoBEnpTWNbsh6YZoydHLaTViAoSFvHEwkiuQCnidjq+YUcfoXuEqKLALjBySyKVDeiuCW+AGYaNdief77grO7ASiF/+lUqruDO9a0eCZ9q1uSNXIhEFsPIq/CUxZzB/QjO2mu7B9vRChY+i8zdzA4xTNMC8aL7Q/B6OS4JShjVGljBuiILfGnoUmftjzS2s+fVEG8sgVwNfdNiUUhaP5nOTHuCB+JuSHgzTK5vCg/6rRDr9g73ExULK9FbMWNvi3kDRHG4dLiASsRcB54e/v+PXTf6DicQN7+ENXhtTh/Q19PI8rLXwKP691ogsJHEfx55aHewr4QSEvMmEDaCRwXYo4/c3gIUM2X06YcQ9H2btsKsVNkXP0i6LvxE14p2cbaIPakyGyZF58MR+HiTkmfp8EvWYYY0vSSNb2gotg1GTdmlZgSJq0ktky4MelG3t72u77qkjPcg rkzQYbTI khcBiLWKMrG1MyHDtI6R31wMAaqFd3BK/31qVSfwaMpg99Xh+QmHIU58IEuSCWj+zBWLMl9xDFyY2kNydn9mFPkSlffAHjg87HjWwl8OrwBczrluJoo2PZWe8gkGBAvCiU3ZpEG9cb+siWSrGNuu5WJ0XkuWEyhDj7RkFqf7csgG3Sh1UuKjBNd6RXMnb8kaYmYVNhHBWWVpyewvvFQ+EeCcWHHerEvjK/yMLLNxQqOTtl7sJsX3a8lxuPGwZCm4NohQhZ10ZzIlxcFZVT9aTRlahOJGjbFXTokNlV/DHjmteB+RtI6/VWXZ9XH9xBLcJPKvk/SMAuFKgsPCAsYm8bpCft95rekV1GVfwJiUaqu1DKH4FUS77FACD/A== X-Bogosity: 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: Hyeonggon Yoo <42.hyeyoo@gmail.com> Convert obj_allocated(), and related helpers to take zpdesc. Also make its callers to cast (struct page *) to (struct zpdesc *) when calling them. The users will be converted gradually as there are many. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index a8f390beeab8..29b9fa5baa46 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -845,15 +845,15 @@ static unsigned long handle_to_obj(unsigned long handle) return *(unsigned long *)handle; } -static inline bool obj_allocated(struct page *page, void *obj, +static inline bool obj_allocated(struct zpdesc *zpdesc, void *obj, unsigned long *phandle) { unsigned long handle; - struct zspage *zspage = get_zspage(page); + struct zspage *zspage = get_zspage(zpdesc_page(zpdesc)); if (unlikely(ZsHugePage(zspage))) { - VM_BUG_ON_PAGE(!is_first_page(page), page); - handle = page->index; + VM_BUG_ON_PAGE(!is_first_zpdesc(zpdesc), zpdesc_page(zpdesc)); + handle = zpdesc->handle; } else handle = *(unsigned long *)obj; @@ -1603,18 +1603,18 @@ static void zs_object_copy(struct size_class *class, unsigned long dst, * return handle. */ static unsigned long find_alloced_obj(struct size_class *class, - struct page *page, int *obj_idx) + struct zpdesc *zpdesc, int *obj_idx) { unsigned int offset; int index = *obj_idx; unsigned long handle = 0; - void *addr = kmap_atomic(page); + void *addr = zpdesc_kmap_atomic(zpdesc); - offset = get_first_obj_offset(page); + offset = get_first_obj_offset(zpdesc_page(zpdesc)); offset += class->size * index; while (offset < PAGE_SIZE) { - if (obj_allocated(page, addr + offset, &handle)) + if (obj_allocated(zpdesc, addr + offset, &handle)) break; offset += class->size; @@ -1638,7 +1638,7 @@ static void migrate_zspage(struct zs_pool *pool, struct zspage *src_zspage, struct size_class *class = pool->size_class[src_zspage->class]; while (1) { - handle = find_alloced_obj(class, s_page, &obj_idx); + handle = find_alloced_obj(class, page_zpdesc(s_page), &obj_idx); if (!handle) { s_page = get_next_page(s_page); if (!s_page) @@ -1871,7 +1871,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, for (addr = s_addr + offset; addr < s_addr + PAGE_SIZE; addr += class->size) { - if (obj_allocated(page, addr, &handle)) { + if (obj_allocated(page_zpdesc(page), addr, &handle)) { old_obj = handle_to_obj(handle); obj_to_location(old_obj, &dummy, &obj_idx); From patchwork Mon Jul 29 11:25:20 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: 13744731 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 C030AC3DA4A for ; Mon, 29 Jul 2024 11:20:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 486536B00A0; Mon, 29 Jul 2024 07:20:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E7E06B00A1; Mon, 29 Jul 2024 07:20:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1D1046B00A3; Mon, 29 Jul 2024 07:20:50 -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 01E096B00A0 for ; Mon, 29 Jul 2024 07:20:49 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 7A90DA35A1 for ; Mon, 29 Jul 2024 11:20:49 +0000 (UTC) X-FDA: 82392547818.09.B478F13 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf25.hostedemail.com (Postfix) with ESMTP id 7718EA0016 for ; Mon, 29 Jul 2024 11:20:47 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RxZcivsx; spf=pass (imf25.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1722251994; 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=7aSS3PfeGPzIHYEgpKcCy3AJpke6a4GKIbhcdDELY+E=; b=IYQTGbRQTl01dLR+BJ2MzRYMFS2/IgcX/tfNcfsIxByANC45ciYaqUTBPXgnh/yDjaHZfr GMVnUeaFazeem7I2cSEEayrDUeCHfBuAEMejsNBWZ46p47OP3mGr9AJQxQI79nAf7My7ox TwKM2JR++JV1tuA/V0spXU1oWhCMXdE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722251994; a=rsa-sha256; cv=none; b=bH+pRhub7HI8t7biZPrQTwcC/XuKr6+sq8GJ8ZHT0mT0tqFtwR4hF5QBav4Njjv5GMW+y4 xhg5HPI3pbylbbjJaZURMzHfV4hfunbMKUTMrg698W5j67/hA6HuFVgLd25Vmv40Xke1Qu tjOPd11Gg91XZOAYHlQXv8AjXI9Ursk= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RxZcivsx; spf=pass (imf25.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 40EBFCE0ADE; Mon, 29 Jul 2024 11:20:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 232D0C4AF0A; Mon, 29 Jul 2024 11:20:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252043; bh=hCA+Wp2koQFPErK04B2puEI5lWDR1Rh4V60AMISo3bA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RxZcivsxHrV7ru1KjcEzOlOvSeKDf/VpS35R1Jm/ckHCF5FkBHfPZZlKMLo1HZlJZ e+mZIYJdkYGOoowl74xkpbxMv+5NuCg1KbSFCL4kZ00Tqa3dTGnIiwH50thl+3pYVa Geh9a7OSmgGpOqv0ZOW2hZIUlBaMFwvD0xV8t4bdMzCjwlGp7rgp+nn3EGq3oahway 16a0c1+b0SjHzRW7oSgs1/gNsL+p0Ht9S6hgw8Abb/W7bj3eI4av9N4IaeoQx0Ogp7 ZP2Xcf2MLAk4ozA193cBosfrjL0qJE8Q7nrWXzuslYTjAjYJOrSlnhZ9DJHaPEbYhC GG/xWcMb4MZ4Q== 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 v4 08/22] mm/zsmalloc: convert init_zspage() to use zpdesc Date: Mon, 29 Jul 2024 19:25:20 +0800 Message-ID: <20240729112534.3416707-9-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Stat-Signature: 1tmu8kzp6djqmoqyrudou88yqqhub1n8 X-Rspamd-Queue-Id: 7718EA0016 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1722252047-165758 X-HE-Meta: U2FsdGVkX1+k0rAz/XyUkcM8d43Jmq7eEL6SpFbqES7OLElWdW4B+hS0ZiTizvQ7PiARkkcLLeoiVReIVMZSajpfQhCXPO0K6O+Z1Rl3lAk7lgGpts1x5Vr7faXe+UVTG+6YBquYE3r/IyntaT+KNXGwixQuv7ml/pG4/lb03d0uD/IrL0W6ZxWjiEkXuxNqE7H8nmOmS+deu+R8vApQSyOyz6vMwMONqaOPOshgPZMYPWHF9got7fFVpgQBA77gWAuTIcZ/k7LszfHTE7bsj0eEL9kW0nEcQGYnZYFgRSzXv2PHlPEPfB7s7OlBIwcS6cU2MsjbJ2YWczL0YNx90w1OxnYibU7c9xEtlqRhEU5hO1U8PEiAskypQJ+d6zBrqP5cDqflAl8blV2SV+1XoNkdDd08uj2jRbLXBd+e8ttxVcCw8nbOeGAQ2idkUfyU0m3yKZ0NYSIXdgOTEl6RqHa6BpMkuTvlN7Ohu81i2lQ5eSkPx40M3uhOtMMDXOSWAwNxZYi4wklVeKi9DJ2VrDT8ySqOECZ08rWoEN10MQQVyKQIiK+4Y1erbryY+XR8QT1DXWgtzajyf2WvW++OaS/APPFrPvYT2AXDFZ7fOu/jhHBLArRpifApR7ZfbiSyx2uVZCk1VSEYgxOmW5jCWhMg7gIZfQP+utV/5rEpM3qwc3Hfryk5lJ1oY9mdBzc+jB/cDU0zb0dRhVVP0ASkcMDOnt8QwGOg04WC+2Y7OyF32R4PUdABbkwPCzJ7ICw/rQsuqmW1wF8nSZR2rE63ibQ2qkToyvepBIuyvZSIJn6Pf5CIqbMol8FJwIGeaCquM3PgkgceO3Sh9xp4bQ6rg/I7e1X8Zbj9n33kW/Lm8KasqU4R4fz389IOrXypIXWc7JBptinxTVVdbP/CMG7rE/mYYznFMqg/KK7ekDFPJL6H7VWGipSImjDJpUGbm3Y5G51jibjr4jdhGF/9Mmp iasv54fg novI3qRU+yQYhntTe1iHv5goIDr/C6953msb/lYpXiqsElKU6XpTrf+T7sbGHp8aR55Qwji5xIUtoMBZdRsToLhRdKuCIur+Rmm4Xo1ZdfOZQcwx7cgGtuhz34WxFGGLwr7P79SWT9wKnd7ebd9TnCDN9B1gDCkFKmpGyvT3iMlHTxvinaTvaWoRBy9V4xhuodHg6gTy3i7cJmTm36uzEM92VkvqoZsmNkHC3Vz7D3P3PaP5wZDapuPG2BjyseDXi0KoljnccJRhS3ai5eqjYlcUytqaWyXvdnyksl7/XPnZqn3w47nso3danat0bJyrf/37TGYda8zdpCkNdMTIwR0ANHKLFIHMU60bZTeZ+vQPjuibtPJXNZSAmVA== X-Bogosity: 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: Hyeonggon Yoo <42.hyeyoo@gmail.com> Replace get_first/next_page func series and kmap_atomic to new helper, no functional change. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 29b9fa5baa46..d3558f3f8bc3 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -948,16 +948,16 @@ static void init_zspage(struct size_class *class, struct zspage *zspage) { unsigned int freeobj = 1; unsigned long off = 0; - struct page *page = get_first_page(zspage); + struct zpdesc *zpdesc = get_first_zpdesc(zspage); - while (page) { - struct page *next_page; + while (zpdesc) { + struct zpdesc *next_zpdesc; struct link_free *link; void *vaddr; - set_first_obj_offset(page, off); + set_first_obj_offset(zpdesc_page(zpdesc), off); - vaddr = kmap_atomic(page); + vaddr = zpdesc_kmap_atomic(zpdesc); link = (struct link_free *)vaddr + off / sizeof(*link); while ((off += class->size) < PAGE_SIZE) { @@ -970,8 +970,8 @@ static void init_zspage(struct size_class *class, struct zspage *zspage) * page, which must point to the first object on the next * page (if present) */ - next_page = get_next_page(page); - if (next_page) { + next_zpdesc = get_next_zpdesc(zpdesc); + if (next_zpdesc) { link->next = freeobj++ << OBJ_TAG_BITS; } else { /* @@ -981,7 +981,7 @@ static void init_zspage(struct size_class *class, struct zspage *zspage) link->next = -1UL << OBJ_TAG_BITS; } kunmap_atomic(vaddr); - page = next_page; + zpdesc = next_zpdesc; off %= PAGE_SIZE; } From patchwork Mon Jul 29 11:25:21 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: 13744732 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 2111DC3DA61 for ; Mon, 29 Jul 2024 11:20:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 740C56B00A1; Mon, 29 Jul 2024 07:20:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 54C096B00A3; Mon, 29 Jul 2024 07:20:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3763F6B00A4; Mon, 29 Jul 2024 07:20:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 140C36B00A1 for ; Mon, 29 Jul 2024 07:20:50 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C1EFD8019D for ; Mon, 29 Jul 2024 11:20:49 +0000 (UTC) X-FDA: 82392547818.06.9680D5C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id 3234A1C0003 for ; Mon, 29 Jul 2024 11:20:48 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=T0HH8kYx; spf=pass (imf20.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=1722252006; 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=TJqG5dwhfFg0PHzR6PQawnyu+ajyYcBzzmI1swN5VQM=; b=4lhidBg3QDI13L7iaN/62kRCc/G9eI0+sejFzMgmNEtS04OxHC4E8WGY/XHLIwXqbeZ6SX Iz+zZ9IfRMjbscFpfnM6FLIj4CfkWdewlFx7Q3wHLwTaAo1Ohk/YI4YzGbaMSCOlPsPKHi 16ko8rQ01O5JjDpS+Wyd0IxK1jeYkYI= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=T0HH8kYx; spf=pass (imf20.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=1722252006; a=rsa-sha256; cv=none; b=WAiKFkPp4kzrk5Sz9Ocoz5SwL/kt9CQJm25YgUfz/ZiusPTYYXaKJj45MG7vUPuY2P+GQH IF+4cVFmn3fWy0K2nHjw6Ph7+SvK9eubMMxbY+HvRv/LuwsYCmZPrHVA3CGhQ3UZna6u2a h2pn3LFDHCYFQYH8rpNnQT3Aqck3w+U= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6DEAC613EF; Mon, 29 Jul 2024 11:20:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60074C32786; Mon, 29 Jul 2024 11:20:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252047; bh=cpsRKinL3S7LbxZnzQMdHFXcR2a2bxLsePv8cUuJa+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T0HH8kYxUU1m2iRXQy2rq8UBV0w9GOrcvJ5BKUKIZP0MxXQhIiJHVXkOYVVvUrFc/ rbr+b4ZBiHZ0MUo9TvktNqnYHiM4n+NSgjKL43RRGvYjmPnPKvw+jCbLo9v9YaBpOV F8ve7JyaLosgbP5LMe+oLr2On8GDoBALuQBVqDlOiAmOJRfKpSmn7ZybSNJ+bx+ffS kGkruVAKs3HzjR0cHAJy5RkX9mjF8+0IztbMD5XpjxbMs7PiqUDSQvpqpyofs8/FWt clA7JVTFSXxI9MlNfs/KV9XHHCns4sVh32aFpY9QJcsQ2236XureRRXkHCFAjdfjc5 Mr+RgjTe17w4w== 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 v4 09/22] mm/zsmalloc: convert obj_to_page() and zs_free() to use zpdesc Date: Mon, 29 Jul 2024 19:25:21 +0800 Message-ID: <20240729112534.3416707-10-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Stat-Signature: jhqqdhzwywnwokjq6wttd6n4drc83p1w X-Rspam-User: X-Rspamd-Queue-Id: 3234A1C0003 X-Rspamd-Server: rspam02 X-HE-Tag: 1722252048-475545 X-HE-Meta: U2FsdGVkX1+7A0mQxaaBZS3kC69pg1XyWuia1MAlX3vlqQ1RQD+ZkPuEO6PPrEGiEWPnEYzq4P+s0xvO7UsTRePeKtq4J+8iMOVKdlonb2KEIslayHxzhmMk5j7Bj8vjgO6hKHIkER1SP5LBqEtlNfhlKLeOROaYESZWQLzFOun/Q1buwaGOSTPnlFDVGOt1MhQv5jj1PSFmsAi8WOS9smiW1N5nOweL4BTpG9FBPKojJQjfiIrFHRzSHazvR0gUvBzO2SFSZf22YdVYBP1YIGRNokpP1jLs57vf35/Xm457RuKIHTg6a6tcK5dHXtSpJiXo4LIeNWrDHZKlP5SDqNaAGfpsc7i20iWp+IRTGj+T9U8cKmIpFcoCb+DzMEFd2fT0KlYiLDkQ+U2Uzbe6rq8W9coloK1XbRdsUUwuvkmhkPHnnwF1KuYqjW+lqQlVPAM/UiW4jDmnz3lv79VvELlch3OBLhDwMUTxTtS8N3LhhBmr4ISwVXvP5M7iCSowdc8d23oNdl7GxzgmZGngpdgwE4Djr4E6wscHVR5tIHXqJOeDdn4wAJHLHlNzoFV4+3k0Fj66aWmjhL85WXu61QIBUq5BbWZpVZunR7n4Q4ZDDW0myK8IUwTIGWnXI9WqTz1JtwgZZHPFzYFKcHEiote04w+m6o8FOr5oxjB3FPvxzgmPFH2xiVMuwpeRowZgY2nb9ovQnRiZvDpqSOYHfHymnRo+LpizBLT6OnS0jQ5l2cNU3+80N+Cl9d1HsgUEeYLcDW1K4JNZt81LpGT0MQMWXiOQUc2YI4pz3rwc7g6/cx4Lec5M5aQJZKt4RxJz3hl7OZ8FAxq9PuQTM8r6ALgCm+foCXb42ns6i++r0H7LoiuIkrXI/5QUXcqsGZzYDnnAJnMquy9w5bOcXiR6vRym+SPg3TUQLnMMimrZvZj6do8UCj2iYBj8mAlBkTEYZFKT8VEbNXL7eER4Wkq iVBqcdI0 M+5Oyl+BoJz5Nf2E5Cr5hVRMG3dNVnFx8B+ASxhXf+bRnXZ0mMdEZrh5xp8HKLqr9P+K1VVc3vAO69wX/Ms5cGcgFY2xSSzURvi1O146cUe4rwboBWVnDFTGS2q28SEgLN/F9XWyhpeHkfaVG/hO8EWRxa1mTTd3BxT8EhoGVoIhOwtixxh8YlJu48wuxeLv3zeMsCjILlXFXktKns0hsK5JPxZxHPk5NQXefIKXj+7zT8GY1g2q2ZT4NTcIVr7kobIcgSbdppm22Ix1AqMqN7JbuU1+zaPQUMFaAp+hUAMloZ0E235ZwCJXa2lILdJpN3qK54Ez7kHBfi2Xe+fR0cyX/gzeHZzn6qbpZS0tHuyZq2dmpYSKEIx7u3NnCR06Gqry4 X-Bogosity: 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: Hyeonggon Yoo <42.hyeyoo@gmail.com> Rename obj_to_page() to obj_to_zpdesc() and also convert it and its user zs_free() to use zpdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index d3558f3f8bc3..7aa4a4acaec9 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -820,9 +820,9 @@ static void obj_to_location(unsigned long obj, struct zpdesc **zpdesc, *obj_idx = (obj & OBJ_INDEX_MASK); } -static void obj_to_page(unsigned long obj, struct page **page) +static void obj_to_zpdesc(unsigned long obj, struct zpdesc **zpdesc) { - *page = pfn_to_page(obj >> OBJ_INDEX_BITS); + *zpdesc = pfn_zpdesc(obj >> OBJ_INDEX_BITS); } /** @@ -1496,7 +1496,7 @@ static void obj_free(int class_size, unsigned long obj) void zs_free(struct zs_pool *pool, unsigned long handle) { struct zspage *zspage; - struct page *f_page; + struct zpdesc *f_zpdesc; unsigned long obj; struct size_class *class; int fullness; @@ -1510,8 +1510,8 @@ void zs_free(struct zs_pool *pool, unsigned long handle) */ read_lock(&pool->migrate_lock); obj = handle_to_obj(handle); - obj_to_page(obj, &f_page); - zspage = get_zspage(f_page); + obj_to_zpdesc(obj, &f_zpdesc); + zspage = get_zspage(zpdesc_page(f_zpdesc)); class = zspage_class(pool, zspage); spin_lock(&class->lock); read_unlock(&pool->migrate_lock); From patchwork Mon Jul 29 11:25:22 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: 13744733 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 82AC3C3DA61 for ; Mon, 29 Jul 2024 11:20:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB7026B00A3; Mon, 29 Jul 2024 07:20:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AEBBB6B00A4; Mon, 29 Jul 2024 07:20:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93FCA6B00A5; Mon, 29 Jul 2024 07:20:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 714346B00A3 for ; Mon, 29 Jul 2024 07:20:53 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 269DE80113 for ; Mon, 29 Jul 2024 11:20:53 +0000 (UTC) X-FDA: 82392547986.29.BB3B11C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf05.hostedemail.com (Postfix) with ESMTP id 73B40100002 for ; Mon, 29 Jul 2024 11:20:51 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=E5iyLufh; spf=pass (imf05.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=1722252024; a=rsa-sha256; cv=none; b=gWPdN7IBOkokHLaYPxY01bSVcT4ZopqsmWNeqdTcpevb+PngCYL1rAGkrtFzvaiOgHQzZ/ ue5lvhFrNXgbsJVdMhoGs6PUCKKqLhls22JQc6q+o8zc/ZAoqiJy3/51M65zyPmPQJ3zsh xlvRNCOCn+SEY5urzdzVKLAbxlG+p5E= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=E5iyLufh; spf=pass (imf05.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=1722252024; 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=/wR/JLWyCBw+98/1Peb9KBstl7/R1dnvU+eYdkVxhdk=; b=e9Ao/ADDPSGYXoBn2ifWlpoFNItDI3RgVzyHS7rHEer0nFkk4K9AdHMMdcoPUmXmurWjph tlaBRb4gaVT+DDmbWD61WkcQC2luS5SOmg8toHK7VcLGmhcNVSCwhRugyWp5AgdStpbJVO c8bdj1H6K96d+WXxVLEcz125rL7DZO4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id AEBF1617A4; Mon, 29 Jul 2024 11:20:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E330C4AF0E; Mon, 29 Jul 2024 11:20:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252050; bh=WyPUKBHEIKzHOQMb2khWX8zwblQV8unnw77vQM7bDF8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E5iyLufhwEDkZ+aY5DI547cHfuH0SyU0cZnKUBidJpNkKOkO5+26+kAm6UVZbixNO njVNEpfbytbIXh+8dvyp2agedOkshPsMVpKvAE8d3t5isV/D/XUHFz12c6g17JUgqq JEIr6IMFyMo6wMOYJApbAtqri95Ugy2upf77adlVIFdVbKOypNKYyistCUwc/ndMip ob4vjCmg1y8Ifvm3jCtN9ViV5NE5fHZmq/WCaKwx4mRXgOwGgZ4Xi3sfywdy2c7cwX CACAKi4+a6TxHXlxR9n+RwdFtn44i7Y7Tcaw5m5yjVWIwJ4SAUHNTl+xl7Qt+wr3OB Y7DEGDaoJUl6w== 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 v4 10/22] mm/zsmalloc: add zpdesc_is_isolated/zpdesc_zone helper for zs_page_migrate Date: Mon, 29 Jul 2024 19:25:22 +0800 Message-ID: <20240729112534.3416707-11-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Stat-Signature: fnhtiz65b3jzr4i1ofucag43anytq4rc X-Rspamd-Queue-Id: 73B40100002 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1722252051-84746 X-HE-Meta: U2FsdGVkX1+SuAhwHtRDdePAtO+iCGQFIlJxKRAdT2NKOfglM6j8gssbAia/nba+yVFOrytvV7NVvWuAHDopDj66U7jm1io4ZK+GJrJbsRgKPOFHtRNKjJ83nVTSpTGQgLBQJoz5cejIEvBDvc1pTWRaF7YBE7qgXO3AuZ3RS9FDYmhDlv1MNBZcZcNKUH/Yg5Xd1O8qqxwYn7zoHhxTpKJh25hCK4BMEN8Cc85+yl6nNi1xW9MuOUMPCHifRzZXyfm7Mz3TlmoGBNVtS7ZLpDTqOLvAWVfiG6bSm+HkE22dW39M/OeKyogCZGUORprGL6N2j/sUYbAZ+6Yo5Rsbpr66gALwdKfBxE9p74lpwleOq1W5Bnh5VTuOlXygQwDCfO93Rnk59xO2SX/F3CsF83sIZRtp1gseng8bk5uhl9WPAoPwaw57jzkG9rJn2bpNEXYN1cimHbcOKHCDf1yC+Xv7QN6+tIHvvxR9N5h7QGMpVncISq2tCR3K5k293apizbxwNAz6rKZZHaC3uqqI81ObOJ5sBY68uH2dnGjr6Ovk9IzkJpqwYIlvhYzNkHgImFMFBK1noz2PF+vJbq/aYJuWY+WcgH50vLvQXNmKu+YrV8nEbxxsR+UC//ftLIrUrGOt4m/XHJ6cPrkIibzQZXJgEWvgNj7Lw7Adljt8vuBz8yFLwsLKcc4yCsz0B9IJlwuCpuMSd/c0KxRFTB5ELdnTLIvPMiGuEPcCTYn3rnm7mkuFVLz/z3qonooN0J4OPCl5/gTkPahxg9tcpvDHab4gyqh5we8B5T54G+qB5ht4OknccuBFSdQRl/XzKTllxixzzBbgORwsDTGy7AzWcFLCFYHAPPd6QRxo05RrdxObeVUbVs29XcmPyOqxkoEBuiHmlGIydZbIFtqzvf2IxVHT7VXJT7dnNwhf6I+OHULPVL3rkiMdh76CcFcN8d6OV2R3ZGPJLs0v2jcZwhw ttoU4MWk V8Y+Q9kc8S06BYV+VYUJA+XRaHPE5woDbVOZjQrsD5jeINZFh0B7HZ2QjwCt86ktfJ86MnwLkwFSkl0GYZZV0yIENHxDOjl1r+/Fw5zeFVLmQJqNKbnD62EqZ1HMLKDSeLsbYbvddQU9eauD2o6RESmDERBgzJrF9ErCPmw5yOWAtlUsZHxBQPZIgmfFjCi6dwsLBIqnrv+REpJ1pDTYtbK9g5BRQjKmmFdgt6y5r3v1+/9BFSLnEgjcr6YZ/VxjV10Oayxs3b2RtsM7ZrIyaDOgVJCZQR7EK/3GXfpYOvlb53LfSf8adcp2w4nY8Rkrzi7y1roqQv4Dx+MXwClqwWdz40YLM0rAXb6En1hoFhOLL++EqCv8hMelBazDqzDikDWyL X-Bogosity: 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: Hyeonggon Yoo <42.hyeyoo@gmail.com> To convert page to zpdesc in zs_page_migrate(), we added zpdesc_is_isolated/zpdesc_zone helpers. No functional change. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zpdesc.h | 11 +++++++++++ mm/zsmalloc.c | 30 ++++++++++++++++-------------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/mm/zpdesc.h b/mm/zpdesc.h index 2293453f5d57..ad04c8337cae 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -108,4 +108,15 @@ static inline void __zpdesc_set_movable(struct zpdesc *zpdesc, { __SetPageMovable(zpdesc_page(zpdesc), mops); } + +static inline bool zpdesc_is_isolated(struct zpdesc *zpdesc) +{ + return PageIsolated(zpdesc_page(zpdesc)); +} + +static inline struct zone *zpdesc_zone(struct zpdesc *zpdesc) +{ + return page_zone(zpdesc_page(zpdesc)); +} + #endif diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 7aa4a4acaec9..9bc9b14187ed 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1830,19 +1830,21 @@ static int zs_page_migrate(struct page *newpage, struct page *page, struct size_class *class; struct zspage *zspage; struct zpdesc *dummy; + struct zpdesc *newzpdesc = page_zpdesc(newpage); + struct zpdesc *zpdesc = page_zpdesc(page); void *s_addr, *d_addr, *addr; unsigned int offset; unsigned long handle; unsigned long old_obj, new_obj; unsigned int obj_idx; - VM_BUG_ON_PAGE(!PageIsolated(page), page); + VM_BUG_ON_PAGE(!zpdesc_is_isolated(zpdesc), zpdesc_page(zpdesc)); /* We're committed, tell the world that this is a Zsmalloc page. */ - __SetPageZsmalloc(newpage); + __SetPageZsmalloc(zpdesc_page(newzpdesc)); /* The page is locked, so this pointer must remain valid */ - zspage = get_zspage(page); + zspage = get_zspage(zpdesc_page(zpdesc)); pool = zspage->pool; /* @@ -1859,30 +1861,30 @@ static int zs_page_migrate(struct page *newpage, struct page *page, /* the migrate_write_lock protects zpage access via zs_map_object */ migrate_write_lock(zspage); - offset = get_first_obj_offset(page); - s_addr = kmap_atomic(page); + offset = get_first_obj_offset(zpdesc_page(zpdesc)); + s_addr = zpdesc_kmap_atomic(zpdesc); /* * Here, any user cannot access all objects in the zspage so let's move. */ - d_addr = kmap_atomic(newpage); + d_addr = zpdesc_kmap_atomic(newzpdesc); copy_page(d_addr, s_addr); kunmap_atomic(d_addr); for (addr = s_addr + offset; addr < s_addr + PAGE_SIZE; addr += class->size) { - if (obj_allocated(page_zpdesc(page), addr, &handle)) { + if (obj_allocated(zpdesc, addr, &handle)) { old_obj = handle_to_obj(handle); obj_to_location(old_obj, &dummy, &obj_idx); - new_obj = (unsigned long)location_to_obj(newpage, + new_obj = (unsigned long)location_to_obj(zpdesc_page(newzpdesc), obj_idx); record_obj(handle, new_obj); } } kunmap_atomic(s_addr); - replace_sub_page(class, zspage, page_zpdesc(newpage), page_zpdesc(page)); + replace_sub_page(class, zspage, newzpdesc, zpdesc); /* * Since we complete the data copy and set up new zspage structure, * it's okay to release migration_lock. @@ -1891,14 +1893,14 @@ static int zs_page_migrate(struct page *newpage, struct page *page, spin_unlock(&class->lock); migrate_write_unlock(zspage); - get_page(newpage); - if (page_zone(newpage) != page_zone(page)) { - dec_zone_page_state(page, NR_ZSPAGES); - inc_zone_page_state(newpage, NR_ZSPAGES); + zpdesc_get(newzpdesc); + if (zpdesc_zone(newzpdesc) != zpdesc_zone(zpdesc)) { + zpdesc_dec_zone_page_state(zpdesc); + zpdesc_inc_zone_page_state(newzpdesc); } reset_page(page); - put_page(page); + zpdesc_put(zpdesc); return MIGRATEPAGE_SUCCESS; } From patchwork Mon Jul 29 11:25:23 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: 13744734 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 97199C3DA61 for ; Mon, 29 Jul 2024 11:20:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C75A56B00A5; Mon, 29 Jul 2024 07:20:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C26096B00A6; Mon, 29 Jul 2024 07:20:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A9D096B00A7; Mon, 29 Jul 2024 07:20:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 8AEEF6B00A5 for ; Mon, 29 Jul 2024 07:20:56 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 453751C100C for ; Mon, 29 Jul 2024 11:20:56 +0000 (UTC) X-FDA: 82392548112.14.D354A28 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf29.hostedemail.com (Postfix) with ESMTP id B053E120020 for ; Mon, 29 Jul 2024 11:20:54 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Y1xfuqoT; spf=pass (imf29.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=1722252001; 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=kJQiG/5I+17lbFKCGyYuI+CpVs0RVUWdddaEyCf/eUQ=; b=KNfYcDRuP4f3+xTk9DfeXUTydOof07Td67Ke9SYkWv3gUF09YWsYvtiKNkEcF0GKcsHFpn z8QDpv3rqITzndu15lwqeSTJD58qS2p8Zgu9/dSkpcMQOhVZRBMqKLzpGaj51TboC3AUwf AHvjAWenjhrbywWekMFkgVpjKHQUqMA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722252001; a=rsa-sha256; cv=none; b=7cCB7UqlJfi3T8T4viunpUhfqZWn8/TXsO20twAKnYrKjyrZCbJsvsleKQU/GmR46cWRdb EySwT2QJY8x0j/izpIZbof+tmwUxxr+1MtI1ro0m2bmD6bhYVzyCflhkaFYBiuwVsvLt3S IWZhI4ORq+fmxqdVL25IyqqeBz/TnBA= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Y1xfuqoT; spf=pass (imf29.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id ED758613EF; Mon, 29 Jul 2024 11:20:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD9A5C4AF0A; Mon, 29 Jul 2024 11:20:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252053; bh=d7GxkLwHXdQyb6XsJEXUauGOBeH6/SyL3Iuz9vNzPwE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y1xfuqoTF8RBa6k5ApOc1e9IzEm4y5wIehqq1Lak4a/tussklfMkbwl3E865wK7Sg NAqDweP7jioqqU8PNGlclmJy+bVTfwgSxrpH6Bn7Cs8W3/dLWLQpvp+BcZMpqoO2qN 9d8znmyUTNzACuqjIZz0RwW+widCJiDk03ZWFhnpT0Q3dPKfYpQAwwAS3wU3LIj0Yw 7YVZuuB/lWRsQeG2lg59DOcbTCrKpJI5IUFSFF4RsrlXmif7ZmLyWSf4nerSPMXzZm o594WC/rvrMnYCSgW/pSL0QNyaXpuXUSFzjnSM+XwWbty1FHL/hvjGQSyRY2kdY73J IySG9ESyAF6tg== 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 v4 11/22] mm/zsmalloc: rename reset_page to reset_zpdesc and use zpdesc in it Date: Mon, 29 Jul 2024 19:25:23 +0800 Message-ID: <20240729112534.3416707-12-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Stat-Signature: ekse1smczachhyns6fuchxm1qpkmhdf3 X-Rspamd-Queue-Id: B053E120020 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1722252054-819993 X-HE-Meta: U2FsdGVkX1/jG/qJT7JyDcKg5uvA6rOFo5iwtjwefP9QdtpAXtKPEbRw3foU1dx1WaGNy3gzXdau+FpWJhg0ECjS504SYDxdtlGt9WZGABtJ81sF6rFxfpzOPrlrU1j0nU44LW6k5UcLEHnu+D7C6hi9sb5oNQy0tkIBw29rdClWvoFHPlYGY9fualXTD3qRI3+ZENHwfTtoQE7G4rpi9QtGJ8wRZlQNh6oMHRvnujphMQOr/Y6diVFlcx8hwyYAf+wPNqYC3M8ZasGAyY9bCrIYUlKBqOliUVGsnb+Irp68wHoSDdKoKKHB/G3+1j25cw0Bfss42jfGN7tNfgUUJKpFA7DkBDPDJhMmRCTZGDsmfWRTTWudqVA4IyBCWJz+FNfNy9KKnT4JUs1hbdjuQhVFmGu2vI2CgDcA1JT9Os/kwuR/F/AACYuI1fu6pY824zHtc7x8Hj9u/NqzcQUlAm3GYlxx9TzxcfM6Hi99qwFqSqwLYYE9q6rblmh+vErM9p1r6d6BqSWOCpYaXdSeX+YRFbAj/HyktKuEYPPTPa69BuBjpJfiJ6HKdQzPhEUi/WvFTxnoRRgAsLgze62w/uPrwO2giMXCVDf+AH4eE9ib9cnEiRfVU0cW3+PPnT5YFiteY0cxm6axmfTykhlJ3vwrlzU556YvSEwh0a07bIDx+mCF2dMb+x6tniaGuEwqptBm+lIoaEg7bU/91SrzNcTU8jkUWZo/+0vJMG0Oi6Tnca3eiagaHvtEwZAP/mTBrAi1zMwENbkBy5ufvq6TEiYpuJq3jmUTej7VfjFujFwnXH4EatoGhoSrHpkQ3PvXnMvrZoUWlAElyoAJ87W2iDeb/JDXgklAkjBxJ1dZO3JoXfjrfPp2nk8o0qlZ02xqKAH8Xva8IsrwbRjQexKglnN0qrexpEZuT2Wf/yjLzHV9V+HEzvg9N6azVfhBm1NcLbfpW7tdy1t96HfADdO Nmjfvi1F E/BF7UZeVAqqKoarCbyNIO+5hqRLcsHVaNdIpi3/GrcYyJICulSgAutcRy5WlOExvLkAm19gPsOu++dTwtBi/NsTcz0dXJzzm2cMAaLI58Q5SOUg2IzlYSyUHbD7Kv+doNOfLEJUFakzd7GgCDCMUGta6oFQcl2c8ZLjGWk7fvCq/DPrLW7Rh1Dj+dqibtx+RoYudWwRirPAa0y+s6GvVPYhEn0jbyapLMxhZaQ2tNTlgg5VxdPAxqDLhgfBFJamKb+udn8znx0kuGxCOa37ZTDv0xxKQcEqyA/yQub1aWtMt/6sZy3GaxUjh3KgB7vG9tpZsZSLgLjsnKq3bgi6r0Fuem77tq92UTCMA X-Bogosity: 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 zpdesc.zspage matches with page.private, zpdesc.next matches with page.index. They will be reset in reset_page() wich is called prior to free base pages of a zspage. Use zpdesc to replace page struct and rename it to reset_zpdesc(), few page helper still left since they are used too widely. Signed-off-by: Alex Shi --- mm/zsmalloc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 9bc9b14187ed..6d1971836391 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -865,12 +865,14 @@ static inline bool obj_allocated(struct zpdesc *zpdesc, void *obj, return true; } -static void reset_page(struct page *page) +static void reset_zpdesc(struct zpdesc *zpdesc) { + struct page *page = zpdesc_page(zpdesc); + __ClearPageMovable(page); ClearPagePrivate(page); - set_page_private(page, 0); - page->index = 0; + zpdesc->zspage = NULL; + zpdesc->next = NULL; reset_first_obj_offset(page); __ClearPageZsmalloc(page); } @@ -910,7 +912,7 @@ static void __free_zspage(struct zs_pool *pool, struct size_class *class, do { VM_BUG_ON_PAGE(!PageLocked(page), page); next = get_next_page(page); - reset_page(page); + reset_zpdesc(page_zpdesc(page)); unlock_page(page); dec_zone_page_state(page, NR_ZSPAGES); put_page(page); @@ -1899,7 +1901,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, zpdesc_inc_zone_page_state(newzpdesc); } - reset_page(page); + reset_zpdesc(zpdesc); zpdesc_put(zpdesc); return MIGRATEPAGE_SUCCESS; From patchwork Mon Jul 29 11:25:24 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: 13744735 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 8AF6BC3DA61 for ; Mon, 29 Jul 2024 11:21:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 152056B00A9; Mon, 29 Jul 2024 07:21:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1026C6B00AA; Mon, 29 Jul 2024 07:21:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE4276B00AB; Mon, 29 Jul 2024 07:21:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id CEB616B00A9 for ; Mon, 29 Jul 2024 07:21:02 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 81FF9402A3 for ; Mon, 29 Jul 2024 11:21:02 +0000 (UTC) X-FDA: 82392548364.30.1BCA70A Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf18.hostedemail.com (Postfix) with ESMTP id 46C711C0028 for ; Mon, 29 Jul 2024 11:20:59 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Q6Z5z02c; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722252057; a=rsa-sha256; cv=none; b=KpKEngOQBOY6om8t5HYFY6R0ECMk9W1nwwRtnzsI3Epg9juw8XRz7xvpB2OO9pCuWYt2gd uNhPT1aiRu0XjUdgdsLyh1sibGg3erLXrbdlbpFQ4B8TnfFtHUiibYtsaCN6gHmc+YOulR tQhN3mM7I7n1tjyk4I4WqD4inZFO/w0= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Q6Z5z02c; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722252057; 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=VhKKPt1PwGZfDksxUoF8M7UxAWykfvuSsOiFdpS2s/c=; b=VNURcaf3Q23E2ajAOU57D1QSkISLikq9fuSeaopIwcmp3E8zQ+oJTPRvjyeoYm1xf5UpnN PXrIOqMRv/0iI+N9PuD47f2cRutxfKR4rBXC5jAjeRoM4ciWiuEEVFIR7OKnXi4Xv7X0tk RoDj8jO+c2v5lIPlA3Iz/H65mDKp004= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id A3017CE0ABD; Mon, 29 Jul 2024 11:20:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 278FFC32786; Mon, 29 Jul 2024 11:20:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252056; bh=/reSYv2I3LBpywbB8eW2CIXO42cQ1NynjFn2dBL53LI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q6Z5z02cPsiz04Im8TmiPZ0LRtDPvb7j/Z7gsVKUC+vY0bQTeAukeCpSUVaodx8qH 7CIS0LLlHtEwTCDlK7Odzu8VbidIbZIBvA+q3YjUryx+a4UHVnii/qXAjvSBqdjqvR 4tD5ERJ0Pywjn30AShewyQPZTcxGolFIewnVmUTha0nTO+e+wgxNPbfao/L22WkvZ1 QIRFfedl+/ckWEC0oJ4OGBcsN0u7rvH6OsXtffWwPRJe4Y1RQMf034J5/jRZhT06aC Q6nd6bZ+aSHBwOqbIJ778lEu/5fNxKYZs9Xzu4YeC2QTW6M27X8mr9eUEenpkCqCLq YG69szOAWaPKw== 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 v4 12/22] mm/zsmalloc: convert __free_zspage() to use zdsesc Date: Mon, 29 Jul 2024 19:25:24 +0800 Message-ID: <20240729112534.3416707-13-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 46C711C0028 X-Rspamd-Server: rspam01 X-Stat-Signature: b4x1ohxghipihyez65915hdtphje1ct4 X-HE-Tag: 1722252059-882788 X-HE-Meta: U2FsdGVkX18VZfbYkGnV6wUohw6/5WXF3kzTVrZYqKAesoQP1PSa1Qu97qrxPaQYYTCczcfaxxmHj8BI00xoHPY5ijb1vV5XiOHkNO6Bkttm0OID99N8cFm9OcP3jo24osS5MhHK+ktgjC/Ly0ax19oHh6m7J6k7j+ZaaiR07eTw3+1OOjSPaebLXSv2ElWp27R9m8bh5JOA+Qn/gPx3hErZyrmbVrFozbC3J70YJtLLb37OMLccsh+qvRsgPzdne+RHrDO+2LMUln0fevDm8e4evmw1jsHXRU2ebUoF3eE8seu4pcKpbdr8A6AZlhJDHqh47FAGxHX7E/HxnqsCJuhJKjcJaa5aVO4e1cPNVAGAkplTUiu78dD38pjlC57993P8k1x3BKhNFBNdA4MVS2PNUE86VJTqwK2OH7vsdHy0HYLwNt7kZQSjGvuzsYwmj/eYi+j9LEd/cHEb3k5U6ze56kpmN1chk2z8sKtUZ3zEMvno3IZq2qyudGaG58yZx1OAT14myKx24ZLeeO3s2FZhx8oeToSuib8oFE73E4bdWLS8eQ5wlQVizsa70DsMgutFFPaR6NjHWBH68smuHfqf1lMp8eEjKvcVdgZI3PuB/UpO0bl/mUOez9cNVl3hlLAVQqmySnNnLUSHkU1X6gdN/T0xhZTc+aDZzeOkJ4dF2JRuJUVBHkx+hp8X0TY/cSrxdR2aOBWchhXT4lzxz2+7QofVFFav9LGYq7igdDJoXrqvhLXnRQXiLOACe8Z8Fhxef7vkJZHaR8FpcjsGkBrIhBhTPcVRjHLl/qD69k+7H/rV8tqE6JA5+SW3i9ViVpt6nOLF/BufbBDOE3vFzGimBiPRxpCHEHGF+rsXvowFGueEV+cRtxEqGfpRjtdXYy4f1um7yWe7SRPPTSUhTg3Ry54JKEaNS58dM7jffFVkhV6fKdE9JJyA9nhFy/BE1mmqpaItW65CyBk3Xcy 7+1k4BaA txoDrmQ9IE9CABXnAnx602xErlr1FtalcUPB372EWdjBXLn/ZJHDUzJ1ci81DIARALkgX2JTgMpp7m9g607m12MaR4h4TmK/0gN6iI9GHprqavnZu7yxYygcSGNtEGK+StF9bjJ8xE+kOIYseBb4NPIF0bOwe6t5xhlAEXJWb57MVlSVUiU8lbYRzPWbxYM4/il8zyPr+qvlYL0ApolxS7PG89hRQc4mZGjBKJYa/CRxeF/y+zfOu2nIb+fvEBw7rddb4yXp00eWm9CxAKjWq1r+h4CsH4rcOD9oK1XWBXBAfPjRL8w/zduqAZ+67vd/zqthg0jeQn40NRaEp6TRdBuzeK7ao9Z+HqhqpKCrC/ClH/ZCs5lb7YcjaZw== X-Bogosity: 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: Hyeonggon Yoo <42.hyeyoo@gmail.com> Introduce zpdesc_is_locked() and convert __free_zspage() to use zpdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zpdesc.h | 4 ++++ mm/zsmalloc.c | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/mm/zpdesc.h b/mm/zpdesc.h index ad04c8337cae..72c8c072b4c8 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -119,4 +119,8 @@ static inline struct zone *zpdesc_zone(struct zpdesc *zpdesc) return page_zone(zpdesc_page(zpdesc)); } +static inline bool zpdesc_is_locked(struct zpdesc *zpdesc) +{ + return PageLocked(zpdesc_page(zpdesc)); +} #endif diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 6d1971836391..68fdea7b6e0d 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -901,23 +901,23 @@ static int trylock_zspage(struct zspage *zspage) static void __free_zspage(struct zs_pool *pool, struct size_class *class, struct zspage *zspage) { - struct page *page, *next; + struct zpdesc *zpdesc, *next; assert_spin_locked(&class->lock); VM_BUG_ON(get_zspage_inuse(zspage)); VM_BUG_ON(zspage->fullness != ZS_INUSE_RATIO_0); - next = page = get_first_page(zspage); + next = zpdesc = get_first_zpdesc(zspage); do { - VM_BUG_ON_PAGE(!PageLocked(page), page); - next = get_next_page(page); - reset_zpdesc(page_zpdesc(page)); - unlock_page(page); - dec_zone_page_state(page, NR_ZSPAGES); - put_page(page); - page = next; - } while (page != NULL); + VM_BUG_ON_PAGE(!zpdesc_is_locked(zpdesc), zpdesc_page(zpdesc)); + next = get_next_zpdesc(zpdesc); + reset_zpdesc(zpdesc); + zpdesc_unlock(zpdesc); + zpdesc_dec_zone_page_state(zpdesc); + zpdesc_put(zpdesc); + zpdesc = next; + } while (zpdesc != NULL); cache_free_zspage(pool, zspage); From patchwork Mon Jul 29 11:25:25 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: 13744736 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 E66FCC3DA4A for ; Mon, 29 Jul 2024 11:21:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6AAC06B00AA; Mon, 29 Jul 2024 07:21:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 659406B00AB; Mon, 29 Jul 2024 07:21:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D2736B00AC; Mon, 29 Jul 2024 07:21:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 1DF8B6B00AB for ; Mon, 29 Jul 2024 07:21:03 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id BFF8AA02A1 for ; Mon, 29 Jul 2024 11:21:02 +0000 (UTC) X-FDA: 82392548364.10.2C51084 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf22.hostedemail.com (Postfix) with ESMTP id 316C5C0023 for ; Mon, 29 Jul 2024 11:21:01 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=soKprBYq; 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=1722252007; 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=wXagLVGUZ9eebRl/j1Zz+wClVG4D6z7RAED/mWVOrM4=; b=gZlAswAU1LK4xHwrQpcCRl/RbK2XVgJ7zmQsjMICz+I/Itgj+K1ocaOXOc6+0Y2d6SGGK2 1NR6jdlvwGrrmQ08QSatfoUamIZfI16Zacq4hncEWNpccsercyt1s/t0Je+XGv74Mb1GGU KuOHHe/4XY19gwafdS2M/Cf8h1dHX80= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722252007; a=rsa-sha256; cv=none; b=BtacN0J+LV4RYURf3S987rTxprY1hdBscyIqiLJ+g9oziQ9QcJpLGmLwsgpCycE4LH610X PIcutcV2LwX0yn2Gh749bqE/Q5Pu8DTW8oY/bXymEAzgFL9yiKQ8PaM0H0SpS2HJUNdtvF A1bjhhh9Y/6K+Nh0/c9VrRItiynj320= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=soKprBYq; 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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 73C28617A4; Mon, 29 Jul 2024 11:21:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64837C4AF07; Mon, 29 Jul 2024 11:20:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252060; bh=wTDI0eYHYt7QQuqfYVSh3nHEsVuSO77v1MHzFFaeoFg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=soKprBYqWURfg25sfItqMlUmjCEOrgiYtNAVU0eDQr68G1KVfp/73qZOeW7TOTupC a4MzcCvbu8bHoU4pupUZtFb30ceJnWgg7D5Dgq74Dc8Lu42X2pxdIrA1XU8XJoRuTr XKCxYMaMOprZnX8ZS/+ih6s8whodTe32MyaDzTAgQr/CuJ/erKwRgmD2ZTw0b73hGS 1rQiKJMZNSv8vii8ZRFqvcMR1hnxy9BF4gx+gEwTHVcXLWhB4Fap9uUH9Om8FWwo13 O6qln7YSujzOPOMEVbMY6RhnaWzjgGqu53rtHRuM8XNeT3KFntHVNBXeVkhf4nO+Ob 8tHZuDQsRuUMQ== 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 v4 13/22] mm/zsmalloc: convert location_to_obj() to take zpdesc Date: Mon, 29 Jul 2024 19:25:25 +0800 Message-ID: <20240729112534.3416707-14-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Stat-Signature: dy7sxkufy7j36i6sd18dingckpeedshi X-Rspamd-Queue-Id: 316C5C0023 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1722252061-605174 X-HE-Meta: U2FsdGVkX18LQrFZU1uvsTvt6ny8TNtp/2jQdjcJ5DdPBDRkRLApdMOrqOjufDicBds1XGSyeUwe/GVyRYXvG7/iCPrNDH0WarEUF53yvWHFXhw8Ngi3e+q/BR8GSBvMFxu97Kkyp1lxCtmtBDUmDYLssDudTcQwrW/OoC179VQbDt+5anFD54UE8uS6cP0srz/+SWt8NAgn3KZtVEsGkNiE/34dH/93SzMRf9/mUhgplsNdTiNRyh/pl9Xdg0yMwIS6W60trBr4jm2DS0cr2QpDxq2Yr46yJRdXK5P09yYcc6NefAvQg8XWmmok36stFK6ViPihmGiwUddBcgIhX2a+HeBfi8dvE8NjYPZIuraT0Fjy0KjWQLTSYEK7vL3+/6NCjyfDWZNyGnxyi5USvbehRQrUsza8aXJZDSMoGgbsdWsGDxmfWDcjz+cRcWNlf+ygRfjdZTdlvDv34V530BjJiXpSDDfe7joez4DbpWr7rJb2Jo92aZQfg4/k9b+2d3pestfYNHsdQZQqND7Rq3tJhcRZ0ZFZA11PkqUV4QURK0NbVBJ36goLpvkEG5whHJic/6i8TsK48DSMCvyWJ/QJMe/eoYuWhcS8yi+PVZ9DGU9lY1MaF+e6/rO69EWYPrXaR9z6kLtVZf7ZstXix4vO0SMgeU2k1rhTZp/TxxdR0KPx4duNcG5p7+TfbsBFPQgSgNChfFI/sf1UVf2mwunwKahPEAbWXX6pDyuNot2r+wWyog687UAi+6cdahvKQMYhKsuqDZfB6PPleBYB4WrQ+FnJcsin83axvXk0pNHMA0HyBLIG2QocXi5f6IAL+mOzBhbOR6nGRWTcUQ5zQ2yQUaoYBdioe7iAod7yCKjI9uF59AYqi8cYuVLkNpfDJr6+1KFx+vgP5xYr+m/iX2IPAqOJkx7naEYgt8V6RqnHc+FfQhZje7zSRddgDiMxMZx1RocjW7Z66pvMYbU SKYrjyuf SUXvkmo5ty7X/+yOBExRWFUssBhvUsKj3GYOge00D67BSEK8zcHz+g2GL0E46OeQ5eZ7510X47E1lvKfcyuLBeIT9W1VQtOtToFoCT9pJCXTyorMb01HWX1MTpF1CyXYAKjj2/L7Exz85QBrWBMEuLz9TfV6tnpdwvo3rzg5x9oOBQuvkh+k3VIp+94JNjSgHaOoeQsa0T2mUonajK/MFK/LnXcrJBCnBK25CjDGNiCygyG65Dayq37KrNbaJly+LdIaH1bZJVUaW2BumsX0Lau/+fKenaF4NkZcUps/gUUv96XjaWWxCcJ3dBmHN7785P0GghD9rhqM5infsdeHdJ0wIwkINLrn4oXDR3mNr8tY8NQW4LZNa7pFo3fmj3jwmsXIf X-Bogosity: 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: Hyeonggon Yoo <42.hyeyoo@gmail.com> As all users of location_to_obj() now use zpdesc, convert location_to_obj() to take zpdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 68fdea7b6e0d..e291c7319485 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -826,15 +826,15 @@ static void obj_to_zpdesc(unsigned long obj, struct zpdesc **zpdesc) } /** - * location_to_obj - get obj value encoded from (, ) - * @page: page object resides in zspage + * location_to_obj - get obj value encoded from (, ) + * @zpdesc: zpdesc object resides in zspage * @obj_idx: object index */ -static unsigned long location_to_obj(struct page *page, unsigned int obj_idx) +static unsigned long location_to_obj(struct zpdesc *zpdesc, unsigned int obj_idx) { unsigned long obj; - obj = page_to_pfn(page) << OBJ_INDEX_BITS; + obj = zpdesc_pfn(zpdesc) << OBJ_INDEX_BITS; obj |= obj_idx & OBJ_INDEX_MASK; return obj; @@ -1392,7 +1392,7 @@ static unsigned long obj_malloc(struct zs_pool *pool, kunmap_atomic(vaddr); mod_zspage_inuse(zspage, 1); - obj = location_to_obj(zpdesc_page(m_zpdesc), obj); + obj = location_to_obj(m_zpdesc, obj); record_obj(handle, obj); return obj; @@ -1879,8 +1879,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, old_obj = handle_to_obj(handle); obj_to_location(old_obj, &dummy, &obj_idx); - new_obj = (unsigned long)location_to_obj(zpdesc_page(newzpdesc), - obj_idx); + new_obj = (unsigned long)location_to_obj(newzpdesc, obj_idx); record_obj(handle, new_obj); } } From patchwork Mon Jul 29 11:25:26 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: 13744737 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 33155C3DA61 for ; Mon, 29 Jul 2024 11:21:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AEFEA6B00AC; Mon, 29 Jul 2024 07:21:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AA03B6B00AD; Mon, 29 Jul 2024 07:21:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93F886B00AE; Mon, 29 Jul 2024 07:21:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 63F306B00AC for ; Mon, 29 Jul 2024 07:21:06 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1E1361A0277 for ; Mon, 29 Jul 2024 11:21:06 +0000 (UTC) X-FDA: 82392548532.15.CC1D571 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id 7A1971C000E for ; Mon, 29 Jul 2024 11:21:04 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=o5gCrlI0; spf=pass (imf18.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=1722252011; 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=C6FyzEKOSWI6MCvUbbMT9Jgk3QqCa38I6z6Mp91Wydc=; b=3wZnG8qAVWDOLnsx0iEkKW/PtGwI34nh3hPgaQhLlXvaN/Wd1H0/ej9gGvEuIrbvuRXUX7 JmUd8mf4RBHLdpOcY3eTOak7YVcIr4w3ayuZE8HCHurB6MgmR5Yx+Id4nde+My6yeXYTcB et43jw/y2S6dDEp3iqpzC5CQZkBt3/U= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722252011; a=rsa-sha256; cv=none; b=a6G7L2byL6n/976j2sSzLkpn9olgSKtiVbEvH+VWGLfOJ6IzurpTd9/82uJl0Sgc2pQ0Bf cVQIcr0lTLnDlJfgow8Z0CRl9DsvelEBAntveP/9o5aKjMOJ5Dq4DTyykDnwfkXPaKvpdV /0kubVt7ioNuPKVAWGS9+ErQ+F3eFg8= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=o5gCrlI0; spf=pass (imf18.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B079F613EF; Mon, 29 Jul 2024 11:21:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A282AC4AF0C; Mon, 29 Jul 2024 11:21:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252063; bh=K3GUIiHemMLy8fa8RNH072Iq/pXEu/mTjv8z/3myXkU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o5gCrlI0q81yaT0XVXU2oqnN965qfPvIFAFcpm5o8+/9uozJOlLo7KU+gwBQ+kwOP iAnLxsVxjYVw3zhS0k4gOkFU4woJ9SVcQP/bLhknsUR1zUBYaLZMii9yqmeKAuapKI U/yfn6gsE25TokO5tBSpDviaM4NXHWSY5+3PCs9Yvqwi0cNmLTS6l+swpRFFoUEw47 glc2GKCDOuvKDd4g1VWHlltI66gYTXQC67wpWqGAQwrBq4RLqouYP96rjmrEw+3uab QDMOv8TaAYsoO6R5qrWC/i34oo75n8qUzH2KXjSeYp09IZ7uZoph5jQun18uSGhPaj mQRK84Tevde6Q== 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 v4 14/22] mm/zsmalloc: convert migrate_zspage() to use zpdesc Date: Mon, 29 Jul 2024 19:25:26 +0800 Message-ID: <20240729112534.3416707-15-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 7A1971C000E X-Stat-Signature: xagnrcugkrpmg43od3edb3w9ubwzcgec X-HE-Tag: 1722252064-280540 X-HE-Meta: U2FsdGVkX1/C1zXrZHs4/UwAEJ3+dnUbaze0AIdylcD0sh0UATRwrm3ALJ2Y84cOfGQaaf+zXQ7nbbg64GyV2K4M1VenIxapFmLOMhd8A2BGlQmr0i/0pQr8wasWO4b416s+WlwfTLUtv7doXsCaIdjgy7cWNPLKzTc3ROPaGx4H/nEWMtfsyilDqvhgjtg0XZX8t8VPYd/x8m0ftOaql3NuPR8CUuJQem0BOwRaec2t7FunqfZV9R+KizG2ruRZOZ/Y6bFPpeAoxxOK9yqi6JkblVzURXNDxpC1MV6kKlWXUp986uri0ZOLssj8hXD/JWTUeFuCVZrsj49mpftNE+zQFrOwluPtodw9/w9gPEalSxELVvhqJm8q8ys9KPwI13LGViAij0nh3Rw8UsMf3n1V4BBoHe9in26C6lhEBkTB0X5s9cTOIx22IBaTmg5zzDrFmtUALPwK31pdWFwRzUenubMKxAvl1E23IbtiIYum3+YIxR7uai2udWfIkDTiw1GUcaEPZGxOKRqmFMSG4y8B32n5GmH6rX7fUiUKxQLwcu/mZM3kfxvbIMrLYHf0ABN1Fdoe5euXkQmerCQQF8PGdpgOBWuz3n21R77ZiWzqwcc5AqbJvUVKA9CIw0C4Z/+m+obb0PfN9hxsPOELYchpM7upPa4Nej39x9bUIjSr8ZvMO0Uas30ePLmaunkNshlzVXil/ASUl1yf1DwWoBXqCOo6QUstw+AUwxv9vcG/XUajRdTZAIDy7BEyGYEejnTXNLl5TjD06sZaeI5Hn+qsTHPr4WZhtudaBCwZnpHIXBOOZRaNVixYBODCuRPMUdWTA55q1RHly8v/2FhLu+Y0shT0qxfTfZP7gxoXQPEop6boTN3q9Bn5dyOyx2LF+wz8ax6eIxPKuMLCGDPitUCMQpJTavjuaVC8t6c6b1W6Jh85aLjBNTJQVl1kAb2VeTbpWMZFagNNcRFxw8H rtwlcL2R 3i4R0sIM6NP31tN7QAMFeQBrL5xFosdzBqWZ8Vgm6lp9KLkqDoFrmEobnCBlS+KuQJjpLcW6aJSogsQL/poDhB1xVECgJiUXThg8v5gUWEWBQ2HydFlbPyBjvqE1abv36NfF+50DV+Vtwb00WI0+ZczKQDvH+bPBS3wr+06EYJbEw9FKpYErCYGWeFrg1Ccyh7xzk/YVJ7Lzl9vjmgG2WYky/+mVNghq15qJTKJS+mF9UDIWHz2hwwCBYPUlmz7AiIiPs+SbJuN58zCa7r2O5ZR+pKiUooS5j16ohV6VpgIkk+FC6QXbPtIBI4KEYlgXqYhIWGaSj/dd5KzFzx5OW7jV6IOqwi9IZEzVk1dlmK+VPlwmUYH1PnpCNoG1Dtff1tC82 X-Bogosity: 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: Hyeonggon Yoo <42.hyeyoo@gmail.com> Use get_first_zpdesc/get_next_zpdesc to replace get_first/next_page. No functional change. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index e291c7319485..7d039b0c66db 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1636,14 +1636,14 @@ static void migrate_zspage(struct zs_pool *pool, struct zspage *src_zspage, unsigned long used_obj, free_obj; unsigned long handle; int obj_idx = 0; - struct page *s_page = get_first_page(src_zspage); + struct zpdesc *s_zpdesc = get_first_zpdesc(src_zspage); struct size_class *class = pool->size_class[src_zspage->class]; while (1) { - handle = find_alloced_obj(class, page_zpdesc(s_page), &obj_idx); + handle = find_alloced_obj(class, s_zpdesc, &obj_idx); if (!handle) { - s_page = get_next_page(s_page); - if (!s_page) + s_zpdesc = get_next_zpdesc(s_zpdesc); + if (!s_zpdesc) break; obj_idx = 0; continue; From patchwork Mon Jul 29 11:25:27 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: 13744738 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 44DF3C3DA4A for ; Mon, 29 Jul 2024 11:21:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 040C86B00AE; Mon, 29 Jul 2024 07:21:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F340D6B00AF; Mon, 29 Jul 2024 07:21:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D855C6B00B0; Mon, 29 Jul 2024 07:21:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B9EB26B00AE for ; Mon, 29 Jul 2024 07:21:09 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 71B4A1402B8 for ; Mon, 29 Jul 2024 11:21:09 +0000 (UTC) X-FDA: 82392548658.03.23382B9 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf16.hostedemail.com (Postfix) with ESMTP id BF3E1180010 for ; Mon, 29 Jul 2024 11:21:07 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=NUq3ixaQ; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf16.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722252064; a=rsa-sha256; cv=none; b=Vmf8mhBms7nR4sWNxwXTcPazKrDzqqxZ4Od9Dy3MWqesnEN0CItMfvTJTPr2mvHL6/73iP Ug3vt2yCngYncFUVxfqYCdkRwYSqcYafBtRP+i7+FG1wgsUAslTWKD6wRZtmQ+Cpk+CHQt /M4BUf3o15J6scW2c1T32fP/4rNRjgg= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=NUq3ixaQ; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf16.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722252064; 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=Q9lrHJyVnJJavlQtfTrhM6Cg7QJsRwBhFfAPgSitRB8=; b=R9j2+2U29/4zKVWI8VXz8X1l8b7+m+brwztjwKcgPtj2d0JsQ23W9Zxpojr1hyYYrmeHH7 tkwfbjJ7RwK+BnHZ2UeuIkLjTFWZcLNwa+eUN8ciLK2OJWRoCW++GK9YUxgtyQoK9j7Dwj eKA/jehJk+sJdlkP4BvnhqDMXrbJD8M= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id F177B6177D; Mon, 29 Jul 2024 11:21:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE97DC32786; Mon, 29 Jul 2024 11:21:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252066; bh=0AvWtekA1fBYWEoFvuJjRv8WAqdxESdkBRdAezOabRE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NUq3ixaQ6u5c4OlwYwdVAJz07eKqVSBQDfBqsWK7nIM0s3VhqwQM/W5WH+38OmX5Q NdDZZABPrBrX/v4zQp5TFRvQHj1pd9c6rvOsn9KYIALCUJ57wdxf4CZQLZQzP23tEk uWbK0FAj5zbEjBN/yhkX4BM13sZH5rmKIGH1X6Zo/yGti7w4jcxTITcf5U6AC04r+i 7J1jFuwdbJdJ3f/JJlBlQ5q7HgEhUuAMtDiij8FsSs48lAraDh/Y92I/uVRmZgL62L wa3A9LbcmwL5fg6tBqdWjMkMRqO662420Fdy4oeamfSZBwv5R2p73tbcBwAqB351ox /xeYlJgosEmEA== 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 v4 15/22] mm/zsmalloc: convert get_zspage() to take zpdesc Date: Mon, 29 Jul 2024 19:25:27 +0800 Message-ID: <20240729112534.3416707-16-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: BF3E1180010 X-Rspamd-Server: rspam01 X-Stat-Signature: cmxr7ej6mo7pjqruqku4zgamogki3d9x X-HE-Tag: 1722252067-312448 X-HE-Meta: U2FsdGVkX18AblUaEotu07pGDe86MrxYD/9/fYVP6YF0iGYddj5eDThLcUJvkIl1+INPen5vvQ6gFcMEk7FxWBFrf2FY+EyWWRkgGMgacZ+0XJlaSLRtgIA/OCfC0hsydIU9LmvnXKzirYim7VecXS9m4R2twJJ/sjxvZaJ9Jo8HHMO2+OTqf+kG/qZeiAKtiOG52RAyYhiAkctmfrsB3Q4qhvIWaaUueRW3GxP4tGbHeq1jxt6QzO1Nw6Lf13nD23RcVzkIgFx9SmJe/29RYPHEGncUk73IerUNRWp68wS2Yb1WfoWM/OeMdMfltMSCX2x5JMeA/u1zkfqBpbWTvf37O6R29b/NMSJpIKEIh28c+PaWU5HuijL79tg1T+JfdFgKZbi46XQ6jdo18fZg4HkDc5DXawGzmg7IHEkX4YWMEOyMDSSaQVOCRUhfjiCrEo1STVxMXgh2UQxZoz+BB7XQytu1OtqsBJrMarr+2tl1MxF634ZgCBgxshqSVG4mPDiNVNLw/8fp0jC3NGzQ+ZCc4NpENsM0hB/XeMEmp5lYbJZt6U1DO0tepKoJmyR7V3EPDNO93DcuvUYNiO8dVVVZAp/S2sHnqH8ZSZR5EJFaNC6y0CASkm46nVpDch0OJF5+Mg/rNj4cn4PLHVZGKsGY8BQD+gagZyh6OaRYU65iaEDNPKTFk99A147JGrzpVSLh8HXP43dc326mVE+/ylH267eU3BPymhxbKB2bV8vpw7ll/yXcjaEkCWN4zq0mLzX5m+8ZENzgy1YVpV06Cg5E3yu0mLeMObqJgzcYxgANizpxGC0jH+mAz/jcq55qKT5Ds6Iz23P/zppzh2sJXPcwaFRqwCHcPidMrnWbDAKL7Pd44F44qQJoUQHQfkdlX9/Dam64WYj/8XU/a88lUYSEfnhoaMhL1GJmiIRBglGAIuJAheoo6sWhRU/PVdxxb9gqRuNXKaYKqGtmxDv TgIYOO3n gQr3rub65tV9dryFWutIAF/YY1xOwxpzcsz/FJqizE7f+sYqq7/zTGSdbcgfHgJgsxVDZtEjNQvHWw0BZiU67E5s0SLKThYezv7e+bzVVPzrZLIYlwUKFk7EEjC0JaKHrNAr0jcXqDCWKMDPbdCXVDxCM+XmG2pBuxmNUMw6rWXXfGF0AYjKesdu1Fde6bWfjJgQ9rOeGZd8a8rwnOnTitnp5TxTDLHuo1md1NXiRfRGv7p/REORmn1/ZEpxjcsiApTuH23n2w6CF2eyvC+jCjeJlJpDmpg051vEZzjXeWwDW3eqqxlWJbl82pOpYQqUcmZVJXY9C9L2PjBblyumkKXfk0KhFoeuVfelJxBrF2kqRv82k2+pUjwhsGVl7RJ+jfWVr X-Bogosity: 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: Hyeonggon Yoo <42.hyeyoo@gmail.com> Now that all users except get_next_page() (which will be removed in later patch) use zpdesc, convert get_zspage() to take zpdesc instead of page. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 7d039b0c66db..458ad696b473 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -779,9 +779,9 @@ static int fix_fullness_group(struct size_class *class, struct zspage *zspage) return newfg; } -static struct zspage *get_zspage(struct page *page) +static struct zspage *get_zspage(struct zpdesc *zpdesc) { - struct zspage *zspage = (struct zspage *)page_private(page); + struct zspage *zspage = zpdesc->zspage; BUG_ON(zspage->magic != ZSPAGE_MAGIC); return zspage; @@ -789,7 +789,7 @@ static struct zspage *get_zspage(struct page *page) static struct page *get_next_page(struct page *page) { - struct zspage *zspage = get_zspage(page); + struct zspage *zspage = get_zspage(page_zpdesc(page)); if (unlikely(ZsHugePage(zspage))) return NULL; @@ -799,7 +799,7 @@ static struct page *get_next_page(struct page *page) static struct zpdesc *get_next_zpdesc(struct zpdesc *zpdesc) { - struct zspage *zspage = get_zspage(zpdesc_page(zpdesc)); + struct zspage *zspage = get_zspage(zpdesc); if (unlikely(ZsHugePage(zspage))) return NULL; @@ -849,7 +849,7 @@ static inline bool obj_allocated(struct zpdesc *zpdesc, void *obj, unsigned long *phandle) { unsigned long handle; - struct zspage *zspage = get_zspage(zpdesc_page(zpdesc)); + struct zspage *zspage = get_zspage(zpdesc); if (unlikely(ZsHugePage(zspage))) { VM_BUG_ON_PAGE(!is_first_zpdesc(zpdesc), zpdesc_page(zpdesc)); @@ -1265,7 +1265,7 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle, read_lock(&pool->migrate_lock); obj = handle_to_obj(handle); obj_to_location(obj, &zpdesc, &obj_idx); - zspage = get_zspage(zpdesc_page(zpdesc)); + zspage = get_zspage(zpdesc); /* * migration cannot move any zpages in this zspage. Here, class->lock @@ -1315,7 +1315,7 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle) obj = handle_to_obj(handle); obj_to_location(obj, &zpdesc, &obj_idx); - zspage = get_zspage(zpdesc_page(zpdesc)); + zspage = get_zspage(zpdesc); class = zspage_class(pool, zspage); off = offset_in_page(class->size * obj_idx); @@ -1479,7 +1479,7 @@ static void obj_free(int class_size, unsigned long obj) obj_to_location(obj, &f_zpdesc, &f_objidx); f_offset = offset_in_page(class_size * f_objidx); - zspage = get_zspage(zpdesc_page(f_zpdesc)); + zspage = get_zspage(f_zpdesc); vaddr = zpdesc_kmap_atomic(f_zpdesc); link = (struct link_free *)(vaddr + f_offset); @@ -1513,7 +1513,7 @@ void zs_free(struct zs_pool *pool, unsigned long handle) read_lock(&pool->migrate_lock); obj = handle_to_obj(handle); obj_to_zpdesc(obj, &f_zpdesc); - zspage = get_zspage(zpdesc_page(f_zpdesc)); + zspage = get_zspage(f_zpdesc); class = zspage_class(pool, zspage); spin_lock(&class->lock); read_unlock(&pool->migrate_lock); @@ -1846,7 +1846,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, __SetPageZsmalloc(zpdesc_page(newzpdesc)); /* The page is locked, so this pointer must remain valid */ - zspage = get_zspage(zpdesc_page(zpdesc)); + zspage = get_zspage(zpdesc); pool = zspage->pool; /* From patchwork Mon Jul 29 11:25:28 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: 13744739 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 B942AC3DA4A for ; Mon, 29 Jul 2024 11:21:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4ABDD6B00B1; Mon, 29 Jul 2024 07:21:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 40E416B00B2; Mon, 29 Jul 2024 07:21:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 28A116B00B3; Mon, 29 Jul 2024 07:21:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id F2EE96B00B1 for ; Mon, 29 Jul 2024 07:21:15 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B96B61202E0 for ; Mon, 29 Jul 2024 11:21:15 +0000 (UTC) X-FDA: 82392548910.10.F2FF1C0 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf30.hostedemail.com (Postfix) with ESMTP id 9C66880005 for ; Mon, 29 Jul 2024 11:21:13 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Cis/sQct"; spf=pass (imf30.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1722252020; 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=kTm/sX+DW/w9pIMx9ScGftKWcPwLIh0BNYGkIGj7FVU=; b=NMvUC7EgNlMXc1Y2FuqWpONST9ifLrZrw8a/VRO0tOh8+FewLHA3y7O3DCszc2yyotmX2x 0+AVQGWQRkLddDRI1UD/jvmfS3MnZxp2cDdgg3Sk98lnAUzZ6uktvj3alGup+qtc2lAS3F fFDGnLYoQpcnpl8o4Y/JCHW+3V9llkc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722252020; a=rsa-sha256; cv=none; b=MebgfD8mzoDj+DY31EibhEAGI+/T277/4xLbCj76ACCZBDOZQ30E0clfsZcfHmhbxOyY9c At4GsqgUPfzWfhfSz6PmI2J0E1uGb+9rORN12tdOcUQaPwdSr7THxAA/AkD5snCY/Dqokb DihegRc9JzFxBGrq5mjH+vzSshWV4Qo= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Cis/sQct"; spf=pass (imf30.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id A8CEFCE0ADB; Mon, 29 Jul 2024 11:21:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CC73C32786; Mon, 29 Jul 2024 11:21:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252069; bh=uH0rZNnpHFMljEmSyKQuSSlLph2dNP0xTWvseJvNDaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cis/sQct2oie4isbX0P4WgsHRrGtWLVh7YFLlWHN4Hqxb4Ps0mGmDN5s2E3j4uoLw hcbPLuM3mQCdC8wAZKHt/Fi5LPEaPrAd5zhVLwPvCiqEEsOOljP8QGnJnBIP7iuO2o denYHvyN+8K1G9sUD4xLP82ZAtOnzeMNsYkan3a5EtkxsS9BZddKDmb03Z5zXVaANg aZe32kqPkj3x+SuS/BhLrA2bB+Mxs7Lto2RiN/O3apyJO7inUD8qPFSXMkT1gMuLKV 1rf5SV/fqXZ108XIFo7MPKqAEtCY8JczZCXeoWKST8sS8Bl1na7887/WCHXFmUE+/3 CBqLzo08RhhPg== 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 v4 16/22] mm/zsmalloc: convert SetZsPageMovable and remove unused funcs Date: Mon, 29 Jul 2024 19:25:28 +0800 Message-ID: <20240729112534.3416707-17-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Stat-Signature: onjn5hyx4r4tidsbr8jxnt9iipksei4n X-Rspamd-Queue-Id: 9C66880005 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1722252073-682073 X-HE-Meta: U2FsdGVkX19BQDUlPhN1QtRvvvqvsP2zVgwd5UbUOPfIGTOJDIMUaHZKA5+PqYQvb2T4xoMTFoF2EF3Ac8+pE4d7Lqh0qX5YO3Cb+dh6h8aUCrf8PlI68X5W9rxCGJOCE6YOxgwU6E8mF+7Ow9ruh1LAv0FLYqQe1Ys23o2HzNC7TRX34xB4sx/DXeuq46eGDfFrjC2VLlL/l/GWEXlsK+uBaoZBjrJd1MRL1gzQIrHbBq8NcTtyjxsZl3UV8NuQ2miNEfTenjMvuflbQBG2CLpF6L6BE7KV9yflAPHPJQtClh95jMlt2RBSRy1azrIjgg3huyzhmwZaJe1PmNWGmsvIrca45otA0zWzGYLb+vGYnpFZEHHISiAgiSa0EQoESlpVKj/WYPxvH5Wj0UBY3SY2sGZWdfPUmukz8dPtAzqf1hvYkGSlRP5f4j8GoZMdY10gEm90joLMveJdZvaWTcUkp05iYS/eEpb1+GbNFFcCxaBNXhiIlIEEUZ+kyo/RurFHei/Tugnr0B2xSiD9wMR+1d+a7zky62kZqT+8LXJf0h66xqXzVRdn/p9lI6yGNyxiqlyB1Gu54Oh5d113EXoEnCV46jzhawZ1vaQFmodGEXV45oSGP2ik9vPKSsscMkxMpaiiFVG8EPNOC2GclJQBlwja3nDvwqcXf4p68C7fdtTfT/0LXAWaadfb1XsFesoB7GYXuP/O+jAW0+zWgWKuIWoi6x6z/3Ey9Q47mOcClq2dgIB2lCHHKQ0JoDvgQ7Sps9ySxoYz58G83uQdf70yU+HZts55p8RoWV3u3h97632Elw2ClJOunoGTgwfHyFB45dFBe5vhpP0P+LZsskCYfHAYAKbsxeEXUd9nCkyImNQw5YNH2F5StqfQCqAiF/SOoIk1xeP30YaOkJW6BRiWti4ERkagbTkLrqaYw8y/A1OiuswCI6u2jppRo6PElzqQJJBlE1ocIPAbEUg E6iHuehA Qf/2x9q2dYYUhTM4a+gUsFVAG0poGJPJVBIjFjA+NSlWOeJy8JTjLZr4a4fsXpv3O9+KYyo+bCSPoluXhljbLollA/KUhsfUleQ1Q+25KUGpQWeV35Ae/QtCG1e341gohFAk9XkKmNjriauH0ek5/WoUfiNBYSkh1IR3kEn7ZUk0/YDJDsUOkAOFuaBpsBB5wCGec7zAnRZ+hObIr+JIm4vq08Ewiq0z6sORa1qSQIMC5vgXCvuTdlGxRGitNhuDY3V1uX9DlewEVM4p4ZFC+0OL5L77auCMrtI+1/vvD/0HVDOoQ+idnnEh3kCKcKpHZtIrvcbwft7pf+7Y= X-Bogosity: 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 Convert SetZsPageMovable() to use zpdesc, and then remove unused funcs:get_next_page/get_first_page/is_first_page. Originally-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 458ad696b473..8b713ac03902 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -468,11 +468,6 @@ static DEFINE_PER_CPU(struct mapping_area, zs_map_area) = { .lock = INIT_LOCAL_LOCK(lock), }; -static __maybe_unused int is_first_page(struct page *page) -{ - return PagePrivate(page); -} - static int is_first_zpdesc(struct zpdesc *zpdesc) { return PagePrivate(zpdesc_page(zpdesc)); @@ -489,14 +484,6 @@ static inline void mod_zspage_inuse(struct zspage *zspage, int val) zspage->inuse += val; } -static inline struct page *get_first_page(struct zspage *zspage) -{ - struct page *first_page = zpdesc_page(zspage->first_zpdesc); - - VM_BUG_ON_PAGE(!is_first_page(first_page), first_page); - return first_page; -} - static struct zpdesc *get_first_zpdesc(struct zspage *zspage) { struct zpdesc *first_zpdesc = zspage->first_zpdesc; @@ -787,16 +774,6 @@ static struct zspage *get_zspage(struct zpdesc *zpdesc) return zspage; } -static struct page *get_next_page(struct page *page) -{ - struct zspage *zspage = get_zspage(page_zpdesc(page)); - - if (unlikely(ZsHugePage(zspage))) - return NULL; - - return (struct page *)page->index; -} - static struct zpdesc *get_next_zpdesc(struct zpdesc *zpdesc) { struct zspage *zspage = get_zspage(zpdesc); @@ -1970,13 +1947,13 @@ static void init_deferred_free(struct zs_pool *pool) static void SetZsPageMovable(struct zs_pool *pool, struct zspage *zspage) { - struct page *page = get_first_page(zspage); + struct zpdesc *zpdesc = get_first_zpdesc(zspage); do { - WARN_ON(!trylock_page(page)); - __SetPageMovable(page, &zsmalloc_mops); - unlock_page(page); - } while ((page = get_next_page(page)) != NULL); + WARN_ON(!zpdesc_trylock(zpdesc)); + __zpdesc_set_movable(zpdesc, &zsmalloc_mops); + zpdesc_unlock(zpdesc); + } while ((zpdesc = get_next_zpdesc(zpdesc)) != NULL); } #else static inline void zs_flush_migration(struct zs_pool *pool) { } From patchwork Mon Jul 29 11:25:29 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: 13744740 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 7CC0AC3DA4A for ; Mon, 29 Jul 2024 11:21:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A03BC6B00B2; Mon, 29 Jul 2024 07:21:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B3CB6B00B3; Mon, 29 Jul 2024 07:21:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 805136B00B5; Mon, 29 Jul 2024 07:21:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 58ACF6B00B3 for ; Mon, 29 Jul 2024 07:21:16 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1C76B1C1068 for ; Mon, 29 Jul 2024 11:21:16 +0000 (UTC) X-FDA: 82392548952.26.72A1F53 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id 63F031C002D for ; Mon, 29 Jul 2024 11:21:14 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=WKtVL170; spf=pass (imf18.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=1722252071; 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=3Cdy16gcWU1T1yBZr30RCaoUoqkrgtx34tTJp2WzbPU=; b=FY91zBsxFdjNif/84A9sqvYXFOG44qS7DTUGPkMQqjahDfLY6jdvn+dJvqrf6d7H2u7mM2 T2QwYBPhvsJMqep2komnaAciWykw3h1016tlnzgEYndDcGPBZRW2qn32PlHIHAGSWyc92C fGMPxIlMqO+k3sl3ULkMNO1qupcdBLE= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=WKtVL170; spf=pass (imf18.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=1722252071; a=rsa-sha256; cv=none; b=LY8OH08XduGzxI8c6xM6HWmmTOz+Z/UM1Fv0dtzlMwOn+COh/dwzOCnaWHv0tRRTNuxD4V eJ1YKRnctoARj0SQSPaOld8Gj3H8vRmucyYZ6XptWrKy+DYXWZ39PB95RFSXZLxC9tPLzj Dv/U+nFuWTkQHNM+LoWcK2L1Srll1YM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 7C561617A5; Mon, 29 Jul 2024 11:21:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 693D1C4AF11; Mon, 29 Jul 2024 11:21:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252073; bh=Itfg7R6iNeKIMJsSCXaa7VK0PRdQ2psxEdNvilX7MGw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WKtVL170fOP1O4XLSDWo1F250iq5RJ80EenjRyd7ZFOT2WvuJuInoIyx92SwRS7Cc pbrGzXYKmIIAT4QtnvMB8ThaarUUedL3E5+TlS+UtYM+YJsxN2p5XSlso+e1SHSb5M xTUP2ijw2w7jJF69q2NiOoesk4j1NPgHOtJ1w0TS2tjj2RqoWf5SEtWI/DS+hgTA/t jwIzd+zFQpYJUj4XC3xJkx35hp9rlt9Ju0MpE+vnq/J8BM6koz0K0BkDwwpac68UpE 0W/f4fyzHaM9zCNTqtvtVyYatxW07+UpA2zA8fi8x/CPXDjyEwZFw9NR4VBwQLbWRv TGyKYh/tyozJw== 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 v4 17/22] mm/zsmalloc: convert get/set_first_obj_offset() to take zpdesc Date: Mon, 29 Jul 2024 19:25:29 +0800 Message-ID: <20240729112534.3416707-18-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: hjj7rcwnweg9p1578ktk38myy19hqq9t X-Rspamd-Queue-Id: 63F031C002D X-Rspamd-Server: rspam11 X-HE-Tag: 1722252074-576062 X-HE-Meta: U2FsdGVkX19a1bEClZLm8wT2eqD5d/nnsh4CmyqpJ3PoA84QMWl2GB+wg9ez/lNmpd7csz0r5AT1xg2BrP+ysi+uVCQXNq1CoEWFUg7oqyil1xs4rN/K44LM9h+nxTTD7bWTPtqEcZIFntAznDb8E6vQaxeHwMPR91NeP7hJMVlauJ7a3E+QYOY+D6onJ7vs2kauIeTxTMrGcnT5QxTOPDi7zbvZZdCcBX9WoXqkftvd2oUWtpMl21OxFTMkRCnjgYlzvdYvDqR4r4YE+w48LhvU+TJ9Gw1E8M2J7CMtSRTVXcMgC4uYkgeXcTTq2dFPPhu5jt7PFmK0QNP5gBz9g7+42SP4HwmU9Nv2aF+WQLB63wFRBqruSg1dFtNyFinLD5D7w/w5Y1ZuzyJZBwxsJyFoovG8gEDfetidrd3a7hx8MFJvgN6vYc2cQYO+GSVM8ud7iaUyYmmwWhj/p2GkXZ5uMiKLAR0rttkGAnCbYEG1WPrkchl2NSlQvOdnIHABcn5yQ9i07+CK5vY7BaTavWc9uiDyndZKejKjtPtRswA6QV2Zsz8BsuhOnh3K71rY16j/lkJvQDUzLeTybBsXGkN/QVmA/l1ZggEwNHFLrwcTzEklo6NGrsnBeAgea5HvVOHjONHysB1wPqd+q2BKrUGelJVz9Vy3yoM43+DChNzwphOhrcvxMTkj3jfDHzJAk1iq2tv5BvCKxfgo7XdfuHHHl7Asob74LAW8+pL5+9Sv3skyCI7nQKiZOaALi1Jb0H2s+cUWEvW0QFC5qzw5AgeCwOvJWxdHcObE2+R/UQeQShTR5ynQfg1LE6w3NW2p+CfFgS7kQMdnRksXtV4n+wb14AZT32TjRZ34cce2oIDz/gFpBYHRfM34AIMIKpL/FHE/LSeFhGw0Caq8F7LnrqW7DCSjr2/dmoVUiqi1KcSDRJk+arfYE34lxmysrEw35FuJmIaUA9yQwC6ku7p joKH9JhG 4o9PDhmtNZYZYRzJ9tL5cJaSv082A8SeOZZE6NO+4bePD0kjU8Kat8OUhw6cBkOaKUatc+isbT8VKzx3OtFJ9JdAPDmvY0giCAAkO/3sRxBZXr1N7EHGEKcDreJ0pQ9PsdDw9ZVdLbIGC7yZjRo/zHBAlosw/M1pd1FXyTlsMDl6ECfPey3ol54+d722XvkMC5R/3QDmVNeKOO1ekcqsb0J+GNtTXx/E0XOrDH8L3Q9ihwjyjQIJBTnv5OKY0AgDxPnC4dPDmZzl7TZrNlQXOAF/bqW22+wdDYfFEqACxT5sFdWD3utrjmQe17GEcI4KG6RPijYV4HLswZTwDIeV3DTYRIKehSFNx+IO0DXAqLJiP70pn1FdQbp212hUhVctWOiot X-Bogosity: 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 Now that all users of get/set_first_obj_offset() are converted to use zpdesc, convert them to take zpdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zpdesc.h | 7 ++++++- mm/zsmalloc.c | 36 ++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/mm/zpdesc.h b/mm/zpdesc.h index 72c8c072b4c8..f64e813f4847 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -15,6 +15,8 @@ * @next: Next zpdesc in a zspage in zsmalloc zpool * @handle: For huge zspage in zsmalloc zpool * @zspage: Pointer to zspage in zsmalloc + * @first_obj_offset: First object offset in zsmalloc zpool + * @_refcount: Indirectly use by page migration * @memcg_data: Memory Control Group data. * * This struct overlays struct page for now. Do not modify without a good @@ -31,7 +33,8 @@ struct zpdesc { unsigned long handle; }; struct zspage *zspage; - unsigned long _zp_pad_1; + unsigned int first_obj_offset; + atomic_t _refcount; #ifdef CONFIG_MEMCG unsigned long memcg_data; #endif @@ -45,6 +48,8 @@ ZPDESC_MATCH(mapping, mops); ZPDESC_MATCH(index, next); ZPDESC_MATCH(index, handle); ZPDESC_MATCH(private, zspage); +ZPDESC_MATCH(page_type, first_obj_offset); +ZPDESC_MATCH(_refcount, _refcount); #ifdef CONFIG_MEMCG ZPDESC_MATCH(memcg_data, memcg_data); #endif diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 8b713ac03902..bb8b5f13a966 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -20,8 +20,8 @@ * zpdesc->next: links together all component pages of a zspage * For the huge page, this is always 0, so we use this field * to store handle. - * page->page_type: PG_zsmalloc, lower 16 bit locate the first object - * offset in a subpage of a zspage + * 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 @@ -494,26 +494,26 @@ static struct zpdesc *get_first_zpdesc(struct zspage *zspage) #define FIRST_OBJ_PAGE_TYPE_MASK 0xffff -static inline void reset_first_obj_offset(struct page *page) +static inline void reset_first_obj_offset(struct zpdesc *zpdesc) { - VM_WARN_ON_ONCE(!PageZsmalloc(page)); - page->page_type |= FIRST_OBJ_PAGE_TYPE_MASK; + VM_WARN_ON_ONCE(!PageZsmalloc(zpdesc_page(zpdesc))); + zpdesc->first_obj_offset |= FIRST_OBJ_PAGE_TYPE_MASK; } -static inline unsigned int get_first_obj_offset(struct page *page) +static inline unsigned int get_first_obj_offset(struct zpdesc *zpdesc) { - VM_WARN_ON_ONCE(!PageZsmalloc(page)); - return page->page_type & FIRST_OBJ_PAGE_TYPE_MASK; + VM_WARN_ON_ONCE(!PageZsmalloc(zpdesc_page(zpdesc))); + return zpdesc->first_obj_offset & FIRST_OBJ_PAGE_TYPE_MASK; } -static inline void set_first_obj_offset(struct page *page, unsigned int offset) +static inline void set_first_obj_offset(struct zpdesc *zpdesc, unsigned int offset) { /* With 16 bit available, we can support offsets into 64 KiB pages. */ BUILD_BUG_ON(PAGE_SIZE > SZ_64K); - VM_WARN_ON_ONCE(!PageZsmalloc(page)); + VM_WARN_ON_ONCE(!PageZsmalloc(zpdesc_page(zpdesc))); VM_WARN_ON_ONCE(offset & ~FIRST_OBJ_PAGE_TYPE_MASK); - page->page_type &= ~FIRST_OBJ_PAGE_TYPE_MASK; - page->page_type |= offset & FIRST_OBJ_PAGE_TYPE_MASK; + zpdesc->first_obj_offset &= ~FIRST_OBJ_PAGE_TYPE_MASK; + zpdesc->first_obj_offset |= offset & FIRST_OBJ_PAGE_TYPE_MASK; } static inline unsigned int get_freeobj(struct zspage *zspage) @@ -850,7 +850,7 @@ static void reset_zpdesc(struct zpdesc *zpdesc) ClearPagePrivate(page); zpdesc->zspage = NULL; zpdesc->next = NULL; - reset_first_obj_offset(page); + reset_first_obj_offset(zpdesc); __ClearPageZsmalloc(page); } @@ -934,7 +934,7 @@ static void init_zspage(struct size_class *class, struct zspage *zspage) struct link_free *link; void *vaddr; - set_first_obj_offset(zpdesc_page(zpdesc), off); + set_first_obj_offset(zpdesc, off); vaddr = zpdesc_kmap_atomic(zpdesc); link = (struct link_free *)vaddr + off / sizeof(*link); @@ -1589,7 +1589,7 @@ static unsigned long find_alloced_obj(struct size_class *class, unsigned long handle = 0; void *addr = zpdesc_kmap_atomic(zpdesc); - offset = get_first_obj_offset(zpdesc_page(zpdesc)); + offset = get_first_obj_offset(zpdesc); offset += class->size * index; while (offset < PAGE_SIZE) { @@ -1784,8 +1784,8 @@ static void replace_sub_page(struct size_class *class, struct zspage *zspage, } while ((zpdesc = get_next_zpdesc(zpdesc)) != NULL); create_page_chain(class, zspage, zpdescs); - first_obj_offset = get_first_obj_offset(zpdesc_page(oldzpdesc)); - set_first_obj_offset(zpdesc_page(newzpdesc), first_obj_offset); + first_obj_offset = get_first_obj_offset(oldzpdesc); + set_first_obj_offset(newzpdesc, first_obj_offset); if (unlikely(ZsHugePage(zspage))) newzpdesc->handle = oldzpdesc->handle; __zpdesc_set_movable(newzpdesc, &zsmalloc_mops); @@ -1840,7 +1840,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, /* the migrate_write_lock protects zpage access via zs_map_object */ migrate_write_lock(zspage); - offset = get_first_obj_offset(zpdesc_page(zpdesc)); + offset = get_first_obj_offset(zpdesc); s_addr = zpdesc_kmap_atomic(zpdesc); /* From patchwork Mon Jul 29 11:25:30 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: 13744741 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 4047FC3DA4A for ; Mon, 29 Jul 2024 11:21:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B16166B00B3; Mon, 29 Jul 2024 07:21:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC7266B00B6; Mon, 29 Jul 2024 07:21:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 940B06B00B7; Mon, 29 Jul 2024 07:21:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 6F5F56B00B3 for ; Mon, 29 Jul 2024 07:21:22 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 260E71C1133 for ; Mon, 29 Jul 2024 11:21:22 +0000 (UTC) X-FDA: 82392549204.25.55460C5 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf23.hostedemail.com (Postfix) with ESMTP id 1D1AF140009 for ; Mon, 29 Jul 2024 11:21:19 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Zp7crNGG; spf=pass (imf23.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1722252053; a=rsa-sha256; cv=none; b=GornukETBXgE2ZxD9n6oo00tglcab1Deeid3711T1DGWE1UEqcRKLfuS+XTb/Xq1U24t3n ee5h8IOWfiAXuYyW1W63j7lYTQJ70/BUP4SgVssuMoufzukbqZ9OJi6KpF7MSYX0VDUYoH MKr1j80kNH7rRRTsFgsYnZ5vmdNrd6c= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Zp7crNGG; spf=pass (imf23.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1722252053; 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=GxEF9VZeHHCS8Akv9FK/sm+o7tLlAYtFkOntzK8ODB4=; b=fReRCma0d58MGUh13q/3euQUd3RjW9si10VsRUQ3FMRtKeKzieKHNy19bFZxUnbKYjkmAo rx7r02KeVjqLm6L3p8VH0Z6jOrnjOs0syCuvgQo0YVWXcHZ6XSbcWzyHdmdAmiYoqLGpd6 +T4yjicR3dsu6WCN72FbcbhIe9zWRqQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 32D06CE0AEB; Mon, 29 Jul 2024 11:21:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABF10C32786; Mon, 29 Jul 2024 11:21:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252076; bh=WC1zVtU8HoKTgwyGG1oBnxz/TQGKFBik73v06jNNZ/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zp7crNGGj8tFuQ+KKFsA4x+ASc1R4kKGuxUypiz+7x5QReIhm0x2m4fG7Jjw/wU+2 8asbu0zMOQYtzwO97Hj1gyyuvmxrSeh3uHcz1xtom7DMR1m4wA6K2gKnUWMi44cLC9 4RsUSKHEarV7mkuTqCVzvlvPMh9hpvgdyVTqCbqSIzcbTBHmMMk83DNuMPyA1s37Yw HgeUQ654r3M6IAG2fRbj+a5gogYPOcjTax9pkat/I3+H6NocMAmoG8dLxWd6Ke1Fmd TAyY1llDoLoeJjnLyQASqhE6ahUVKMGbJsipzXyx5hy5YgFAomQu8YaHzpo3BHs5Rz 8/Ugyd+q+VGcA== 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 v4 18/22] mm/zsmalloc: introduce __zpdesc_clear_movable Date: Mon, 29 Jul 2024 19:25:30 +0800 Message-ID: <20240729112534.3416707-19-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Stat-Signature: mh1h749uxf1f9as61xiueears8g11tq1 X-Rspamd-Queue-Id: 1D1AF140009 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1722252079-992260 X-HE-Meta: U2FsdGVkX18V5YxNajG9U2aF4Alag8ca7Xm2xMABK78igOGGyff/uoQkHXGDqKazfAfX1sjHKLGtoOQU0Ec2UqnF/gHL7B73v3RMtS29OkZRifuSGyd+1zM+OcCsVWjrMsz3/e82+HMsGU/iBA4vNtjn6PCOMkFaI9J/yE01Q+SEUNDXnjEOkgZDd6d9YnHe/M2VddWT8yjjuLrv9M+AhqJPJCZdwYcvvxM6c3MsJYlBPvv41wd7qntQc5CxjzBqbbDWtVlNnCaAkN680WcVY7qIinqC75/lQUPCcVmePvjfD7tcdHTiaK9H8s2PZeIEEZHYpg3IU5fzdEvpnheWl+CvRyyVD4vqHOaz4ZZfIScSst6v9RME4t8xj+BjLauTa0AtvwbNAz7JJt+bXkzgTRFj45as5tCmUmFYjmKko4qWv++Q4BNsOy91JE21w4z1uIVhWxucTobIktNGU2gxm7+q04uqi7RfgWh3KAdEGsSjXf2N/D92dMJKFJrCaIUL29VRqG9/KX9Ba5OmXAiQ0Ty/3cJpSUup3AQCRFZWPIba+yK9JdQURJkVwaHWkxXoXpnUOULxZoP65562WQMmAERe5x1lwF/QDUiokVV4BIvOzBFact5rHvr1tB1p+TK2ytWXSwMaX0Nmjkw7o0617pithMZZGdhXg6L8NJyHXnoJ/CY+c3/eKGMJO3SHc+uCNrPINggMUOoFUCtA8yoBxSwUfkOqRzA3uiA0Q4Hb9gJuXkFG+5U2g/9KLP+9/EtuK1zHwlw56WAwatrGUfcYF41/K/HDs0q6Ffhqyz9MLE59aOynHVxzccE3lGMMJFWeTVvq55EMzu3yeyvjc995jz88BzUN3PcazGpl23ztc0NaWz2ZSv+8xMvdAj8Vypq0Ot7p471rCXyXei31O2a2Ys3ZG8ZZtQar9MbOTsf9ojvWvi8f2pX678jKv/WFkGwBBO9pJrv4foND66rddU/ rUwkqClK ayhBJZAeBshfXlhMs0tzb+emDNCqldbNEVx5OLjyDnBwRhAoBMz3JIQYwMFSh412Ko2XzhoU5vReh58z1jOXvFuIQk9rC/hP4dnr9H1uPHiMxKKkW+Xyt2LVqp8sTMurhMg7xRaG/i70kvXVflbYNY1X3CGqgBZYT6CnX/kokyDmZrbtC+/VAFr60NXyrmZj02goevFr5A8bbYMnRfB8dhzNIcAAHMIJ8YUWziQbAvVGJP9Mb1rQzqFK4uHIEjTqlNmssxK4BP6x3byNbsvUdq8WfAtklESY6YRp2XoVZRtHS1YuQznwpvqEzPN+kyX0knVipkakPMf8TB3Nz6WP8QpvTjpbKU8aqyZAB X-Bogosity: 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 Add a helper __zpdesc_clear_movable() for __ClearPageMovable(), and use it in callers to make code clear. Signed-off-by: Alex Shi --- mm/zpdesc.h | 5 +++++ mm/zsmalloc.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/zpdesc.h b/mm/zpdesc.h index f64e813f4847..5db4fbe2d139 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -114,6 +114,11 @@ static inline void __zpdesc_set_movable(struct zpdesc *zpdesc, __SetPageMovable(zpdesc_page(zpdesc), mops); } +static inline void __zpdesc_clear_movable(struct zpdesc *zpdesc) +{ + __ClearPageMovable(zpdesc_page(zpdesc)); +} + static inline bool zpdesc_is_isolated(struct zpdesc *zpdesc) { return PageIsolated(zpdesc_page(zpdesc)); diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index bb8b5f13a966..e1d3ad50538c 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -846,7 +846,7 @@ static void reset_zpdesc(struct zpdesc *zpdesc) { struct page *page = zpdesc_page(zpdesc); - __ClearPageMovable(page); + __zpdesc_clear_movable(zpdesc); ClearPagePrivate(page); zpdesc->zspage = NULL; zpdesc->next = NULL; From patchwork Mon Jul 29 11:25:31 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: 13744743 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 63BD5C3DA70 for ; Mon, 29 Jul 2024 11:21:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AEFE56B00B8; Mon, 29 Jul 2024 07:21:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A9E116B00BA; Mon, 29 Jul 2024 07:21:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93F336B00BB; Mon, 29 Jul 2024 07:21:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 6CB076B00B8 for ; Mon, 29 Jul 2024 07:21:26 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2FE0A1202D2 for ; Mon, 29 Jul 2024 11:21:26 +0000 (UTC) X-FDA: 82392549372.19.A148701 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf12.hostedemail.com (Postfix) with ESMTP id 1C42A40027 for ; Mon, 29 Jul 2024 11:21:23 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="NpQwJ0V/"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722252041; a=rsa-sha256; cv=none; b=E+kx1yYVjMR5GRSxq1Hm2SUQEQ6gCwl40fZTOkZx8DKsHJ8xMUTAgQCe3LNmdvrmrIgobL HlNgVqBC5N4OcHSrU0e/5yNS7FTAVynNzJSOMcB5IEI0khHuyVAcgcBqf05c03pNbQFd6/ +FP6c4Ys1yh808tbosUH734MRuU77D8= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="NpQwJ0V/"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722252041; 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=p0QIqgbhoMoSNPXNsrBhFeM+VqFxoSiKdVrme93wtPw=; b=tcj7uvpJ33a9eUBvCDxX670K2lLRmgK3Jg8Mmhu6qaIJy9B1GmgPJznVxhLIr732SrYigq 7Lol94qIak9EqE3hgtXA4UprcfKwvRsrKsDZjLFtyynckiBIy9eP8SrCBxmhQW1gC1jU+P RzscazEK27TpWDfq7Byc0WToOJBO3cA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 7342CCE0A1F; Mon, 29 Jul 2024 11:21:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7CF5C4AF07; Mon, 29 Jul 2024 11:21:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252079; bh=PC5jkQnfMoZxwZVAO0ES1OaCQkwLNtrVhI+Kr1f/doM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NpQwJ0V/9xj+pd3NV/uPFqOuWZuUCH5VTltgNIR8JOiw68vnQc/mmjRL0R+hJWPxS Dqj7sdu4p9fgtW71tq2acbFtvgIwIS+KcTUjHrotVN/yVR/dZRkf2/NTlNH88FSujg vs/cboP6T/die3KPnUcQ3a7vLIHFQAd7vhxELPhr0uAgH0yLI9u4oj4KCueAQQtQ+j hfJa1OSHq5027FOLujL3t3jPAv+nnvPLuFDnOI8ZBS8pVQPq+XweejJbEpa+AAFBUE 9ODKZcowCZRBUoWE/Qunc4kTxmTQBQGxTG7Ktvz9eiAMTsjs7iqp18x5xpqq67Z7H0 NU6nTU1sOW4uQ== 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 v4 19/22] mm/zsmalloc: introduce __zpdesc_clear_zsmalloc Date: Mon, 29 Jul 2024 19:25:31 +0800 Message-ID: <20240729112534.3416707-20-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 1C42A40027 X-Stat-Signature: b6prdr5ag8zoywahz8d1gcbw5dqf9dg4 X-Rspam-User: X-HE-Tag: 1722252083-667150 X-HE-Meta: U2FsdGVkX18Sqvi/UsvpAMFh1fVGEbRu2pJggoJ6AzUyVLOgAXOihoNUoRvxcj1F658levGoFTWtHoSAYKZPtMbqiLI9MOdvETW2Ds+GlCn0ZQU+j8qeURtOLaoggfCde4jINC0qyTkKrqeAv/gBZfCXrdLikh8rvK3/PF7NtxVVuYsf1Clnvl8++XuBc5A2sR4QmC84gWTiR0Ram2QLSGVGiRPj5fg6hV6Vs0lLG4RiB99nCM6ugec04zMiS3Hh0pnI95WAiq7jghC62zsTkpwxlbfTVMS2Ak+E04I9Kci+147hKDq7gM8EUg2GWbyZlcZAWNVnxHe8ZbULu7L3djLzV++jRDJT4giZ0bUXjHvBEewxqo0I1qjx4n64MlHl5jU0M0yyBPu8p8KaLXwKB4v6AFMorXWm30ctEHvf7lHN68NSNcdB9L0MBTL6one4DpJj4QuSS0iX56WLPyqAiiudOxPqVJ+pEjIFrAPvizj4kvO6/ctQWBAx7gqhey3hVpGv+pSTayXmFQatXzIMwWG5IerY2DC2bIhcB8J9KNCMs1vGjguhn0+956RQc9OarSEX+xQyJGljacrZG07HQdSLTY7QX1HbYt2Kq/D8C8uuDn+j0fezaPncISuKrRnupVe2XZyrct93X/5vkza8iUthSD4sn0wc1xKmimje/639fzqVd7DaGu9zTI8lTlhW81Xa1G7Yyvp5BRCgZTwSJuss2sp8cXR5Hjp/tF0lYtbdwnS6OWenbuU1QuGCLgNEDF6LFFxxbFMc04XkLbgvkyTyxzs3drNaEOOjayNdANwT6v6jDm6+eTo1IkcWsv2OhNru16yEnkXnRrSmQ4O+rK7U3z7Oe8Zz3BbOXvftTtJA7GAUI1Qgv3w+9z7Bxeqou5OHILxF2HyFel1D/NXGedqDxQ+qXYf+8/oorJy7gxiDN3cvsu5Ih/isU3M5uf+SHnR91AtyAs0d4V6ZTvO tS8YRmMw NXJTwc/t3Rc0HFTbLbKCrXy5vL9GamevV/CDwPnG4IQprczjRrtwYKavNW/5laKXDiMMJxccqQKBDeln9rovR/Z+TB00s5sWok7bgP59eQEmK4vnzHQguDPc6peGx/Bkv9YLkh3sRweTcP+FOmYedXTak417T1ytP8u0itnBfz3FIJgZadzrrcizYP4SKcDqohukpAW2SD6HghqriCnMk/pxf3WvUwU44cjzwK5uHFLExUIuI53PEotUNElDhPK7SRxgM37TtInIe8QH2+b35En0xyrWgvQOG8vcjhfpVrjRvhsaQQQAiEVXDdSqUWSUJdVOxQWUlf0Eh2Yzh9lV0pg33xmcr8V5U3PeI X-Bogosity: 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 Add a helper __zpdesc_clear_zsmalloc() for __ClearPageZsmalloc(), and use it in callers to make code clear. Signed-off-by: Alex Shi --- mm/zpdesc.h | 5 +++++ mm/zsmalloc.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mm/zpdesc.h b/mm/zpdesc.h index 5db4fbe2d139..05def4d45265 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -119,6 +119,11 @@ static inline void __zpdesc_clear_movable(struct zpdesc *zpdesc) __ClearPageMovable(zpdesc_page(zpdesc)); } +static inline void __zpdesc_clear_zsmalloc(struct zpdesc *zpdesc) +{ + __ClearPageZsmalloc(zpdesc_page(zpdesc)); +} + static inline bool zpdesc_is_isolated(struct zpdesc *zpdesc) { return PageIsolated(zpdesc_page(zpdesc)); diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index e1d3ad50538c..d88602fb0233 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -851,7 +851,7 @@ static void reset_zpdesc(struct zpdesc *zpdesc) zpdesc->zspage = NULL; zpdesc->next = NULL; reset_first_obj_offset(zpdesc); - __ClearPageZsmalloc(page); + __zpdesc_clear_zsmalloc(zpdesc); } static int trylock_zspage(struct zspage *zspage) @@ -1024,7 +1024,7 @@ static struct zspage *alloc_zspage(struct zs_pool *pool, if (!zpdesc) { while (--i >= 0) { zpdesc_dec_zone_page_state(zpdescs[i]); - __ClearPageZsmalloc(zpdesc_page(zpdescs[i])); + __zpdesc_clear_zsmalloc(zpdescs[i]); free_zpdesc(zpdescs[i]); } cache_free_zspage(pool, zspage); From patchwork Mon Jul 29 11:25:32 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: 13744742 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 838B6C3DA4A for ; Mon, 29 Jul 2024 11:21:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 040B36B00B6; Mon, 29 Jul 2024 07:21:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F32DD6B00B8; Mon, 29 Jul 2024 07:21:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D5DE96B00B9; Mon, 29 Jul 2024 07:21:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B4C856B00B6 for ; Mon, 29 Jul 2024 07:21:25 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6DB7F802CF for ; Mon, 29 Jul 2024 11:21:25 +0000 (UTC) X-FDA: 82392549330.02.05FDA2A Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf30.hostedemail.com (Postfix) with ESMTP id DBBD08001C for ; Mon, 29 Jul 2024 11:21:23 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="hUHlbM/T"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf30.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722252044; a=rsa-sha256; cv=none; b=iTc/lfN4lrZGdFz8+WmjFEBHP86nVm5Acl9qrkhCS5XGrTaPgDquD7WWG+tYbHmndyGq/z w/HwIKutZC6fXjRZ6WF4haQetNdv1SQ6wlzGwQHGj6xRA4DiMcIiY9EKaEQqINlGWykzsq 4jG1mOaSb6xbLO1HWjofx26eZXAvhKg= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="hUHlbM/T"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf30.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722252044; 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=9AJyJQMNBE4AqPVQezkcYoW4glyqNYedmb7MWvUGoo4=; b=3Mv3D5bfJNp6H+ibGUIRDJ3aJWDCz8KxFeSVvyOPMAmsv7vuTVgPQeAxRQzWRtHXIiL99Z YyTnTd+y8kDLhA0ZoS90Qaa3FSXlL3I37Tbtg6EJ9ayqUq922eomRq29218VLC8X6CazNI kPR65u/W7BCEFN0yQvlU4lX3aIVhRRw= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 26A8A617A6; Mon, 29 Jul 2024 11:21:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33FA2C32786; Mon, 29 Jul 2024 11:21:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252083; bh=U4TlC31Eh5dq6Szo/Iu40dA9+YSQztS7ohMuHhtrtaU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hUHlbM/T2v2RtXsHmp6QIE6F/mi7q6Je8OLzlD/lexCb2P1pX21JgHzDv/TbkSYP7 j/i58sijth6hxlaay3bpDMXYY1XTUB32nZXeDQI4c0iNeq3R8hqJif09oqqGFIHW03 ycgzafFlbbUM7z1E/+is1BED+Izlg3fW34+e+sdv7n+eawGF0JgSqqNp/X6hI06t5h 5wOzG3uFnpYyb7tHw6LyNAC3dMteobqFfLN1K5RoZB9LszFDuRCtlc7BElwgP1BgeK EliDMwNkMg93GXpaKvhxPKwZSgj8Go4CcBcdrVaY57+nI4Kzh5Ueooo/GqGxUhgsZ9 XljEaxsXtUaRA== 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 v4 20/22] mm/zsmalloc: introduce __zpdesc_set_zsmalloc() Date: Mon, 29 Jul 2024 19:25:32 +0800 Message-ID: <20240729112534.3416707-21-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: DBBD08001C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: wodwrjja8b4qfhpsqmmktytjeyb4gdcq X-HE-Tag: 1722252083-179959 X-HE-Meta: U2FsdGVkX1/1ODiBseIb/dq/dYK/TgoqkoVvaBoHYeA4b6bMmqugf/71bL+GYEiNauC59xl88Du7ilnA4Gltrs19D6sF0CbpkmeSJ4Gz3h/AWACBkYCPUQrm9kJAs3nlNdVwFHFGHmOsy2wY9yXuNBB0bKDA2dJLe25dxWBH9ni4LDztBv9jfWrceb2y5AZpPuxZz6Yb/ON0tjxYwLAzrDWsZUDJPOZo/R6MC/eMVlAo9IfVZL7ZVr9XA9nDGO6FmDM7Dr2pjIdzM2L/JFoj18xxVQ93oWHiOob6d4jfhE/TeAccAu6u8QrG8j3MuEp1dOZ2DXML6DP052AyN+GjRTPfZdLjUGF/TCxRUEeaPeR84jrprqzG/6xJhh+Hqt0tLSeGoTNBXut1ckkFCHnri8Du96B0Jh3JTCMHvhEgSHRFENVAQ1c/foKIe6Fw0dJ1rngmoyOaVQE4z6qRYjvQUzOHplbb6NedjnVSSoZdKoSHqCgtbVG+7OgJjAyRpYlpM9PUXzVHzrySrJXxFciCpO5kUVl9UdW4DDcHGJ8wNjy8K+PC2N0jwK3tyTJvfOv188gReWIh8zaCG/dfIJNe7v58lHT2d2HBxfAfn+/UELmFk8uORFeBtkWme44Jk6eg2Wu6p66zacDuWWUCzrk/M/BR5MSigfGHbm15pGgIkWJ1iNsRsMVpDCBFy40Ukl4EFa6ZY/h5FX7zujITxIFx87oC/iC+HBfIoAtNKUpz/ohGpFdYNOLCtWp3yK3p7V4jmtXjrhxX6hkW11ormSINWh3tHGGa7WVmBGlgimGZYOA8t9OCfmSofFl3rrL8DU0YNalrT+TZDscc1kLIdJ0IWhViOQfGfey3scI5W4TFuOLrN395p/0KmPohQ+oJm1Z9mNw+gX6PdUISqjROZvfOaNAR+9xP+nljfsa7wVfIWD8MgKMKoI5NqTlDr+f9HThPOFzxl1/GQ2PtsQ76ROu sXmx48ee hfq2nAP6OEbrTGZS7EpwbpHK8+1IwRBRKH1EUJdamBrvl2cXgX1HhhZWFSoY6YuVw5NrfoyLajB45bxD+VFx9K8XjHygaGnsqndj1mlZltRNZm+2gpVDlmdxCmD3teWbF7LjEUOyhHkxtZM7VJbe93XHjdrIFhqPyAPetv8qYQ8VE04+b6+T0yLZnX+IV19ur6KbSaDjgV7ino9zGh0TdU8Hxy4MOIpp4aAtLKD2/JLVfNW4JorVVF+aFO1eiUs5RKVS0h/xlG2RsS8lXdQYav/+W8ufhE/z7JVJ/lMfPFVEzlc7qf1PmJ/l4dOkM2qwJchyMMfN7Wh2Vd9Hvaz1zm9JvkDdMUMAcV9HB X-Bogosity: 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 Add a helper __zpdesc_set_zsmalloc() for __SetPageZsmalloc(), and use it in callers to make code clear. Signed-off-by: Alex Shi --- mm/zpdesc.h | 5 +++++ mm/zsmalloc.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mm/zpdesc.h b/mm/zpdesc.h index 05def4d45265..06371ce60cd1 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -119,6 +119,11 @@ static inline void __zpdesc_clear_movable(struct zpdesc *zpdesc) __ClearPageMovable(zpdesc_page(zpdesc)); } +static inline void __zpdesc_set_zsmalloc(struct zpdesc *zpdesc) +{ + __SetPageZsmalloc(zpdesc_page(zpdesc)); +} + static inline void __zpdesc_clear_zsmalloc(struct zpdesc *zpdesc) { __ClearPageZsmalloc(zpdesc_page(zpdesc)); diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index d88602fb0233..7f8e02df4e3e 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1030,7 +1030,7 @@ static struct zspage *alloc_zspage(struct zs_pool *pool, cache_free_zspage(pool, zspage); return NULL; } - __SetPageZsmalloc(zpdesc_page(zpdesc)); + __zpdesc_set_zsmalloc(zpdesc); zpdesc_inc_zone_page_state(zpdesc); zpdescs[i] = zpdesc; @@ -1820,7 +1820,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, VM_BUG_ON_PAGE(!zpdesc_is_isolated(zpdesc), zpdesc_page(zpdesc)); /* We're committed, tell the world that this is a Zsmalloc page. */ - __SetPageZsmalloc(zpdesc_page(newzpdesc)); + __zpdesc_set_zsmalloc(newzpdesc); /* The page is locked, so this pointer must remain valid */ zspage = get_zspage(zpdesc); From patchwork Mon Jul 29 11:25:33 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: 13744744 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 1A805C3DA61 for ; Mon, 29 Jul 2024 11:21:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B89C06B00BC; Mon, 29 Jul 2024 07:21:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AECDD6B00BA; Mon, 29 Jul 2024 07:21:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 98CC96B00BC; Mon, 29 Jul 2024 07:21:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 795886B0088 for ; Mon, 29 Jul 2024 07:21:29 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 3874C1C0C8C for ; Mon, 29 Jul 2024 11:21:29 +0000 (UTC) X-FDA: 82392549498.15.78361E2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id 7AA981C000B for ; Mon, 29 Jul 2024 11:21:27 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Q1CgdvR2; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722252044; a=rsa-sha256; cv=none; b=evvLv5dPms0/3G2XECl3l8nRgUEbFk46dugO8RyQjAZ0vI0HaVZYFwjgy/9b069Dd/hpbe dE+DmuW/SwkXNd9tMm8KGwzixnHyLbOLAxo2uOjB/jNSVrsbwnxWmANVkiyo4TbCIfrK4D bVUDi5KpKi1zz2QMKfU50vbF3UR4zg0= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Q1CgdvR2; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722252044; 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=B1n40j21H3rlLYzer+9c9HErHW186d/2a6ccxgSeZtI=; b=o9JkgXNUfcY2g6qq9BGG+7sg5yg/Jo4BndnXKaG+YvLPTQh37IyUJIFDBIzf9qGc5nJ6hY tLtYDtDu27K0UcBBJHqwvjgIeDvoKWj3hAMVJVCwZQpGG1MGiaujkqxKlxKb4ZuLCD9098 bZUc+wIkxxb8GlUjMUM6I3yov2puAe8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id AA67A617A3; Mon, 29 Jul 2024 11:21:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 707BAC4AF07; Mon, 29 Jul 2024 11:21:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252086; bh=lHz4+kv9JsOYqs60tdoZ6ATt9ROlCYt2854vH8gmrb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q1CgdvR29F1u5T1ro7OnwYP8ZI6Z8m5hqoCiuU6o2r6/Llckc5OZClzt+xtMn3slx AFvT91UPiTj2FxS6Alp1vxaZ3e++kWdf5oS7M3Sj3DUCwEoJth7Ceb7JnkuabRtR0l R5iECzCnEGJmmx8aarCKgA4UNXSt71i1vHs3BXW+pArZP4RaS+ZMO6PZT+855B6LaB 9BGgI25HnzxXeJBvgkW+SHFyRqJ+tu43jYM6AEzD62G+fWy02YX00rzqkL0+2y4ACp 7UEsjmUXSG3nhoO+rx5BV2wgsV31LrkbcwddZpOqClNWsrD/liVk7o5QAksSAwuHQZ Db5SyjD/FlHIA== 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 , kernel test robot Subject: [PATCH v4 21/22] mm/zsmalloc: fix build warning from lkp testing Date: Mon, 29 Jul 2024 19:25:33 +0800 Message-ID: <20240729112534.3416707-22-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 7AA981C000B X-Stat-Signature: ma5nyumtf3czpne3as4915awxnw8xq5f X-Rspam-User: X-HE-Tag: 1722252087-566856 X-HE-Meta: U2FsdGVkX1/qtkVydWOIHk3LErW5lU3imj8GF5TfkgN8rZ1t3fC97WzTrerTIkK9iT/XTRm7zHyJLXXpUstiwUN50RR7b5daekkKuPesURkpoohyN6BOcKDmxVJcE35bzMWW5vZlTuCKEPl9qZ4ODYVaCSerJRP+A091CwMcboD3ydEWNF8QRsYy4Mrq9dW8nbgzLW9fVjdBPCUiWCr3D0JPmoDSB2wgbG/yKe30/LvbqvbI1k3QsuG2WD7IKmUZJkQXHcfgAMufoh825ZB0NS96hw4fHRHes1jvHlTcx6NFgYwFUjz8dF0qosvDHxRs3jI/ixjURLcwRkodSAFSzSJIritcg+Y+c5JUVqTTGW/+oCpNCYrNRBNHcS2AyJFC4Pe2dJxFn3vKecq4QjTnQADNFoQLvwNQEzrBPuJ/nCPHn/Qn5MvNYHxSBUwHjW5mJsRcEnngS4M8mrApILD9vubIp+q+CE6ZiElYCF6pzOaCrwVopKScE9svW95edFO9JaoUBujDPzKTP4HN5WzvBnblVycKGRHhCj34lgPvfMWFzr33VntF9Y+nqUaJkmehvGrotjqmQ/kUq4dZ+Z44nWUaa3W/U0Mqh5pcRtZ8w3731AfEhDVzjgIbl6fZY0oq0L3XGWo5SEUukrZle9w1LEc4ganhR7d4n7efRNaemEF1iDpqkR1ft/5ggnHORrUbamRiHGUA5BnPFikTjqzg/MU7kcfPpMdlto6VtPBgCeM9+gGeXVZwrurL8YBzo7PvNsBDHZ3bBNC7WAtR0fvH3sPTzvpTm79K4rg22Pf+vN/ucx5Kz9BB8P9UIOCKFPhKda9eI3MeW89p2QxtVoTMqiwggZt4hhuwvxdWCbflAAbFNGGVzGhD6RpsbJy42lc2dbewchx/+t6EIUocpGNEAK7ELpN0LOc55nyFyouFkCOxbVFmjaJ77IWqohr0I7PrD234Cuv2Y0PuqgGrg45 3MnYGXrb 2/C3gDX/0psXfK8kbVWxeKewJqZ3SVqhsmygfp3opU45+NawPHDeQMg7zkFbLs871eheNdZBxfR6f9kD0RM5ryARh4tawis7Rrrcf2hd8zHYsNDbcpVhtauYgNNip1fAUxtBgfWv6BCY1NPL7GfkNBEXQ1JJvKrwuhqzkvPk0lNd2eIdsPyCSaVcfqo7BkT5R5nEX/dOB3VgVFVbcW5MhE8UyAn7Y7551IlZ308KGQfGf/CrZS2u9qA/cI49OB62BIbtpcOtiwzFEXHyHJZuoOQ++XEZp6WwIW3LeirFXxVZTB4YDsBlX3rZ7wkII4VnBuXdsTkBwWGFrlZA= X-Bogosity: 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 LKP reported the following warning w/o CONFIG_DEBUG_VM: mm/zsmalloc.c:471:12: warning: function 'is_first_zpdesc' is not needed and will not be emitted [-Wunneeded-internal-declaration] To remove this warning, better to incline the function is_first_zpdesc Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202407052102.qbT7nLMK-lkp@intel.com/ Signed-off-by: Alex Shi --- mm/zsmalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 7f8e02df4e3e..64e523ae71f8 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -468,7 +468,7 @@ static DEFINE_PER_CPU(struct mapping_area, zs_map_area) = { .lock = INIT_LOCAL_LOCK(lock), }; -static int is_first_zpdesc(struct zpdesc *zpdesc) +static inline bool is_first_zpdesc(struct zpdesc *zpdesc) { return PagePrivate(zpdesc_page(zpdesc)); } From patchwork Mon Jul 29 11:25:34 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: 13744745 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 CF35AC3DA4A for ; Mon, 29 Jul 2024 11:21:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DAD9E6B00BD; Mon, 29 Jul 2024 07:21:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D5D1B6B00BE; Mon, 29 Jul 2024 07:21:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B62A76B00BF; Mon, 29 Jul 2024 07:21:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 8B4C66B00BD for ; Mon, 29 Jul 2024 07:21:32 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 3F7D0802C6 for ; Mon, 29 Jul 2024 11:21:32 +0000 (UTC) X-FDA: 82392549624.13.75A16DA Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf08.hostedemail.com (Postfix) with ESMTP id 9727C16000B for ; Mon, 29 Jul 2024 11:21:30 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=hRs0YtQX; spf=pass (imf08.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=1722252038; 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=8/lHwzwwUkHEYMClxl5C8LP0fLL3XtkQXhSCyjQULWk=; b=X2/rQW8/DpfRC2Jc//0GeiJTvpLeGpH0/aGg8+IrVFeLn0e1yVIVp4n2tMUxkkE5+pix1W Bo92Ng97nTJx3dr0AkD2XyOdXOAqGNzMrX+d6LFTHKQwGlPDHHA4pwRewC9/yPEo4QKdVS fYiVxM/Tx3FlRSxi7S17boTmXEI0in4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722252038; a=rsa-sha256; cv=none; b=PbfSdhrfHiIxHgYLNFEdO41ZruyMnS1YkHy4/yEBLkeY5giuhftRseOXjFPFqO8rB6n6xj XGRCW1FSm7amfG9WsI2ejWsYXgIXQ0JM7qtLx1VT5UCI666xCpfiVt0fVYKQDoj3PpzMON kWNf3oyNz8NdMcudDPclcH90ePqlP0c= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=hRs0YtQX; spf=pass (imf08.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E44D56177D; Mon, 29 Jul 2024 11:21:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8204C32786; Mon, 29 Jul 2024 11:21:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252089; bh=rElfU0d71iABwZ67rvpmRaqaEhOUs/Njjel6X7x+ZZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hRs0YtQX+izREwBhLyXvqNE4b9sY2v23cdCN/KVwRcfz69oPiD+Hvnh90SwhTsaPb Vkx9r2ZgMQTy4rmd0MnKCimmI3w9vx/KaFmcPpT3SCdLMXKPYzhSEKbXTYzzNr3oN7 m26rXcx/pzAXE1R5k5eAqJYKMvinugxhBLA8twMfBgA+zJMoWYPl02pDo+cWmUbHLa Dm5UOuCX5Ae3mcSJ3o7Ckxn/IDqSbGnvEiu5bcPkEHVnYDBb3x2T6p1MDJsrdwE0E3 yqlmrYcH1BamgQHFciiWbXWkrO8PfJIgvAik/Cpka48aj+BCo5XT+UZrbc0mlt8Fu+ Okqo2hQrbz3mQ== 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 v4 22/22] mm/zsmalloc: update comments for page->zpdesc changes Date: Mon, 29 Jul 2024 19:25:34 +0800 Message-ID: <20240729112534.3416707-23-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 9727C16000B X-Stat-Signature: o4skemp4be9oh8w3rcpjrk9mtqmj6iuf X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1722252090-569858 X-HE-Meta: U2FsdGVkX1/D4pYSSAFqeNksPHbnOSqgMp1joyNWsoXQbfNh5WttHnXuU40tFNRErMlvZX/Bg9GEzt0Z4rZyE6jwxu2xG7CPAPBCtA2lamwxbL7UQ6b4D8KfUgOcezFHEu2HNWQ48M6JgbJaIgmUhWZjXMN25Z6pbCD8F4aHsUfIJMGWRDuwW/Vc5FspALcnGXC1PPCvPo3EqVRRoiUwOCYtIF2hlhZf8K1tK/tWRbjOqZmRZptN3DRkezcFwU9Aexen+5fLOW6JID5ARUuJF+VIZ1nzSu+cpfSt06JR1xVzMg6r80ZTJ97KtLiYpABfNYjuFNwgsK9VCxxj0vdFuphSQ69AYLMRHCqREz6pXWv2dyb14VkjPZtMtBDsd50rK3riyVknr8Obh8jzH32QpKOauW1pEcLRESD3yjGIiX4GK+eCYdcWa9SN9k/5f0YviqShCrDVXewbgAwJS/x53simUlmI8xxrgBs9Ta18djDELb80AdQRcok07uvbbCO1l1BXamAbFZ4WXILD2DmgPSE6HSQ3sN3locl2qPvB/4kA4VYMe9hpWiHAk9M0UnvHBLzJhkCtfK5s0rxld4+bs7W7pfVAXxasjclmp5UqFuLEIAHHn9YqwePrla+kxp7naxo1a22JDOfR9i3qyVfDFOgVECsn07aj4kOfL+/vC0Jny2tqSzOJ1Rx6R55g9NHTlHZkz9AIlNrBSQfrf7tCDD2WzKNMsJofd04yXKYDMNar10PiqZgGBFwzkLfYrWEJKh6vX2Xjy27Te1c0LnkPlwL8q6wGsgTY9G4A9RmoxxUQb09vGEp6GChTYqyZN9HUxsJiJJBpXc2pp75my9dsIEtDW+ADjo91rI0iMqGRreVYdEKVIaDVROAd5ZF6cJhjgvpZTTHFpt3O0njz69AtImphCVIkVmgw2zZy99u/E441hQ8mXe09zyohp1bKNnJJWic54bKb+WBAltAyPB+ WLmNc4Us CaanY1M0mS8pueHqcusYTwtvbWlD1wIjcHG6Vy9re94Tl3GXq8tM+uDJt7wsmbhg6CQ4WozQV76GQIbsC7UkslWNIhLbfI+s8Motd6H80IiMbUyes6GrOTiW5RWZYFcMEJjx4Z2cUs0RCmcbtskc0nKGaiNmk3fOOy4Idyo6piqj53ZY9Jlrr7/Hzt32R3RYGf0upxdV361mrELTcaSX5/WUpmrBnEHgt5oXtHqqj5Cio9nM9LVaz4e3ZbJhNZK28OtY9kg9Fmn1FxJrPhGJ9heRcn+lo/2hPy+5gOj6bP4BKR731LJ7NDiJhgg== X-Bogosity: 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 Signed-off-by: Alex Shi Signed-off-by: Alex Shi --- mm/zsmalloc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 64e523ae71f8..50ce4a3b8279 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -967,7 +967,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; @@ -976,9 +976,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). @@ -1036,7 +1036,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; @@ -1363,7 +1363,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); @@ -1783,7 +1783,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))) From patchwork Tue Jul 30 12:31:57 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: 13747346 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 B938AC3DA49 for ; Tue, 30 Jul 2024 12:27:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C2946B0088; Tue, 30 Jul 2024 08:27:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3721F6B0089; Tue, 30 Jul 2024 08:27:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 23B166B008A; Tue, 30 Jul 2024 08:27:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 04E3A6B0088 for ; Tue, 30 Jul 2024 08:27:45 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9F27A16029A for ; Tue, 30 Jul 2024 12:27:45 +0000 (UTC) X-FDA: 82396345290.29.6CF300B Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf28.hostedemail.com (Postfix) with ESMTP id 018DCC0020 for ; Tue, 30 Jul 2024 12:27:42 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=CL4YamNW; spf=pass (imf28.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=1722342408; 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=0Zue9HC98XpUEOekFfNgJBL83dFJyjOO75Yl4tyINhk=; b=WXdXDK+87y+n8mMsUhIRlrQr+TDuGFX+D0ZuNlpBEKCtdV/3fmeiGhumaFSLKmLc3Fc6Y8 BI4AwGlSkbs5JTDOBU3CBxxBtA2hwqPsiiRtWLztz6K8n6k/ZoC047OKFXUags2ot1LEse vki7B9hyphnqIQjYu04e94x8RgH82Jc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722342408; a=rsa-sha256; cv=none; b=jsNkUPBOpub3N9uRCaUac64g7tpU9WP8g5DFU8tBrauMBv7d1QX7NLc+v0zDLxRZV2CPpW 83pI5cEfxZBfwZpajHP3Dx8DdWVfUGHLV7pXWXg+sEIU+dUaRshBVR6Yok6HXP9e1mwggZ MROXW0DWCkOBAsVmCfR5xAvI78BdRo0= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=CL4YamNW; spf=pass (imf28.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id DCC4061E46; Tue, 30 Jul 2024 12:27:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BC51C32782; Tue, 30 Jul 2024 12:27:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722342461; bh=rBOTxVukObDt26c+er7K24D5TzmL/+0zcqF1Wh3ZGHE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CL4YamNWq/Sh4OpNbR8MweHnWdrmkAREEsaoqPREX07MePcgTdhGqtesC1js1Awty qc2hh95WqP5Pu2/aFf9j/Xg+TNY67MMwk9HzZFVMivzAFZogpcGCd76qJ25KXj82d1 T3vhlM//Y30II7zafEEvIifpvK/iPqFtr5k+J9fmGCHE9rpIKuPbur7mU/3eyUg4pz VoPNv5r87i0T4jm2kHnDon8VU8AJG4VUOBIUvTgeDhaP9Ym5aL6N1B0iMt2ExmNbnt QwzHKMzrZVJCeO6AAliH+4JF/TsjzXH+2OkCp603oaAukOdkyqqSWT7Iv39JtP/ULI 1KluTFaLBQB9A== From: alexs@kernel.org To: alexs@kernel.org Cc: 42.hyeyoo@gmail.com, akpm@linux-foundation.org, david@redhat.com, linmiaohe@huawei.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, minchan@kernel.org, nphamcs@gmail.com, senozhatsky@chromium.org, vitaly.wool@konsulko.com, willy@infradead.org, yosryahmed@google.com Subject: [PATCH 23/23] mm/zsmalloc: introduce zpdesc_clear_first() helper Date: Tue, 30 Jul 2024 20:31:57 +0800 Message-ID: <20240730123157.3761782-1-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Stat-Signature: j5ru6d4gxgnxu5gtk4g8fe4r8q5jt81m X-Rspamd-Queue-Id: 018DCC0020 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1722342462-524369 X-HE-Meta: U2FsdGVkX18wCSoz8NZXc+pIEMIrXTweX3/a1y3Al+9Ln3YPgSdvJn5AAtZoTZvEejHuqnPQ6jOHKwHGyEc4EC5gqaY5RGhPdrYLkQnXlhUCVFmObmBkM3tSalN2l0W+L6SGoU8eFtisDoBKPvPhaj7lRIKiwodiDOydtVv7T1irBiJ8GVKW806bcwiU9inxzb1ubj6kU+i7XlTNVSHX5iOpnP+bwCreJOGp4fTgH/I9RTAObKDycWcpXzq1MSHftfQu/KmSQbL3MXSUKJQV4RL7lzjnEgSJkibChEc7vGLxyiwzOc/M0b58mbC4+pna9sX1n/fYiAMttJViBikofcKLx77n7F5dj71pW90EWEHxb/dCvj2IcpTsBGrmUxj9hAyhcDCvKSmmXcZHKhWknZkRvQcXeiB3pT1Yl8eSat/qF7L+6Y0zF5tIJTTy6MItBbg/0Q/OeS1E4y+ivCsvPeAWanZHL1IdOVbiNg04Uwp9RoADi0aXTv41plkXW3ukYPXYPwNFh8cRWrehjo0cRi2ZAPP38lAHOFQoJiOaqpzN+xqPn5WyvMy1ASlG+MgYRBQ/CQAGCaNy7KTvsE1hhO5lJwQaI4rp9cOrg3nYi5w7s2zlukDqpLf2KwUFyrV900HKvrivBYkBoLCcHFZNDUz9AavWIJUZidN0sZqadqFNmGj2AmNYepJsQTHbvujpcHUK4SVuAxKq1OHqFZF+5fnlnNR95T2+BI8XOjv5Xttb3ve1dmCkt20hOiR4AJLM5thd7uf2qopp7WLzbnH8xkCodSHvH4ImbFVd6/i6SEf4c+lYSbyo4uueRCoGBwEHhRWGXJSp8FmE5e7cnbS6nXq8B6DCvnvdgrVge+YUDtFS6Tiwh0iHDpaoq5m4iOJI6OWV5wl7ik/yDbhZgtxGBZ93TTpwFa/xEJdXDOb2g3sFNbyaBKL2OtehNUwt3/qx4vd0G9XdSbprhpzf9tB IU8xC1oM Qq9V+0HBlc8ews2lzyYb324pyA27xtMdJdc3ifdctkhfqtmNvp+Cske5FzT5jgbJ8vkkNW85kpLu2Ukm/sorHHK8yIs4BFk1uBXTLG9uHys6UnpAXIi3Y1634QTWB3B9hpBVj1G+XIHujj+xUeNvEvff6CcruViZAeA0khnqUnrF4lI51OFzqUE1vXg9CvMZBtd+oDweKWcorDjx1X4kPvstsj0tvV4qE3RH9kjPkZR08ByCmdWQyF3NWGDLJMDhrOrLE6jKm9Sy8NeEPfAuhEuhJOdMkazNl9u9376HlVQdG48ggdjGri1MFCP/pm2pOXngbbA8kZz9pMNQJEh7KvzdehWTkFlLbdd4H5Wo5nRPEGh1SruCoa59Ro19NIFi6yPrZ4VsRdmCXwPEFqIZhmzg4PmWtUvjIYSy8FL6o3dTxH0q00leRlivsxBwkMo0EqN2nJRLn/Q9pjKQGTWUCO5epAwu+kcf8UHNaiHWAKYTBKvGbr+jctuNcdp2dSlZJtXD3PGXLgM838lbo0hrQOXvulA== X-Bogosity: 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 Like the zpdesc_set_first(), introduce zpdesc_clear_first() helper for ClearPagePrivate(), then clean up a 'struct page' usage in reset_zpdesc(). Signed-off-by: Alex Shi To: linux-kernel@vger.kernel.org To: linux-mm@kvack.org To: Andrew Morton To: Sergey Senozhatsky To: Minchan Kim --- mm/zsmalloc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 50ce4a3b8279..731055ccef23 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -259,6 +259,11 @@ static inline void zpdesc_set_first(struct zpdesc *zpdesc) SetPagePrivate(zpdesc_page(zpdesc)); } +static inline void zpdesc_clear_first(struct zpdesc *zpdesc) +{ + ClearPagePrivate(zpdesc_page(zpdesc)); +} + static inline void zpdesc_inc_zone_page_state(struct zpdesc *zpdesc) { inc_zone_page_state(zpdesc_page(zpdesc), NR_ZSPAGES); @@ -844,10 +849,8 @@ static inline bool obj_allocated(struct zpdesc *zpdesc, void *obj, static void reset_zpdesc(struct zpdesc *zpdesc) { - struct page *page = zpdesc_page(zpdesc); - __zpdesc_clear_movable(zpdesc); - ClearPagePrivate(page); + zpdesc_clear_first(zpdesc); zpdesc->zspage = NULL; zpdesc->next = NULL; reset_first_obj_offset(zpdesc);