From patchwork Fri Sep 1 07:19:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ze Zuo X-Patchwork-Id: 13372129 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 6FA76CA0FE6 for ; Fri, 1 Sep 2023 07:20:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D99378D0023; Fri, 1 Sep 2023 03:20:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D20ED8D0022; Fri, 1 Sep 2023 03:20:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B75878D0023; Fri, 1 Sep 2023 03:20:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A0A988D0022 for ; Fri, 1 Sep 2023 03:20:09 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6913012015D for ; Fri, 1 Sep 2023 07:20:09 +0000 (UTC) X-FDA: 81187179738.10.F0FA268 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf16.hostedemail.com (Postfix) with ESMTP id 0FAAD180024 for ; Fri, 1 Sep 2023 07:20:06 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; spf=pass (imf16.hostedemail.com: domain of zuoze1@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=zuoze1@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693552807; a=rsa-sha256; cv=none; b=Y55AEWkBa73EdAYrOw2U+aFXQvoFOHY298jZ3es6IvEf6bfNJmPI+vI1OlwH9Gub21nInf 9eV3H7uY5xKGO3E4VXfu6gN+hPrh4+6TmzJBeRF7fDHc6L8iAFsNqe1i4SsPOiPp13r+a4 18vzV/Q40ofVjLvixGw7FzUs0cG5EiM= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; spf=pass (imf16.hostedemail.com: domain of zuoze1@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=zuoze1@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693552807; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HFJRC4la27KnwjPMFYKF6HEaLmgN63X/p33IyH6z9pI=; b=4nAzjqYfz//9UcG05jyuemvNR+hj0Zw0E26hpMQ+TrUD4ZDxKyIkSs35ZLVbHbGO3hkbz9 3X20AO0vBhOJA8uShvhX8y8eZG7F8ZnaPbzvpG7LJ65h5DK4Zd0zjn26MCXBclJrYrSnU6 FWOY5MZHAXm51To353OoqTT5ZxEPc7E= Received: from kwepemi500002.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RcTpb6h5vzhZHN; Fri, 1 Sep 2023 15:16:07 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by kwepemi500002.china.huawei.com (7.221.188.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 1 Sep 2023 15:20:00 +0800 From: Ze Zuo To: , , CC: , , , , , , , Subject: [PATCH 2/2] zram: take the benefit of kvzalloc_node Date: Fri, 1 Sep 2023 15:19:42 +0800 Message-ID: <20230901071942.207010-3-zuoze1@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230901071942.207010-1-zuoze1@huawei.com> References: <20230901071942.207010-1-zuoze1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemi500002.china.huawei.com (7.221.188.171) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0FAAD180024 X-Stat-Signature: jr9wy1gin9mr8uo3x1hasepd3hqu1r13 X-HE-Tag: 1693552806-1051 X-HE-Meta: U2FsdGVkX1+pXG1nU3ND8C5PN4t6kRn2gH1vQk5a86VSm//nJATYJJN2XZn2PKKwnJvcGd8ZoVmdO+JfSuFid+Ak47sbFskV3Gew5HclHpTSHuJ6vMFdntifG/IKBffC6h0QVfJBFppLqKg4+ef3656tNKXPUEkE72uiJGi8vZbAD1Vmb8sTqGHiDcaGpfrPA9DArqX9aWXkewVgYztZvsy+BMcNKOrzadtReQqye8IVA5UJBIibnjex/iowtcIf4U+fkrSMLNyyYTP/Q/CeA7mdQUHZKiSGckrXgjvOTF8376J0eEJB7UzXbavZhXeVMsVS3IuWhF8/YmiZBWxrCkOnYIwzG7IHsyEyotOr8nIQKSOgqlSC94yVLOtwRPEgdTASNtoN9fuW4OvrqTUr+hiNzi5R0U5xGm+aM5EbC9B1+pkjE176iUM+NU3BXcqkd1GD/6Hw7CLIqZDkJCh8fTmVPklJ2dJP6TB384fHnVFoh4MDmBz1i90Vh+lLyW4M5iVyb6RaRUtxusU1jvPsXaBM24FI+V50gB9OMJQqqKS3JTOnyA8E++t94xEcVHauXBvYlYs9akYRkeS+zWV7oMBR6D6TUCxVBNay+QCuvEyMRl9Cydb9shHhcpgIq+LLfeYs9Z1+hw2rIQRT6BbDICrBq42mvyJUOGhxaGbAdaT8mqizHQAlPjneVZ0HeFv46agUNO/AHtCdxk1Cpa4+74Ak+3WkCU6BMj5rM2LiMPCETkupDMgunlM5EKScX2Sn2t3CN1MeG3bkGTrft7UbK8qMIiERzsq887PeNxsRRgWg1rGLM0lP1v7I/jLRQeIp79itFoT62bQY//xLUsHMjOHny5sV8fMBQ2JsUzc5kVtQkeNHdXpt4xGDtMDAzK3jES9d5uzmY075pzuRPl/7F7W+OE8CQiaIpllT5j1zNxMx464nNNUybiSSyz5eRIMHHxEy2ie6VugTQHLcd4J +lMLpqh3 MUi4mwwvowxKJh243Ukg8jRzEVidjLwLH/DWAPJO9CIFRkTO62WUrIRTkhzQtBu2p/c49rbzuulzwd/aZg4vF/4FNu5b9uD6hT0o4UjnEi9loEJvu77BqxTk6tiqH0Y3i+SM7381TzOpdwPNcZnNIEtKfLBd9HwWAbJYuYuXegSoJCo5hObHr6dkBFOuABTPF3CsF 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: Using kvzalloc and zram can benefit from huge page table mapping, so lets use kvzalloc_node/kvfree instead of vzalloc_node/vfree. Signed-off-by: Ze Zuo Signed-off-by: Kefeng Wang --- drivers/block/zram/zram_drv.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 692993e48e93..97241f166324 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1249,7 +1249,7 @@ static void zram_meta_free(struct zram *zram, u64 disksize) zram_free_page(zram, index); zs_destroy_pool(zram->mem_pool); - vfree(zram->table); + kvfree(zram->table); } static bool zram_meta_alloc(struct zram *zram, u64 disksize) @@ -1257,13 +1257,14 @@ static bool zram_meta_alloc(struct zram *zram, u64 disksize) size_t num_pages; num_pages = disksize >> PAGE_SHIFT; - zram->table = vzalloc_node(array_size(num_pages, sizeof(*zram->table)), node_id); + zram->table = kvzalloc_node(array_size(num_pages, sizeof(*zram->table)), + GFP_KERNEL, node_id); if (!zram->table) return false; zram->mem_pool = zs_create_pool(zram->disk->disk_name); if (!zram->mem_pool) { - vfree(zram->table); + kvfree(zram->table); return false; }