From patchwork Mon Jul 29 11:25:17 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: 13744728 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 9A936C3DA61 for ; Mon, 29 Jul 2024 11:20:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2FD916B009B; Mon, 29 Jul 2024 07:20:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 286CC6B009C; Mon, 29 Jul 2024 07:20:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 14F936B009D; Mon, 29 Jul 2024 07:20:37 -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 E88276B009B for ; Mon, 29 Jul 2024 07:20:36 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A9942A2922 for ; Mon, 29 Jul 2024 11:20:36 +0000 (UTC) X-FDA: 82392547272.01.3E101BD Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id 223DC80004 for ; Mon, 29 Jul 2024 11:20:34 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=N1dl0pOc; spf=pass (imf02.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=1722251982; 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=VMCQhHDdGJOKLu/KVq7ZZe30LH202MU5dyPStXWIX7Y=; b=G5/abDFOZ+miMTzfkK3B8adP1sjtwnqwIcPRUhocl8lzmrzjjYjls08GOXbMAeHWlOSNw+ WENkkhHyxa3d4rHSdSRhjDQEV47TZPymcXZX81P8J0XrJPHddphpMvvuB2hn36ZbDRRDXy 7+VUxOYHNwAbu5aHy1kEc6xYZkKVV0k= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722251982; a=rsa-sha256; cv=none; b=zckTsIquQISyc3/dsUd/ZowqjVrf8akGQHpekkZXxRRk+gV5JA6QA/v5eZz3Lsrwi1eU8g pJnOAjW/QtItnzu55SxkQg5esU0w2VWFeBM4h5GqVikZ6oJMJcCLEUG9fvNvm0Z+8bhNYj Wqfz997MXG2nQquc12Ax3AFrsUtFTVA= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=N1dl0pOc; spf=pass (imf02.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 51C83617AA; Mon, 29 Jul 2024 11:20:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F00FC32786; Mon, 29 Jul 2024 11:20:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722252034; bh=OUw0L1+EEkxStexhrY6FwqktPPZ5HwiknqjqfzU6PXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N1dl0pOcTFgdmJMCVClV0yXxSZWm7Os6wsGJ8ws8QQxeG1j3yfc4V0ckuKv4YRMv/ N5hoiL5nFmBw9n5kMO//6XdEuvI1hUezsU07uTtuoLOWXZf9d7IUGz7qr8PrG7Ou9P oz3DyQNNb766EmVqx/Ph2tCIOxiJYm8TzWmi0nRSA3dytbAskWr3IWIfrIMpzw9y/D oVY3NFI/tP0Wjs+PVcxCpfRBSSKz1lDKt0FCv6Aznv+WWyn5nND3SBVMP8rLdaRzof H7D20CRe1/5dp+pGZF7Nyz3t615VHG60okruZFTRx/u9cA4QYBXyElY4tQZktkitMc /UvAS8vIlC8Bw== 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 v4 05/22] mm/zsmalloc: convert obj_malloc() to use zpdesc Date: Mon, 29 Jul 2024 19:25:17 +0800 Message-ID: <20240729112534.3416707-6-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240729112534.3416707-1-alexs@kernel.org> References: <20240729112534.3416707-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 223DC80004 X-Stat-Signature: cq95prqcsf1ogw3xgryj7yb5fpzqgmtf X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1722252034-476712 X-HE-Meta: U2FsdGVkX18eTDe63AH5OQPZyNA9592LGChbaUyj61P90EGennwogoQ3/0TcvXoq5AlHx9YISyRUf/6Xt4BP40o94t7Ccr5otZ8hBzF4dT9YPqbLey9H/8iQ1RlWCFBKPu4T1jEgYGwrz09cTe1MEolM0CV2lcUBD5T6+uhmOrf0eD8uwT4Sff/G0EOfHvD7TWNskwpC6z1VtmblM5t4TpMtBjd8iscD4IMPqhTv+9qCDeKjQbgYO4lQNE8TT/YiSD14B75qrEXlrLoWWmtMrXtyd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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 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;