From patchwork Tue Aug 6 02:22:54 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: 13754324 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 A960AC3DA7F for ; Tue, 6 Aug 2024 02:18:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3DAC86B00A2; Mon, 5 Aug 2024 22:18:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 385A26B00A3; Mon, 5 Aug 2024 22:18:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 189FE6B00A4; Mon, 5 Aug 2024 22:18:24 -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 E6DE36B00A2 for ; Mon, 5 Aug 2024 22:18:23 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A69A0A8A29 for ; Tue, 6 Aug 2024 02:18:23 +0000 (UTC) X-FDA: 82420211286.08.C4F56F2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id E3E2040018 for ; Tue, 6 Aug 2024 02:18:21 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="FoXry/KR"; spf=pass (imf07.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=1722910619; 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=TK3D9BhHCud4UbGasCGJxl/q7H+vBmcvyIb8ehzvADg=; b=bvi9Z4AgdWTZGuF9tIkmVFR6JN5WB8KhvnrPevcx7revdC2pX/p02+O3zUo06RsT6/CzPP N7VWuaOjsgbVNvZnoY2gpbnf458KJ00NmN2uA3X3hoMqmzWVBzJe/gx3tGtQ0IknKoFftx jqH5ogXKReELmRDpQ2JrAGeJlN278SY= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="FoXry/KR"; spf=pass (imf07.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722910619; a=rsa-sha256; cv=none; b=V7EaXlOhaZCI6ZwzNpKVWzy7k7MXYt43soS+OM9qE0VaBZApmphzs188mGhFqaOOUr5fWp /65ktn4OiAO/us6Bl41QbhcOWYk8BGyOLPf9JgdTXXkWsgBJexex1CNHASfyK+kyOtgi+O octdOF4f4nl+K3e+1xarNEUZaB4UHkk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 1F21E60EE4; Tue, 6 Aug 2024 02:18:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7EBCC4AF0B; Tue, 6 Aug 2024 02:18:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722910700; bh=S9lb/ZM2ddFk5ykU4pBIY4i0BSbXkh97cFi/e+1K9AA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FoXry/KRy6McNtYGfI2Z6enXmj2PWAy7b9Lk8XnIwOINqaCLUi2tLUaqmmtgbrpG/ MxbLCcc0DyuZARER7WhzK6gSVOwnOsHFc6/RIAwicCSRIGdGeoRD1WcpwBuRgSYNlB kH1juNG7IOd1xdgQDziBMjpAYa4BgcHE3F6FXY4SanlKYCBX8Dg00AfglkRQ9Md6O4 lxZENUCGEbNYf4+TLt3zOZ2H3MKXoY9KXp+kd38tme2pa0wo3SFHn68t6XoGliUpbi mfFhW6n+LPNt4zSKnSof8Uoueji5zXnGJ0yBZbj3+XJqo46Rfrfv+PmvZHTQMa1OTC 4fc970Hz8u/Hg== 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 v5 07/21] mm/zsmalloc: convert obj_allocated() and related helpers to use zpdesc Date: Tue, 6 Aug 2024 10:22:54 +0800 Message-ID: <20240806022311.3924442-8-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240806022311.3924442-1-alexs@kernel.org> References: <20240806022143.3924396-1-alexs@kernel.org> <20240806022311.3924442-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E3E2040018 X-Stat-Signature: z7r7hcehkzmd9ion1geg7zynuux85swu X-Rspam-User: X-HE-Tag: 1722910701-298965 X-HE-Meta: U2FsdGVkX1+giJcXh0g1FZwqR1OxUZ4op0VDgoo65Rug2pSKJhc/bfvFSI9qiwDNU0f959MBRZZr4EW9HKHtf41R2XknLDp6FVQdloOgCztwQSeByzkhHTh6fvXXQ5S9ccvGmM+gK3zw2rvrRk+yPjnJ3mifW4rr9bbHDPwaa8wFdk83kiWUMcdbtPqNN/kpHCgha8YAbKZspA6cF2+KE63CyENzpsZEA7+xzBoSp/BX90l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/GTmYsS5eYQGMgd2bEK5pRPdykmkuWgM2qvndlyCjFHf8iFiiJeLLhMgl0HOLvaPKuzo+S/ 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 33a4f7d026e3..3c1755227706 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -825,15 +825,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; @@ -1583,18 +1583,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; @@ -1618,7 +1618,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) @@ -1851,7 +1851,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);