From patchwork Fri Jun 28 03:11: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: 13715393 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 EA89CC2BD09 for ; Fri, 28 Jun 2024 03:07:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 72C186B00A4; Thu, 27 Jun 2024 23:07:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6DA1D6B00A5; Thu, 27 Jun 2024 23:07:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 554136B00A6; Thu, 27 Jun 2024 23:07:21 -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 336E26B00A4 for ; Thu, 27 Jun 2024 23:07:21 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id BED3F413A7 for ; Fri, 28 Jun 2024 03:07:20 +0000 (UTC) X-FDA: 82278811440.09.3E3ABC8 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf19.hostedemail.com (Postfix) with ESMTP id 85C741A000E for ; Fri, 28 Jun 2024 03:07:18 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=EsLIVXmX; spf=pass (imf19.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=1719544015; 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=9YOZBj0WCGbWMxC2N8ScdBz2jFks4pm4Zy/Mo/8+yTs=; b=BuyakJoJXq1cJ2Kj/U4fFxwY3nfNrzKgMyDqGRZZmw4hUXkYetCe89//rE/OV3baZRuUYu 1R9i6PHZxL6DPSi+yWdQE9IfFY4aQm2a23UX9LxSWon9awPv8QydU388mUpFctEJ7lO7+M MGS/ss/kF+0x/AiXnNTdOF0tMU5Mq/8= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=EsLIVXmX; spf=pass (imf19.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=1719544015; a=rsa-sha256; cv=none; b=6PEPLGgP8GCfO5UBw/I4knTBjaD4B+PZywtUlOR2aYpNdir5luXaLQSYnynCLQD/CIPzJ/ Ppxoo+PlFRCuLRxPqAlxNTgrcOKepJNUDpGj5rUMyY89+2K5mt48U1pURl8NCDDXMeqmwE fzB3fMILPQs1pmLfEqOrhSZ1jJEnAeE= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B29D8CE1390; Fri, 28 Jun 2024 03:07:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 370D3C2BBFC; Fri, 28 Jun 2024 03:07:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719544035; bh=6Pm9+ydZIsO5c9qRiniJl+L1KPC6XDYzIyrZkkU9aKI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EsLIVXmXFHNSPRxWd3m4+VHHl+VjFRdCHM8BTCvp4ASArnVdJg45eBwEpv1PTcc4+ eEJ1NHhHKtGm0C4A8uG2fnOzsLTe/goC7j/F4+vvDSYh3WgGjhkYDVegoswWQD2w4w prk/ypbbDn0J4scwSNmm3arQFeDX6m7bbKum0YUg/hBmQqvW5hthU1GNKPG49VCX5B 49mb0ZY9H9gEpbKIwx/47UF2WqV/ndYyAlhSva5OnEzxDIigPsBJWNOxaqEhf5HIGL Lxx2fFFVNA5XFHqBlSh73eJ7YpfzwDn8cAGEfxmnV26rCFrqUT3RiR/gVjKJDXYw9s cStrQQm3EJOJQ== 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 Cc: Alex Shi Subject: [PATCH 07/20] mm/zsmalloc: convert obj_allocated() and related helpers to use zpdesc Date: Fri, 28 Jun 2024 11:11:22 +0800 Message-ID: <20240628031138.429622-8-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240628031138.429622-1-alexs@kernel.org> References: <20240628031138.429622-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 85C741A000E X-Stat-Signature: nbyfb59rfnckxyq4nq31gk8ma449ib9f X-Rspam-User: X-HE-Tag: 1719544038-52347 X-HE-Meta: U2FsdGVkX19kEVypUTL7AllIrGLX2bhDliL+8qgJMps0MEN0LiEaCA+JoPe/I1DJidXIT6WERi+TnaAQRcmQvC/2aX+ugU23jUT02ZXBbYQS39WjY/GApYI4yrqhFzOfd8Dk9JOtRMyhqhuH40mJukmo9pwy25kQsMLM5JILmiiOkl7LgcHU/Pe+fKat26TqhuRYde/o/VnTIGFDDg7n6fV3cFMOzra3mQKpUlpxAwty8Bs6dQpZ4fzcisO4nwcNS+qnj9amOy+bnl9N8+kXfyk1sjIm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=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 ee890d513f6f..6efaa6279687 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -847,15 +847,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; @@ -1607,18 +1607,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; @@ -1642,7 +1642,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) @@ -1876,7 +1876,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);