From patchwork Mon Jul 8 06:33:24 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: 13726191 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 36A8BC3DA42 for ; Mon, 8 Jul 2024 06:28:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C29C36B009A; Mon, 8 Jul 2024 02:28:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B89F56B009B; Mon, 8 Jul 2024 02:28:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A7AC36B009C; Mon, 8 Jul 2024 02:28:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8956C6B009A for ; Mon, 8 Jul 2024 02:28:55 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 392E81C219B for ; Mon, 8 Jul 2024 06:28:55 +0000 (UTC) X-FDA: 82315607430.11.B255D48 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf15.hostedemail.com (Postfix) with ESMTP id 887BEA000B for ; Mon, 8 Jul 2024 06:28:53 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=sIFBrxAh; spf=pass (imf15.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=1720420105; 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=La+n7rGIuGdFgnpyRwIwda8lqibLhQ76NX4rjz+EkHc=; b=F7BdwZYvCZYxkPvoXXalQ+sjEOywszq8GPo9HjJ9IZ8rtwrEMkTwr77np9Re+XCQJh71yr +BNb1I6unLDYJrLijIoOSy8JY8wwIDGXHFGjAlETMVwETTa7iAoFs84Ih0DcyOkMxBFzXi jv/1+fuNiAFD8e7Iv8ytxteGwBHHITU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720420105; a=rsa-sha256; cv=none; b=asOqkvkhc3+f5aQPpQaW5N//0eNVVTAlOYUNxMje5LWNEwrr2B4+caOQjSFwvB3HhhUm4z Ok6Qvhd4JLEZSxOjIePerg6KNVQPhPguX0QQe47Xap61DsN19GWQNWRz3zVCJ027K2nIOV 8jfLymjOJL3ZsD+k9MCK4ixUZYCgp1c= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=sIFBrxAh; spf=pass (imf15.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id BEB0660ACD; Mon, 8 Jul 2024 06:28:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9EC9AC116B1; Mon, 8 Jul 2024 06:28:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720420132; bh=tmhg+UoGuxLgiU/lnh0EuqzBHj5JgCLnTFMLR6vDXTI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sIFBrxAh+/uE4yv8Zd7MjpS9ccK07cFXKmfpP6Zay+VljtAK9V1ULuV2jXwDkIedx V715o8OO3VX4wzi3m7mMJYZwfQ+fFFf4QqDMjdcW76M781nHLVnMdsWMQb7d9NaqW7 63O+xYhqtBjdx76BJ9dY662CFuFOfHPjOZV81/eUEa5g6yuL+st800m6rL/1u+wORn oVGzoxHA5x+orY+sjaOiWnp3opLoh388Qd+uKplMd6+eVHwHHbWp8cPq5+mzY4eK0w 5I98WraI3cj1UYwMg59uY3taov4j525VdhWGHymwEupsZOqr1iHiN88zcvjLqBSmoe nEpSVZXJv0MNw== 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 v3 03/20] mm/zsmalloc: convert __zs_map_object/__zs_unmap_object to use zpdesc Date: Mon, 8 Jul 2024 14:33:24 +0800 Message-ID: <20240708063344.1096626-4-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240708063344.1096626-1-alexs@kernel.org> References: <20240708063344.1096626-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 887BEA000B X-Stat-Signature: tzfjb4ydt8cf3zyd5aizs1enoz1yphyw X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1720420133-666699 X-HE-Meta: U2FsdGVkX19mp4RDkWF5Z2CWSYscNfK1FZAT/KOuBbNbaxOSjmEYAz5dukqAuMx0j909UU3FotpUyTY+XpCpinoELqeKgKLSfXzBWF8yISnzhDZJqY9cJlJRJz+b4CDNbPqsvsc5HNr33C1D91Kqp6VSH2ZqmKA1I88RP7kVlcMjzWmZNJoAd/5Ga1p84XdN1uflw7h19Bs870TlHajbrFr4lUGg+rj+Qv5WT81j015VcxeX1pxJWTbVOCcv7ZgSG1OS1+XOBnSVotA1jz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qSLvtj2 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 (Tencent) --- mm/zsmalloc.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 243677a9c6d2..68a39c233d34 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);