From patchwork Tue Aug 13 08:45:51 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: 13761554 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 E14C2C52D7C for ; Tue, 13 Aug 2024 08:41:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 655226B00A2; Tue, 13 Aug 2024 04:41:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DCB56B00A3; Tue, 13 Aug 2024 04:41:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 40C576B00A4; Tue, 13 Aug 2024 04:41:29 -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 1FE006B00A2 for ; Tue, 13 Aug 2024 04:41:29 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A61A8A621D for ; Tue, 13 Aug 2024 08:41:28 +0000 (UTC) X-FDA: 82446578256.19.88777A7 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf03.hostedemail.com (Postfix) with ESMTP id 137CB20021 for ; Tue, 13 Aug 2024 08:41:26 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="tRCXz/JP"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf03.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=1723538435; a=rsa-sha256; cv=none; b=jUHuSAfw9+NCoxJcPA11Lw0vgj4OYRKJZuT9Q4YVSV/deEWWxRQ7AvVGYNVlxMeGf1BhvJ JWQ/db81JFJRHcbOBPPz1OVKtR/Gz0CP5lrQnWe/S5NaCZyeExn88/Rj9D0AZXEEjkPWBy 1o7+ECM7QqmOBP6PQ2QnDl/+zzjpbA4= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="tRCXz/JP"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf03.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=1723538435; 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=Yh2M3ze6FPP2pb5gtVIfrEf+1wX6q2uwXp/9ylWsfqo=; b=ixRzd/anIvf+gtIaJxhsCtgzERdkuvWXfO0shrHh0fzlSRFPcOVn/9sDEDQkG4ltuYRUG0 /5nLVpR25109+IRHczrvPYBQl4uCgY4EyeKBzoUsv4k+U8T/XxwigpIJNZWcXYMUtxuD14 8ngCqtS7ggOhOuND7mRxGaTyjevbJiQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 437F1615B9; Tue, 13 Aug 2024 08:41:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCC2AC4AF09; Tue, 13 Aug 2024 08:41:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723538486; bh=j9RlWiCV98maWH46GH8LQqP9KXOBrIEnE2eMblguIA0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tRCXz/JP3Ty7JtZpW73rKxJ1lhhYk9Ol1Cmy9UFewuVw/ovD7dnyJn3Fbc0FM9JyH mbyqFfGvvltrcRIkhc4Kqz8hdrpnbnVVrP2SWs7vG5U6rft8AnC4LlOKPQGi5ClCVH 3Mn+kEiwvynvpeD3qsCqqNS3lbmOLEQg0BQgJID9O7ZBmqUXu/9Ptl/7Ocu0ngA7bQ AxxymPJxLhXJdFG2aFdsZZLVsIwDpMKZsq9uEsIf4ZtIkaZnzsGRiYyyQzOnk/d8WL eoFkQ512SDtJmPOshzJRwq8BO4kzCBEv+6GJFUI/d80irjxb7cVWmkqi+WJHy3Gh2y VvTRBPTeO0Y5Q== 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 v6 05/21] mm/zsmalloc: convert obj_malloc() to use zpdesc Date: Tue, 13 Aug 2024 16:45:51 +0800 Message-ID: <20240813084611.4122571-6-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240813084611.4122571-1-alexs@kernel.org> References: <20240813084611.4122571-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 137CB20021 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: giue37quxfnc5y13acotb89yahhudm4t X-HE-Tag: 1723538486-975729 X-HE-Meta: U2FsdGVkX188mOgpVBh/ViQ8hMn8qK/WHUlk7ccB0U011mV2EjXo+/mzK72T+sabHyCbQxSUylKQxJSYHo8V9K85smdEXtGqMqJAApZj3G0peTSJZEFUwj1Iz0D3GgGzS5J0jXBodDO5qOMhzxbH1S2Mj1PFiYXfEfmGTyjlUiSKHwZ6iRKQjM1jDXhf3f6da1/TFtHpLsL8JdkcVVndKYZTMvIgUSQHcGwOKbdvyoym/Th0xD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yqg1kX7LWtpIwinoygUUnsmchL1eR8VV/X6+vjHOL4c0bzIH/S/sPTVW 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> Use get_first_zpdesc/get_next_zpdesc to replace get_first_page/get_next_page. no functional change. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 384a5ba49788..7421d7678880 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1322,12 +1322,12 @@ EXPORT_SYMBOL_GPL(zs_huge_class_size); static unsigned long obj_malloc(struct zs_pool *pool, struct zspage *zspage, unsigned long handle) { - int i, nr_page, offset; + int i, nr_zpdesc, offset; unsigned long obj; struct link_free *link; struct size_class *class; - struct page *m_page; + struct zpdesc *m_zpdesc; unsigned long m_offset; void *vaddr; @@ -1335,14 +1335,14 @@ static unsigned long obj_malloc(struct zs_pool *pool, obj = get_freeobj(zspage); offset = obj * class->size; - nr_page = offset >> PAGE_SHIFT; + nr_zpdesc = offset >> PAGE_SHIFT; m_offset = offset_in_page(offset); - m_page = get_first_page(zspage); + m_zpdesc = get_first_zpdesc(zspage); - for (i = 0; i < nr_page; i++) - m_page = get_next_page(m_page); + for (i = 0; i < nr_zpdesc; i++) + m_zpdesc = get_next_zpdesc(m_zpdesc); - vaddr = kmap_atomic(m_page); + vaddr = zpdesc_kmap_atomic(m_zpdesc); link = (struct link_free *)vaddr + m_offset / sizeof(*link); set_freeobj(zspage, link->next >> OBJ_TAG_BITS); if (likely(!ZsHugePage(zspage))) @@ -1355,7 +1355,7 @@ static unsigned long obj_malloc(struct zs_pool *pool, kunmap_atomic(vaddr); mod_zspage_inuse(zspage, 1); - obj = location_to_obj(m_page, obj); + obj = location_to_obj(zpdesc_page(m_zpdesc), obj); record_obj(handle, obj); return obj;