From patchwork Tue Aug 13 08:45:49 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: 13761551 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 867B2C52D7D for ; Tue, 13 Aug 2024 08:41:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 20C306B009A; Tue, 13 Aug 2024 04:41:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 195D66B009E; Tue, 13 Aug 2024 04:41:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0366B6B009F; Tue, 13 Aug 2024 04:41:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D98696B009A for ; Tue, 13 Aug 2024 04:41:20 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9FD2D1606D8 for ; Tue, 13 Aug 2024 08:41:20 +0000 (UTC) X-FDA: 82446577920.02.CE2E479 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf27.hostedemail.com (Postfix) with ESMTP id 0451840007 for ; Tue, 13 Aug 2024 08:41:18 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="jJgXG5/M"; spf=pass (imf27.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723538443; a=rsa-sha256; cv=none; b=n3dZhnYc587KuYYxyFmINqHeCPSE+v72+hYbns2PeXzGiRlf0yoNrb6o8rOMjhO5fkrbwZ dBbLqM4VFElidkP+WL5Doa1TW2it2fKwJsqJ14986+pUsQdT5dB5HUHh/cjUD8FVrfO95q 14qjlTXTs1f7jEBRovX3sFvgJpKkIAU= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="jJgXG5/M"; spf=pass (imf27.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=1723538443; 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=cAi81bWlDHMmhHwcU64lYTDVUKa+q1KUucaRaXn58z4=; b=PlMgfe7jazp9nNTnbuEbrbs1QdDLDBcspFnkagOx4siTjXdfzrPaHm02WfhYCvO2+x0WWF 8tSyNMA8Hp8FpwU+xpEPPNGlJur51EdVnN2stwuYAwFNKOx625fi5zIth/4t20MqgmQeCu CWyh/LDoni5X/ge4VjTQjV76GzECTR8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 38FEA615B6; Tue, 13 Aug 2024 08:41:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D74FCC4AF0B; Tue, 13 Aug 2024 08:41:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723538478; bh=rMm13SX4aLf3oZ/lBmcjJeeV3CGO+2RCAQN5DP+xGmo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jJgXG5/MU5u93XZsl+G9CJ0mZ5Zsa5hW1D87/ECOlkqHb+Sr7/6G9JpU9JSleiaMM jeO2UHtuI8wPWRVqLVhxb3dyjcW8uiCm+Wre+EoFb8xV3wGDYcMFKa9RWetwLmAfpW 7wGshauiHkGZQEFx7I7wSWteKnO22jVG7YHziDbs66qRtrx9x/JGYl0r8S9g0dUrhw pe6jnDZAoZToI0zoFrugdc2rA141iOVEivfjDwK26VKKJn39xFkNkKoNQ5vYFHKL5I V1bo7H8J9Swu0EPIh8U+xtQC+GvyGGiBC1koj5PQ+iVCqihCzllNAuur2U0FggB05u phlueemlWNrtw== 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 03/21] mm/zsmalloc: convert __zs_map_object/__zs_unmap_object to use zpdesc Date: Tue, 13 Aug 2024 16:45:49 +0800 Message-ID: <20240813084611.4122571-4-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: hqnjsjmxkjoctqnsrt4hkobt3bzmd6u3 X-Rspamd-Queue-Id: 0451840007 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1723538478-825860 X-HE-Meta: U2FsdGVkX1+BF1kevXMGaO2ywGHxNEWmnvH+lfos7t9bgPm2IAtdAorOs5J7zG0bq5N8gjIc8R13dPH/O2/+MDuLQdpfy32tbPUgOAL4bDmuNz01/CBGA7eP1gO0Qoj5XIFUrl81Sl6IgozbIFiCfKchJGFDhMZJfapmqELN4rfreQlHjd/BRP56ddB6R+m5jQoXmMoQMJu0G8T7SEebF+zSonCoZOz/tBw8Y9xgoYvRe7t0UZNOlpYtmksMYC2XU11trfQRgfC3a7nv+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3CuzsLpPRxrHW1K 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 25c90224f21f..b9b5e2824f2c 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; @@ -1061,7 +1066,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; @@ -1078,10 +1083,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: @@ -1089,7 +1094,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; @@ -1108,10 +1113,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); @@ -1252,7 +1257,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; @@ -1287,7 +1292,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);