Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1890531pxb; Fri, 5 Mar 2021 02:07:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJy5fdHhTAtmCHEdlrZjWTO6MWbqHXw33k6cUG277yaIVD685UGN5f2LFDL54WB4IUCfYQci X-Received: by 2002:a17:906:f6ce:: with SMTP id jo14mr1631692ejb.476.1614938852441; Fri, 05 Mar 2021 02:07:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1614938852; cv=pass; d=google.com; s=arc-20160816; b=STC6LfdO0AFz7boKgdBlkJjGKXxAIygL3/1RyivhXWMPzITorYE0EpLUCZM3JoPESA 7SdtneFMJMoFBk7FYyLx2ZPCiK7kLtdx83YaBpL2sqe49zJgZGnnrZzjykHRmdwDJs+P yOqBRgh5J6a+GrMGLdcrkHAh7TsGzlSSbcOSyhAGb7hmWsRmSqOjm/48uOi8EpV5KZyz NkcbBGqQK/6ZLN46jAgdxro4vmH258Icoyqs6vbmCNNKtENrSDvEpYFJK87G0RITUYM8 t2NGKUYygLBIcj5fa6w5Ht1w5d5E73IIxaoWfxcutkNB8l/z76JaSF93mbk4obsot0Fx /k0g== 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=xu2G9oEQnuVSblE7G1nmtK5TyDa/Uz+e4XlecxXyVTM=; b=ebaL2+vf4GL6HXr6fM0KVX6IQwcmzXVRDBwT6abTxQ1t3cVsrfEtm/dIRB9Ohyj6OP xOJ1ues4TW7AJbQ6HMKx/LFSWZf+m8ASxcJLtWGoji5oUPzq0UxL5FixUK52Y9aN2PbU YqsH5bC/GSm5gHDpTIdzRCv7ggtDn08ygFj7m9D6dGym/Sr+A0v175EHP/kOxL5J7qFt 4v2ExsEQrKjfvWI4kFdU5aCg8IxWj4wk1px637x/mrrqw4k2zuv4fWOhqT7Bg4XvP5r/ r1Ogzg9StvnPiSZRVKJ3JQwWNkh+O3Z/WE1hsmJfM12USSd4RUpExL+MsonEUb5leH/p m61A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oppo.com header.s=selector1 header.b=hGTT91mP; arc=pass (i=1 spf=pass spfdomain=oppo.com dkim=pass dkdomain=oppo.com dmarc=pass fromdomain=oppo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=oppo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mc14si1107118ejb.639.2021.03.05.02.07.09; Fri, 05 Mar 2021 02:07:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@oppo.com header.s=selector1 header.b=hGTT91mP; arc=pass (i=1 spf=pass spfdomain=oppo.com dkim=pass dkdomain=oppo.com dmarc=pass fromdomain=oppo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=oppo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229935AbhCEKD5 (ORCPT + 99 others); Fri, 5 Mar 2021 05:03:57 -0500 Received: from mail-eopbgr1320051.outbound.protection.outlook.com ([40.107.132.51]:24920 "EHLO APC01-PU1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229669AbhCEKDr (ORCPT ); Fri, 5 Mar 2021 05:03:47 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b/kk2vnTV0mSqCfzkbIg4/r517ANvfRQ4GW+hYAZagG0xeXNrZkIoEBL/8ySvwlFnLgHyZ85dAvYnN9nCJRiI3h5P6mQw0tKbmhvBboCryMk0yx4nqkBnFlhCoXwfHcYuw832CFdq9ccZDqXSl2pGmx/nZaAqevuo27OBiU6cVXia3D3hYQALzyrEAdGVN8nBtwvXJ5ClxLK8FcLgRZSqDQbb7bZtgcVsLE1AL4zk5JEq7ZyuRBauUfL/gM1yHoo3z1/c9X7pGYJGQ4VMsVCnuelKPonSD+otJvBiYz5CK2HhlkgWicKS7Gonw0Nsq/JWfYBPrPoUjAzM41b2xi6ag== 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-SenderADCheck; bh=xu2G9oEQnuVSblE7G1nmtK5TyDa/Uz+e4XlecxXyVTM=; b=Y9YhXcVAGC3qI1b1Fxe5+sOSNKNjoec5Xw4jm7HUwFTPSSgzqgShVPAFZIQ4ec1Acrrvk3msnALcoYMIxO8BIBuDV9Ym7Y4f698RzbgllhxurBEp51QDKUWz4G7NBlPbsrvAw+A2UqEVNrEuGWJv5zN6Q7HHgDdzrN7YggFL4y5WRiToSJDkKahivCGLo0yspP8ynQuL9lQFENezAhMjHp1qM+Gf9pCJOX4XemftS8bcC1K+WMFoa9IUt9dzQsdCto4r+/EcVNF35hLynNYNCdOA+eRb8DyLjK2E9UcDIRVVaejIlXOQs66LZ+tPmlEoAgb/Z7jdNN3g92o+1Cm8JA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oppo.com; dmarc=pass action=none header.from=oppo.com; dkim=pass header.d=oppo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oppo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xu2G9oEQnuVSblE7G1nmtK5TyDa/Uz+e4XlecxXyVTM=; b=hGTT91mPaN+ITgpL3w07F7t1gFwxFB7+GyECcpUGireE3TlyfqeMGrEebM4YgAnfJWE71Kd8/dgTxf8TpRLMZoRpunMjMptiZGCFvRf3cRL/k0+qXb/K/YwYZzJZKKvQxLJIomYxb+NBsoo6N44ZaVa3QcH2sT1Rg8pCYOhvC1o= Authentication-Results: oppo.com; dkim=none (message not signed) header.d=none;oppo.com; dmarc=none action=none header.from=oppo.com; Received: from SG2PR02MB4108.apcprd02.prod.outlook.com (2603:1096:4:96::19) by SG2PR02MB2560.apcprd02.prod.outlook.com (2603:1096:3:23::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.19; Fri, 5 Mar 2021 10:03:42 +0000 Received: from SG2PR02MB4108.apcprd02.prod.outlook.com ([fe80::1143:a7b7:6bd4:83b3]) by SG2PR02MB4108.apcprd02.prod.outlook.com ([fe80::1143:a7b7:6bd4:83b3%7]) with mapi id 15.20.3890.032; Fri, 5 Mar 2021 10:03:41 +0000 From: Huang Jianan To: huangjianan@oppo.com Cc: guoweichao@oppo.com, linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org, zhangshiming@oppo.com Subject: [PATCH v5 2/2] erofs: decompress in endio if possible Date: Fri, 5 Mar 2021 17:58:40 +0800 Message-Id: <20210305095840.31025-2-huangjianan@oppo.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210305095840.31025-1-huangjianan@oppo.com> References: <20210305062219.557128-1-huangjianan@oppo.com> <20210305095840.31025-1-huangjianan@oppo.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [58.252.5.72] X-ClientProxiedBy: HK2PR0401CA0019.apcprd04.prod.outlook.com (2603:1096:202:2::29) To SG2PR02MB4108.apcprd02.prod.outlook.com (2603:1096:4:96::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (58.252.5.72) by HK2PR0401CA0019.apcprd04.prod.outlook.com (2603:1096:202:2::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Fri, 5 Mar 2021 10:03:40 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f8c5435c-61cf-4562-bce2-08d8dfbdf47f X-MS-TrafficTypeDiagnostic: SG2PR02MB2560: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Cw/eDfhjVkEYeJ9pQEZwpn/6oj9ZHqsNzMqXTMARw50Zc77/Kuuq8rXbSfE3MOdTcOhG4go6L5HYnV1n45Mlsem6GvwsNnZUfpUNjcez2MYZPGnn0ZpHBl5NzgGkQ0XYNTaqdIfV4Hns1h3JGLq2zd3bNITO8Eb4boI383H7rI6jrmj5CCOG78OX1SbHHyOYeWCP7W3i0aZr6guWJRrKx/7GVs5ssys9Blc9xGesjlESyEOUvGFleXQKAdoRffg5tmTuhFcl/s2BSU0t5tMGYIacvGaCDjebRfeIKZ1KXYOu7fHZiPjHSJEW+Dqo4SSdRUVpp1wWWWZQxInxGp9xSrnN34G5X+kYb+5x9aJFeshkALdXBEM1SyJbZCRjlnwq1QMNq4sXRx7ZxvcT5pkELNZnP+7YiAwlI9L6OVNtFbbkh6/jsj8v5osS3K3xDgRymVNAwXCAYqxYPpSdnrF8R73RTSNtjZw+LaZhrj68OWMX7JjPdAfUopHkNtmlYtvcyn5+r7T/wkA+h6YtoIjYYeOIwzrG6gl7FoRAiDq6b4Kmz0dt/Jn/OnDWKVGvqg40Ca0tBaAdNoIj8AvPb/RHJeEcgL/SRpdlDW+LJoUQ3rY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SG2PR02MB4108.apcprd02.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(366004)(396003)(136003)(39860400002)(346002)(37006003)(2616005)(36756003)(956004)(83380400001)(107886003)(5660300002)(66476007)(8936002)(8676002)(66556008)(16526019)(66946007)(186003)(4326008)(86362001)(2906002)(26005)(34206002)(6486002)(52116002)(6512007)(316002)(1076003)(478600001)(6506007)(69590400012)(11606007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?XSij946jLWqupmfiYCitd31SdamqCX0/cBdxGL6OX/laasnAIfxSTYcgM4lJ?= =?us-ascii?Q?uTippnTiTr8JfuhrASEJ6hynaA3yXnrU3YreoTU3/ivLunXdi+7h4aRfwqy8?= =?us-ascii?Q?dBnVPKJriw2YozgnnHLR9E2zs46/E5Glt6GD+z+oomsjUdSa8yWki6Ct40yJ?= =?us-ascii?Q?U5roN0XJpWvWWcW7gV2ADu+asaItWRkVh5874zFM/KP0JylCIVy1zgOgf6AU?= =?us-ascii?Q?1wjZqKQYGLs2Ssm6rX7+hy/huAodwSTCweuum7298UbiSI6F6GfG60dc/sC8?= =?us-ascii?Q?BNV+2W1lAcsU14OD12PbJ2e7WSeUED4AFEORKY4f+ZVTW8F4kwcByDuHttn3?= =?us-ascii?Q?a4xja0l4dXW0uLSP+uYj2hcjrv+QnEU0f/PKiy+xxJIF5p40TgZbMLazTORi?= =?us-ascii?Q?zknHeRu3S/wEzATyvWMojf5jm/cKHUwfV+DC0O/u7Nx8bYhV4bkKWXPLQOt2?= =?us-ascii?Q?tkj7UIldv7HXa89NYdGcnYmrbd+tf+Cz8Q0oARrcePxMB+6iqWzGgyEn3kTH?= =?us-ascii?Q?U1lPVRR3hdu0dh+eBXTDoQ8+26qqa6YsirQSZC3ToyhAPomfEqiDycaaxZ08?= =?us-ascii?Q?uO2yVggWG7ncEa05iwI/QuNBFdHgZ6Bl44wuRCTOjZUciqS0G98XwUVioOF6?= =?us-ascii?Q?mmZvFreATpGzdIcafzWBo5qIB2QyWpm0TW+NwtB2lJGEFaNewozS+xVaPHcw?= =?us-ascii?Q?k9/W6LBcWxVas1Oj0OjvvVZ0gatz9Y8JgsRlQQeICWRtS8rjU3WrVemN61XQ?= =?us-ascii?Q?hlaC1DZK9ikjvzXnPWe+L9vTUZzNbux3WFDvSmqj0uiWuvvSMgjbm/vvypNG?= =?us-ascii?Q?ub6dDp1wqBMnaNlqmN/KiCNtTTGGrYxU6IAQOYuWIQvYQxLBe8C6TMQd5bsF?= =?us-ascii?Q?B5ue4PXP7xMTNrGp2rLdoEvOxRFjz/3WoAkxUNCCjhXmELYOPV0Sj+ML/Z1i?= =?us-ascii?Q?DCKQ06lJNI7+7Fr9f7hFB4aqCknQY0HWu+L74X5aN7yMtFFh5xvqhyM3DgiM?= =?us-ascii?Q?su9mV3Vs58ifIzOMbnQP+ysJNij3ktDj/Z/K6WXEG3y9Bb2Kq+nvfH6+LA+l?= =?us-ascii?Q?RiK1jI5cR0MlZN+OE2NgdazzeNo0KHacqwcJ7NJYtinujCKXgp+/l3NYZWRd?= =?us-ascii?Q?iNQ7HBTfcjYq5HzXxe4lFLOrF+WSaI0dOKktOkDr0Eesl4gjJgnuCdu6uoqH?= =?us-ascii?Q?WURRKSKwMFWmKzr0TLqRavWUO/Y9uGhFTGOJLkjPIahsqqKtWq7NZUj23zS7?= =?us-ascii?Q?Ll0ecIwbiiYUSlHtbwVuvcFz9nRwHimCL5axOpiRKkYM/obYG/cxIH5t8e/1?= =?us-ascii?Q?AveukmP8ZDgEqI1XFcuzIGUb?= X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f8c5435c-61cf-4562-bce2-08d8dfbdf47f X-MS-Exchange-CrossTenant-AuthSource: SG2PR02MB4108.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2021 10:03:41.8079 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f1905eb1-c353-41c5-9516-62b4a54b5ee6 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fS+DmA7w+NPEcqOs7G4oqxRc6uivx4CcZaZJ8KXqzu/IYVPvmoWk7zmGgS5MKkYlOdt0OxzAqn6JNkqiVqDppA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR02MB2560 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org z_erofs_decompressqueue_endio may not be executed in the atomic context, for example, when dm-verity is turned on. In this scenario, data can be decompressed directly to get rid of additional kworker scheduling overhead. Also, it makes no sense to apply synchronous decompression for such case. Signed-off-by: Huang Jianan Signed-off-by: Guo Weichao --- fs/erofs/internal.h | 2 ++ fs/erofs/super.c | 1 + fs/erofs/zdata.c | 16 +++++++++++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 67a7ec945686..e325da7be237 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -53,6 +53,8 @@ struct erofs_fs_context { /* threshold for decompression synchronously */ unsigned int max_sync_decompress_pages; + /* decide whether to decompress synchronously */ + bool readahead_sync_decompress; #endif unsigned int mount_opt; }; diff --git a/fs/erofs/super.c b/fs/erofs/super.c index d5a6b9b888a5..0445d09b6331 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -200,6 +200,7 @@ static void erofs_default_options(struct erofs_fs_context *ctx) #ifdef CONFIG_EROFS_FS_ZIP ctx->cache_strategy = EROFS_ZIP_CACHE_READAROUND; ctx->max_sync_decompress_pages = 3; + ctx->readahead_sync_decompress = false; #endif #ifdef CONFIG_EROFS_FS_XATTR set_opt(ctx, XATTR_USER); diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index 6cb356c4217b..b22cea78a9fd 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -706,9 +706,12 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe, goto out; } +static void z_erofs_decompressqueue_work(struct work_struct *work); static void z_erofs_decompress_kickoff(struct z_erofs_decompressqueue *io, bool sync, int bios) { + struct erofs_sb_info *const sbi = EROFS_SB(io->sb); + /* wake up the caller thread for sync decompression */ if (sync) { unsigned long flags; @@ -720,8 +723,14 @@ static void z_erofs_decompress_kickoff(struct z_erofs_decompressqueue *io, return; } - if (!atomic_add_return(bios, &io->pending_bios)) - queue_work(z_erofs_workqueue, &io->u.work); + if (!atomic_add_return(bios, &io->pending_bios)) { + if (in_atomic() || irqs_disabled()) { + queue_work(z_erofs_workqueue, &io->u.work); + sbi->ctx.readahead_sync_decompress = true; + } else { + z_erofs_decompressqueue_work(&io->u.work); + } + } } static bool z_erofs_page_is_invalidated(struct page *page) @@ -1333,7 +1342,8 @@ static void z_erofs_readahead(struct readahead_control *rac) struct erofs_sb_info *const sbi = EROFS_I_SB(inode); unsigned int nr_pages = readahead_count(rac); - bool sync = (nr_pages <= sbi->ctx.max_sync_decompress_pages); + bool sync = (sbi->ctx.readahead_sync_decompress && + nr_pages <= sbi->ctx.max_sync_decompress_pages); struct z_erofs_decompress_frontend f = DECOMPRESS_FRONTEND_INIT(inode); struct page *page, *head = NULL; LIST_HEAD(pagepool); -- 2.25.1