From nobody Tue Feb 10 22:15:36 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D749376E9 for ; Mon, 8 Jul 2024 06:29:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720420148; cv=none; b=T7fegP5Jp2tBK6RG+75P7JpoAXFEn9O0eXBGGuauukUuCePdn3bNsnAZY0mITEs7e9X31i4SMLX+b6EbsHd8LqraesvcgSLLjd6Fbme9pAVqn8EkmxX6NSx1s1oQRTArv882E6uXtdGv87PuFt6xkTo2k/322Y1liC7ECNQt6ss= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720420148; c=relaxed/simple; bh=eUVr/nevUiypHdkqs90LAQGcxdPsPYteX43+BHTjXcE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SiEMff3RsLUsVX1fBSXuzjNCqzQCIv8AAiI3+hzFVjgIRh4S/ctk+oqJRGaroYcIF7pgeG+Y4njwoaGHdavZsOfl4agpvN5V4XWBvyd2YyaQyhOjNjCMwuwpAaaITyPwTPd2dQ78YrgGhVEq8AI3vnPAQgOdHn8qI9sA8JlZAOk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oZUatPhA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oZUatPhA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47754C116B1; Mon, 8 Jul 2024 06:29:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720420147; bh=eUVr/nevUiypHdkqs90LAQGcxdPsPYteX43+BHTjXcE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oZUatPhAeDrGrCo7sj3uta4gUIoHLfsfvRqLImOTiu9Ew6pEEgEFIOq0FSp+n5nwr QUQtfQqHNsuPdOaitMA8AzGvFRLInyN24C77Tk7y0e98ECidpaZy2xPt6WcuarP7L5 TBOyX1bZOTr7g5ZtY4U7xHoKTOGv9CJ0Ii9hB6TgLH4X+XjfqtBiqYubR/UrpapQHY bvCJQvBU/k1baFZ5PsaTYfxcJGwbs7QtuI7RelgsDIjmtrGKew2vbFGQE177XxhgdU bkpQ0aVFkhdhzwcff+LWaITeqGvljAUNPo8L8o/7dFg4yBfq34RKmo2O+m8jrmccwF WyP+xYNxqjE0g== 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 07/20] mm/zsmalloc: convert obj_allocated() and related helpers to use zpdesc Date: Mon, 8 Jul 2024 14:33:28 +0800 Message-ID: <20240708063344.1096626-8-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 (Tencent) --- 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 hand= le) return *(unsigned long *)handle; } =20 -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 =3D get_zspage(page); + struct zspage *zspage =3D get_zspage(zpdesc_page(zpdesc)); =20 if (unlikely(ZsHugePage(zspage))) { - VM_BUG_ON_PAGE(!is_first_page(page), page); - handle =3D page->index; + VM_BUG_ON_PAGE(!is_first_zpdesc(zpdesc), zpdesc_page(zpdesc)); + handle =3D zpdesc->handle; } else handle =3D *(unsigned long *)obj; =20 @@ -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 =3D *obj_idx; unsigned long handle =3D 0; - void *addr =3D kmap_atomic(page); + void *addr =3D zpdesc_kmap_atomic(zpdesc); =20 - offset =3D get_first_obj_offset(page); + offset =3D get_first_obj_offset(zpdesc_page(zpdesc)); offset +=3D class->size * index; =20 while (offset < PAGE_SIZE) { - if (obj_allocated(page, addr + offset, &handle)) + if (obj_allocated(zpdesc, addr + offset, &handle)) break; =20 offset +=3D class->size; @@ -1638,7 +1638,7 @@ static void migrate_zspage(struct zs_pool *pool, stru= ct zspage *src_zspage, struct size_class *class =3D pool->size_class[src_zspage->class]; =20 while (1) { - handle =3D find_alloced_obj(class, s_page, &obj_idx); + handle =3D find_alloced_obj(class, page_zpdesc(s_page), &obj_idx); if (!handle) { s_page =3D get_next_page(s_page); if (!s_page) @@ -1871,7 +1871,7 @@ static int zs_page_migrate(struct page *newpage, stru= ct page *page, =20 for (addr =3D s_addr + offset; addr < s_addr + PAGE_SIZE; addr +=3D class->size) { - if (obj_allocated(page, addr, &handle)) { + if (obj_allocated(page_zpdesc(page), addr, &handle)) { =20 old_obj =3D handle_to_obj(handle); obj_to_location(old_obj, &dummy, &obj_idx); --=20 2.43.0