From patchwork Tue Aug 6 02:23:04 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: 13754334 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 46D18C3DA4A for ; Tue, 6 Aug 2024 02:19:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9F0556B00B6; Mon, 5 Aug 2024 22:19:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A3416B00B7; Mon, 5 Aug 2024 22:19:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F4456B00B8; Mon, 5 Aug 2024 22:19:01 -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 60E946B00B6 for ; Mon, 5 Aug 2024 22:19:01 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 14480404FE for ; Tue, 6 Aug 2024 02:19:01 +0000 (UTC) X-FDA: 82420212882.04.34F4AE3 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id 72D2140016 for ; Tue, 6 Aug 2024 02:18:59 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BaWMFlpO; spf=pass (imf07.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=1722910690; 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=uWAjWyRacCJyVicWR8YrrX2R+eFZhZcd/reMVPUk9oA=; b=2CevD4g3+pscqmePepZxpih+qStJBpVcISVVqZOGWN4jtewBWFkfBNBzQKBgDr5YE9j9jn +e1oq+mljKkFq1Z9YMbp9LwBBETvNYHuU6Q05ru20rigsgxHe/1+Pd22Pfbt4rSBBH/5K6 3tGUjlHCxBf+IwiNkvszMaLgLqCj3mw= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BaWMFlpO; spf=pass (imf07.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=1722910690; a=rsa-sha256; cv=none; b=m9GM+j4ecxy6ubXww7bpGuH0SNqt7yDcT2t64Xf93tXgtA+EK2LbJtsa/Gvx9ZlLhFQeSZ DfMpCDphXwGO3uUkwPn7H59MtpHbgpqDlVki/a8qkNlZI4L+S9dZbN3FO1728XbJtVp6jD J73+Zh4ngVghTb5RjbS+jKVmIqmavPw= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id BAF8360EC7; Tue, 6 Aug 2024 02:18:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B6A3C4AF0C; Tue, 6 Aug 2024 02:18:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722910738; bh=xBRbiPI9Fj5vFVKbb/yDx6Gk1e8RF8irjBVrIsL9n4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BaWMFlpOOvQxiuUrEdt0K4kqxnxvptrUSrrBTxZQhjnf0InUS+rHp/YA9L18z0U/j o5GFJeiz6YFu/eejUX1D3OwapL+PjeF8zf/2vZEs8ccrA84UfOySV0QI9jatpp15Az xz8nX1jKA+eAf3fiP9Br2fwstLZFEXiPeFHtLhgnOBmcy9ACATYNVDLet8rtdgtY2p fwnDQi+SpyOlv71NA4smr8Y+8jIBLZ8Pa3+WRph3nNejjXqF9EnM9X3i52KFE/XAX7 PJ0RCylZSMz2WHISlIgceqb5JLJl4q0/+QKv7mFavS/oXXL4FUDFILThvNu7v/30Tu xYIIdvUjvEPvQ== From: alexs@kernel.org To: Vitaly Wool , Miaohe Lin , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, minchan@kernel.org, willy@infradead.org, senozhatsky@chromium.org, david@redhat.com, 42.hyeyoo@gmail.com, Yosry Ahmed , nphamcs@gmail.com Cc: Alex Shi Subject: [PATCH v5 17/21] mm/zsmalloc: convert get/set_first_obj_offset() to take zpdesc Date: Tue, 6 Aug 2024 10:23:04 +0800 Message-ID: <20240806022311.3924442-18-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240806022311.3924442-1-alexs@kernel.org> References: <20240806022143.3924396-1-alexs@kernel.org> <20240806022311.3924442-1-alexs@kernel.org> MIME-Version: 1.0 X-Stat-Signature: qt1dyku48xrxf9m7tbw8x11bh6h9u3a4 X-Rspam-User: X-Rspamd-Queue-Id: 72D2140016 X-Rspamd-Server: rspam02 X-HE-Tag: 1722910739-510505 X-HE-Meta: U2FsdGVkX1/RYBzP6cvooQ/ObE/DKdrTUc6/vzRrYaA02UyHKUGcJQkgvotRm21YBMi2lzrc3TZX/uNDNYjDUmqfylzTJ9MXTFdz9G+1eFVSpTSd6kiVcqMYhRg505RXBfsvqORlGWo2U9Eu30+/fm8FuypwZBE4IJ4jxzA6IArdjBbQk97L9Kpvnzeusov8ppfNq5GXF5pN6v2sYNaemPeaVOU6jqW0zi0sO05wQ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7T5smJxO98pboSTPLiFj1Vcm2mKCSLWDzTgpSakgPWkcQz1bfzjDM907CfOzl 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/zsmalloc.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 1c53a58e6473..e2cfee57a39a 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -474,26 +474,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) @@ -830,7 +830,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); } @@ -914,7 +914,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); @@ -1569,7 +1569,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) { @@ -1764,8 +1764,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); @@ -1820,7 +1820,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); /*