Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1837022pxb; Fri, 5 Mar 2021 00:23:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJxWrzGJcWi/RRC7qOkHieamXETDGM/OXisRermyYs7NwGwn0SQoxqir+Me1S7p0J98Kytkw X-Received: by 2002:a50:fa04:: with SMTP id b4mr8204464edq.293.1614932589361; Fri, 05 Mar 2021 00:23:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1614932589; cv=pass; d=google.com; s=arc-20160816; b=w7vHU5xZnbGI2LCiTiyrVyAnPImCbd/Ee0CSo2W7gnU3Vmjp/QJAhd3628MCvQsjwz cP1rWjKTet7BJI60aKXmXU39KHg5HJ4zBa3iCIOToPU+fF9gFBchk6UlVI94NRCNOg2X Ns2WK4yViLO2Zu2ME9sTwYImz1sWA8GQkrvJwk+68gim461YIL6mfE0JYVGHqc8P8Ekd vWPy7Pw3iEx+DB7rZcNR5MgkznU8u5ln3MWBpS8UrIpSPRMhqg3hFa32RVULAeryzDVG V1RxYSWc9EWWu7YK3tCg7NMbv8RNPthrRiKslG64cFg175GjculMbaSNKISqNvzHfYxJ BaKQ== 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=XW9yITYANNnTIcGl3pG9pq+M97yEdZtj0eRnPE06HfM=; b=aEGNz2Xenb7vliVmD57zFhE79rY3CSmPIXUnPSrXgVKjMC2M92yVeAJu871VD9uRAt OlP62y+KfiNAguLrWIuWbQ/jNqzwqj0iRPI19zRjOkxMx0Eqevkep8vq1u2kKLTk2CyU oi1RxnfDZpxeM9B/qYPkof3ZZuwbHXPCIz2AZ8f1suJmpEVBygDgBIw2rj482QxRYyRr X3vcZdrOFe8cGXorLW+gYCMjhgo5R3kaCiFQw+deMtT4MbsRpL/lxJhAynHsJ01gskAJ EyaODfHKOpRFLUYADkiVvyZUHv3Eu35cZ6ZOZNR1DrodPCAmwHh0Foow3bTuPHdi4JfQ NeYQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oppo.com header.s=selector1 header.b=CeJJbfna; 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 jg8si643542ejc.657.2021.03.05.00.22.45; Fri, 05 Mar 2021 00:23:09 -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=CeJJbfna; 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 S229512AbhCEIWS (ORCPT + 99 others); Fri, 5 Mar 2021 03:22:18 -0500 Received: from mail-eopbgr1310079.outbound.protection.outlook.com ([40.107.131.79]:24752 "EHLO APC01-SG2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229493AbhCEIWA (ORCPT ); Fri, 5 Mar 2021 03:22:00 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kN3ObUWO3dFABRC5fgS+rPSGUi0PHQJJJ/lOswpYIuWWaDQ3wCZbwKgUkOj2ydvPedLAE8SR/+J2DmGj8+J6HEFkFuCpfGr+TFLDTztMnx5nSomOGMQ6ZTq6QlBFdEOU6edxmc+nw/pUUIKeg0L2dEKe73qKsfYXuD4Mfw5qtZtUd5BRIC8AZxjDBmP4VyPykfMaws5/HBAyBwSAtQixlW/AI52ATfpzyhSODWu13XpjcaMbNq0HjlXJxzJrc+kgL/YQ3Ris+ick9oQDRFShCzW6SFjk7g6ljEoGEBSNcVxpkXBQQkWI/5Gbx8NkyHm5wYXzaqm1upskSWScsrdbtg== 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=XW9yITYANNnTIcGl3pG9pq+M97yEdZtj0eRnPE06HfM=; b=ddUjXkvzgUNgWFC5Ms7SqHdxd5ClQMXmCmkmFrJcjye6+nV/MP3RzzbXUkfYNkT8LqLTjp6bx8CmPD8PCxAo316t+XbAH36X/15Ixel0985hMscbaMp7BQ2WVsJvD4ge4WOFEaDfdIEt6WMs9ZKSOI53eItS+HGB0SLn0N+sGIJFPY8Dt/XpGazDttswJEng90w/1wa2X4lSq45dStXcwkeMtG9UjXCg8p7nuM+ShikgDgkLFVAUvC8qD9rtzjP9FYXDq+tYg6gDttgLrENri1s/w3qoSyHzZ7wOZazqfG4riP0hSYWJ3xLefHNV/+PuQWWNSPd4n8g+kTw0tq4pgw== 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=XW9yITYANNnTIcGl3pG9pq+M97yEdZtj0eRnPE06HfM=; b=CeJJbfnalEVf0zwF0XlOBo/Fd9KqmjuXm20qx1BTvxqHDYY0QW+IbuCto14xlijrNeqhO3u2ABqsemPYAJTEb6et6BkBUkRYqXdbV/Qsw0J0FRqiEQ3CwkQoznhIPCuTnFMsEjIXNSJJDo77eYqo6cWjFmKq3bo7S9qlNMB5yr4= 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 SG2PR02MB4021.apcprd02.prod.outlook.com (2603:1096:4:80::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.20; Fri, 5 Mar 2021 08:21:57 +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:21:57 +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 v4 2/2] erofs: decompress in endio if possible Date: Fri, 5 Mar 2021 16:21:42 +0800 Message-Id: <20210305082142.877265-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: HKAPR03CA0020.apcprd03.prod.outlook.com (2603:1096:203:c9::7) 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 HKAPR03CA0020.apcprd03.prod.outlook.com (2603:1096:203:c9::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.13 via Frontend Transport; Fri, 5 Mar 2021 08:21:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 22bd466d-ca83-40f3-45d4-08d8dfafbddb X-MS-TrafficTypeDiagnostic: SG2PR02MB4021: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 53ZshKKIRHFIk/BjYWaBqWwodSrK+iwE6Yn2uJB453ndmRie1WYP1d4OaDEw1xsDTS/j7Bzjr2yjnjKkottZBr2tvyGVQcm70q/kuf33P5X2MMPRJ9zDJVNo3fbTtmI61rACjPcLhU4x0C0rFbfbYMQLE8xAayakGtNuFLT4bonvg0r7eCXvcujN7q9J77PpNNK8UtXT495g+TEVv/Kdz9I61n/Oalw0mXjkw4VwYRGO5vnCvboAeV86X18HDTJXWAL7vXVzGLcIejRZPOA0HIGW1dvjkpOjTiHibMNGCPHcxGT2wKC1XF/5cOx+yv5f8XmTgKg3/POH5SCOcfkTwFxGWl86YoTyhNzIk2Ho4c1H8gx7JPG86JaPiZ8ie2uMC5d6WKoMXXwmLdIMXtK0QX7/5HqTfRlEiQCmWqJmif0PZEZf2/MtLHGJZJMe8sZyZVYKCJsjp5mPq7Fdk7GOjflbVBt7A8dNXEVYlb1oneCnzody8SiFuZs/bfGukT0BwNdOQXolNXpDM2pt1pU3UnHpaTanpJjCVRnhlFhdWjJhsMJSFxp44a528ZQBU9xcBt1e2B1iJO8edLTGjJ8OkrpkhCpv/hf9byrC6OP7XXA= 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)(396003)(346002)(39860400002)(366004)(136003)(6512007)(26005)(83380400001)(2906002)(86362001)(8936002)(6506007)(1076003)(66476007)(69590400012)(8676002)(316002)(2616005)(5660300002)(956004)(6666004)(186003)(66946007)(36756003)(16526019)(478600001)(6916009)(6486002)(4326008)(66556008)(52116002)(11606007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?mbypNGnLlaZ9p+bvpgNEG4JdJtOF1X0bIrzDp3uJv0NZWFJxRGsije6Phhfl?= =?us-ascii?Q?NFmy4K61tj9hovSVYXJWfCL+aasP4ur+FalgqKQFRa7rCLdZ5iLWPluBoPtU?= =?us-ascii?Q?oWbhBKj8JDsAC3AAuKKc5DvSClZxt435G6HqQTLiDo5dl9JzVU+KIgRcUguQ?= =?us-ascii?Q?9wdnH3IgUPCsC7bRiRug5TWmn6RNnsz8gefkCUq6GGZhZuQPSSQTJVJnH/cL?= =?us-ascii?Q?Sw6RBh6nWNDhUZx2u6D7OFZoiqa8Yi7kwq2p8wYdtTvfUP31cxDwpEqhGhGV?= =?us-ascii?Q?5ZSzXDTmSw98W+HBEzvXgl6Ymn6htkjZvhxk2mSOTam14WJJj+KB80sFpgac?= =?us-ascii?Q?+4d+V6HQQMVSLTu5PBT9EDPxp5KpkFHzj7WU6jRrA9r9if943MI8mR2ftkHi?= =?us-ascii?Q?stv3BpnuzisBhivBPtZITMNKlLJtFgg9cEZNT77rfIRwCqH2FOkkXLBXlF2D?= =?us-ascii?Q?JJJseVN4KVhZaJr8mlfMJXehSjFA41Uv6vOHOuR9ZNQTSpGhe4pe6DSjzFf8?= =?us-ascii?Q?Fr78DRygG1lgtXFFcoemmeSodOoHRV15Dnm0aDM0S6dBKMKHjC1W1f7obYZF?= =?us-ascii?Q?8GRUMAB3TDg8QtL0ULASwCBPKPD79MR/4xNLXjSEQYxoS9GiAP+HXSOmo1LQ?= =?us-ascii?Q?jckWpwsKmck92Rs14PfreelWgb3m0InG+khBTNkRpwA0FghWVWbxlV/ZTaqY?= =?us-ascii?Q?L0YF3D8eIBqOnGp8a6YiT5/FP3CqDcgxxihjC9sWZPssf9AMCTQz5F3FGU5i?= =?us-ascii?Q?cOEdjjEolRjUmO+nYCzYVR/pgE5JEPQUwbg0UTFdBEdGaXSYeJtCGTDg8NsZ?= =?us-ascii?Q?udrhYyJlftERmMHxUqoLzMS17bgQFHJhHlx/wOFuHzXe1rqemRDYctmNSMl8?= =?us-ascii?Q?5IMofuwHVbv8t8TkjSmIY2BVXUFx+70aBJs2vyCYX/oZ2ZbfcIvbu9WNpYCU?= =?us-ascii?Q?zAQWjm0MJDmoJeWrPPluU/nBK2C623aH/bmLDSR++JkvGZOaSy4gT5Om2BJX?= =?us-ascii?Q?XSCJgwUtE8WO/bUwTiEQB0uK14e64mdkypN0ZbUC1pRXWHwwb0shweNDSFBR?= =?us-ascii?Q?liYP7pGr0cvKsu1nu6Lp6hxVJaGVZJeei2Vb35n+3I0hovYEqQjt5nGMr36X?= =?us-ascii?Q?vUbxd0hcA0CmqEYqrwsgNcvFFSeiMZGetkvspsc+OviQnYc9mtyRV6JVS6+H?= =?us-ascii?Q?Bk0c0bPybtC/qBJflEN88kHAm+HBK0WYsxvdl1tHC/2RnpctF5DW/pzAr0Xc?= =?us-ascii?Q?qrlUCFNzZ4YVo89yzDRFxSJzIoRFc2AkLV85IXNcPlTCmxTTYWnHdq8O7VZZ?= =?us-ascii?Q?hWqmYk+uazKksxi3kId+2l+C?= X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 22bd466d-ca83-40f3-45d4-08d8dfafbddb 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:21:57.3288 (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: EWZ8wSS8udIj51Wwwm31UdIzR5V2MUDmUe6HRwisEJHvX+Z0TlX9YuXMl91YGdOoW0G5AETQWvzCD2a/hA7/6Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR02MB4021 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 | 16 +++++++++++++--- 3 files changed, 20 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..c21447c42eb0 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->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->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