From patchwork Mon Sep 2 07:21: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: 13786831 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 6A348CD13CF for ; Mon, 2 Sep 2024 07:17:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EBB798D008A; Mon, 2 Sep 2024 03:17:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E6CBF8D002D; Mon, 2 Sep 2024 03:17:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE61A8D008A; Mon, 2 Sep 2024 03:17:00 -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 AA49D8D002D for ; Mon, 2 Sep 2024 03:17:00 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1726D419E5 for ; Mon, 2 Sep 2024 07:17:00 +0000 (UTC) X-FDA: 82518941400.22.DD1EAFE Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf23.hostedemail.com (Postfix) with ESMTP id 724DF140009 for ; Mon, 2 Sep 2024 07:16:58 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=CAfKDYNX; spf=pass (imf23.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=1725261372; 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=Z9k8kc3Inzc/Q35w1e/KpFGxKa6k+uyrWulTPS8rXV0=; b=u5aPoM9P9ON9ZSuvypZJ2jUhI+njwwXZVkugd5sQj47cFh9kEhOaiPD1IVcdZR1V/t98h7 DiSESvqhaCjeMxrjp3W9/rGfy1NG6IkTXkuH3GAotFW3fvjQPV5uWiVteqYjHIvEVec+zJ H5pa6DZyuvr4F2VRPqIepU9QyOnV5nM= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=CAfKDYNX; spf=pass (imf23.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725261372; a=rsa-sha256; cv=none; b=xFt+rjXkdm3+HIE/uiKEH6FZocHC8RfhmiW8xXWDngTzBUgKreCEzuDm1RgpCpV8d9xnoU Zah5ao9xlq+WCwW+oHYc+sGKtMw1wJTVpGPlG/hDP7zxekTL3WH/lXgOvF1y3vfvRzNvup 58r4eVi17q2MEQ4z3bbTsODJwz1S7XY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 93BA5A41720; Mon, 2 Sep 2024 07:16:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 533AAC4CEC8; Mon, 2 Sep 2024 07:16:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725261417; bh=Br29/5+PsdLeZ/2tyuIzR5WeYQvl1vCMxw0jQ4y7I0c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CAfKDYNXjkGUMjjB3LlqQwolWE5LfDVmqwftcV6wvGJkYybv1hqip4//3RUWCXBE0 YopBu9YKpW1ldrbR0e9ShcXXpwmaI6gIc/4ttV2oKrteRG4M1HKS65E20+U+R3o7yM OAltuYv3c4EPwZjcbEtD7NJKJ3LGTe3YNRi3Oa5DHNCXVhHT29BWWzkUcwAuyPHaUG t/uhkkC3MUTgkk3pxWxY+yC6uFQ5ms5l1hG+8G7ElOlF8KBnl1Qga5dNieECRmUhUk 4jwlkCj/prBwfMUZYq9Ht59LMc5RBEF9mj17eEC2zhUSdTCdi4syzKXAvjIeSQEr+b d/CkesoRyrHHg== 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 07/21] mm/zsmalloc: convert obj_allocated() and related helpers to use zpdesc Date: Mon, 2 Sep 2024 15:21:18 +0800 Message-ID: <20240902072136.578720-8-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-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 724DF140009 X-Stat-Signature: 66zmbj1f3mkzou7d8undn3x73a8ufd5w X-HE-Tag: 1725261418-775244 X-HE-Meta: U2FsdGVkX19j2xWjCSC8idwGYT9GeUidy0ivoETuQwV0EM+ruIggzP9cFUL/8KqIiDQU2PogY6sAxI+AzJEvccqcwgyQ1DqQyum6o0+8FNP/cqKBcLNeapwM8JS0vC8kDE48LdBCL/o4bebHzWjjZIFNocn2fbywb75dIey16dW16SR+MAnBXx2S3VWqnfF28/QH82+3q+5QLvwn5jAZiS3deqiXw2i2sFVbVq/3+8eym7DmxNRy8FzTFQTY/nIPey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uzQSdG4OgLysgBVi+i3XGgo2KLlRf0BySNyYIcWz9A== 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 6afc3e642e02..46d8be5cb4b7 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -833,15 +833,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; @@ -1590,18 +1590,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; @@ -1625,7 +1625,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) @@ -1858,7 +1858,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);