From patchwork Sun Jan 29 08:30:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 49980 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1766032wrn; Sun, 29 Jan 2023 06:33:53 -0800 (PST) X-Google-Smtp-Source: AK7set933pEMkPTW3ZILqZsODDGqrQbJxFWtnuEBXOCLH441iuZbge05Qml7v85EQ3OaIW0wt4pu X-Received: by 2002:a17:907:9705:b0:7c0:be5d:59a9 with SMTP id jg5-20020a170907970500b007c0be5d59a9mr8313229ejc.20.1675002833679; Sun, 29 Jan 2023 06:33:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675002833; cv=none; d=google.com; s=arc-20160816; b=hX4K4koTBsKpl6jBxJIzbz2PAOfZiRkVss8ciUWmYJPpNr2Dy5803t4OD2Z/7lz07I TI+Q+C69DuuDzl+rBkWMSwHK2YmucShnc4c4CfjX0oRY0qJ+XrTYaULyVe4mAbMcdeDU AbfiPm9quOsxwqJul3SSJW2tvu3qkJ53YLzH4G7kOC+e4Z1r6iO24CkvLyY2JreHPvSw 31lop50CEMYJfBweRjqjwNkmGs5CUEVDizqPMY1wZqxUtXG0am6pHx14BbgF2J9Pd0Gw HE6+H3kd0PoYVYnI+6Jt+9hGMwci0A6saqI6wuZHQIOiaaMhj0b6UVZH1XwTi6wBMqQA rU1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=1z+iCS46Yr3lm9ACNgc7qodB+R5Gmf1kYOzItj9dp4U=; b=LtRPGPq/VNi8aRrRBpO6hq80O9FMT3pgQzHNfo3yQyy9fkOpUK1qTe85Ls4g+cN1H5 OB2D7xncpR3BRtngdzxZkWxkzaoHPgoWGNhU07AvaWC8QCl8uRIbR++n6h8yPJA0CY2y KaUcO5ckZrQ2LVsMixLeEP8IC++RQmKMjPC6KzyWG6BWFsI/OkC4zqmPEDgbTSGwil6z Ur/V3uoT8GIXkKa/ybjjFuQjijanRsewiMHMX8hl2A8nDyNDdcXHicNM5z+sMsssAwRA qE3ZVeKO6OLXiIxli8bYI2eII+M/2HcHxsNCln9EnkGcAOrBbeqGScSFLGsKIfV0QTQG lMvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="JqAp/Hc9"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y17-20020a50ce11000000b004a2181432ecsi7190906edi.558.2023.01.29.06.33.18; Sun, 29 Jan 2023 06:33:53 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="JqAp/Hc9"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231154AbjA2OHx (ORCPT + 99 others); Sun, 29 Jan 2023 09:07:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229741AbjA2OHv (ORCPT ); Sun, 29 Jan 2023 09:07:51 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 250294482 for ; Sun, 29 Jan 2023 06:07:50 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A178CB80C98 for ; Sun, 29 Jan 2023 14:07:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E340C433EF; Sun, 29 Jan 2023 14:07:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675001267; bh=bivgQD4hccIujFULNfSi51tGjZlhLoS4MaUhofH0cSc=; h=From:To:Cc:Subject:Date:From; b=JqAp/Hc9UJhdXEb1d4OF6T7gLXjUOMIttzWm4qjncnt6y+JzSfVCQlRw8zBxhOIDh aFvOiUOp4J79fM36UPDgJe9yGWrciOioFsS1CkJ3Y8W2kj5LzXQ8ZZxsR1sxGr8/zw 7020xN/e1BWTLpQjF6iWtgkKYqjaihUyBzDmbU8TWxDLTo9/wykwiOTYq9kYfE9m64 K8ndYaMC3KLaf4z1mVTUHq7e0Ta3Pw5ST3JlRsfEbGqotqEhc+FFTHNNyrCH8P+NPW KEUs8cIxn4NQuGmb59oDphE2bXorgTMF7di9Ips+jrES/1PGtKPw/p+9g7wq4c51TO WD/O/1vgXducw== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH] f2fs: reduce stack memory cost by using bitfield in struct f2fs_io_info Date: Sun, 29 Jan 2023 16:30:45 +0800 Message-Id: <20230129083045.7754-1-chao@kernel.org> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DATE_IN_PAST_03_06, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756367771337092973?= X-GMAIL-MSGID: =?utf-8?q?1756367771337092973?= This patch tries to use bitfield in struct f2fs_io_info to improve memory usage. struct f2fs_io_info { ... int need_lock:8; /* indicate we need to lock cp_rwsem */ int version:8; /* version of the node */ int submitted:1; /* indicate IO submission */ int in_list:1; /* indicate fio is in io_list */ int is_por:1; /* indicate IO is from recovery or not */ int retry:1; /* need to reallocate block address */ int encrypted:1; /* indicate file is encrypted */ int post_read:1; /* require post read */ ... }; After this patch, size of struct f2fs_io_info reduces from 136 to 120. Signed-off-by: Chao Yu --- fs/f2fs/f2fs.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index fa41c0dad308..f2f201e2a6a6 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1212,19 +1212,19 @@ struct f2fs_io_info { struct page *encrypted_page; /* encrypted page */ struct page *compressed_page; /* compressed page */ struct list_head list; /* serialize IOs */ - bool submitted; /* indicate IO submission */ - int need_lock; /* indicate we need to lock cp_rwsem */ - bool in_list; /* indicate fio is in io_list */ - bool is_por; /* indicate IO is from recovery or not */ - bool retry; /* need to reallocate block address */ int compr_blocks; /* # of compressed block addresses */ - bool encrypted; /* indicate file is encrypted */ - bool post_read; /* require post read */ + int need_lock:8; /* indicate we need to lock cp_rwsem */ + int version:8; /* version of the node */ + int submitted:1; /* indicate IO submission */ + int in_list:1; /* indicate fio is in io_list */ + int is_por:1; /* indicate IO is from recovery or not */ + int retry:1; /* need to reallocate block address */ + int encrypted:1; /* indicate file is encrypted */ + int post_read:1; /* require post read */ enum iostat_type io_type; /* io type */ struct writeback_control *io_wbc; /* writeback control */ struct bio **bio; /* bio for ipu */ sector_t *last_block; /* last block number in bio */ - unsigned char version; /* version of the node */ }; struct bio_entry {