From patchwork Mon Feb 20 13:22:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyeonggon Yoo <42.hyeyoo@gmail.com> X-Patchwork-Id: 13146436 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 42F16C636CC for ; Mon, 20 Feb 2023 13:22:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D2E2E6B0080; Mon, 20 Feb 2023 08:22:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CDF8E6B0081; Mon, 20 Feb 2023 08:22:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B7F816B0082; Mon, 20 Feb 2023 08:22:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A9BDD6B0080 for ; Mon, 20 Feb 2023 08:22:58 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 709BCA0994 for ; Mon, 20 Feb 2023 13:22:58 +0000 (UTC) X-FDA: 80487735636.25.B82B048 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by imf11.hostedemail.com (Postfix) with ESMTP id 91F634001D for ; Mon, 20 Feb 2023 13:22:56 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=aXlF5sZp; spf=pass (imf11.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.216.48 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676899376; 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=vOHr4kwn4dxg23tNChjWJmg9YRUx5gIQnzpZr67MPeo=; b=JfzZsspUNB3lsmA4zOSCPjAarGygAEVx/+ktlvpRRkvOU/+pmcpkczPMAh6MRc//xK1hkR tbdAQ+s4CdjVB0vF+o5nwgLdXXw3XLiQT6kMWzSuYB99yCqR12GcTooE+FJlJexu2uCFtp Av0ICGFb6DYp2i63HjPKt99Sej6qySo= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=aXlF5sZp; spf=pass (imf11.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.216.48 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676899376; a=rsa-sha256; cv=none; b=btVlRxjfWSPo+6cCWllMJasCmh5zvOXF5S3AaKYYZAFXtB8PX8XspTIWqKboOFhN2CCsZl yN1Vim7qYX+q9sQm0PTBoj7h5XvoEO5vxw9wRlhLOP6iWGomekOLucMhKnQuh3FCMPnnbf Kxv6ulvmI4bhQMMMRpgk7QeW21sNLCw= Received: by mail-pj1-f48.google.com with SMTP id oe18-20020a17090b395200b00236a0d55d3aso1829342pjb.3 for ; Mon, 20 Feb 2023 05:22:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vOHr4kwn4dxg23tNChjWJmg9YRUx5gIQnzpZr67MPeo=; b=aXlF5sZpldikjxWRJ/my5E+ingE1RhF8dVifICaQk2wDUTNUW5F5nTQoCEz+XzdNwc 2TQWxjTjjrYetNz1AP1BET+Uzc5Vnu60m7iwGvQQIm0D+4cCAqLtK+2A6L6AEQU8xKdf kqOurraEIhRY3updQhz2i42CN5t2wCVUX2e/BYiuWDhu7y2c9hce2/Y4Xbx3wLGTR/kA XDM9PM9ENgUZGw3ypTcgxu2zMLlIXGz+HM/yOBWRXvRHbemhjIunzZw0ZcYSOVYLfR45 SdPcyWb+dOH18+aVGqEGe4nPly4ESVy/0phlpIKq2lGCLpsRZFymD6oy2y0BodQ1sWqc O8pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vOHr4kwn4dxg23tNChjWJmg9YRUx5gIQnzpZr67MPeo=; b=xUD0UTs7UmHDbZTKXPPyelpQ2Yufc/M33qYrLGGja4/8obJdZak+67/2nOEnPiPBYE Rs51fzVC/6WEOPlePDKaNpIrqd1Aj2kGKjCXDrVy/8Is0i+kka3TQEpBmkGFezf07K/J FhUznudwOwNWjfpj/HdjEXQp23OGYSBsiIUOFM3QQ6ehZToMVcvtT37bj5lgbSXkUlQw fCBT/fW9ajSXwjyzb7yAdGpeIqWPGPmhm1jhY3npEOn6h1rtiR31+tgrD4YdvQHLOZur 7CV86w424QnXTfhBS/pzi50r3lv3+doWqVyh+ytttuF52/6xHKS4oNgXthTTk1OP+2+C AGrA== X-Gm-Message-State: AO0yUKVho7JMbHvjGE+Wr+luL/+mZMdxZPp7rY4cfYrXD7CG+a902G+j WD85TjPr1pwhh2eS9lP8b04= X-Google-Smtp-Source: AK7set+KtKzsqqJ9T/y0lDan8IQgQ33wV1mEcFH9zQLcXwlNElKMBTWvbl2+6vuSwVgcAI+VMow1Tg== X-Received: by 2002:a17:902:f9cc:b0:19a:f556:e3b6 with SMTP id kz12-20020a170902f9cc00b0019af556e3b6mr899104plb.32.1676899375531; Mon, 20 Feb 2023 05:22:55 -0800 (PST) Received: from test-ha.kr-central-1.c.kakaoi.io ([210.109.63.229]) by smtp.gmail.com with ESMTPSA id x2-20020a170902fe8200b0019c13d032d8sm6125436plm.253.2023.02.20.05.22.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 05:22:54 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky , Matthew Wilcox Cc: Andrew Morton , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH 08/25] mm/zsmalloc: convert obj_malloc() to use zsdesc Date: Mon, 20 Feb 2023 13:22:01 +0000 Message-Id: <20230220132218.546369-9-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230220132218.546369-1-42.hyeyoo@gmail.com> References: <20230220132218.546369-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 91F634001D X-Rspam-User: X-Stat-Signature: 9ttkt7xfgtbrjnqesk15ag85rngz1wcg X-HE-Tag: 1676899376-428003 X-HE-Meta: U2FsdGVkX1/0YR/qj7ku8GdaoxhNUIGobI5Qh7sVUdX3RdHB1PaRvdorAn/sQD8wJ9UdDBvwKZr5qXn/Zv+fwVMI5XVYIcLAdo+dEEPKn/2cl0+ZGm928HwVRR699YTkVRHcqws48ZOB2+30rmoASEZt7PLYbbWYjnm2cG1S32i3r61CYdbwRAcaP6hQBQprA2zVhqcIHwECzc7Myz4supi0yxdNlkSGtuLDT7xAhmd6kzJvomAmAUdd3GVU6XACQEO9/DK3LNxW0XQEb5SoncawovBCfsMOprkyzBSzIIwAf47r560dUiJgoTYysIR3A/3PFdCBGAEwMQyvgIuBVjEM31y5HKsPz8/9Sg6VbYAh9aoT8kJ6bNmcXvlzCb46GGphYiUAt7spRf5ywJyKhtNTg+PBMn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7zk+s1w6RcnoBNXF5Vp+hWeAQ6pG8f2d28+7+h3gLj/bhLZYGQauy7e2J3jHr+T4F0MnmdBOL4OWIWQvT9ugRep8FjJA1UZl0m/g54npkT550ou1Pk8 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: Convert obj_malloc() to use zsdesc and replace helper functions with new ones that take zsdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 56cb93629c7f..4386a24a246c 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1637,12 +1637,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_zsdesc, offset; unsigned long obj; struct link_free *link; struct size_class *class; - struct page *m_page; + struct zsdesc *m_zsdesc; unsigned long m_offset; void *vaddr; @@ -1651,14 +1651,14 @@ static unsigned long obj_malloc(struct zs_pool *pool, obj = get_freeobj(zspage); offset = obj * class->size; - nr_page = offset >> PAGE_SHIFT; + nr_zsdesc = offset >> PAGE_SHIFT; m_offset = offset & ~PAGE_MASK; - m_page = get_first_page(zspage); + m_zsdesc = get_first_zsdesc(zspage); - for (i = 0; i < nr_page; i++) - m_page = get_next_page(m_page); + for (i = 0; i < nr_zsdesc; i++) + m_zsdesc = get_next_zsdesc(m_zsdesc); - vaddr = kmap_atomic(m_page); + vaddr = zsdesc_kmap_atomic(m_zsdesc); link = (struct link_free *)vaddr + m_offset / sizeof(*link); set_freeobj(zspage, link->next >> OBJ_TAG_BITS); if (likely(!ZsHugePage(zspage))) @@ -1671,7 +1671,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(zsdesc_page(m_zsdesc), obj); return obj; }