From patchwork Tue Aug 6 02:22:50 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: 13754320 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 91AE8C3DA7F for ; Tue, 6 Aug 2024 02:18:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1FFCF6B009B; Mon, 5 Aug 2024 22:18:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1896E6B009C; Mon, 5 Aug 2024 22:18:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 04FDD6B009D; Mon, 5 Aug 2024 22:18:08 -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 DA7066B009B for ; Mon, 5 Aug 2024 22:18:08 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 95775C07BB for ; Tue, 6 Aug 2024 02:18:08 +0000 (UTC) X-FDA: 82420210656.27.FCA839D Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 04BD140013 for ; Tue, 6 Aug 2024 02:18:06 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Y9bMfZD/"; spf=pass (imf12.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=1722910656; 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=tvfnubfIWOPg5/jVB4tsJ/nqmrbqsD7xwKTVAq6YLlApHC6zf5VNlJ0pulK7mzXAhDy7rT ShrtiN9kNkOwF2UCoTfk1IRHHJ0RVZZLEr8e2ENh30XY3xZdD+PAmAx5WBWPRIeXSlN273 JMgJ9FDEOQV8H4GGSRhxlN3n55STxf4= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Y9bMfZD/"; spf=pass (imf12.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=1722910656; a=rsa-sha256; cv=none; b=b8Ktsa3IQmzEmbz9POBLiM2AQfxlxgok24RgiY4dIjVsJUxSHcnLy35wDOwCQ1WXIwopyX HeYPU7QbqBW0P8g+9g8XoHTtpNN+NF5XfzOTBdZVbkTlWZMWU15xOki+JzmlZzcW4C4udV kYFWRLq2Dva6IeOIkQRSVpu6Nbi8drE= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 2E39D60ED0; Tue, 6 Aug 2024 02:18:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD578C32782; Tue, 6 Aug 2024 02:18:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722910686; bh=rMm13SX4aLf3oZ/lBmcjJeeV3CGO+2RCAQN5DP+xGmo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y9bMfZD/5HIEGcjAndQ/lypfE4f+loM6ikbINUx7e4ZVxqmabtcM3IJIvPbKyohqh R0lCElOP1IqSvv4eN2T5KrP+x7QIi/l/v+tKP2fas0PoG5toYLpB4I8hyrj3HHzO4l i3LfF0/shOAC/fAypNubA8AmCHtevJ6wxFiamGL7VuIWUQzJUzakpEWwkMwS6V270S 6YI85bUWbzpkTNsuW+b7q0KKgWs4xbBRXMUf/5dTRjxYEjlzTdU1434myFq2/48qy8 9UhQf2lLEHTOM1xIgk/f1Tgn8WKUcPUokYFcZtIK4WiIPOvpjGiU92Bq4SJtbV7Sl1 uNm1Wpab5IGyw== 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 v5 03/21] mm/zsmalloc: convert __zs_map_object/__zs_unmap_object to use zpdesc Date: Tue, 6 Aug 2024 10:22:50 +0800 Message-ID: <20240806022311.3924442-4-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240806022311.3924442-1-alexs@kernel.org> References: <20240806022143.3924396-1-alexs@kernel.org> <20240806022311.3924442-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 04BD140013 X-Stat-Signature: jk65fpdf1m4ao4otum4u68a1ft3sjbm3 X-HE-Tag: 1722910686-273969 X-HE-Meta: U2FsdGVkX1+bx6QbvEgiIVBRyh79MMkTTRRvbaHZxKbsGWkwKk6N6YsUZ4bfd7CWX4J0kJtnHpJnycRf1vsLZV3rcwzaRwl4ZYQLRra/bkUmtcntyYX/a+S7olPu6zPJ3n5grmtLuNuyMH/m38r3pwX3YS9wN8lC3EnFKnTyoe/4tU7NHCBO5rE4qizzfob+xlWVr6XnmUMfZt+CAX4QCpVn4cg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IgaGNVIPdOc2A1RfE2CLG7c0UKfTnLRgBbcU1xtMuKTD1PaVRo+GATkd7JkhnxcOsovo6NW0y31VYE1tXQm 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);