Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3666329pxb; Mon, 21 Feb 2022 03:12:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTC2bXUOIL7KOQX8NyH3QigHxYV5/g0RqFF6yTH+pwTxDifGQB1bi7zMHo76Khx0BggPhc X-Received: by 2002:a17:902:850b:b0:14d:9b77:958a with SMTP id bj11-20020a170902850b00b0014d9b77958amr18451546plb.123.1645441948112; Mon, 21 Feb 2022 03:12:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645441948; cv=none; d=google.com; s=arc-20160816; b=kd5aSPmxuyu3bRkxHPAbC5+nRjSLZalcCqRPjIJEl3cd18Dv8CxS/qXxo0G+2c+/y8 sRhtz7gb3l5KJmyi35tM3Y36RLTcFkQnjbEJqnOQYYuMJTd8mZ+toKPPW0QiOJGzBxLa 6Tkc9btHM8ZauScztkXTxlc/Y2B7k16k6cSx2OoK4h7e4Qj+SqPFfF3dneeHQ7iWcprv v29T4JkukkMY5zdqKTJSAa9gjgw6xY/C5m/011xEyysI2W//09tdCv5G16BH2d7y4tWW BVoKl/bZKgpRonEGuSKLykvzGu6cExFCHDUa7hTx5795Yii5XFHap4Z+GGjliEjVbA9J pb8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=sYIKJSfIPuM/6jGJDi71hsnZ7zSC1NteSYSTzSe15Vo=; b=CVq570qsOqmbV9U7aJsspoQxfZ1K1ODeh6oZe0MhME/n6G/7aBj+DuthK+XI5dTAQm YxCQKmAgtt6Ymjzwqye5vlazXzUu1igIC4UmPzRBq50g4VmrCLsVZAMwCrfK4WeVQIUq nBeuHbzE53PbMkgM0+edqwle5b3Q4V8y8caCqZXhOsY3ZLuaoxTI7vQgEbDM4XYzeAJH kfELFBEynhyHc9aes8Tav+n7a30EUJssaAayGtL3QNnS8DkII5ZdHzU5SO4zJvbxuVKu jj2HKWztVR0hB2PN1h0XVLujnG+IIg5gPJ3EvoK+NMuZYUrRx5D1oaIKOWnK2FcOwq0i KCJw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o18-20020a17090ab89200b001b917d0824csi6029918pjr.115.2022.02.21.03.12.15; Mon, 21 Feb 2022 03:12:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354679AbiBUKY3 (ORCPT + 99 others); Mon, 21 Feb 2022 05:24:29 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:55968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354654AbiBUKYD (ORCPT ); Mon, 21 Feb 2022 05:24:03 -0500 X-Greylist: delayed 3599 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 21 Feb 2022 01:43:42 PST Received: from lgeamrelo11.lge.com (lgeamrelo12.lge.com [156.147.23.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EEA303EA9F for ; Mon, 21 Feb 2022 01:43:42 -0800 (PST) Received: from unknown (HELO lgeamrelo02.lge.com) (156.147.1.126) by 156.147.23.52 with ESMTP; 21 Feb 2022 17:43:40 +0900 X-Original-SENDERIP: 156.147.1.126 X-Original-MAILFROM: kyeongdon.kim@lge.com Received: from unknown (HELO localhost.localdomain) (10.159.40.99) by 156.147.1.126 with ESMTP; 21 Feb 2022 17:43:40 +0900 X-Original-SENDERIP: 10.159.40.99 X-Original-MAILFROM: kyeongdon.kim@lge.com From: Kyeongdon Kim To: viro@zeniv.linux.org.uk Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kyeongdon.kim@lge.com Subject: [PATCH] pipe: use kmem_cache for pipe_inode_info Date: Mon, 21 Feb 2022 17:43:37 +0900 Message-Id: <20220221084337.207414-1-kyeongdon.kim@lge.com> X-Mailer: git-send-email 2.10.2 X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Because kzalloc() is used, the allocation size of pipe_inode_info is fixex at 192bytes, but it's only use 144bytes per each. We can use kmem_cache_zalloc() to reduce some dynamic allocation size. Signed-off-by: Kyeongdon Kim --- fs/pipe.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fs/pipe.c b/fs/pipe.c index 7194683..3054816 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -47,6 +47,9 @@ */ #define PIPE_MIN_DEF_BUFFERS 2 +/* SLAB cache for pipe inode */ +static struct kmem_cache *pipe_inode_cachep; + /* * The max size that a non-root user is allowed to grow the pipe. Can * be set by root in /proc/sys/fs/pipe-max-size @@ -786,7 +789,7 @@ struct pipe_inode_info *alloc_pipe_info(void) unsigned long user_bufs; unsigned int max_size = READ_ONCE(pipe_max_size); - pipe = kzalloc(sizeof(struct pipe_inode_info), GFP_KERNEL_ACCOUNT); + pipe = kmem_cache_zalloc(pipe_inode_cachep, GFP_KERNEL_ACCOUNT); if (pipe == NULL) goto out_free_uid; @@ -820,7 +823,7 @@ struct pipe_inode_info *alloc_pipe_info(void) out_revert_acct: (void) account_pipe_buffers(user, pipe_bufs, 0); - kfree(pipe); + kmem_cache_free(pipe_inode_cachep, pipe); out_free_uid: free_uid(user); return NULL; @@ -847,7 +850,7 @@ void free_pipe_info(struct pipe_inode_info *pipe) if (pipe->tmp_page) __free_page(pipe->tmp_page); kvfree(pipe->bufs); - kfree(pipe); + kmem_cache_free(pipe_inode_cachep, pipe); } static struct vfsmount *pipe_mnt __read_mostly; @@ -1496,6 +1499,9 @@ static int __init init_pipe_fs(void) #ifdef CONFIG_SYSCTL register_sysctl_init("fs", fs_pipe_sysctls); #endif + pipe_inode_cachep = kmem_cache_create("pipe_inode", + sizeof(struct pipe_inode_info), + 0, SLAB_PANIC, NULL); return err; } -- 2.10.2