From patchwork Tue Aug 13 08:45:53 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: 13761556 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 6F70FC52D7C for ; Tue, 13 Aug 2024 08:41:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 05EE46B00A6; Tue, 13 Aug 2024 04:41:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F2A736B00A7; Tue, 13 Aug 2024 04:41:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA50A6B00A8; Tue, 13 Aug 2024 04:41:36 -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 B4B456B00A6 for ; Tue, 13 Aug 2024 04:41:36 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 704301A06E7 for ; Tue, 13 Aug 2024 08:41:36 +0000 (UTC) X-FDA: 82446578592.15.82BB81B Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf24.hostedemail.com (Postfix) with ESMTP id C670B180013 for ; Tue, 13 Aug 2024 08:41:34 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=oBiwvACn; spf=pass (imf24.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=1723538424; 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=8zG/EU/V1Tv+2Gp64iQ8usdpg3DGgcILcWSP8Vl3WXU=; b=fX018f1KvgiKYgFFk8X745BEVse7mj8o/Bkv1f31iSTyEe++Hk0zQWyet9iKFnAxf8UuCS ojciVOQz4ddb0awVIzcFbD/3fSrd4gygbYH41s4S48si4AakfZzh8FkUtHPbrrOx9wK+x+ Yr+JQlEMLhRYRnVeWrDti5bjBgh9w88= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723538424; a=rsa-sha256; cv=none; b=IWlz70YKaNeTn6zNq/jdoDR7oKg3CTYQuiZwmnYf4m1K5h0rwopxoRddSCEqdgBftpvojj uAlajiXhRCdoqNLEjPrKPVtf8vAv367A/ODKHwnCTZy94x144w7avuNhoRKdxc4q55oPpn 7IW7vIlOOV3P5H+EizuHWJeR7WYqmhE= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=oBiwvACn; spf=pass (imf24.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 1228F615AB; Tue, 13 Aug 2024 08:41:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB249C4AF09; Tue, 13 Aug 2024 08:41:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723538493; bh=NHbMPinJZbaSf10+aKQqs+WxIPwaHLYUrrf2vkQMe8s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oBiwvACnUOx9fF6WAJKC3Ncc3QfJT0w+4/qElt/JAmOLrk/TUUoDtXszV1zYfezaL mXeZYTtMykO9vw1MJ0ZryLAbrLv1yQmWSXLhYgkk5XkQ2fzFKHYmGgOotSgGy1y7WT 9G+VzpmkPb8FjojkNTnSlkAS7pTaMN+oR7H16qLpjNBHtuNKW1L/c/dY39laZ4V4uf g5tsJyjl2CE3UaiBoR8IUlYBHYpUFtzwYlVR2TXMTSsXAHcyCHx1rinO6IQ+bFPgbJ yQAMoEoXrz+7v60ZL3sHg2Ud0fA25HisV1hIksvPKXlAGbd0LNhCPYuUiX05aaqzKa Vqku0Xt3M9vtg== 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 v6 07/21] mm/zsmalloc: convert obj_allocated() and related helpers to use zpdesc Date: Tue, 13 Aug 2024 16:45:53 +0800 Message-ID: <20240813084611.4122571-8-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240813084611.4122571-1-alexs@kernel.org> References: <20240813084611.4122571-1-alexs@kernel.org> MIME-Version: 1.0 X-Stat-Signature: 3aw1z85h81jicetzyy4md8wh193ikzy9 X-Rspamd-Queue-Id: C670B180013 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1723538494-1630 X-HE-Meta: U2FsdGVkX19uAPWC80wnZ4yj1Pxly6EM2mXumvPo3gnBz6ABKpHavR8Hnh7UorG3yvHsxnwG3dVMHFWL1LY64frwWWkOugJjxjbDmscmAkGnEMQsuN5FlTt6pTOanfr7SwpzptjQM1lrz56WK2UqceImrjH7PopbQMLfQfs+1tMobSj+63BN1WLBdgOWmhMTBGJKx0kXet02LQBzPhQdfD+AhqOZ734ygzz3vZgQ4rYc3isWTT17foebabxGdABWv6KLe4MkoijTUtRxLl/Fqhf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xnI4PK3+Z91rLtYuAUNY4 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 2d0f3d9011ac..69305ddc0e81 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -839,15 +839,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; @@ -1597,18 +1597,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; @@ -1632,7 +1632,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) @@ -1865,7 +1865,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);