Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1830576pxb; Fri, 5 Mar 2021 00:15:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJy3zFFCjCP2qvrCWrISx900onFgIL9BF64wve8apJ7qYsmnw6jKVnlWaOaO6TTuZGakA2Th X-Received: by 2002:a17:907:119b:: with SMTP id uz27mr1241131ejb.464.1614932104204; Fri, 05 Mar 2021 00:15:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1614932104; cv=pass; d=google.com; s=arc-20160816; b=CB/Z9LldSKyxJOx8ZE7SIZ4/OqGvlVACE1lmX66zgRZoSEIrq6RCAs3OZPG61GeuEa iaeApkXdLnv3+0MsMtfA0d4PlFOr7XTY8qitRZwmT1ivJDmJkSQF4h/qtv8cI6iMTYTD yWDzbDGYmO6mEew4IXibzLBJv/evS/CCOmfPq+2+DGro+qD74mHMpWFm3HJXF54sXMXQ O0M9Pj1Oqm8BeNddJafKmO3tNF8ALr5z8yUrsty8Egq5PQtp21KkQeb1KcKEV5prd/D3 MgifZAnA4MQrv2fRfvvxhLnUQBV8tPlf2IFCe6JqcwrisL11wZh7EV0sAbnDQ02aNxtA j91g== 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=ozGZBkNqUyuHVsiwa3G1hdTlL3qmn3Yc+PxXCUqgbB8=; b=xa9WiTDrL6Rxct01oQxw2Q3Af3xO4lPbVFbtepBRY88F8aM4M57nsJPWWwiyJXdktu OffFpy6GrP/aCHf/iODAesRHtFGqhIFju9H07kC7rHu/I7oFI/qoa3VjciYaJl7VwzSZ e5TOlwpfTsyDJW1e3T3X2BtQZMxbMsnQbnCNoUXrBEXAWCMHQ3LDwzJ+1HJ5CDOATlE8 PB1kyv8hDRrw0fXpdkqJrnIbGgHd1ohc7GN4aZmXf3/AlGIqCYoUrjW2Ia/wX8NIZqo3 xO8rvvngKvx/6ALFjYA/MVsjA3St/MXHo7o2MogJNyK4KMEUbqSsdDmfGm9qtFG6MU0j HZhQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oppo.com header.s=selector1 header.b=d42wbJ0u; 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 dj7si1130730edb.378.2021.03.05.00.14.40; Fri, 05 Mar 2021 00:15:04 -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=d42wbJ0u; 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 S229551AbhCEIOJ (ORCPT + 99 others); Fri, 5 Mar 2021 03:14:09 -0500 Received: from mail-eopbgr1310075.outbound.protection.outlook.com ([40.107.131.75]:30734 "EHLO APC01-SG2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229528AbhCEIOD (ORCPT ); Fri, 5 Mar 2021 03:14:03 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PrBJxJViV2jMjQJjvonwFIG8P6YF1w44LV1tiTFMxZqNavY1yrjGHdz1/MvZA7GemgGzjPyOFWhkLiOU1pOmiaI1koNJCUk998uPEtuK79ZVBIof6aqRTy3EVNCCgcl1XkfRlVBb7lV6/frFAmrh4Xqh+uZmxXaqLXrG4KtaLOwrdBtPHkcC0RRugzN5y+GGsGNbE4NMCyLN54AgzKGdGIhjaULcyVL0zcolUWFp2JqZFaC0f9FJzz/vR4KTLgIj66jJbjm0Gk+cRTwacwAfLGXkPxTHOFQE6OlBCgYAHNEExIceiUAk8ZEZAV5XHh9/CUNgUAC3HIOj4P6rWVBYgA== 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=ozGZBkNqUyuHVsiwa3G1hdTlL3qmn3Yc+PxXCUqgbB8=; b=KcoNysjJMqyEm6QLqMMNY6pkEvrvf7ta5F8LEkaJB0+NHKwQ4QBNRZ0hHdP7DSy4wG5DzwEhxr/Io5dKwye7KwCJ4kuJ7lI+RcjsED7gFMfgO7JINXgA7yRo+mnHwK9VPnGlLhQYXRi+cnlSCSKbaj5qoJ+cPTkrlo1YAE6MB6OgqJ+uZ99VhgeRkQYHbHh77DMRZuYR3BMEyDQHqpcBnSnY5qie5xo6DkLC4rxxwMawkoj0E6ebT1K/OalEJ4/tf+PGNOXSZM26ZgE3K9HrXJDzAG6WD2PsMmVsdcPrWSnsL9OCIMnHAi+MovgRan3QOrrywT/F32mzcJ3pM4NVFg== 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=ozGZBkNqUyuHVsiwa3G1hdTlL3qmn3Yc+PxXCUqgbB8=; b=d42wbJ0u7xvL8ikFVpMGFwPD6ZXXIejqmNQfHx6N/jg3UtUym4+oHAvsaGFDZKp01bW3UY5hMAmYRy5rJnxW+U/1cYZxwmXko8DvulIkRiy+9QH4jh35ENXbA4jI0VqUSNF/jIQ+aRzvN72iXtJKZdlsx86Kv+Ujqyx1Ul0OM80= Authentication-Results: lists.ozlabs.org; dkim=none (message not signed) header.d=none;lists.ozlabs.org; dmarc=none action=none header.from=oppo.com; Received: from SG2PR02MB4108.apcprd02.prod.outlook.com (2603:1096:4:96::19) by SG2PR02MB3847.apcprd02.prod.outlook.com (2603:1096:4:29::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.25; Fri, 5 Mar 2021 08:13:58 +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 08:13:58 +0000 From: Huang Jianan To: linux-erofs@lists.ozlabs.org Cc: huangjianan@oppo.com, guoweichao@oppo.com, zhangshiming@oppo.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/2] erofs: decompress in endio if possible Date: Fri, 5 Mar 2021 16:13:42 +0800 Message-Id: <20210305081342.789943-1-huangjianan@oppo.com> X-Mailer: git-send-email 2.25.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [58.252.5.72] X-ClientProxiedBy: HK2PR02CA0135.apcprd02.prod.outlook.com (2603:1096:202:16::19) 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 HK2PR02CA0135.apcprd02.prod.outlook.com (2603:1096:202:16::19) 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 08:13:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 03056b38-4d22-4d37-0a8d-08d8dfaea070 X-MS-TrafficTypeDiagnostic: SG2PR02MB3847: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JumfiDstrGpSS90vCjLFYni4+E6zacq91BJmUMUuaZ6+jkmkruRv1/QvsO+9hZxp7bFDOe67CEBWj+LeEAIqAUjMZEq3oAlpLPMTtrYrFCDp9Arh+bE8NLethD2gHy4GnLnBiN2e6eMVQiKx1f6xQ6RqEqhm/SvZyA9NoCTt2ybEBwBifmqkvRdM1RR3ibsXC7rOgx1ABgz7MvSrayd8BJJMa8tBqXpmHRaopK4nkWyUp3lwX3xgnMZVAZuSKI8/1aR48L24ke76Ax9T4jODIpYP6RK0Fq+kzzH3daPNw72IEMmLNA/1x1+NKNuEkLA+krcSs+35nsRwjDARwjPWGZZYTUWlFR+cKmkECOuikyhZ7ntRR9tFT6IR/w//stAP/twUA5wmgUV8zA1BIVCvkfB0T/CYTYi9Ju6HtYt+33LxEoV5Za1dPUQQccRBER9T7iN8YOrcwMwxREyfmQxXvjxTkRms8/SuQvAInEBBhNhZWjLstp1SHBwaH+dMR7tvpHXNrGi4FM844QsWuJQkacZx3yLsbmcwPFwAq7AIzde7HqMnX8x3hdUMk920OXkphKZJ9zkd4IPZFMsg4vH+VmDnnqEVagEDxJ8pb0tmCYs= 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)(39860400002)(376002)(346002)(366004)(136003)(396003)(16526019)(2616005)(66476007)(8676002)(6666004)(66946007)(8936002)(36756003)(26005)(69590400012)(1076003)(66556008)(186003)(956004)(6512007)(5660300002)(4326008)(52116002)(6506007)(6486002)(83380400001)(6916009)(86362001)(316002)(2906002)(478600001)(11606007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?+yj7hxw9lvdKtjwpjq4NoX15cUBEr+3XJM+Yb3bhvB5iT6Mf/+PtrYakDiGB?= =?us-ascii?Q?5HEt4XFJgAoIXKDouHvciyBPxGIjhqFcuzQLtZg5/1NsC3p6PzLsPDBLOaRe?= =?us-ascii?Q?yTFLGDK/5SxXMqcmS/2NlCSH5+WgObE/9dkfqLgsI8JsQZZYgTsjPuGW0XkQ?= =?us-ascii?Q?my9CCkpJECw24oKCsiNDbWgk/bzhvmSULLpmmoUBAP3EgTHq1SPAfN2e4Woc?= =?us-ascii?Q?+k7ygby3Eg4oSaStdsfosye+R3HepQahFE0iGTqvkStn3n5wCglc+WCfg19c?= =?us-ascii?Q?zrqbCNHSvmJn5ztDo6Jzln0EFJkNp58or5ExEd9ZLeFv5kZICQDzn5xG2Tqc?= =?us-ascii?Q?/PWMX2XA+RatUcPVbDcHeIy+Us5dyD8M92qW5017BvatzL1L810AmEoXh8Jn?= =?us-ascii?Q?NH/szmWAaYlc4gRdZ3nw4rMBrNdZ0CmDUOXRn/Xop88zHSWn1bZjcqgB1ZtR?= =?us-ascii?Q?nOom2uEn5ib+y08NNt8FmxWhKTyBfFcQNVFjHD+8DmunmDIrkpy/jdNUhvKN?= =?us-ascii?Q?PhnGDiJPTaOnn4Y9qZWrkH6bMd/M20jTDyT4QdKOrnT1qcvxwOPsWH+HvvVV?= =?us-ascii?Q?7b6yLKbyBjdd6DQM9w79oeoCkgKDo0ClzSjvagU34NtZ/uFnmr+i3XCNi6YO?= =?us-ascii?Q?SANrj1ScA29bxCLQ2/UO1keCqbyuYsAOLkOSqUI2yYi8ft5D97K3X/OyTY8c?= =?us-ascii?Q?k5Yf1d2/3zc8sPPCjB0NJO42sdIJgVFdxlhWB4E48sisdfC+1X4wqrIAPfIr?= =?us-ascii?Q?ItEUVtEcdP+q/g6yaevwxcCX9qS89LSVJQ2r3GzWFW7xkH472tf3bzFapISp?= =?us-ascii?Q?bqgr6tM0c1h8Oge4h+Etzk5aM1OdeCqsR4m/5MZhzZxIrVHn8d7okrwAGadc?= =?us-ascii?Q?LK6lhlKumZl9HmYR53UogMiRB3vmHpC3h7muMPE0BMpu6CoIL9zLR3swlIg+?= =?us-ascii?Q?0wlVAndXoiZ+3DrT0+PSSsiVot30T59kk/A+LTJMz6WXOPWHZpsEBBj2T63u?= =?us-ascii?Q?06Oy3whEkIlPmhnnN6sP16wWLNxA4P2BQxZeXv8HKmMK+z5kKpJQUxPs4KG+?= =?us-ascii?Q?T3V+CVCiqNwfRxd3OfzOHW2jp51F5dGvY2PdWUEnz9oFjKZSQXpys0wdpPh1?= =?us-ascii?Q?XMMifXNvhHsLk78gRHQsCCqhwzAJKasZbItEGAZDZ3JPwqGMqfihVaS7L0nt?= =?us-ascii?Q?g+IZYjXiyvFBZNjN2yxeRqe5Dbh5NqM91ZNhyPNTcsIrvChSjSt6zAxLR3f3?= =?us-ascii?Q?0GStr4vgxEC38hEe/eLJo+FjXkBdZlwQp1MtM5evBxMpTH38UZpfwzfF3s+r?= =?us-ascii?Q?epWROLiT8xtrE17AvTPe0/qc?= X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 03056b38-4d22-4d37-0a8d-08d8dfaea070 X-MS-Exchange-CrossTenant-AuthSource: SG2PR02MB4108.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2021 08:13:58.4684 (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: HotB7/LljyNJQD+l0GmHPRiPfIaBZOlAquk5sKndc7SVD/ohPmLS1r7WhEbHSMno/GDgdg58sKc2X6secE7/mQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR02MB3847 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 | 3 +++ fs/erofs/super.c | 4 ++++ fs/erofs/zdata.c | 14 +++++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 67a7ec945686..b817cb85d67b 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -70,6 +70,9 @@ struct erofs_sb_info { /* pseudo inode to manage cached pages */ struct inode *managed_cache; + + /* decide whether to decompress synchronously */ + bool readahead_sync_decompress; #endif /* CONFIG_EROFS_FS_ZIP */ u32 blocks; u32 meta_blkaddr; diff --git a/fs/erofs/super.c b/fs/erofs/super.c index d5a6b9b888a5..77819efe9b15 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -175,6 +175,10 @@ static int erofs_read_superblock(struct super_block *sb) sbi->root_nid = le16_to_cpu(dsb->root_nid); sbi->inos = le64_to_cpu(dsb->inos); +#ifdef CONFIG_EROFS_FS_ZIP + sbi->readahead_sync_decompress = false; +#endif + sbi->build_time = le64_to_cpu(dsb->build_time); sbi->build_time_nsec = le32_to_cpu(dsb->build_time_nsec); diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index 6cb356c4217b..ca90d0993599 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -706,6 +706,7 @@ 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) { @@ -720,8 +721,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->readahead_sync_decompress = true; + } else { + z_erofs_decompressqueue_work(&io->u.work); + } + } } static bool z_erofs_page_is_invalidated(struct page *page) @@ -1333,7 +1340,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->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