From patchwork Thu Dec 5 17:49:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13895902 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 A9201E77179 for ; Thu, 5 Dec 2024 17:50:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 273146B0184; Thu, 5 Dec 2024 12:50:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CD08E6B0180; Thu, 5 Dec 2024 12:50:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8AEBA6B018E; Thu, 5 Dec 2024 12:50:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id CE0B36B0185 for ; Thu, 5 Dec 2024 12:50:09 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7CFE8141879 for ; Thu, 5 Dec 2024 17:50:06 +0000 (UTC) X-FDA: 82861643676.05.D9331D4 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf17.hostedemail.com (Postfix) with ESMTP id 69A6E40014 for ; Thu, 5 Dec 2024 17:49:52 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=efDVzj+1; spf=none (imf17.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733420990; a=rsa-sha256; cv=none; b=AQYZcghT43rgUTB3UQzlrG2RTVxYVogMC53yb1xXFcSTWZR5CqeKAoPwJ/v5l4Cup/T5cd Yw7ZNYKBUDJUbXZ2apXc9o9aErXiUKHvf9jq0bs2tYxIAOXQFaWPupUH9eH/mkfZ+svQaQ 0IRHHe/1fEx5YsMfcR2Jqh6+FfpMPg8= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=efDVzj+1; spf=none (imf17.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733420990; 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=HVYO14EAznZJJrat10eB6Gq5Pa+UXwqYVmPbaoMVuzM=; b=VJR3c2ttABZ2mhIAcMe+45r+qbnlqhSPsY10TSZwu1PT1GCez/yLiuNbAwVxktXPDugCjy pgebxjka6vIhB5rFmwmxMiCVXnv7KJCZ7wlai2W8zo9jJRK85dDB71RoLDp5umUflLEn+6 c3Wq29Rv97trOjR5YLWWMV+fBKQ+mCI= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=HVYO14EAznZJJrat10eB6Gq5Pa+UXwqYVmPbaoMVuzM=; b=efDVzj+1SkMmZUl80u9mk3pQ/8 gD5TTdksVUS2W+Y91mVZkq3jpAzUDbGpSoFUF4tsLqdCfESIVKNnf14yzK1tFu6kD5iZynFs/QarP E8KBYMlvubVxEOK8K9IuU/tnuDnVq+6ZqhS/7LxqOENtrjy4WOOQnIJG8EjoCwxY77ekGcfrrTY55 9tFDUgqiH8210A8UL1GVA3X3/jlAgf5YKtzti99/SgYvt/0ZWF6Iw/miAKkkolixnseLnnY8yCyCA DhNYlq5p5oVr7kGH0/6aU3eo4xzgynYVsBwBD9SCkNaRZvRsVrFf9WBAOe2oy+LBaR2KdCc/sTTFm I9nit+Pg==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tJFzH-0000000DN7v-0NF7; Thu, 05 Dec 2024 17:50:03 +0000 From: "Matthew Wilcox (Oracle)" To: Minchan Kim , Sergey Senozhatsky Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, Alex Shi Subject: [PATCH v8 07/21] mm/zsmalloc: convert obj_allocated() and related helpers to use zpdesc Date: Thu, 5 Dec 2024 17:49:44 +0000 Message-ID: <20241205175000.3187069-8-willy@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241205175000.3187069-1-willy@infradead.org> References: <20241205175000.3187069-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 69A6E40014 X-Stat-Signature: w6sacp8s158gtgyfanf1mrew6o1issf7 X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1733420992-569908 X-HE-Meta: U2FsdGVkX18XLp8TiSvHxya5jjJ4LLJWhSHxB8pwX9oEN+9SBNNuOIdacfE1wyzulYNXmH98GZSmOUq6rOWUfZ+I8+OfiJ3WbBdvSeN8YGXF/FAAKza7rsg1omKEoCubc6mMHGPxg8w2O8+DCyowGajUezFj42ql4Ge+41X63+uZVIvE0XGimXlodFxfeu//IHx+XaQoTDT/z6YHi4M6w5yCbkrwYnMYcR/UV40by+d64SuNV1iK44nU7BCjXSPi/H+uMsYjnfGRxX9av16ZqWpuyM3U4TpJiG2Zbnnsmh66JsL9a+1ATXKSdWbmZzif0B11lXKwUNrvOOpZ8JQdfx3jWbYkl5N7A7v5kBdJyb6cIN+9vuyJRxWmF52egEo6YiprBm4KNy0mQSzgRrlx7rFuPvLv/EgM1rw4b3yeBEaOvSOdTGzSztQW2vs0XuNy33rwma3/2ccFifC6nlfpi6iWcc4sjF/E6mOTw2+n+z7vqPhMRdUZIvy7LDh7aYDdfnfqiRs96Ib/4vmOWbAedKQOl5OSMqH5XxyKR7L9C/xlbQvoG3II2qwTAnoMPUk8oJVLGm0GgtjKHNfGKHDkgdBSdnYhX225q6gElqhB1QMN42ery9CUXjYVyOxk3z17Z1dMyKzE27rPnK4BDOKbmNwFJY4KAlH7EJ7lmRfInMemfG8khgVaygXjV/rf5ZA+cOwLeQqly7Pmd4I4uouN05CSOUyLruykFMVueepKeRjfmWqahFKT5pcd0U2riQCjVB6qwSF0IUx1PUou+s5m6G2ehiDxsDKrttOBxnnnI8Bb7osuZGQdx23z6KhyUHJH2mnv1BZZ1PSc7n0K9saWq8UVeXWFzK4SNs5lDjelUY2p5F1jF4oL99bNYrQrMKUTUesI/7/saypjCeb/4TPsRTVbNKfuEEXm0OiXLOc2lmv3FJXAQADNkBfOGhrT/BgUbBxuyMk4nlq/GLafimv NHm1/tT5 mOQlO9BIP/b2XpXmP4CMOPmZYAUjLyQ1o6buIDrr/rWYbf9uI5FF3O0K1oH1Ut61p6i40G8HEX/Xwto5UuBTCVNpTSGWIibtD55LgkLFe1sB12S57sV93EHXbf/waarqASaUkXg0GL00HAFeCjS/9FwFkmZ9YZWh99K0P1D6qyXRfr7ysng8Kcw89ZP45SckxQ7Em+0fpH9b6dwdx2lZQzY4Qr/I4XD9lMvXhIfeLWHrz5AYRyxR2oMYnkvlFu73yzopn9k6YAxt3urEdPl2Bbj5Y9+yTQGmgnDEL6ZWBa2Sh5RPyfzZ02eVKA2XHYrMfPmubhKLAc74ca0KpFM9rxm6TSA== 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 6beb7cce4c31..894a3131ea2f 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -841,15 +841,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; @@ -1588,18 +1588,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_local_page(page); + void *addr = kmap_local_zpdesc(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; @@ -1623,7 +1623,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) @@ -1856,7 +1856,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);