From patchwork Wed Jul 3 04:06:05 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: 13721085 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 87227C30653 for ; Wed, 3 Jul 2024 04:02:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C7B756B00AA; Wed, 3 Jul 2024 00:02:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BD2316B00AB; Wed, 3 Jul 2024 00:02:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B0186B00AC; Wed, 3 Jul 2024 00:02:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 762666B00AA for ; Wed, 3 Jul 2024 00:02:09 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 2ABF6A27C3 for ; Wed, 3 Jul 2024 04:02:09 +0000 (UTC) X-FDA: 82297093578.12.6F9D2CE Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf16.hostedemail.com (Postfix) with ESMTP id 89DD8180005 for ; Wed, 3 Jul 2024 04:02:07 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=XVwqKhxq; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf16.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719979310; a=rsa-sha256; cv=none; b=7bAzgJKSLUhWqqU7D3wcff8WTXJh681NsLlNS6jeCqaop69ddfFOpjgUUioDPfRd6ls4Qf COekU0nG5NlTw65Ewrkgj/+z5vGcA54QBk+UEHhrx7f48jOqeZAF+D0Ix/mZAmneOkSR9O D8Z3pGa0AH5ZRQB6hrbkR/T+Jaam/NU= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=XVwqKhxq; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf16.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719979310; 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=Q9lrHJyVnJJavlQtfTrhM6Cg7QJsRwBhFfAPgSitRB8=; b=Ei8uwhVyZmhz4uStZzqKDGfzol5ig9/Gnw+PJA7jmQw02Y29oTX7aGS4YnegHOhpPLE6RZ B3MS9rPTttU3aevvIqH2XZzm6NCRGiUoOsbs/agNBSE8QanoDQ0c7ZCL/DZmFEUT6JJ8Un /Xpb7AD28sWR6HXlxZLIWF05rnk7Zpo= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id C4AA1620E8; Wed, 3 Jul 2024 04:02:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 369CFC4AF0E; Wed, 3 Jul 2024 04:02:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719979326; bh=0AvWtekA1fBYWEoFvuJjRv8WAqdxESdkBRdAezOabRE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XVwqKhxqJJIYI4ImJo3+psdvnBbfEXhEGJDSfDKi962ESzTtF5/hbZ2P7VODY/3r5 4I4jG8LqmmhAtzostIdPRwMaxNugcJ7W3Lw+obRV2bqbBj41gU9MiaOVMBBEmkrvAP uUfWcaK1g6MOHtA4amW+Zy5h3GHC9ilT1fvyNp4vMZF045n4UCOPHLdeRlWk1ATdJf ZeKKavWcPN4rFm71clrnhy3cPlRVjb7FwjSU4mIeC/PyYBtQN2Mj0FXTUNviqAhJYi 2GI9UT/7KubfIvR8WPuJlMYEUEnCU4gkEmis4XUM0cBgldgN6W+/DIW3ub3foDmaZT kRSS3fBZLRMnw== 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 15/20] mm/zsmalloc: convert get_zspage() to take zpdesc Date: Wed, 3 Jul 2024 12:06:05 +0800 Message-ID: <20240703040613.681396-16-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-Queue-Id: 89DD8180005 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: jqj4wegk9wrbijog4t5fhmazwmg63sk9 X-HE-Tag: 1719979327-722974 X-HE-Meta: U2FsdGVkX19CbyQN9oGSgqZvws1Xy64y/m4PLXqHS2ekq0ixpHvPZhUoCZT8Vw4yaYCJTLKk+lY+zt/698mWjrXM6whGm7rT8RnRjC0+7S0CjOp1L9USMinsMYK8LFdJf29s73gJli6cYIHk+8yP5CJR0ZW7IB83qZa1z50aeSOBX3vJtO5655BBkRp1jAV/kcnHU0DA9jUKv6wY9jhEqBFSXm+9FckhkU76WWbAwztScHj6AW1FBQ/HERka+kupK288P97qmUHx1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ayqPybk/DILHh/l4lR 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 --- 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; /*