From patchwork Tue Aug 13 08:45:59 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: 13761562 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 C7AB8C52D7B for ; Tue, 13 Aug 2024 08:42:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 591246B00B3; Tue, 13 Aug 2024 04:42:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 51E236B00B4; Tue, 13 Aug 2024 04:42:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3928F6B00B5; Tue, 13 Aug 2024 04:42:03 -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 12D0E6B00B3 for ; Tue, 13 Aug 2024 04:42:03 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C2B34A74A9 for ; Tue, 13 Aug 2024 08:42:02 +0000 (UTC) X-FDA: 82446579684.02.65438D2 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf29.hostedemail.com (Postfix) with ESMTP id C9909120009 for ; Tue, 13 Aug 2024 08:42:00 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=SyU1F0CU; spf=pass (imf29.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=1723538451; 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=wvcMpJhOWVpL4p36y+TteGibialMwhqjG3mnLTxXOsc=; b=HbTcepD+iSFWDlMev4py6d6q0qNhkgObgvq8/ZZ1cSKssjsy/uwPvHP0H6jrYjZW40HTRT 4xRMIlZrp66w4mrGBzfmyjXqjD9IH4pfCVDdYuzlO4lOgOSFo09uK2mom1pcbAMw+GxxLA yh/kEavBSHP+19yy0WPjw3Tc1xiByUI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723538451; a=rsa-sha256; cv=none; b=ahUMem0VZ0uISD41v9dStJnLJ/M42HoD6WgVZmePVtDYeXQG3GUsno15kkhiAHN7Wx6Szj Lt87Jv96QYwtL0bYA7W2Un/W6H0mjVcpjyIcfnWKE0PZ6F5bRSFeHiTFGZI5ajQjgBBjh6 YmX2jHk+HMumjlskwEBY9lXM3o3pRAE= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=SyU1F0CU; spf=pass (imf29.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id DE359CE1234; Tue, 13 Aug 2024 08:41:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 094C4C4AF09; Tue, 13 Aug 2024 08:41:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723538517; bh=P2h4TL0al2Tdq16vEvHZlxJuPRha9tB1mdH4uW7GsvU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SyU1F0CUC5fJJ+b0xwqG/Ht51CluyUnYwwigzprVYJCkZsEq4VEoBHyVwwQ2VHi+8 3QoMrvaINRWhJ/usOIFbXtV2ZefP60g2/PcvhoM6VIgi9e9J5p0EcYK7sudn+/ET3Z BiXsmhroLMiO0q5npsqO+h9hJRPRkv/trQP27fIIiGhqhZJt+2OdqFtovOSWnue1zN yc4GNEfoV6BOTJicX27tXNKpte65+7eeh9T6ZKi1C+gw/Wt9/mMOG5Qx6CYVTu3ouo 1qWLwB/0gyxRxR3udXWKOGCr8+5kajpmf1mzvCscAOe45l1aezR3oeHw+vkUDjAd7d Vb9d+lE8wwL/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 v6 13/21] mm/zsmalloc: convert location_to_obj() to take zpdesc Date: Tue, 13 Aug 2024 16:45:59 +0800 Message-ID: <20240813084611.4122571-14-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-Rspamd-Queue-Id: C9909120009 X-Stat-Signature: 78nuj6yp4po5uw8kpz64zczm64954np9 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1723538520-418094 X-HE-Meta: U2FsdGVkX1+MpQzbnDg/fmI/DI9TsjMyo1z2XtO3+giKB48NQU5HsEc679LG+wYlOuLvlrpwcrZxtFuuzJNOuHux7W2JpKVx9SyuU5K/EDTEBnRcJvb6SILyhUvi2dJA7W+FSYQFvkz5N0A+UpWY8E/oB4ejou24tPnqjROcW7myiSljwBY56/3KAVQ2vRw7covtTmFrQPDkUTXCBZKIUyiuGtQ7GeuiLoXNhLJQbZJMTdmveSGaQZvg3SsHPP58abkLMp6stvUqIXOo51iQ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XtxLeCUJ0nQw== 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> As all users of location_to_obj() now use zpdesc, convert location_to_obj() to take zpdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 7b3344c226a0..9218f1e6e8ef 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -820,15 +820,15 @@ static void obj_to_zpdesc(unsigned long obj, struct zpdesc **zpdesc) } /** - * location_to_obj - get obj value encoded from (, ) - * @page: page object resides in zspage + * location_to_obj - get obj value encoded from (, ) + * @zpdesc: zpdesc object resides in zspage * @obj_idx: object index */ -static unsigned long location_to_obj(struct page *page, unsigned int obj_idx) +static unsigned long location_to_obj(struct zpdesc *zpdesc, unsigned int obj_idx) { unsigned long obj; - obj = page_to_pfn(page) << OBJ_INDEX_BITS; + obj = zpdesc_pfn(zpdesc) << OBJ_INDEX_BITS; obj |= obj_idx & OBJ_INDEX_MASK; return obj; @@ -1386,7 +1386,7 @@ static unsigned long obj_malloc(struct zs_pool *pool, kunmap_atomic(vaddr); mod_zspage_inuse(zspage, 1); - obj = location_to_obj(zpdesc_page(m_zpdesc), obj); + obj = location_to_obj(m_zpdesc, obj); record_obj(handle, obj); return obj; @@ -1873,8 +1873,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, old_obj = handle_to_obj(handle); obj_to_location(old_obj, &dummy, &obj_idx); - new_obj = (unsigned long)location_to_obj(zpdesc_page(newzpdesc), - obj_idx); + new_obj = (unsigned long)location_to_obj(newzpdesc, obj_idx); record_obj(handle, new_obj); } }