From patchwork Thu Feb 16 14:09:35 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: 58095 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2388:b0:96:219d:e725 with SMTP id i8csp547401dyf; Thu, 16 Feb 2023 06:12:36 -0800 (PST) X-Google-Smtp-Source: AK7set/CDD3ZGUQLAcA18dwpotqXBG8zYtv1FfM5slzxH2zZgoh5tRPtXVKvPQsCHE7AWr8fC0JD X-Received: by 2002:aa7:da95:0:b0:4aa:c77d:fa0a with SMTP id q21-20020aa7da95000000b004aac77dfa0amr5810607eds.22.1676556755908; Thu, 16 Feb 2023 06:12:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676556755; cv=pass; d=google.com; s=arc-20160816; b=l5pGdza60lsWGYCOKRftXSE1F+/61sB72E28dPktEycJBGNNRk0+i0EsBxQQp/0+qy mv7w/+MP3o+IZHWRdBn/4nMS3TYyHlR+UCNB1mQIF4iUhrSlWAxO+2wMYVC21rKKJ9eT Mx0ba2/jPqwzRTfUHF4P3MYcXMHLjbaAy+e2DEwJQVwVscV6nX9KrtuCMWuwScXhCgzp vZWOCQEaP9QqEVKO0e5xE6UsyuwFhmKZDrFCHw4lmsyvE4KhwjQR1d/hZ/FLQlBjQAtg ipoFTiYq+6OxOvVB1tshgLT5FzcNxxStf3aZFdlDH22JoVk6Fao/wSAxUs42ff0LRLFu CltA== 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=njKBpNZG/OWGljuPOd7ZM34F7lFXHOxn3UcVLZ1fw9I=; b=A1PpqtYVLorOMa3l0bRzPEexNQlouM9NBP/Np25no8MC+EWopvlk7PdsnBxMzGpb5e 7jKQ6WQhC4lNXhlNC0rus2W8KU2YsP6GN6NdWGQErpAXR96PusGGQG7+CG8pyJbIHdl1 7F50u3TBhXMKWqOZS3oWbSLJWXX+WOAn43vleIjoIuFdFQ6T2ckrguNUcYYk3a9OBdUQ gEoeAc8P87rIM6+551MMCICmvnxBVOwGSi4+RvbfRt6a+/Z03mLApXFv0HhukbvHhig3 TBxjS/piC6sJJRjAIG2hNWBvxCJ0JiAskLaLXCbGw+GYnFdY9/RkHWv1atn47fsYeEx7 xquA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=rCKrhMNn; 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 n13-20020aa7c68d000000b004ad15601457si2198944edq.629.2023.02.16.06.12.13; Thu, 16 Feb 2023 06:12:35 -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=rCKrhMNn; 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 S229477AbjBPOLW (ORCPT + 99 others); Thu, 16 Feb 2023 09:11:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbjBPOLS (ORCPT ); Thu, 16 Feb 2023 09:11:18 -0500 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2112.outbound.protection.outlook.com [40.107.255.112]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BEB24AFEE for ; Thu, 16 Feb 2023 06:10:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b0CesmbRYzqGY6jK4GA77aJcVcQPvDFVyXDkexsPWaaxt0HUbZFXwR16QkJcCgAggVa3MZWpxnjyOUxi5cJSwzLe7LDFCam6bNP+jNffdTYLHRPQQQIExEqxQTeKxGT2uJD7/x/JDVgj1AGLDP3WeXUI+PXa71pi63acRILUmdBoLYH2CUnw53SIgGnHc1pSu5qsU1WicGsVMrFZs4eu+ndZcmIPuzigg9EWEjd0FzCwu8iFIxwp2kJ0FqBkgUQ2raLXjGxdYz9sCAboOTB0cS5hJw7XuQYUg/UwGkr6SRhEiEPbqDcfHlXYBLR1ZNnf/xZC6FTvmRcgZako8YaXqA== 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=njKBpNZG/OWGljuPOd7ZM34F7lFXHOxn3UcVLZ1fw9I=; b=TO/pvYI8lVTvCOif7nbzjXzxMme+ASSFc2dJEOEeWR9O/DcKoxzNUFdSYgOVumqN9Y7kwWf7mPGkik6mPFujCebqnm2oz2uPdlnBTwlKY25yinOSOvLut5cj05DClbcDAryaheikrQdF3BNW7LwXVgW1AIvfyz5jp08U6JNQ5Y4wjQCdbkkNkxNbxFTPZqkbhsR7Pizkec0A/1MTXpANnAuTqw181xRH04uvEIC62A3IiTa6a7lU584jccIx8icpQhepBdXRCFxbofons8vFczYlGGQ0WS7+9lFyalTu9EzN9R9D0On2Dc5b5wUqz0UXtrUzd5mbi7oL4Y03LiQ5hQ== 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=njKBpNZG/OWGljuPOd7ZM34F7lFXHOxn3UcVLZ1fw9I=; b=rCKrhMNnH++RdtyaFt5lQVohwFfmYS8R0k5SQgThwnp4edJF95Lpi5Z8QQhJ5QH07HhQ2CDGFR0VxgNECMVaZkhkdN+0lyn+iYiHC+E1T7VBj6+JCXG7xQj5hm1AA37wA1o9ok5RUv3Lz0FrTprsBWALZIvlwcKtX8wEBsl40Ha868EHPKXYUz3lUQWSjR6ql3G2VNDq0L+ZLN6FczLAyp+OYCTOA/9AdvDhq+n7od0vF8SvfAPy1TpNbA/g6bfXO5lrw3jxSasA5k4bvFFFwdEhb1/5IpATEjtcTJqEZ3gs5s10+rBvGlkb2rmBobTRnN1+0Ix12MnvaeYPb1s0Sw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from TYZPR06MB5275.apcprd06.prod.outlook.com (2603:1096:400:1f5::6) by TYUPR06MB5947.apcprd06.prod.outlook.com (2603:1096:400:344::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.10; Thu, 16 Feb 2023 14:09:47 +0000 Received: from TYZPR06MB5275.apcprd06.prod.outlook.com ([fe80::a2c6:4a08:7779:5190]) by TYZPR06MB5275.apcprd06.prod.outlook.com ([fe80::a2c6:4a08:7779:5190%3]) with mapi id 15.20.6111.009; Thu, 16 Feb 2023 14:09:47 +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 v2, RESEND] f2fs: export compress_percent and compress_watermark entries Date: Thu, 16 Feb 2023 22:09:35 +0800 Message-Id: <20230216140935.20447-1-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: SI1PR02CA0056.apcprd02.prod.outlook.com (2603:1096:4:1f5::7) To TYZPR06MB5275.apcprd06.prod.outlook.com (2603:1096:400:1f5::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR06MB5275:EE_|TYUPR06MB5947:EE_ X-MS-Office365-Filtering-Correlation-Id: f7a543e4-2725-4517-d550-08db102775a0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ITe7vSJ2AGcefPwgIsxsEOfDNb1dVxTbHW3VOckLzuUh7GgdVul91rvdKqp+S2kvtd0CumbnRn1EqzNrlt2nfK2zxSYIf1/87Io7xSdy5F1s8/G0p/uXCmBNu4vLQ02eMdEWPO1+S6a8qFUAgB1o6ufeVRi04ZlNIwEmlIvavUHu+WBkZ6BMPcmBiVSwlQY8iekc1A1pxYpcLL2mDl8bHlYCEmMUwOmmIHHOuFIF3+Tn02KDdzwQUpbQtcZTPmVwrzNO+xsxv7obDbv3hZpjFgzjP8k4/3JSKhWKmJEbs2Q3WnWbUZq0yyXvqYrzk6Wu8lu3/lbQiC5vjIo65BFJOoZZp2LVJUJgfNUL8QY/hyXNex29TH8ui6UBflqX/Ix9VKLOcftHP+xVCaV7pJ38HkIaratje7LNBaOjnjzDPxJGjBdUyPL5vQlg3nN2RibG10iR71f4HFUB0q6vsyzFpI1hecBrsa3tYrGdeOMN1qRbykJ+cDjjMZjGIGqHnX742lb18XOv/dcWaFOLoD96Uizu88E56A80diPTecNOgnfiDnHjsd281yEAO4Pd1QghIES5bweKDT3WgLzVwkFLmu1dKVr/0/KDIPAr6qL+UVs+8ZzhaKpGGpqvmjnepl+ZyRoLqT47jYNYcTmY4il9E/fG76k1J66bTz/QuTmyJPSod5ELcZSbnhUyVk42AE1NfxjwHs+quU8exrTM3Wb/YQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYZPR06MB5275.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(136003)(376002)(346002)(366004)(396003)(39860400002)(451199018)(186003)(52116002)(478600001)(6512007)(6506007)(19627235002)(26005)(107886003)(6666004)(38100700002)(1076003)(316002)(2906002)(36756003)(6486002)(2616005)(83380400001)(38350700002)(5660300002)(86362001)(8936002)(66946007)(4326008)(66476007)(41300700001)(66556008)(8676002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1+vnNwnnV0qAOljwl/zEtHCJM4vRJavZg0ciz8hZzmqP9GvA0i9DR3ytsAzt0ZyVsvyQKC0pxl5ZJgrJdZfHxL4UNpPjITd1+Nym/GcU3MX5TvgHke0ZTiL/ChcSHw9CpCjM0bgqx1M+EQy5pHWy3ov7FA0wxw6pRJWPoWnb4/Y4wzIWwbGaKgDaHxeW5e8uyPNaYHWA+zivvjcbDEejF7Yfvl5h/NVOVPUMYVDrEwH7+VzYuNddsjHnnj6VMVqHgov22p/CFUkEpF2avqqXw6yCFZw+tqo9OOErJHpIhxU/INevWO1NG/12DzqFCVEl33CbPViJIFaauWNsYmqc8VY9YizYExyms03dq8r8gkmlIk0ExTYtMf9gyKVLK1j9xVZXscZL6uCY8lBfsl1dRc6cOidt9/IqIcjcW7WLX+D+OIJ2j+UOP8GdI8vbZWskWQ9hSH44P6mZTzCRn8GvXZWnnlVTqUZQCwUnhFpHeSZXbYM5rv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R0ybdZzzvKQRJgr+DJ0hkvY7hoDMlZgjHFOyMY1 X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7a543e4-2725-4517-d550-08db102775a0 X-MS-Exchange-CrossTenant-AuthSource: TYZPR06MB5275.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2023 14:09:46.8813 (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: jkuD8eDqZGQfTbLLnw0fE6WWG3yvHwCqLn9rSAYtsGKC9txCBP2TjB9Yey5ZomXgk4NN4+VWLG9dHKEHNbhEBQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYUPR06MB5947 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?1757997176775160529?= X-GMAIL-MSGID: =?utf-8?q?1757997176775160529?= 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 Reviewed-by: Chao Yu --- v2: -disallow to set 0 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 94132745ecbe..c1314b7fe544 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -729,3 +729,20 @@ What: /sys/fs/f2fs//last_age_weight Date: January 2023 Contact: "Ping Xiong" Description: When DATA SEPARATION is on, it controls the weight of last data block age. + +What: /sys/fs/f2fs//compress_watermark +Date: February 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: February 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 0b19163c90d4..5397bd8bfcf7 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 == 0 || t > 100) + return -EINVAL; + *ui = t; + return count; + } + + if (!strcmp(a->attr.name, "compress_watermark")) { + if (t == 0 || t > 100) + return -EINVAL; + *ui = t; + return count; + } #endif if (!strcmp(a->attr.name, "atgc_candidate_ratio")) { @@ -950,6 +964,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); @@ -1057,6 +1073,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),