From patchwork Mon Jul 8 06:33:26 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: 13726193 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 D1737C3DA45 for ; Mon, 8 Jul 2024 06:29:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 01A4A6B009E; Mon, 8 Jul 2024 02:29:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F0C066B009F; Mon, 8 Jul 2024 02:29:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DAD8E6B00A0; Mon, 8 Jul 2024 02:29:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B458B6B009F for ; Mon, 8 Jul 2024 02:29:02 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 7B24A1A10B6 for ; Mon, 8 Jul 2024 06:29:02 +0000 (UTC) X-FDA: 82315607724.23.0D34EF0 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf22.hostedemail.com (Postfix) with ESMTP id DF34DC0010 for ; Mon, 8 Jul 2024 06:29:00 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=e+9GU7+O; spf=pass (imf22.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=1720420118; 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=l5UquMvigMJ3jlequ1KKubsljHfVWFhIyFeAFPJfZAs=; b=A7OC8bICYQd9TjxDt7/LdQBzQvHZ9P+4mj0OemzhZlX8sD2ouDGe22ky2UHineMHUr7Dts TaOsejSNlp0YIoptijlhckxusYUfPsxWDL2wOYv3/icy01cw8Ftm5M6NaW8pG2SubXPqIv vDX9JXDwn2AsEgvZcexerg0FCnTvqh8= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=e+9GU7+O; spf=pass (imf22.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=1720420118; a=rsa-sha256; cv=none; b=2POiMb5jxkZlDDYCbC8ayQ1GKfBV1rnXMnbr6Ce98dmIPVo3OoHab0TDP+7ckter1kldG0 OOoSMS5XkAVbj/WsbIR4R3sBXLwCFiXhBJxvrEYNxwtmxPnFG/baY3yrMVYDQzd78FMtLi KKyX/vu9Wyr/u1APtKCf+qbU9ESOmO4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 134EB60A78; Mon, 8 Jul 2024 06:29:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC9ABC116B1; Mon, 8 Jul 2024 06:28:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720420139; bh=Kaf63ckMzfd8JfdGDWbfHAhpNFgdzACIKJu7j9bsBGA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e+9GU7+OFriAgyhewgBuS4MpJ13g2HtbEpGw2kuHmhxZGAFHfZrMhm5wfrLZt6eSu MF2wyNfgAdjMs9E8qq5ZSCV9PMJAr4/A1OaqAx8uKJabfBUQR38cugW/jaeyMk42rK RQMEpRHjPzDEPwQrXf+OZ6N9tpRgoJRDv++LCDOZxvLEdvf+FMPtlmENm8JmLvLO6a +/RnpebZBStyMYM1IHwbCJKZpxkRFUUEpCMF/DK5JHekR4mjFG/ANV615+EmvR0SLR OXmgjPJq0yh2NRtIZKeP5dQYB1AQ/luVVGcKmwcAKJT4Lg43bXs4RbfPa+gouK3IQm ul+eMziT36sgg== 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 05/20] mm/zsmalloc: convert obj_malloc() to use zpdesc Date: Mon, 8 Jul 2024 14:33:26 +0800 Message-ID: <20240708063344.1096626-6-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-Stat-Signature: fnfih6igbahr1qpcbiikrcnxfrxbwfyf X-Rspam-User: X-Rspamd-Queue-Id: DF34DC0010 X-Rspamd-Server: rspam02 X-HE-Tag: 1720420140-697336 X-HE-Meta: U2FsdGVkX1+OAtRWSTUr8hCi6aJdpby96UZ9wW1hgr5Hr2f7P7ybPj8KkUBYxj50CBk1k1lCW4g81RDLe+zjG5tb4WbjwnkirbwwnIVp0Jjia0tCVM8/NJ0FiuAJ+Ld7P60VtrBNDlmpTTqqu+HGZ8EgPF9BRqjKajjqPJU8uWjDezQ0BxUnIT4y+VO+Bqi5tTYaqpobgbSEWQ3ItZof1ZmOT34QWwdwSfc3oUrGKEqPnCs5eD+3d/My891CiMPxJIY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ft5Eb3c0noNvumfH0CL3lS 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 (Tencent) --- mm/zsmalloc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 149fe2b332cb..bbc165cb587d 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;