From patchwork Fri Apr 7 17:46:07 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: 80923 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp444978vqo; Fri, 7 Apr 2023 10:58:00 -0700 (PDT) X-Google-Smtp-Source: AKy350YCbS2O9iAyU3ItYVCGTBUfJj21AUJ2j7rjp/ktjxYlVgPNo9Ow8AujOIJTZ1MLCEcU6+HO X-Received: by 2002:aa7:d6cc:0:b0:502:2440:577e with SMTP id x12-20020aa7d6cc000000b005022440577emr3279188edr.16.1680890280617; Fri, 07 Apr 2023 10:58:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1680890280; cv=pass; d=google.com; s=arc-20160816; b=0xxLuTilvZavQ926a4Ufn0Y9s2oYZ/ztuHj0uxy7UBmL/97pnf+4kAihSParYl41EB y16h5wC7Q2LcsO7GMwZpjADGMnNq2g1aSwIMyYj127ilHFuoiRXnCMXjj1fGO9eBLAP0 jJ2RFtN77ploJxauszZzb4e3fTJFcsIqPasE8bdS05WyaPdAqptXjg6Twm/s2SLODCNv CxkW559N6ThHR6btFsPwlRlOjuKsxaV6OQ2y7xyWCj/6WQzD3T7p+GXALYbL1FjMbDIq Gg+rBgMPhUaPggTl7sbjC06mWChaYaDmr0yP2GVxNtsteBqlwlRODjlPM2xcD+WazFPm 5FAQ== 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=YmfXcCsXN4o/FIs6g/+CLsFE+z5Gk+zVqU5lRRDjHWg=; b=zVLD/6LmbcqTynkUn2w1HkYSgJyiAsElie2V8woYM2sSpw1IqqpPIv3EZ+5D0klQle gUNwAHDfd9eKuMoz37aOtDienJeOega9g8MzxcSJA9EoSbjbfpM9MYtf4oe31xFA/hUw BRz3r2BpznsEHgHvUEhJFlfMYQW16vd1SlsRdLbWixZkeRo0mW5JSOhMANcizSHOfWcO u3jK/dDWV4c08D7CmjhKnw1wU74ZexVrl6M+UGg2ktkEqvJEqirYnXg8LvMUFzQl2sZN b8a+yWFtQZTyRnbM/omZz7aPCLBhSDgwi1X8y9hwD8WRUooxKfLNPFqefZ47PvGzA7So zIvw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=ISGIk1cV; 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 u23-20020a1709060b1700b00947bb5b21a0si3564219ejg.722.2023.04.07.10.57.35; Fri, 07 Apr 2023 10:58:00 -0700 (PDT) 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=ISGIk1cV; 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 S230117AbjDGRqb (ORCPT + 99 others); Fri, 7 Apr 2023 13:46:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230077AbjDGRq3 (ORCPT ); Fri, 7 Apr 2023 13:46:29 -0400 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2135.outbound.protection.outlook.com [40.107.117.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9659DB469; Fri, 7 Apr 2023 10:46:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bGnRJCujd/g3mMCMIuoxO5qM0YWeqr5B8rCq6scSg5IMyBJZ4MZr3DzAcQ8gUrD00sk/Dj0P94UduQvYW0WWSDrtl8Sj6355h0u33v0BhMv29+Q2XzccFu6G9r3lNfzHrS/8o9aT0q0gy9hX3BvOnSnXaYGOUsRlm2dgjMjiQdOs7311IYIGr+GKibswRC7vlt8/mQ4mNIllxKShgBaI7aW+R7RGGsjJnlKPhZNHNCwCNk5NmKfUL6mFMiR2bJmXJcHjEZiU/w40SIf6BGMARy4g+W5t215u/7TNrFxHPd1+tAJsUJa8At7w9CAOObH5ZCW96cqxZ3f1gt9F+utO2w== 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=YmfXcCsXN4o/FIs6g/+CLsFE+z5Gk+zVqU5lRRDjHWg=; b=CuYgENGAZQjzZ7/DRECJQX15n0c60W+mXz2ZJqUivfnCwB5SSCE8nH7yNbETYpCVNuzSrRVH6EHHVmUO3GAfv3dIoZteUUJSpSIJbzylCzTCDXQZPGGOS+mKoEmoPkIR8mjAGugIu0O7/apCAOMWRup0bp05RmLJmwxtYzkmGAFuyads0VcPyyuP6fGKWWPEKvXFH3BbZoOjis/IH7MUWl7Wlny+3i/PkeA6W9srPBa0FcYf+zfvAVjQtPcWcgRSoF5gcwy42w0ie+JDQez3jv2nuNgN25ir8wUArcBXEBWsNMzdbULq6HCtFplVDWYpJl9ufeuIxDhni5Kd7pGgkw== 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=YmfXcCsXN4o/FIs6g/+CLsFE+z5Gk+zVqU5lRRDjHWg=; b=ISGIk1cV5PUsvhlnaesV3TqYm6z7oDWLHbbQYXqEsgkLg0a0MfKu2zC5D/n8HA4WyGNXZxw44E/oDbOzj9cZ2UN7yKz3M0vwtYz1lFXri0T+zp/6HIQOPq+q6OM+5mrteC+yJBhVmDMoyKh2egfX3CxHwAcy5Kspu/ls2VKGdhiIgVcOyA81kvnPVzhP5t9MiPNFkvBHwahE2WF80cFwvm2iQnOBrHVtKTTcijBtKZi8AvIGM8qxCA+GTh5RW3QzIw8d04dg40jtZSfZr5MB3uNlHBRy0hvSzMTwu0NQR0R3cBmLmeP0JfVzQG6p3pf4f2QWyXPJUyvU5/nwbn6Syw== 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 TYZPR06MB5907.apcprd06.prod.outlook.com (2603:1096:400:339::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.34; Fri, 7 Apr 2023 17:46:20 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::a3a1:af8e:be1e:437c]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::a3a1:af8e:be1e:437c%6]) with mapi id 15.20.6277.031; Fri, 7 Apr 2023 17:46:20 +0000 From: Yangtao Li To: Jaegeuk Kim , Chao Yu , Steven Rostedt , Masami Hiramatsu Cc: Yangtao Li , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH v4 1/2] f2fs: refactor struct iostat_lat_info Date: Sat, 8 Apr 2023 01:46:07 +0800 Message-Id: <20230407174609.4939-1-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: SG2PR02CA0127.apcprd02.prod.outlook.com (2603:1096:4:188::7) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|TYZPR06MB5907:EE_ X-MS-Office365-Filtering-Correlation-Id: 459fd702-c2d6-455b-5d8a-08db378ffeec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5L2STOmviU+Uv7IrYdfq63X6/pGmGFWxRvZzSdVK8XDw8WYdXBIvrIGuLLMWHzmcX3RVERnFaJP7CLrjqPgWDLWgvvqyx37XgyfA4DIZpmLMuDyqdUG8JZ6Rn9+CQgUPG6ClGWNRLa9A+cKWO0Ao0RSSr9L4oADh8svONoPLkd5duN23BZpRLrt5UHngMSx6++zn7jlxAOs0jAzMuNcfEvxqHt3i/wEJKaQjcGyE1ev3Q0tbDw8n2lm4a7WRlwGZvLP3+o55CAsGU+fAnY8Sv7VCqO90d0OsfqMHAYW3Ax8DR5VgnU7cUwIWyKWnP+eST6jfnvQiwkqsYU1wjBs5New0kgo8KGFYBhR1MB5/7gbykaAxWaDhlbxpREjEe5iArsIWQqIxeJSlqodn3C8N5PFudbX3Pum+W1tP1XGHl7YgrPqWfWIelysJGABcatbymTwLDx7GAJL5AYxVCrp3UuC8lQF1+412vzLvP4ICrZMTrGPDd7t9DP4gar68TjG1gudCfLR8E6Wicw8Y6pc5I2UUJM3c+/SR+50s9i5TKUzGQrUZjLIzZzRGFm0CXwvqNFokY5mkVKp3BU6P8pSlF1/kn7AVJPFjT4Q6xZyLA2d2wHR58fWn46bVFWQYumGg 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:(13230028)(4636009)(366004)(376002)(346002)(136003)(396003)(39860400002)(451199021)(38100700002)(38350700002)(36756003)(6506007)(110136005)(8676002)(26005)(186003)(5660300002)(6512007)(1076003)(8936002)(2906002)(4326008)(66476007)(66946007)(316002)(52116002)(66556008)(6486002)(478600001)(30864003)(6666004)(86362001)(41300700001)(83380400001)(2616005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZX2Fa1KrSpm6cxzMX78hr5/s/P78d479YF/uMGAsb4QiX5JIB2P7RHRAgxpCJvCQk7AN6dBDJR5pqPzzXsxWZRjZi53BIFJDWl2w5U/0gBknpM34rTDbk2UHJ8HTPpJHsEnx1wwHSFiXTII3e9EfGPR0fhhBJJbflEz1PRbh0ohLr28ZL3/lga/0g7VWk7xJCrNdnz6vUCsCYeCshRUy2V5wyAyBVBFyJekPjHWgYsBDf9HZ7NVQpfxmCYt7NfTDDefjteJIE2GWiHngGq55KTHXUWoB7ZVYog6bjmULRYoFfGpYIaUoGAzsyN24YhyC9i4P3MxJsF7v1hdhQqxmG5gN2U77fEmL9+8r1wNEQnxdfDjex/7ctGkJG7EVYNit2RkILEOlfVruTwFGF6/LBE3mdfmJfPXut/H0Mo0zEtfOto2KBfbuoschn28JDl/kHb9DzOHw+FljhYP8eRZ9crQvdxurz5giyOB9bsHtnRS+YM/iLMEifOjAI2XOyKw9SK0JFpXQ254+dZ+AQ1l4hRx5y2y+Py0bDe+rJExEGJD2QXAUQyW36169RLmKdg5WcT8Ba7ceHe2xzc0fiN1sHh6uJx1H5iXrubo1x6yk3wxsP5YpKKLACrgFfWPaqT7EdpQSZlrnbSR4reZ3K7WAZff5ZnhD/T72MMs7eZyBnJ0nfqra5KcTwmgMXyLJml1d8wG1QbUaT4Vs/Pb47K4SJwcQ5dFZmlkhXTJODeJQAPBVZ7WbCtMELpyBE4G9uEWrp8T7g1AZdyDsn++EFtWb2QX5LXEI0/FL0fAeUy+Q2tYQ4qKtusDADfLLFE8KkLPPD9+WD5nGmDOBrzVXCuNTIooJDOhBlJza2TrAwz/qSpq7EM8MFoVozfk/zQyUqWGTmFA2VyXCP7+Z3Lx/Z4w4GZPhHI0UOYbbWSRjEvLt02fqNzDIV5KrLX3CsMVJ7ynYYMPY3XtsxLFIOlZ2+ef6ZuUDFVbidizUUp/JJbao495h2mhNZhDhfQVGrHUfxH8Qeyyhuch8rHYclXE1LLPIeVP97/TcJ5op15k/7GS//AHPi7EHfphwjLyyywa1afSiaUSbGrbR4pDacMA9tPb2+NWVZzxGBT+euK+x2kZTvb0FvF3sdEnyu9kselfPgCRZ9AuGvByleROw+O0p76DxwSiqBDxhc+BdDi52oMJ8ge5Mc6dwRAC5DXFiEmKZ0u2geOx7y4SXLsm4YLMBornFBar+BRyl/s3Q1BbTN6WTQfEhHev4zFDNRb4ZXWyWoVllbBsEoIiw5t9QurcepLi0Sm7d28C5MocC5zZxIqHtLcrxlU2+BzyLIIXArNPw5an8u9XlNRo4hM/GNgPo6JcmI4vg6sDHE3hpAGqfJlQsJe+WIND6oCjh7ahU+U8TpxkFRNqGHIHMpvK3hIfbAVH12PPR85RZY7oCvTB5yDTar9C52/LkUL7NupM7w4PGFqsJz1634xRS2jzRgrgHQKSBU/31r2klUlY/hKNrfWzmPpiCk+tlP9xQQu1toAjpUkNuc/OkIPk+qG6MlFe/+rvzrUDuM1b7fysVWf3djCIH+3AJ+iVQi+m1bzChxgUgFf8K X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 459fd702-c2d6-455b-5d8a-08db378ffeec X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Apr 2023 17:46:20.1806 (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: zSDNUC2t9h8AxYVbZFjk4jVPtL8y7WHH8JDGrynz2QaGE12cTPArgapKZd3txja7dspt63LgSteCWkkjFWLLVA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB5907 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762541207115079565?= X-GMAIL-MSGID: =?utf-8?q?1762541207115079565?= The current code uses a mixture of MAX_IO_TYPE and NR_PAGE_TYPE to form lat_type, and uses a two-dimensional array to store data. NR_PAGE_TYPE is 3, which is unreasonable for a discard with a PAGE_TYPE of 1. So this patch changes the array to a 1D array and does some cleanup. Signed-off-by: Yangtao Li --- fs/f2fs/data.c | 2 +- fs/f2fs/iostat.c | 79 +++++++++++++++++++++---------------- fs/f2fs/iostat.h | 49 +++++++++++------------ include/trace/events/f2fs.h | 56 +++++++++++++------------- 4 files changed, 97 insertions(+), 89 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index e975f9c702ab..38cab984496f 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2311,7 +2311,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret, if (bio_add_page(bio, page, blocksize, 0) < blocksize) goto submit_and_realloc; - ctx = get_post_read_ctx(bio); + ctx = iostat_get_bio_private(bio); ctx->enabled_steps |= STEP_DECOMPRESS; refcount_inc(&dic->refcnt); diff --git a/fs/f2fs/iostat.c b/fs/f2fs/iostat.c index 3d5bfb1ad585..5d496d5b70d3 100644 --- a/fs/f2fs/iostat.c +++ b/fs/f2fs/iostat.c @@ -86,23 +86,21 @@ int __maybe_unused iostat_info_seq_show(struct seq_file *seq, void *offset) static inline void __record_iostat_latency(struct f2fs_sb_info *sbi) { - int io, idx; - struct f2fs_iostat_latency iostat_lat[MAX_IO_TYPE][NR_PAGE_TYPE]; + struct f2fs_iostat_latency iostat_lat[MAX_LAT_TYPE]; struct iostat_lat_info *io_lat = sbi->iostat_io_lat; + unsigned int lat_type; unsigned long flags; spin_lock_irqsave(&sbi->iostat_lat_lock, flags); - for (idx = 0; idx < MAX_IO_TYPE; idx++) { - for (io = 0; io < NR_PAGE_TYPE; io++) { - iostat_lat[idx][io].peak_lat = - jiffies_to_msecs(io_lat->peak_lat[idx][io]); - iostat_lat[idx][io].cnt = io_lat->bio_cnt[idx][io]; - iostat_lat[idx][io].avg_lat = iostat_lat[idx][io].cnt ? - jiffies_to_msecs(io_lat->sum_lat[idx][io]) / iostat_lat[idx][io].cnt : 0; - io_lat->sum_lat[idx][io] = 0; - io_lat->peak_lat[idx][io] = 0; - io_lat->bio_cnt[idx][io] = 0; - } + for (lat_type = 0; lat_type < MAX_LAT_TYPE; lat_type++) { + iostat_lat[lat_type].peak_lat = + jiffies_to_msecs(io_lat->peak_lat[lat_type]); + iostat_lat[lat_type].cnt = io_lat->bio_cnt[lat_type]; + iostat_lat[lat_type].avg_lat = iostat_lat[lat_type].cnt ? + jiffies_to_msecs(io_lat->sum_lat[lat_type]) / iostat_lat[lat_type].cnt : 0; + io_lat->sum_lat[lat_type] = 0; + io_lat->peak_lat[lat_type] = 0; + io_lat->bio_cnt[lat_type] = 0; } spin_unlock_irqrestore(&sbi->iostat_lat_lock, flags); @@ -208,62 +206,73 @@ void f2fs_update_iostat(struct f2fs_sb_info *sbi, struct inode *inode, f2fs_record_iostat(sbi); } -static inline void __update_iostat_latency(struct bio_iostat_ctx *iostat_ctx, - enum iostat_lat_type lat_type) +static inline void __update_iostat_latency(struct bio_iostat_ctx *iostat_ctx) { - unsigned long ts_diff; - unsigned int page_type = iostat_ctx->type; struct f2fs_sb_info *sbi = iostat_ctx->sbi; struct iostat_lat_info *io_lat = sbi->iostat_io_lat; + unsigned int lat_type = iostat_ctx->lat_type; + unsigned long ts_diff; unsigned long flags; if (!sbi->iostat_enable) return; - ts_diff = jiffies - iostat_ctx->submit_ts; - if (page_type == META_FLUSH) { - page_type = META; - } else if (page_type >= NR_PAGE_TYPE) { - f2fs_warn(sbi, "%s: %d over NR_PAGE_TYPE", __func__, page_type); + if (lat_type >= MAX_LAT_TYPE) { + f2fs_warn(sbi, "%s: %d over MAX_LAT_TYPE", __func__, lat_type); return; } + ts_diff = jiffies - iostat_ctx->submit_ts; spin_lock_irqsave(&sbi->iostat_lat_lock, flags); - io_lat->sum_lat[lat_type][page_type] += ts_diff; - io_lat->bio_cnt[lat_type][page_type]++; - if (ts_diff > io_lat->peak_lat[lat_type][page_type]) - io_lat->peak_lat[lat_type][page_type] = ts_diff; + io_lat->sum_lat[lat_type] += ts_diff; + io_lat->bio_cnt[lat_type]++; + if (ts_diff > io_lat->peak_lat[lat_type]) + io_lat->peak_lat[lat_type] = ts_diff; spin_unlock_irqrestore(&sbi->iostat_lat_lock, flags); } void iostat_update_and_unbind_ctx(struct bio *bio) +{ + struct bio_iostat_ctx *iostat_ctx = bio->bi_private; + + if (op_is_write(bio_op(bio))) + bio->bi_private = iostat_ctx->sbi; + else + bio->bi_private = iostat_ctx->iostat_private; + + __update_iostat_latency(iostat_ctx); + mempool_free(iostat_ctx, bio_iostat_ctx_pool); +} + +void iostat_update_submit_ctx(struct bio *bio, enum page_type type) { struct bio_iostat_ctx *iostat_ctx = bio->bi_private; enum iostat_lat_type lat_type; + iostat_ctx->submit_ts = jiffies; + if (op_is_write(bio_op(bio))) { lat_type = bio->bi_opf & REQ_SYNC ? - WRITE_SYNC_IO : WRITE_ASYNC_IO; - bio->bi_private = iostat_ctx->sbi; + WRITE_SYNC_DATA_LAT : WRITE_ASYNC_DATA_LAT; + lat_type = (enum iostat_lat_type)(lat_type + type); } else { - lat_type = READ_IO; - bio->bi_private = iostat_ctx->post_read_ctx; + lat_type = READ_DATA_LAT; + lat_type = (enum iostat_lat_type)(lat_type + type); } - __update_iostat_latency(iostat_ctx, lat_type); - mempool_free(iostat_ctx, bio_iostat_ctx_pool); + iostat_ctx->lat_type = lat_type; } void iostat_alloc_and_bind_ctx(struct f2fs_sb_info *sbi, - struct bio *bio, struct bio_post_read_ctx *ctx) + struct bio *bio, void *private) { struct bio_iostat_ctx *iostat_ctx; /* Due to the mempool, this never fails. */ iostat_ctx = mempool_alloc(bio_iostat_ctx_pool, GFP_NOFS); iostat_ctx->sbi = sbi; iostat_ctx->submit_ts = 0; - iostat_ctx->type = 0; - iostat_ctx->post_read_ctx = ctx; + iostat_ctx->lat_type = 0; + iostat_ctx->iostat_private = private; bio->bi_private = iostat_ctx; } diff --git a/fs/f2fs/iostat.h b/fs/f2fs/iostat.h index eb99d05cf272..67b468691498 100644 --- a/fs/f2fs/iostat.h +++ b/fs/f2fs/iostat.h @@ -6,17 +6,24 @@ #ifndef __F2FS_IOSTAT_H__ #define __F2FS_IOSTAT_H__ +#ifdef CONFIG_F2FS_IOSTAT + struct bio_post_read_ctx; enum iostat_lat_type { - READ_IO = 0, - WRITE_SYNC_IO, - WRITE_ASYNC_IO, - MAX_IO_TYPE, + READ_DATA_LAT = 0, + READ_NODE_LAT, + READ_META_LAT, + WRITE_SYNC_DATA_LAT, + WRITE_SYNC_NODE_LAT, + WRITE_SYNC_META_LAT, + WRITE_ASYNC_DATA_LAT, + WRITE_ASYNC_NODE_LAT, + WRITE_ASYNC_META_LAT, + DISCARD_LAT, + MAX_LAT_TYPE, }; -#ifdef CONFIG_F2FS_IOSTAT - #define NUM_PREALLOC_IOSTAT_CTXS 128 #define DEFAULT_IOSTAT_PERIOD_MS 3000 #define MIN_IOSTAT_PERIOD_MS 100 @@ -24,9 +31,9 @@ enum iostat_lat_type { #define MAX_IOSTAT_PERIOD_MS 8640000 struct iostat_lat_info { - unsigned long sum_lat[MAX_IO_TYPE][NR_PAGE_TYPE]; /* sum of io latencies */ - unsigned long peak_lat[MAX_IO_TYPE][NR_PAGE_TYPE]; /* peak io latency */ - unsigned int bio_cnt[MAX_IO_TYPE][NR_PAGE_TYPE]; /* bio count */ + unsigned long sum_lat[MAX_LAT_TYPE]; /* sum of io latencies */ + unsigned long peak_lat[MAX_LAT_TYPE]; /* peak io latency */ + unsigned int bio_cnt[MAX_LAT_TYPE]; /* bio count */ }; extern int __maybe_unused iostat_info_seq_show(struct seq_file *seq, @@ -38,29 +45,21 @@ extern void f2fs_update_iostat(struct f2fs_sb_info *sbi, struct inode *inode, struct bio_iostat_ctx { struct f2fs_sb_info *sbi; unsigned long submit_ts; - enum page_type type; - struct bio_post_read_ctx *post_read_ctx; + enum iostat_lat_type lat_type; + void *iostat_private; }; -static inline void iostat_update_submit_ctx(struct bio *bio, - enum page_type type) -{ - struct bio_iostat_ctx *iostat_ctx = bio->bi_private; - - iostat_ctx->submit_ts = jiffies; - iostat_ctx->type = type; -} - -static inline struct bio_post_read_ctx *get_post_read_ctx(struct bio *bio) +static inline struct bio_post_read_ctx *iostat_get_bio_private(struct bio *bio) { struct bio_iostat_ctx *iostat_ctx = bio->bi_private; - return iostat_ctx->post_read_ctx; + return iostat_ctx->iostat_private; } +extern void iostat_update_submit_ctx(struct bio *bio, enum page_type type); extern void iostat_update_and_unbind_ctx(struct bio *bio); extern void iostat_alloc_and_bind_ctx(struct f2fs_sb_info *sbi, - struct bio *bio, struct bio_post_read_ctx *ctx); + struct bio *bio, void *private); extern int f2fs_init_iostat_processing(void); extern void f2fs_destroy_iostat_processing(void); extern int f2fs_init_iostat(struct f2fs_sb_info *sbi); @@ -70,10 +69,10 @@ static inline void f2fs_update_iostat(struct f2fs_sb_info *sbi, struct inode *in enum iostat_type type, unsigned long long io_bytes) {} static inline void iostat_update_and_unbind_ctx(struct bio *bio) {} static inline void iostat_alloc_and_bind_ctx(struct f2fs_sb_info *sbi, - struct bio *bio, struct bio_post_read_ctx *ctx) {} + struct bio *bio, void *private) {} static inline void iostat_update_submit_ctx(struct bio *bio, enum page_type type) {} -static inline struct bio_post_read_ctx *get_post_read_ctx(struct bio *bio) +static inline struct bio_post_read_ctx *iostat_get_bio_private(struct bio *bio) { return bio->bi_private; } diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h index 99cbc5949e3c..040a430e1199 100644 --- a/include/trace/events/f2fs.h +++ b/include/trace/events/f2fs.h @@ -2045,7 +2045,7 @@ struct f2fs_iostat_latency { TRACE_EVENT(f2fs_iostat_latency, - TP_PROTO(struct f2fs_sb_info *sbi, struct f2fs_iostat_latency (*iostat_lat)[NR_PAGE_TYPE]), + TP_PROTO(struct f2fs_sb_info *sbi, struct f2fs_iostat_latency *iostat_lat), TP_ARGS(sbi, iostat_lat), @@ -2082,33 +2082,33 @@ TRACE_EVENT(f2fs_iostat_latency, TP_fast_assign( __entry->dev = sbi->sb->s_dev; - __entry->d_rd_peak = iostat_lat[READ_IO][DATA].peak_lat; - __entry->d_rd_avg = iostat_lat[READ_IO][DATA].avg_lat; - __entry->d_rd_cnt = iostat_lat[READ_IO][DATA].cnt; - __entry->n_rd_peak = iostat_lat[READ_IO][NODE].peak_lat; - __entry->n_rd_avg = iostat_lat[READ_IO][NODE].avg_lat; - __entry->n_rd_cnt = iostat_lat[READ_IO][NODE].cnt; - __entry->m_rd_peak = iostat_lat[READ_IO][META].peak_lat; - __entry->m_rd_avg = iostat_lat[READ_IO][META].avg_lat; - __entry->m_rd_cnt = iostat_lat[READ_IO][META].cnt; - __entry->d_wr_s_peak = iostat_lat[WRITE_SYNC_IO][DATA].peak_lat; - __entry->d_wr_s_avg = iostat_lat[WRITE_SYNC_IO][DATA].avg_lat; - __entry->d_wr_s_cnt = iostat_lat[WRITE_SYNC_IO][DATA].cnt; - __entry->n_wr_s_peak = iostat_lat[WRITE_SYNC_IO][NODE].peak_lat; - __entry->n_wr_s_avg = iostat_lat[WRITE_SYNC_IO][NODE].avg_lat; - __entry->n_wr_s_cnt = iostat_lat[WRITE_SYNC_IO][NODE].cnt; - __entry->m_wr_s_peak = iostat_lat[WRITE_SYNC_IO][META].peak_lat; - __entry->m_wr_s_avg = iostat_lat[WRITE_SYNC_IO][META].avg_lat; - __entry->m_wr_s_cnt = iostat_lat[WRITE_SYNC_IO][META].cnt; - __entry->d_wr_as_peak = iostat_lat[WRITE_ASYNC_IO][DATA].peak_lat; - __entry->d_wr_as_avg = iostat_lat[WRITE_ASYNC_IO][DATA].avg_lat; - __entry->d_wr_as_cnt = iostat_lat[WRITE_ASYNC_IO][DATA].cnt; - __entry->n_wr_as_peak = iostat_lat[WRITE_ASYNC_IO][NODE].peak_lat; - __entry->n_wr_as_avg = iostat_lat[WRITE_ASYNC_IO][NODE].avg_lat; - __entry->n_wr_as_cnt = iostat_lat[WRITE_ASYNC_IO][NODE].cnt; - __entry->m_wr_as_peak = iostat_lat[WRITE_ASYNC_IO][META].peak_lat; - __entry->m_wr_as_avg = iostat_lat[WRITE_ASYNC_IO][META].avg_lat; - __entry->m_wr_as_cnt = iostat_lat[WRITE_ASYNC_IO][META].cnt; + __entry->d_rd_peak = iostat_lat[READ_DATA_LAT].peak_lat; + __entry->d_rd_avg = iostat_lat[READ_DATA_LAT].avg_lat; + __entry->d_rd_cnt = iostat_lat[READ_DATA_LAT].cnt; + __entry->n_rd_peak = iostat_lat[READ_NODE_LAT].peak_lat; + __entry->n_rd_avg = iostat_lat[READ_NODE_LAT].avg_lat; + __entry->n_rd_cnt = iostat_lat[READ_NODE_LAT].cnt; + __entry->m_rd_peak = iostat_lat[READ_META_LAT].peak_lat; + __entry->m_rd_avg = iostat_lat[READ_META_LAT].avg_lat; + __entry->m_rd_cnt = iostat_lat[READ_META_LAT].cnt; + __entry->d_wr_s_peak = iostat_lat[WRITE_SYNC_DATA_LAT].peak_lat; + __entry->d_wr_s_avg = iostat_lat[WRITE_SYNC_DATA_LAT].avg_lat; + __entry->d_wr_s_cnt = iostat_lat[WRITE_SYNC_DATA_LAT].cnt; + __entry->n_wr_s_peak = iostat_lat[WRITE_SYNC_NODE_LAT].peak_lat; + __entry->n_wr_s_avg = iostat_lat[WRITE_SYNC_NODE_LAT].avg_lat; + __entry->n_wr_s_cnt = iostat_lat[WRITE_SYNC_NODE_LAT].cnt; + __entry->m_wr_s_peak = iostat_lat[WRITE_SYNC_META_LAT].peak_lat; + __entry->m_wr_s_avg = iostat_lat[WRITE_SYNC_META_LAT].avg_lat; + __entry->m_wr_s_cnt = iostat_lat[WRITE_SYNC_META_LAT].cnt; + __entry->d_wr_as_peak = iostat_lat[WRITE_ASYNC_DATA_LAT].peak_lat; + __entry->d_wr_as_avg = iostat_lat[WRITE_ASYNC_DATA_LAT].avg_lat; + __entry->d_wr_as_cnt = iostat_lat[WRITE_ASYNC_DATA_LAT].cnt; + __entry->n_wr_as_peak = iostat_lat[WRITE_ASYNC_NODE_LAT].peak_lat; + __entry->n_wr_as_avg = iostat_lat[WRITE_ASYNC_NODE_LAT].avg_lat; + __entry->n_wr_as_cnt = iostat_lat[WRITE_ASYNC_NODE_LAT].cnt; + __entry->m_wr_as_peak = iostat_lat[WRITE_ASYNC_META_LAT].peak_lat; + __entry->m_wr_as_avg = iostat_lat[WRITE_ASYNC_META_LAT].avg_lat; + __entry->m_wr_as_cnt = iostat_lat[WRITE_ASYNC_META_LAT].cnt; ), TP_printk("dev = (%d,%d), " From patchwork Fri Apr 7 17:46:08 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: 80922 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp444248vqo; Fri, 7 Apr 2023 10:56:10 -0700 (PDT) X-Google-Smtp-Source: AKy350bNJBlMcGGTjdWhKEZkVGoOE+vAP6g3FepH+MMsHZ3Rs/L5VmIl1HTYXfnXJVUTPOCCGlLY X-Received: by 2002:a17:906:b2d8:b0:947:71cf:7c97 with SMTP id cf24-20020a170906b2d800b0094771cf7c97mr177098ejb.36.1680890170292; Fri, 07 Apr 2023 10:56:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1680890170; cv=pass; d=google.com; s=arc-20160816; b=O/EtzqOHdPgg1qK0dqyiR46XsWFR0JEQidqY4h+pvekiOlT4sE+KH2OgmgK9xQzigJ XzDTX8yFOXqh1ZnQsFs8OV08ScHRBCfNyE7NHOR4nLKldPj3euWxS8aW7HYM4SfCuAI1 RCYtz5f+d+qKYurjDMzb3ov8ld4JzQEYWinm/WLnRVzuiZdHFM9oDFQ9FY0dPqSSOY4q 8VCRZmXWlJQh3hepRZKtFWbuXYo7e26NWuR2NdwT+Ypl4r5rKV8kw1B8vqZjeM9nzHCZ UEF0xgVl4zyhPx3+JiuLTkaXNhpUQwv+Esd5zUs6MIgT/6nkBevFS3ycrufn32I6bu8Y PrYg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=l13cqtxzQcUOoYpmE+V0PGtrr5i/usoTVpOWUdBlP/0=; b=MmxWeZqL0eo8PXSJxvUPhD20zv5qQzu2ivTBB/Esprtm8L9EwFBktsdMJmfiAv9RTw e5kuvfkOfGDEnkhEVx1nOZezvkZJKQMEyP/HG9QUWUP85ad98pjBVYa/bXQ8WrgWvNVS Q450ADbbSsCj+J9tvhJ+oB0wJ2N59TL32X2IUYvxko8NW9ItwQ933nX8ty2UbaNuF/Ok ntcuv9ShQM66Vd84dlAqjytsvkFUhKOHycnFZmsx+OYeSITJV+3pgI/36E11+cY+K4b4 O8eVEwzb7Zj96I/A290GprhNU1pTO0Fsa0tFVFV396otiy6xDaAg1uE8f6ilL54NY4eN 4tbw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=IavwA5O9; 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 gs16-20020a170906f19000b009314fd54ad1si3465569ejb.703.2023.04.07.10.55.45; Fri, 07 Apr 2023 10:56:10 -0700 (PDT) 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=IavwA5O9; 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 S229963AbjDGRqi (ORCPT + 99 others); Fri, 7 Apr 2023 13:46:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229853AbjDGRqd (ORCPT ); Fri, 7 Apr 2023 13:46:33 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2134.outbound.protection.outlook.com [40.107.215.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EE879ED9; Fri, 7 Apr 2023 10:46:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FhC8LLiGw1ZccWXgw/vhFAxiJnoynx2kGnUxXdh0HFmul01Z7/f+CH3WuzOfhNVKJeXJUiq43dmlMo2hzLhg0VFcMLw3smZNS+3hnHG6w9m80769nDwQ94qmmV6havDurd81xN2ryQOeIdoDUv1trCXrjskJ2BggnzJkTh2gnovs4HA2tmml6BwZhep+e76IOSsCsM1k85TBUvjuibE/hFBh87VaOMV0Qs/j+nWNgn4XbVf8XzkPHJfG9Txur+tx8MjSmxaSs0kPZA2CbRObRtW6D14Oic8J6uS2q3WLZjI+O5r/4f/to4nXKJez48xW0Lwza7w1XZAp+P6W1rBgnw== 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=l13cqtxzQcUOoYpmE+V0PGtrr5i/usoTVpOWUdBlP/0=; b=PG7kvsGcNEVv696RpK5Wdk85mc85pcSRA302Ezt843ix+O9JNes6yXwLkILAj3/xu0WaqKyBoPkvTYqa/DtEwjqm4fBYB6lyumvpszZEZ2aYAFr/s3Y+Mdu9iH1+9ENRPNyl4jzaZ16WuYAXEHtjSNegQ67qVvnKafE/kQJiDFZziyEKOhAyt46oGO9h58wDpMouuY3tS5r6J0YqkjlUMBU2lU0R3I+9JBIbjM+09joP86VJ9xN4OqQ+jlB3leZWHrlrR2zPH70RgHJEU6hVPdRzocxCEZFUQb0QqBP8b2POyowMtwpiRa1r4Faoex6iDJRRrGLj+px4WHeSjUbfxg== 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=l13cqtxzQcUOoYpmE+V0PGtrr5i/usoTVpOWUdBlP/0=; b=IavwA5O94j9hUSOqgRMG2aWsPUK9PLKgQC7o9r96puT/c62X6zgO6+gb6FhkszHljK1BvrGST1IB0JJUC1A70HhQTcaEQbWt96J1WwaShpafPIyI0m8npA42rv0RCo/XbXQZlKHvG4oc3lyLaz0f3eUcWtbomY7zqQHTHeLhrbfyRfrQZkkLYKkSn3NtOolmVKWK5TCYhheydOkTkr7+JHcHE3cm0CivQbneyx8D68pXgUUWWX1egqjld37WG3n2lACN4eexCrs5HsNCVQ7EvuxqiWVreNKMghzPsjQwExW8Q9ezIlHlhpcvGVlA2eNX3i0ZWoXaIs+iMuVhHNlQOg== 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 KL1PR0601MB5613.apcprd06.prod.outlook.com (2603:1096:820:9a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.35; Fri, 7 Apr 2023 17:46:23 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::a3a1:af8e:be1e:437c]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::a3a1:af8e:be1e:437c%6]) with mapi id 15.20.6277.031; Fri, 7 Apr 2023 17:46:23 +0000 From: Yangtao Li To: Jaegeuk Kim , Chao Yu , Steven Rostedt , Masami Hiramatsu Cc: Yangtao Li , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH v4 2/2] f2fs: add iostat latency statistics support for discard Date: Sat, 8 Apr 2023 01:46:08 +0800 Message-Id: <20230407174609.4939-2-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230407174609.4939-1-frank.li@vivo.com> References: <20230407174609.4939-1-frank.li@vivo.com> X-ClientProxiedBy: SG2PR02CA0127.apcprd02.prod.outlook.com (2603:1096:4:188::7) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|KL1PR0601MB5613:EE_ X-MS-Office365-Filtering-Correlation-Id: 931756d5-9329-4742-dc3f-08db379000bf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hCu4mhKfhHqlK46MeUKEbcZCp5DOlO3D68Y/IbYPgbitYMafUrYR1r4B1CrFu9GRiiTm6dMZu8VimijMOzdLNt+2hvkUIlp1ik8NP70BlTrUqHOyVVDVi99OitPUclq5ik5R0rFhWQd3Jjv/Cfn7C4xi0DOvyczbTTrgkH6HxNj3h5zqxdJ8taCSJ8nC7D701DtXaeaSqSvaJS8svfGwrAbegu81uHazDF5ClKJ6vIzxWvPDynETg5eWUgQnvspunfm04TF+V6nEJDLXYRuoxQhzwoljfnjGyvRKGZyH5HiEm2h4IIZJUoIMD/CP0hkUgo15QAFlxZWYMYa9C4BayxhDl8fJoQhyuXV87atR8ttFAUSv4CBslTXTnuJsZ2Cju98EbLycg6tyUTYsVDmS2E45wm+GOMBlxtpyC8qpRgWvOx0lW5VcRIilbYr8K/Te4Bs+fsV33kznqP4wtNOeTAbXFbjFliwcsSqA2KHwa9vQ/poApyC/k3GSehNIDBBOK6IyZcXtigD4J5i23JaSohl8e/U2LaOdnB69uUshcll9pBvRooJZ+eq3mQbARMDSfvoH0tinC5bvH2WMznbkrAHc24VUo44wPgiG8v+FP1wgkxvouc7N2YlS3PmP94QR 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:(13230028)(4636009)(376002)(366004)(136003)(396003)(39860400002)(346002)(451199021)(4326008)(66476007)(66556008)(66946007)(110136005)(316002)(36756003)(2906002)(41300700001)(2616005)(478600001)(86362001)(52116002)(5660300002)(6486002)(6666004)(8676002)(8936002)(186003)(38350700002)(38100700002)(6512007)(1076003)(6506007)(83380400001)(26005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tlxwxtlFsvIqiUilb6JIeVY+PWOnK7IecupfyEbocy75ceA/LfxBBGfb6riLCYT/CVtOwcEOCzdfYJMgCjjZZRODR+TAdAbENgXdLW5lWJ4WYLtolXrG/NQo6Y3040zY3pwlRp6CP3Y8aEUA1JZadTxguAOAs0FB2SZXv6bsRwh1VQtQ2cGcOugnfC3l9mCMu3A5ZyDegMxaVe1pFedaZsHTnN7fI5QGCE4B/AGmh1CIdWilLOLLSmQgAmnMRq7+xNqT61KwqxIqDEEbG00gMv8XyEKf1D06CPYMrOWfkRoZ9oDYM7QNYp7oRTT3+9Qarf8D4YXtnXjK3H+bFWzhGDNH67yqea6ke1AAtN8cfQXV34CNQcRzGIUCcJowKfKBoWGKK1sVNKkGdD5tOUgpikdgYqrdlaKARXpVyToqwlQlRGXYAIan8ovtCVbrn7EFOsC2BiT98a/UYR9K2pnqkocKo6M5F9a4gD9ZD9lKnUS7FsVauh8kf+Sv0qdUknjlGin+RWm5Hndmk3cozUzM02nY0FTVsUwVsJBBvo7BUwXhZdrf76Ig8tkxaSBl6Y9i34LqvwZnXaGl7Z5M61T2S4UVf8cwH0kh9hA+ewNqUB8KUXhCKJpXCwd6dVPxY663tU42O+6MLtxM/zSlmDgRwlxM+GSNTRVqw8CqASPcRZG7N/PAIiJP+02r/Labgm7cDTaOWAO/ypftNfoURmxrZ8ID0j585tf/VkMed89IyLJ5C5S5fh3qWc/+MjSaIfUw1MeyLx5aWk0BhMGy8+v4ic/Y9NbCUCd1F0b1a5bDhz/C4Uk+FbjvnNdSm6gKeVH4d1RWI9xrXPmqEgrwgru9+NG5Y8/xO/LEi5yR1lCI5dACS2wm7dy3qHR39+Q8w8VqzxJO2FTE0W2c7nHaY7AK5Y9fVKh4GZGa03L3uAYzktOnE159EoCBJbKa2KPWfHbioQa8Kqss7Yl8BJ+pPBY/Z4tDXI2QnTAQRFEYCY7bhLhImDOy1Ew9znTCgAHgxdlPxoUgpnpZUlJOYbOfxuoCTO778NpMOM0VlO0JwzE5sNMU+NFDZv73YBo71anxKlFo2P2mjGNoxJJ6bDNUy2hfm4FJkotFDuZdTCsoqSslnABmR588yWtI1PtlP3IHxn/D7R42XC0tKQb+Gxvvl4Zuf35lcszwB8HjMlNq5stYhlds11BoSxsf35xEnBNr5jlCr9wwP9E8j7EFfP3+29uP0u+LrHwv71Mt8R4bMS7aVnZOVlIe0QQNRSqiJrycFcG+2JeN2QXo2pUwJSiCdoD4wpWgvLuvOBv7OYDvwzEFtqLi6bNIiER9OBBk4kgWPRCqk9U3u+Hqoxa2K9uHMkfQYSZF3Cy0Hy7r1tuxMvDt1XXq9urwZ1zX8qQnsrm/EBtxvgwePa8i1l9t/knw1LbFzptWG7OI28XZ8xJ3UMtqbMbYAMNMC63OlrnS/RFu7h57qfKgKNoyedKba8W/QWKoAe2TADUvAWAdYFHwtT2hrui8XvpI5bzdx320lH7ImngD+3XcKcFLN04DRytssYmJgGYhoW7sbWWdf8eUMrloJ/Xput2d58qUoqzCk86040Rl X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 931756d5-9329-4742-dc3f-08db379000bf X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Apr 2023 17:46:23.1753 (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: +CDNQp5QufVD77XIxJf7iTA5Z7SIuQ8n/T6h0TIFk5e4tENaNGIqP7t3PAxGO8MUlqQH2EzJnzcPAfUO/paqMA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR0601MB5613 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762541091237284496?= X-GMAIL-MSGID: =?utf-8?q?1762541091237284496?= In this patch, it adds to account discard latency. This allows us to track the discard io latency of the system lightweightly after enabling iostat. Signed-off-by: Yangtao Li --- v4: -split it to two patch fs/f2fs/f2fs.h | 1 + fs/f2fs/iostat.c | 6 ++++-- fs/f2fs/segment.c | 8 +++++++- include/trace/events/f2fs.h | 12 ++++++++++-- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 3d883201e7a5..1779f3596176 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1112,6 +1112,7 @@ enum page_type { META_FLUSH, IPU, /* the below types are used by tracepoints only. */ OPU, + DISCARD, /* used by iostat */ }; enum temp_type { diff --git a/fs/f2fs/iostat.c b/fs/f2fs/iostat.c index 5d496d5b70d3..f40b8915ae1b 100644 --- a/fs/f2fs/iostat.c +++ b/fs/f2fs/iostat.c @@ -235,7 +235,7 @@ void iostat_update_and_unbind_ctx(struct bio *bio) { struct bio_iostat_ctx *iostat_ctx = bio->bi_private; - if (op_is_write(bio_op(bio))) + if (op_is_write(bio_op(bio)) && !op_is_discard(bio_op(bio))) bio->bi_private = iostat_ctx->sbi; else bio->bi_private = iostat_ctx->iostat_private; @@ -251,7 +251,9 @@ void iostat_update_submit_ctx(struct bio *bio, enum page_type type) iostat_ctx->submit_ts = jiffies; - if (op_is_write(bio_op(bio))) { + if (type == DISCARD) { + lat_type = DISCARD_LAT; + } else if (op_is_write(bio_op(bio))) { lat_type = bio->bi_opf & REQ_SYNC ? WRITE_SYNC_DATA_LAT : WRITE_ASYNC_DATA_LAT; lat_type = (enum iostat_lat_type)(lat_type + type); diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index fc0734e4fb92..be24e9c945a3 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -1100,9 +1100,12 @@ static void __remove_discard_cmd(struct f2fs_sb_info *sbi, static void f2fs_submit_discard_endio(struct bio *bio) { - struct discard_cmd *dc = (struct discard_cmd *)bio->bi_private; + struct discard_cmd *dc; unsigned long flags; + iostat_update_and_unbind_ctx(bio); + dc = bio->bi_private; + spin_lock_irqsave(&dc->lock, flags); if (!dc->error) dc->error = blk_status_to_errno(bio->bi_status); @@ -1276,6 +1279,9 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi, bio->bi_private = dc; bio->bi_end_io = f2fs_submit_discard_endio; bio->bi_opf |= flag; + + iostat_alloc_and_bind_ctx(sbi, bio, dc); + iostat_update_submit_ctx(bio, DISCARD); submit_bio(bio); atomic_inc(&dcc->issued_discard); diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h index 040a430e1199..385291ac9ad5 100644 --- a/include/trace/events/f2fs.h +++ b/include/trace/events/f2fs.h @@ -2078,6 +2078,9 @@ TRACE_EVENT(f2fs_iostat_latency, __field(unsigned int, m_wr_as_peak) __field(unsigned int, m_wr_as_avg) __field(unsigned int, m_wr_as_cnt) + __field(unsigned int, discard_peak) + __field(unsigned int, discard_avg) + __field(unsigned int, discard_cnt) ), TP_fast_assign( @@ -2109,6 +2112,9 @@ TRACE_EVENT(f2fs_iostat_latency, __entry->m_wr_as_peak = iostat_lat[WRITE_ASYNC_META_LAT].peak_lat; __entry->m_wr_as_avg = iostat_lat[WRITE_ASYNC_META_LAT].avg_lat; __entry->m_wr_as_cnt = iostat_lat[WRITE_ASYNC_META_LAT].cnt; + __entry->discard_peak = iostat_lat[DISCARD_LAT].peak_lat; + __entry->discard_avg = iostat_lat[DISCARD_LAT].avg_lat; + __entry->discard_cnt = iostat_lat[DISCARD_LAT].cnt; ), TP_printk("dev = (%d,%d), " @@ -2116,7 +2122,8 @@ TRACE_EVENT(f2fs_iostat_latency, "rd_data [%u/%u/%u], rd_node [%u/%u/%u], rd_meta [%u/%u/%u], " "wr_sync_data [%u/%u/%u], wr_sync_node [%u/%u/%u], " "wr_sync_meta [%u/%u/%u], wr_async_data [%u/%u/%u], " - "wr_async_node [%u/%u/%u], wr_async_meta [%u/%u/%u]", + "wr_async_node [%u/%u/%u], wr_async_meta [%u/%u/%u], " + "discard [%u/%u/%u]", show_dev(__entry->dev), __entry->d_rd_peak, __entry->d_rd_avg, __entry->d_rd_cnt, __entry->n_rd_peak, __entry->n_rd_avg, __entry->n_rd_cnt, @@ -2126,7 +2133,8 @@ TRACE_EVENT(f2fs_iostat_latency, __entry->m_wr_s_peak, __entry->m_wr_s_avg, __entry->m_wr_s_cnt, __entry->d_wr_as_peak, __entry->d_wr_as_avg, __entry->d_wr_as_cnt, __entry->n_wr_as_peak, __entry->n_wr_as_avg, __entry->n_wr_as_cnt, - __entry->m_wr_as_peak, __entry->m_wr_as_avg, __entry->m_wr_as_cnt) + __entry->m_wr_as_peak, __entry->m_wr_as_avg, __entry->m_wr_as_cnt, + __entry->discard_peak, __entry->discard_avg, __entry->discard_cnt) ); #endif