From patchwork Mon Jul 8 06:33:28 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: 13726195 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 70B47C3271E for ; Mon, 8 Jul 2024 06:29:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1EF916B00A2; Mon, 8 Jul 2024 02:29:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 12A176B00A3; Mon, 8 Jul 2024 02:29:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE52F6B00A4; Mon, 8 Jul 2024 02:29:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id CD0A86B00A2 for ; Mon, 8 Jul 2024 02:29:10 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 4452BC0ECB for ; Mon, 8 Jul 2024 06:29:10 +0000 (UTC) X-FDA: 82315608060.20.21674E0 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id A7D9040008 for ; Mon, 8 Jul 2024 06:29:08 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=oZUatPhA; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf17.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=1720420125; a=rsa-sha256; cv=none; b=VR1+yiPIpoRVImsMF4trOCqP0x23UHjnC7KLIJXNvVvPRGf+J7lFytKInaNa/XAFEw4dnr CW7ugl8qKmKCgDgApbrt1gPnC0z1cOtlgJpSqRvcj64+LCQHzqGZRZ7d6RkHP8j960pr4s AUUscXTeaoDNSrff3ZaccvAei4MhUbM= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=oZUatPhA; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf17.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=1720420125; 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=Vht4Mu2UzYx5Ihggdky1n1LO1j8nZdajLePSwRaN2xo=; b=dkUM7BEXjFSaeV7v4e/49WEviPl16Wnwrzb/vISs8Qi9ELCOaRd0DnnKkFt4uzp+FdwhdS Qipfw526JakqWQN7ThQQ6rZ3Bx5EOTMumIXvN94O2DwYPiXuCcfmqUCn5JegzDP6oRAkqI /+PEEo0QIBCETcyTfW8YJn2k3ASkLPQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E629F60A78; Mon, 8 Jul 2024 06:29:07 +0000 (UTC) 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> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: A7D9040008 X-Stat-Signature: jtgy6u89iqj8gpxpuzdazymc1nrryjqb X-Rspam-User: X-HE-Tag: 1720420148-410079 X-HE-Meta: U2FsdGVkX1+m4+Q0LodWYFH4ts5Tk21FSGKFBXU1372It3lusBvA3GrLOzwzjb3wykttpJ/m8OzjrKlujn8wvaaBulpbvPPbwA0i5VUUoiSNvIyUkpKBGQ0aVJ4mgIQ7ZafpTwY7Q3CuOwYABuqK6qjIBXTmN52kPQn7kOrU0prnXHoXYm1MYJqEkfPd5p9gu0sNQvUf2V+rRmNxyAbZ+UXJkCz3NAhXufNJg2xaYYkhn0eFJwtkOjBfog8pZ18RfQOrOqN8rY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J/iVztgiSNQdGXnKzTMzyeyNeO4Sbu 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 (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 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);