From patchwork Wed Jul 3 04:05:57 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: 13721077 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 283B7C30653 for ; Wed, 3 Jul 2024 04:01:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC3F46B009A; Wed, 3 Jul 2024 00:01:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A7DE96B009B; Wed, 3 Jul 2024 00:01:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8CC3C6B009C; Wed, 3 Jul 2024 00:01:41 -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 653B96B009A for ; Wed, 3 Jul 2024 00:01:41 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 20C84140730 for ; Wed, 3 Jul 2024 04:01:41 +0000 (UTC) X-FDA: 82297092402.03.BA264B4 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf24.hostedemail.com (Postfix) with ESMTP id 36EF218002B for ; Wed, 3 Jul 2024 04:01:37 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PE3Mp3iK; spf=pass (imf24.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=1719979268; 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=0SrS60HvLY/N6/E75A0QfavAHW7YWNFLHpW+OVguC9k=; b=I1bec+66tsi5g4auEkOqG2xbl0ffQdifDzC4WQFNNpKKrSQLb5kTAxXkHkUKsRcf817Ubd b2ct9k00c1a/C2rnRjja8qgKFwz6gG1zdgtIDZ9y8ehjdp333REIHd507j8cYWyX1IigIJ 4wruFBW5dQDwjghMcQMdoEQbMJ90778= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PE3Mp3iK; spf=pass (imf24.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=1719979268; a=rsa-sha256; cv=none; b=bE7j8OtnH/U4iw1chLZ/guWTSWxZZwxXeSqvudUNrN2CtK1a55jMZFYAxy8PQx+R94fnw+ tp8pSn+6BpBWd2kBguuLaB4/r97EQ9EmqJcdFiiaUAAsurrIyZ84D7HGfKCRyOcS2cXchS OYWlRN3VsJQ7q82GGX6Y8XvEBnZSHU8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 9F90CCE28A2; Wed, 3 Jul 2024 04:01:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D144C32781; Wed, 3 Jul 2024 04:01:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719979295; bh=82zz9HxUIo/V08TGVJ1E1ZkMfjqggCMIVYH80TRsdU8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PE3Mp3iKrGg+MQDziwiQtLqamfGDcd2BwzU0p66UpdNRzzHqrtP5zJJ9n9wogEL/9 P7K8fhmXl4L80J6DnfajNfBWAagd+7MGFej4mxZtsPMEvifMWkC8+EZmgbWyOy0Cwr LLmeNC4OLQaUHi4I0If9evvI/v/cZiITs3kNJWrM8rqSVbiAYS+paY30MeeHGZieo1 teIsVLI7MRzFlZhYW9wQutQkrZ+zhLQHFHUYWEcVOqBnkcAUUmd+yvFVqr51dTSUZD bsX/vwbYMqctqwgH4SyV5nxPb1Mib2Lyir1b/Wxfm+yvAeRhSx1GO1BEpiQtU0UJDc oF+pN+0ejOKJg== 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 v2 07/20] mm/zsmalloc: convert obj_allocated() and related helpers to use zpdesc Date: Wed, 3 Jul 2024 12:05:57 +0800 Message-ID: <20240703040613.681396-8-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240703040613.681396-1-alexs@kernel.org> References: <20240703040613.681396-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 36EF218002B X-Stat-Signature: saispbm6dfk5phy1y3hsu4dadq4ky9gb X-Rspam-User: X-HE-Tag: 1719979297-731297 X-HE-Meta: U2FsdGVkX19AmBO8v7UrGpUmRbnqfd6vd3cHA7i2eyyW+Q/+UhK2my29eIBK8uZanDC/5Mu4MytKNYfvfkAJckanzVdmjx9gD/0/gmffj7z9nhXG3KNWfC7DxkZlfqiPGTX2U2vornQ8vBtSzQBxsuoKjx8+0EkVEpWiHsj6wf5StCVblqj8fqrefoVVt8vDHFpTRM3qtFGNvwDrtgPSIuPWHMG4UqCievZODiPh/eoZuOxMub+3hMIyrwB8eP4TcwoK8632S+k0cEozqp3HiIq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ti6NeCAQ== 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> Convert obj_allocated(), and related helpers to take zpdesc. Also make its callers to cast (struct page *) to (struct zpdesc *) when calling them. The users will be converted gradually as there are many. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index a8f390beeab8..29b9fa5baa46 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -845,15 +845,15 @@ static unsigned long handle_to_obj(unsigned long handle) return *(unsigned long *)handle; } -static inline bool obj_allocated(struct page *page, void *obj, +static inline bool obj_allocated(struct zpdesc *zpdesc, void *obj, unsigned long *phandle) { unsigned long handle; - struct zspage *zspage = get_zspage(page); + struct zspage *zspage = get_zspage(zpdesc_page(zpdesc)); if (unlikely(ZsHugePage(zspage))) { - VM_BUG_ON_PAGE(!is_first_page(page), page); - handle = page->index; + VM_BUG_ON_PAGE(!is_first_zpdesc(zpdesc), zpdesc_page(zpdesc)); + handle = zpdesc->handle; } else handle = *(unsigned long *)obj; @@ -1603,18 +1603,18 @@ static void zs_object_copy(struct size_class *class, unsigned long dst, * return handle. */ static unsigned long find_alloced_obj(struct size_class *class, - struct page *page, int *obj_idx) + struct zpdesc *zpdesc, int *obj_idx) { unsigned int offset; int index = *obj_idx; unsigned long handle = 0; - void *addr = kmap_atomic(page); + void *addr = zpdesc_kmap_atomic(zpdesc); - offset = get_first_obj_offset(page); + offset = get_first_obj_offset(zpdesc_page(zpdesc)); offset += class->size * index; while (offset < PAGE_SIZE) { - if (obj_allocated(page, addr + offset, &handle)) + if (obj_allocated(zpdesc, addr + offset, &handle)) break; offset += class->size; @@ -1638,7 +1638,7 @@ static void migrate_zspage(struct zs_pool *pool, struct zspage *src_zspage, struct size_class *class = pool->size_class[src_zspage->class]; while (1) { - handle = find_alloced_obj(class, s_page, &obj_idx); + handle = find_alloced_obj(class, page_zpdesc(s_page), &obj_idx); if (!handle) { s_page = get_next_page(s_page); if (!s_page) @@ -1871,7 +1871,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, for (addr = s_addr + offset; addr < s_addr + PAGE_SIZE; addr += class->size) { - if (obj_allocated(page, addr, &handle)) { + if (obj_allocated(page_zpdesc(page), addr, &handle)) { old_obj = handle_to_obj(handle); obj_to_location(old_obj, &dummy, &obj_idx);