From patchwork Mon Jul 8 06:33:36 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: 13726203 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 DD09AC3271E for ; Mon, 8 Jul 2024 06:29:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 749A66B00B2; Mon, 8 Jul 2024 02:29:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F8376B00B3; Mon, 8 Jul 2024 02:29:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 59A0D6B00B4; Mon, 8 Jul 2024 02:29:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 386416B00B2 for ; Mon, 8 Jul 2024 02:29:43 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E08EA140E9D for ; Mon, 8 Jul 2024 06:29:42 +0000 (UTC) X-FDA: 82315609404.16.E78CC98 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf06.hostedemail.com (Postfix) with ESMTP id 99E6F180008 for ; Mon, 8 Jul 2024 06:29:40 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YL80aVHo; spf=pass (imf06.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1720420166; 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=1DflF/ItTzyTCM0gRNFR0nSyEfyNKXkOXyCf3/nI6x0=; b=x+b6GC3EsEn1SWXDHYgz7usuteSfJmhw7cfvsWwTbyPv9zK3yagOEtMewwYmJI0zeQSsOZ IWbOGCmCXUoURDbr82TfOigJ5VOnSYQJkUa0qC/1ykRdsHhycY4GeoZqdLOXsphxnFOTHj foVrTg2mubqm5c9fNoxV+d8ZUIIKTB8= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YL80aVHo; spf=pass (imf06.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1720420166; a=rsa-sha256; cv=none; b=iTT8R/vzFOD8uZ7Zk8Pq4GATczlHwRwhcTbjl/yZhXPaXMc6sIKR+/MdaMwbOB/Uvnbtu7 qp3FSYT/kSEbO9aQI8HbfQvVPqHEocDg4NgSLcxswnLsJAbHtMjnsa+N/mqAoJS4sKM1DC N7zWPlhkSJRtfSc7em6+a6GP/6IsJho= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id F35D5CE0AAF; Mon, 8 Jul 2024 06:29:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 365C6C116B1; Mon, 8 Jul 2024 06:29:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720420177; bh=7eF5F3tLj5M84TMn26AMq8BpyTBKqnCtBSnMwvbth1I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YL80aVHoDjsPpQiEFbQTkgxQsZ584pywl8w3bPOSXFSqwYmZXgdEwogm6GaWDr7Jz IL40gwAKS4R5HieLcR2aixdW1ZSNWXe2OK3CXRIKSoqf6zPhWdbVbWekFTy2yUNuAM qPrnz32NbPsJ3fKvenqrjhmV08ZQio/iPNunbTc3ItLjwdwL7FM7J9vSZcOQxmzurn 6tByRNjMwTTOFDhCdCinryOYpSJDfCLxfgx27Q4A75DaxcaCPsMDUkvPp76JmkCXIH 1/sC7c74gsr+OeCq7Vh8ij43eR84+rzJcYe23EQgfrfR8uwEZSnKwA2xlTFVEXYTcO ebeTPLAH4yTSw== 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 15/20] mm/zsmalloc: convert get_zspage() to take zpdesc Date: Mon, 8 Jul 2024 14:33:36 +0800 Message-ID: <20240708063344.1096626-16-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-Server: rspam11 X-Rspamd-Queue-Id: 99E6F180008 X-Stat-Signature: f5zqxsngdbxbdc57mpqr7rus4teor6ck X-Rspam-User: X-HE-Tag: 1720420180-404161 X-HE-Meta: U2FsdGVkX1+IO2xwOe9c5PMk93p42wEbPCXxGMo/1D9teG1YM0qd88tja4gUhhU5K1cKE8WS0dABT+1UM7F0Q7rtQGMV7J1RiHzAAVy0wjpOo5/uqasuXduZNj7kX4J2La/tyFgYgW1gk6Ckr7tAAzJvenGEUqwBIRrXA5YhgZyH+/4yXXz9hs94nWP0de8JYnAv2ZOwo4CcaqfkoglTqdRu0uv2F5geli2Hzq7ZViWop9ekdn6JgGzwAxNkj5a/PxlSV0KskpwP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Uj6BjbWqB+f2ixuRg== 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> Now that all users except get_next_page() (which will be removed in later patch) use zpdesc, convert get_zspage() to take zpdesc instead of page. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi (Tencent) --- mm/zsmalloc.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 7d039b0c66db..458ad696b473 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -779,9 +779,9 @@ static int fix_fullness_group(struct size_class *class, struct zspage *zspage) return newfg; } -static struct zspage *get_zspage(struct page *page) +static struct zspage *get_zspage(struct zpdesc *zpdesc) { - struct zspage *zspage = (struct zspage *)page_private(page); + struct zspage *zspage = zpdesc->zspage; BUG_ON(zspage->magic != ZSPAGE_MAGIC); return zspage; @@ -789,7 +789,7 @@ static struct zspage *get_zspage(struct page *page) static struct page *get_next_page(struct page *page) { - struct zspage *zspage = get_zspage(page); + struct zspage *zspage = get_zspage(page_zpdesc(page)); if (unlikely(ZsHugePage(zspage))) return NULL; @@ -799,7 +799,7 @@ static struct page *get_next_page(struct page *page) static struct zpdesc *get_next_zpdesc(struct zpdesc *zpdesc) { - struct zspage *zspage = get_zspage(zpdesc_page(zpdesc)); + struct zspage *zspage = get_zspage(zpdesc); if (unlikely(ZsHugePage(zspage))) return NULL; @@ -849,7 +849,7 @@ static inline bool obj_allocated(struct zpdesc *zpdesc, void *obj, unsigned long *phandle) { unsigned long handle; - struct zspage *zspage = get_zspage(zpdesc_page(zpdesc)); + struct zspage *zspage = get_zspage(zpdesc); if (unlikely(ZsHugePage(zspage))) { VM_BUG_ON_PAGE(!is_first_zpdesc(zpdesc), zpdesc_page(zpdesc)); @@ -1265,7 +1265,7 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle, read_lock(&pool->migrate_lock); obj = handle_to_obj(handle); obj_to_location(obj, &zpdesc, &obj_idx); - zspage = get_zspage(zpdesc_page(zpdesc)); + zspage = get_zspage(zpdesc); /* * migration cannot move any zpages in this zspage. Here, class->lock @@ -1315,7 +1315,7 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle) obj = handle_to_obj(handle); obj_to_location(obj, &zpdesc, &obj_idx); - zspage = get_zspage(zpdesc_page(zpdesc)); + zspage = get_zspage(zpdesc); class = zspage_class(pool, zspage); off = offset_in_page(class->size * obj_idx); @@ -1479,7 +1479,7 @@ static void obj_free(int class_size, unsigned long obj) obj_to_location(obj, &f_zpdesc, &f_objidx); f_offset = offset_in_page(class_size * f_objidx); - zspage = get_zspage(zpdesc_page(f_zpdesc)); + zspage = get_zspage(f_zpdesc); vaddr = zpdesc_kmap_atomic(f_zpdesc); link = (struct link_free *)(vaddr + f_offset); @@ -1513,7 +1513,7 @@ void zs_free(struct zs_pool *pool, unsigned long handle) read_lock(&pool->migrate_lock); obj = handle_to_obj(handle); obj_to_zpdesc(obj, &f_zpdesc); - zspage = get_zspage(zpdesc_page(f_zpdesc)); + zspage = get_zspage(f_zpdesc); class = zspage_class(pool, zspage); spin_lock(&class->lock); read_unlock(&pool->migrate_lock); @@ -1846,7 +1846,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, __SetPageZsmalloc(zpdesc_page(newzpdesc)); /* The page is locked, so this pointer must remain valid */ - zspage = get_zspage(zpdesc_page(zpdesc)); + zspage = get_zspage(zpdesc); pool = zspage->pool; /*