From patchwork Tue Jan 17 13:17:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5oms6Z+s?= X-Patchwork-Id: 44664 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1750912wrn; Tue, 17 Jan 2023 05:20:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXv3Q7S7U84zChSSRmkHGMVRtIcqS6rG3Oe6uLz8U7CW++s0wyaPfMw2swANlKrC/blOoUNB X-Received: by 2002:a50:ed0b:0:b0:49d:7e68:d66d with SMTP id j11-20020a50ed0b000000b0049d7e68d66dmr2426042eds.42.1673961636661; Tue, 17 Jan 2023 05:20:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1673961636; cv=pass; d=google.com; s=arc-20160816; b=Jrfcb58ikM+eOx9UsBeuig0NWn392am9tsgJx7t6Ckc4+h4zt4gdsPAWiYqDXpsrzb Y1s6RiQOdh+dxzXHfPRICTUygCK2lufd4IWXXjNHGo6BqdqpHVcyGwPVz7g+nHCpFcCs +bdubK5W7C9IWQAeKf82yLQP8nHNKKeX4326QIFmCac+0KzzFkxt8RR7cwcWANeZ50yj A/lZOgEa6AcJUNuKLDkNBD15YrA4OQLgHLv8wlel+b2LzBpwbShgSZpWJy2rv7liiw0R 1oAuBwEH+9bnhP5NEb4TtGwIdKDCpfBQNfjbv81M6t5NkVnseQfJaNMbnKB9Rh3s3+Xe /osA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=8bMnH5jWPEKaNdGYDSsNc8HEQKql/H1lFBS/NuavcTI=; b=KKBQsooPkltZW1Pgkz0OIqqX7r9StQJU0FgDqLC86WmbeKnjM+SNTp/0wXXlHNuHIY cUtE/11UM4BBc0KsLzk2IF+ICpu4N63I/WFKUf9zChxi7dI5YUW7Qghbcqg7ifH1Z4FA /TeUyfYZfdI8e/Q/DnBu3BwEDW1Mn0esHKphzemyfnG2IwazvMgfKdvUOMOAsh7yvmX9 KzQouqeqOPBXO0FAhEIwMZ7p5JwW1/yhTLeQU9B9scpui5e2g6lMrFm/IViQjlpRB/6M yP3Myq6uR16vmO4Z2EJN8m3DSMZph9fqKi9oodU9qv9NIocCZV7U6XqGKhzUS0qcsUMz vUkA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=YxEh9Y2e; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x2-20020a05640225c200b0049e24913887si4749352edb.356.2023.01.17.05.20.08; Tue, 17 Jan 2023 05:20:36 -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=@vivo.com header.s=selector2 header.b=YxEh9Y2e; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237086AbjAQNSO (ORCPT + 99 others); Tue, 17 Jan 2023 08:18:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237116AbjAQNSA (ORCPT ); Tue, 17 Jan 2023 08:18:00 -0500 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2112.outbound.protection.outlook.com [40.107.117.112]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDD4939BB2 for ; Tue, 17 Jan 2023 05:17:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HoihBhxPq+vsMo2yLxWtTNLHIu8aGskRl4x0ZvGTEqdJ09jglJ5I8E/AudEe6F7wxKSWQq0kytlaE22+NppEze2q+77uMdCU8jshp+k9DK0aGOVGI+0XOdDxMCIxnqkekzL4Vu4NcTbElSmBxfpSlcl81xWVpYyDOnam3mMSGVM8pP4nffLdh0EYxkh1/K3wAeLUHOWXS3b06KnlwjpvfTeoy7iG5hBZilZok3H3ik0OMo/mmBfoF3EgHG8Cw9Er80C/ZW/d9pjIQ3ybe3iN2ldArybKKRwhiXV4Npzc7U9+TifgH2Bmkj3mn9xgxF/TcMJNpCMrsfRm017DsiPkhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8bMnH5jWPEKaNdGYDSsNc8HEQKql/H1lFBS/NuavcTI=; b=kfFB23Pk954Al02WKBzGgiwRIN3UKburpc5nENDAEzBk0VgtqSHYV57Wwb09iW6IaR2rQCylAEPXQ2irHDBlWhss4amJt8UbydG9cf65xOq79nYD7hClCtlTSF8O9xGyBMBK4VGEEmWpOvU5SWQaDManWwsFYda9G0jPm2H8eXDLsCGnAGQ/sQF8gBaT61wTI8k34PBqIPQbWmLXAZhnGw+gBDRY0w7PYtTsMAi0ZgNf+0xwar+pWWblXW4vfvnWClnT9tZVnxplps6YM/VIo0S/pUDbzV/YBpW+JDN0cUFeZ+C2fceFMTn5D3T+OcskBmEKV0Qv137QGdJMIvsAVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8bMnH5jWPEKaNdGYDSsNc8HEQKql/H1lFBS/NuavcTI=; b=YxEh9Y2eP7Hzhg6tpQIPDKGm7p1bLX3HQtXlLKKpGJzSNDUw3Tg5/cMBKnWPcq4RI0uF470kxjByg5yOjNspDmMgN0sGEXMDOcvgZTwEbvmptfWfD7YuspTIEUIe4HZYkp2V5DxVeHFNHebp5j/oy4pqln7TYzBTb6DnEYJkxGKrv1LH4bRw4QLh7oF2JmSYMTxnEo8w1TSrVvfE6X7R+qY34w0IX7ZPhA0mI0cwUnVBLdk4dItbxABy8iCbHKLGrQ7zTVeTIOtmXPLb5o0Zp6LYeyVMo59L8CAbdwWe+7+wOkyWkn6Lb0kMOpENQHjjrtyTwbxb54gSQv1yF7tvAw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) by KL1PR0601MB5566.apcprd06.prod.outlook.com (2603:1096:820:c4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Tue, 17 Jan 2023 13:17:51 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::3e52:d08c:ecf4:d572]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::3e52:d08c:ecf4:d572%5]) with mapi id 15.20.6002.012; Tue, 17 Jan 2023 13:17:50 +0000 From: Yangtao Li To: jaegeuk@kernel.org, chao@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Yangtao Li Subject: [PATCH] f2fs: export compress_percent and compress_watermark entries Date: Tue, 17 Jan 2023 21:17:40 +0800 Message-Id: <20230117131740.76597-1-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: TY2PR04CA0019.apcprd04.prod.outlook.com (2603:1096:404:f6::31) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|KL1PR0601MB5566:EE_ X-MS-Office365-Filtering-Correlation-Id: efa2afb8-2722-44ed-ac12-08daf88d3be9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1YhKBBMs94CVubTDZea41d6vE+bK3CNpxZCIgAOaduGFQjmnQqHoqR7z5NQ67T1vDSvpPpi6t47ar4rvpPTy1nINpTq3q3auLYozNTqAmEpl2diLr6RNqIu3Oknoaw6XjgaEn4Mpo+Q6tvm37iPK6NF/0xwqVNJUlU5JGerg2cYUYSjh8MrhXBJtPdqWc1uOPNNFaLKRRLju/PJM5Fawp0Ryo+ATNnA8v5dIS+vUzQMGrijMPvo9A+HffvFKR+lezdsb4moqAp+HjWmqSNSPLdelLnXXBMieklIIBJekxckCMqqARV/0ubG4129Z63mNcAHmcQX5PgOTAdCQQM/9QoTlgpOcRmp0IAfIOEXkE/5DMHoqG7IpCPoizylQq3v0F+aPgYWRokm1p2ohCtx5q9fdN4n6585D4EVICIhHOINJv99kniYxQEPdthTZnJDKpmbAjaAUeugtfDphzOTCu0PMRxjcq+uBSbWfEo3smi45+shy25++JqIUr5DJtTct/gvChCQnWYTZMEdK24tpJ3Yn4H7pyxZd3i2nTFDwfx5uoKeLnHvRPGOV0JMbEbVaC08aKEQyFtvKBwP0voQpV0397wMowCCECcDbJMi/QBdZT6hpyx29S7pJ2OQenxB/KVtPHELLOpZPowX8CXA5GAccS00R/O902ba91307c8XqI2ignxfKgHj5Gr+n607di00N658gIS8uwdT0qy+HJQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEZPR06MB5269.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(39860400002)(376002)(366004)(346002)(451199015)(83380400001)(38100700002)(38350700002)(86362001)(5660300002)(2906002)(8936002)(8676002)(4326008)(66476007)(66946007)(66556008)(41300700001)(6512007)(6506007)(186003)(26005)(2616005)(1076003)(316002)(19627235002)(478600001)(107886003)(6666004)(52116002)(6486002)(36756003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GElBx84mvsoyUA//7GmlrNTm6/ocjBt5n6pnMXzwYbY7Gmf9h46lpn3jmzjRPA3tjsg9oIJidITM6hyXtPUX0yRE+/J5DOpb/AdW5V/xmzDelay4ceD0ReajdXn53P3fB2SiLvyZtEkbV1Sby7KZo5Z1OXvAQBRa3GAVRZgvcCEeMiqlIjlTg5x4D6TneLqv0x668zCJEvgtf827Aa4vB67ClfPkTHA56+LG7jwlzydxsjJuZN+WT6UKqWjnxKGm2PzjKxR9BlCoSyPBNOUthRhq2LfBVjoeoTCvFmVHEG0OU8V4OmYgutvyI4pNz1HLDEGoWCuZzn1Ubh4V1/rCskpo3DjfSzQ2NrAjgL761QKzYi9f6lzvc4Q32x5rFxJnp/z9QRoxS2/zM0jPH7JD1FUGMHAsJeZGB4UbLCm7cYpS+SgJ39oeaL1nkyhg/rFPvcendyHtoUykZbxr7z/awTkOiCgBnbn9xN+D1LrUGztNZ9QuPnqzxphC0ICLDlgJYsBqqyiNxogWpyBHXo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o.com X-MS-Exchange-CrossTenant-Network-Message-Id: efa2afb8-2722-44ed-ac12-08daf88d3be9 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2023 13:17:50.7635 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3dbNRdYjn+xKsRfsqwktrGHqM5NEVLP4x1l/6VJ50LMBfu5Mhb00bjJrk2q7+QOYhnt5PqoohxeRmuNfHgZjqA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR0601MB5566 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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?1755275997276699523?= X-GMAIL-MSGID: =?utf-8?q?1755275997276699523?= This patch export below sysfs entries for better control cached compress page count. /sys/fs/f2fs//compress_watermark /sys/fs/f2fs//compress_percent Signed-off-by: Yangtao Li --- Documentation/ABI/testing/sysfs-fs-f2fs | 17 +++++++++++++++++ fs/f2fs/sysfs.c | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs index 75420c242cc4..920562742655 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -717,3 +717,20 @@ Description: Controls background discard granularity of inner discard thread is smaller than granularity. The unit size is one block(4KB), now only support configuring in range of [0, 512]. Default: 512 + +what: /sys/fs/f2fs//compress_watermark +date: january 2023 +contact: "yangtao li" +description: when compress_cache is on, it controls free memory watermark + in order to limit caching compress page. If free memory is lower + than watermark, then deny caching compress page. The value should be in + range of [0, 100], by default it was initialized as 20(%). + +what: /sys/fs/f2fs//compress_percent +date: january 2023 +contact: "yangtao li" +description: when compress_cache is on, it controls cached page + percent(compress pages / free_ram) in order to limit caching compress page. + If cached page percent exceed threshold, then deny caching compress page. + The value should be in range of [0, 100], by default it was initialized + as 20(%). diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index e396851a6dd1..37c6ef080f7e 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -598,6 +598,20 @@ static ssize_t __sbi_store(struct f2fs_attr *a, sbi->compr_new_inode = 0; return count; } + + if (!strcmp(a->attr.name, "compress_percent")) { + if (t > 100) + return -EINVAL; + *ui = t; + return count; + } + + if (!strcmp(a->attr.name, "compress_watermark")) { + if (t > 100) + return -EINVAL; + *ui = t; + return count; + } #endif if (!strcmp(a->attr.name, "atgc_candidate_ratio")) { @@ -932,6 +946,8 @@ F2FS_FEATURE_RO_ATTR(compression); F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, compr_written_block, compr_written_block); F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, compr_saved_block, compr_saved_block); F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, compr_new_inode, compr_new_inode); +F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, compress_percent, compress_percent); +F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, compress_watermark, compress_watermark); #endif F2FS_FEATURE_RO_ATTR(pin_file); @@ -1038,6 +1054,8 @@ static struct attribute *f2fs_attrs[] = { ATTR_LIST(compr_written_block), ATTR_LIST(compr_saved_block), ATTR_LIST(compr_new_inode), + ATTR_LIST(compress_percent), + ATTR_LIST(compress_watermark), #endif /* For ATGC */ ATTR_LIST(atgc_candidate_ratio),