From patchwork Mon Sep 2 07:21: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: 13786841 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 A2E94CA0ED3 for ; Mon, 2 Sep 2024 07:17:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 324918D0094; Mon, 2 Sep 2024 03:17:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2AFDA8D002D; Mon, 2 Sep 2024 03:17:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 132928D0094; Mon, 2 Sep 2024 03:17:35 -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 E37A58D002D for ; Mon, 2 Sep 2024 03:17:34 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A5AF9C176E for ; Mon, 2 Sep 2024 07:17:34 +0000 (UTC) X-FDA: 82518942828.27.2B2826D Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf11.hostedemail.com (Postfix) with ESMTP id 170AA40010 for ; Mon, 2 Sep 2024 07:17:32 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gQujTYAA; spf=pass (imf11.hostedemail.com: domain of alexs@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725261359; 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=5EFT3knBScgr8IG5LmtuktpfCJ67L+lmDkF3KSnfYtU=; b=NQ7exKMHqPKdI8aQ2ZY0SpKU862dJHmF7VGsCjwVPzfR/xX1BrGEroBvNxvB8WZLuVHA1k uv0+luS4GpwqfGUWO8FBRui/3ULlhBvlJJp63AE7iLJMShNxHdLonXCnGQTJgVfnAfRgN1 Utcl5EIfwjIDHjXz3VWwmAPYWmbMVWM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725261359; a=rsa-sha256; cv=none; b=p5eQBevGW1KPLPmj4K8Qu9CV0b6it6jHXMTmkV+2CCCd7aUauAlnnq/mA1XP8MBVbkUDI2 q++MA9Lkb5xPqtV9Eg1kgk+u9hryDVKSI0AsuQCTZO3Fm1BFS8xeLnB8dR9q+BXOQDPKty qG0QPkMN8xnZVAliP0Ccxhgiw05NOQ0= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gQujTYAA; spf=pass (imf11.hostedemail.com: domain of alexs@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 52D50A41746; Mon, 2 Sep 2024 07:17:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A176C4CEC4; Mon, 2 Sep 2024 07:17:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725261452; bh=mUt+2jl57a1O3x/5Q9wSnZvk6+ZzUwzDrkQBYoscUAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gQujTYAAUF38D+/6f3rqz71xwGDllZgvbzpatRIu87HIi30swSwSE/K0ycx4vmIfl oqE0HY3KHgIE50k9iKI7PrQXI8TUzZPYgpAjpYabGLaVvtX4eEVL8YXBVMy0OBYb5x DpNOctRFE/8cBs7OB5UGid0JG7sHC1jSAOTOdVaee2LWSE6ozbnSHn+RgjVD2KI3fo KrMqJoCwDNOUe+Uz+r2k/5fJzP2DdEmhbb2/VhBxuab4pmB5bfiXjdaRYI2KKOWJTX FPGJ3k9WoBD36mKBgspStCsQzlzxftZjTo8/Hx22ZT38TQFA0rdz/+7aYpDWxNCHVG 3JwYu5XumfIUA== 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 v7 17/21] mm/zsmalloc: convert get/set_first_obj_offset() to take zpdesc Date: Mon, 2 Sep 2024 15:21:28 +0800 Message-ID: <20240902072136.578720-18-alexs@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240902072136.578720-1-alexs@kernel.org> References: <20240902072136.578720-1-alexs@kernel.org> MIME-Version: 1.0 X-Stat-Signature: qzfbgtfainy8ihinhmoigatpzwtuxjsp X-Rspamd-Queue-Id: 170AA40010 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1725261452-894064 X-HE-Meta: U2FsdGVkX19+bRUG7W9w8ab3FV+/q21rMPWNCagtWipehy6I5L26GNOVsrq7XgZB+t0ayC/6zu9x8wXFIZ1q8d6gSPdyXR8V5+MOIJ9Ik58YzsoKrK6Cak73sCsVuYcY+2v41sYvseTa+0Kgewxcb4kToorPKlq/tUUVJIOWGWGywXVmDLEaiLsQuc2kweDMrIoUEP3JXMxSGIGtJkDJy7/hpVt3pQYASy6Acccvk456tfKHgG8I+dfPl4+/h/9n5/Ndo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h/TZyr6fNUzey3IhrTNA== 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 | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 3b98daa63ece..839fe7eaca8a 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -488,20 +488,20 @@ static struct zpdesc *get_first_zpdesc(struct zspage *zspage) #define FIRST_OBJ_PAGE_TYPE_MASK 0xffffff -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 24 bits available, we can support offsets into 16 MiB pages. */ - BUILD_BUG_ON(PAGE_SIZE > SZ_16M); - VM_WARN_ON_ONCE(!PageZsmalloc(page)); + /* With 16 bit available, we can support offsets into 64 KiB pages. */ + BUILD_BUG_ON(PAGE_SIZE > SZ_64K); + 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) @@ -921,7 +921,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); @@ -1576,7 +1576,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) { @@ -1771,8 +1771,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); @@ -1827,7 +1827,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); /*