From patchwork Mon Sep 2 07:21:14 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: 13786827 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 B30C4CD3427 for ; Mon, 2 Sep 2024 07:16:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 34BA58D0086; Mon, 2 Sep 2024 03:16:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2FABA8D002D; Mon, 2 Sep 2024 03:16:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 127168D0086; Mon, 2 Sep 2024 03:16:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E37A18D002D for ; Mon, 2 Sep 2024 03:16:45 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8170C1619A1 for ; Mon, 2 Sep 2024 07:16:45 +0000 (UTC) X-FDA: 82518940770.06.22376EA Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf30.hostedemail.com (Postfix) with ESMTP id F09CC80011 for ; Mon, 2 Sep 2024 07:16:43 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Hwc3Rqz3; spf=pass (imf30.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=1725261356; a=rsa-sha256; cv=none; b=nBRNMbiZyC8i8fQ/PEakP7ZB1hqal9SoKSzR255evqphiDHvRv4VowqgFLQaX6CrFTIG5l 3y2bQmi7Dvn1NVWjUWV7PhZ3uyM3s0dMD945/pbCE/pIaYgTw4vD6zTgnPuav55ZgFNfTr 8XuvCfjXXQwMz9F8oJpmSYIDB+Iq1/g= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Hwc3Rqz3; spf=pass (imf30.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=1725261356; 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=+NRszuVfACi8AQX1aYZ4ZW5Y5ZU31/p/Vio5ThCTz1k=; b=XSTkzPPEVrVeysQjA99XIdPAo9LkFy7P6uPrSByh02c/ccMWTkbJAXwCqfpZvi62rIH3I1 3VMGbn57Lz60vATpV06QQQmGnNQlQGBKYU4L00wWxhbY2wjQYGMgwvibfc1H8fZqkj4lJk gaHyRxxJDyBdMLpuWvF8ZyCy0CxvOMg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 4ADFFA416D9; Mon, 2 Sep 2024 07:16:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72301C4CEC9; Mon, 2 Sep 2024 07:16:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725261403; bh=WINuZGeFx9tI8KdY19QN4OBBU7X+cSgJrgZBdb4m5I0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hwc3Rqz3ixvX3jviF7KczOLII9qkX8ppPQNRek7rHhU8uwwExWu9TBfPEG0Z+d9b5 d1gtCEaQNeEsMRzGfr7gUwCFA1q0jlki4TeEvvDrJaXFnyrwiK2qkSTY3NscwUMmFL V8YeGKG+79ICG94273EdMqDP7cIBali7OEv5KU2y8SpOdC0m5Pv93IVlaBBvAg8goK VDA0Cp+KGinMewjf5gDY3forURqjs1gT8nJ/EqzDzoFaz7AGVA7wePPX69MVBXyFVf 2/az9VA4ty2O5MCtt+zhpVcXthqY6Zq0BoyOOC85PHRjAG4EtRmvCtTYtqX4D5aW+P HNBJVQlZhwv/Q== 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 03/21] mm/zsmalloc: convert __zs_map_object/__zs_unmap_object to use zpdesc Date: Mon, 2 Sep 2024 15:21:14 +0800 Message-ID: <20240902072136.578720-4-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: qg46fzi5ki9iq33jipdpno38xaperwbr X-Rspamd-Queue-Id: F09CC80011 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1725261403-222329 X-HE-Meta: U2FsdGVkX19KvtCt7Mphw4NWZ2i+wIZ9Y+cG/uS8rZM6ya+E/FNhCiKK8CbaH9FzTDw+l480GHb2+fdtIUfC8svLK3FpmMBYG4PWwTVWT3Qty1Mb3Afdr1NhhyLYFuOYHctd155fpncFumIsfZPFxfeQNBctrZxdXXZQmi8PesfLPMFYG5ej0Tm9Fr9mJXK0zojVUr00IQkk8JXIizpUa7t7UelLtLKPkl8OSBBbgqOkeMhZZKZ8oj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jDXlL/um17TybSV2oks/tkwjKgTQkZOG3ag== 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> These two functions take pointer to an array of struct page. Introduce zpdesc_kmap_atomic() and make __zs_{map,unmap}_object() take pointer to an array of zpdesc instead of page. Add silly type casting when calling them. Casting will be removed late. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 9806b1629880..1b49f74fd728 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -243,6 +243,11 @@ struct zs_pool { atomic_t compaction_in_progress; }; +static inline void *zpdesc_kmap_atomic(struct zpdesc *zpdesc) +{ + return kmap_atomic(zpdesc_page(zpdesc)); +} + struct zspage { struct { unsigned int huge:HUGE_BITS; @@ -1054,7 +1059,7 @@ static inline void __zs_cpu_down(struct mapping_area *area) } static void *__zs_map_object(struct mapping_area *area, - struct page *pages[2], int off, int size) + struct zpdesc *zpdescs[2], int off, int size) { int sizes[2]; void *addr; @@ -1071,10 +1076,10 @@ static void *__zs_map_object(struct mapping_area *area, sizes[1] = size - sizes[0]; /* copy object to per-cpu buffer */ - addr = kmap_atomic(pages[0]); + addr = zpdesc_kmap_atomic(zpdescs[0]); memcpy(buf, addr + off, sizes[0]); kunmap_atomic(addr); - addr = kmap_atomic(pages[1]); + addr = zpdesc_kmap_atomic(zpdescs[1]); memcpy(buf + sizes[0], addr, sizes[1]); kunmap_atomic(addr); out: @@ -1082,7 +1087,7 @@ static void *__zs_map_object(struct mapping_area *area, } static void __zs_unmap_object(struct mapping_area *area, - struct page *pages[2], int off, int size) + struct zpdesc *zpdescs[2], int off, int size) { int sizes[2]; void *addr; @@ -1101,10 +1106,10 @@ static void __zs_unmap_object(struct mapping_area *area, sizes[1] = size - sizes[0]; /* copy per-cpu buffer to object */ - addr = kmap_atomic(pages[0]); + addr = zpdesc_kmap_atomic(zpdescs[0]); memcpy(addr + off, buf, sizes[0]); kunmap_atomic(addr); - addr = kmap_atomic(pages[1]); + addr = zpdesc_kmap_atomic(zpdescs[1]); memcpy(addr, buf + sizes[0], sizes[1]); kunmap_atomic(addr); @@ -1245,7 +1250,7 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle, pages[1] = get_next_page(page); BUG_ON(!pages[1]); - ret = __zs_map_object(area, pages, off, class->size); + ret = __zs_map_object(area, (struct zpdesc **)pages, off, class->size); out: if (likely(!ZsHugePage(zspage))) ret += ZS_HANDLE_SIZE; @@ -1280,7 +1285,7 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle) pages[1] = get_next_page(page); BUG_ON(!pages[1]); - __zs_unmap_object(area, pages, off, class->size); + __zs_unmap_object(area, (struct zpdesc **)pages, off, class->size); } local_unlock(&zs_map_area.lock);