Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1019303pxb; Tue, 9 Nov 2021 03:56:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJxGsiuRxZ44FK7cUuLMRya/YRz60bFhCX8M8QG6rInyF5fA/1jBIuYa1btrweyD7/qIqIrC X-Received: by 2002:a50:cd87:: with SMTP id p7mr9334603edi.205.1636458991414; Tue, 09 Nov 2021 03:56:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636458991; cv=pass; d=google.com; s=arc-20160816; b=KhrGFheFyRcocXGK7JYdJLVr51iySh+yss4UhR9DM82mE4X4F9N78oxsSaMp3nh85A aZ/nB8c6sksBDgd8qpNDZpgjWifZ4Z3FMNe+F6TaZNmSMy8vBSBj/nvhI4eTjqw1tkwf mbiFEqMrkdyfypiCIna0weO7CDcE86jatqJvai5lyAJB4URl9YM0OYe0+W8EYzp6O2mY y8HzfA6ABMTBgzaChNW+56jhM8ES+3aopwq/Prep/hZvw9Kl5S0O/2lR5v2P/vHhDktV scZI7HgCEXYKHhH03t0lam+X/r+abW6ccn2jxfRVxYDzZHBgh7EKFulg2MDC8e1Gdc6F fbjw== 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=VvLokOUf35eCgKTRGFw1MK+UKYgI2JDRCOQeHH+KKQ4=; b=UpFK45AnviFBnYMLQkm1EG240f68roi3LGCs3uoI/aqFpho9AtuznzpJqFCtR+3F2D kRJSqERF9YBdDQSuehODL541uywULHDSTN0K43uJiwTfM8rnfYWKOfAE0yLwb/GvmNSs jga8tkSahsuzD4KYO7xKDaAGV+vzMb4uZt4oPXpmM7G6pUwWaV1u3AZaxHDS/9i2X9wq KF7XL3bd75qqhCeJvPsUF0sU2sl8X3FciQ+dyddYOZQpxUfor451tUpTsEfYZ/jesNPp 9GWJVgnm5aBBUY44kNAoKvIjEzNV4gQVrlnP6Q50+X0Flk64k/miqCj5p9nklbLnJtWp LdbQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oppo.com header.s=selector1 header.b=bt22hiGa; 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 ho42si19328103ejc.50.2021.11.09.03.56.07; Tue, 09 Nov 2021 03:56:31 -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=bt22hiGa; 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 S242043AbhKIC57 (ORCPT + 99 others); Mon, 8 Nov 2021 21:57:59 -0500 Received: from mail-eopbgr1320085.outbound.protection.outlook.com ([40.107.132.85]:44224 "EHLO APC01-PU1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241851AbhKIC5w (ORCPT ); Mon, 8 Nov 2021 21:57:52 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MjRucwjkwyra3K4VQGGpEGg0XydrtEBjS7+TSe46p5uUMEejBKUTgSCPb9/oudfSNrmbtw3lI15Z4BWZP6V8YiUQE9jp7imqTzIoCa2msh48FQta4bHxHJ/uMy2yTdz4Vg0UWjIkoHb72Gk2mEMLkjmCJ2fSruVMYU2IqWvuviX7pZgPj15/guUgFq/py1DU88OLkZPDKYb4nNXfnGi/DLwmp4YXHAPHTlz5WIcFbEbPErdA0YqyDTEmf5UEbbeTFi40EiKzAsVGKBLySutBTrjgpAZeqa9XthMVJU5zdrix++6RDNnJvD30kVKG/UIVpCVN2nab/qlWX56Q2B0iDA== 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=VvLokOUf35eCgKTRGFw1MK+UKYgI2JDRCOQeHH+KKQ4=; b=mkPPDP4m3Pwvxde85moB4f1bO6hETzkIf1ZWK3VF4X/LUESc2sczNxIx5JZtS5mv6PG5iRtop3u/DcjjaHgX3lo7NYrCUqjPhVevX+kL1sCWH6NvkX3xfgwtTaMNxeFRq0HcbkWHG3ZWG8X7wmkzNexxvDwFSAXi4uJLdS2K9+lbjYpX0WAAbMAIBYN1R9OWAjxTgKDJecUFfzZwfdQQvuFkmYEPRJo9M7acRDAoazEy8qL1YBW9JhQM35FULIVDy6/TBBktFffES/B9fmeTbVcgE7ZqMBVCU+BJeeyHCFvJKutqJrvsLjHbQpyfyZQaoF4w2CwoHYaZTjDsXjmvGQ== 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=VvLokOUf35eCgKTRGFw1MK+UKYgI2JDRCOQeHH+KKQ4=; b=bt22hiGaP3dYGUGuMsYr9K5txS10sgN8piIw1U45Ta3KtPPFy871Xq729ywbGfbd2XEdn0La4DcIRch4e9C2dO0TC4D1h0JnTsi2O+t4supGT82pgSQFLPCFfXntRPK2tFJ050LagT9bGI9if5eLRK146+ziv/9YQEUpLvFIpWE= 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 SG2PR02MB2699.apcprd02.prod.outlook.com (2603:1096:4:58::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.15; Tue, 9 Nov 2021 02:55:02 +0000 Received: from SG2PR02MB4108.apcprd02.prod.outlook.com ([fe80::7e:59ef:bec3:9988]) by SG2PR02MB4108.apcprd02.prod.outlook.com ([fe80::7e:59ef:bec3:9988%7]) with mapi id 15.20.4669.016; Tue, 9 Nov 2021 02:55:02 +0000 From: Huang Jianan To: linux-erofs@lists.ozlabs.org Cc: huangjianan@oppo.com, guoweichao@oppo.com, guanyuwei@oppo.com, yh@oppo.com, zhangshiming@oppo.com, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] erofs: add sysfs node to control sync decompression strategy Date: Tue, 9 Nov 2021 10:54:45 +0800 Message-Id: <20211109025445.12427-2-huangjianan@oppo.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211109025445.12427-1-huangjianan@oppo.com> References: <20211109025445.12427-1-huangjianan@oppo.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: HK0PR03CA0109.apcprd03.prod.outlook.com (2603:1096:203:b0::25) To SG2PR02MB4108.apcprd02.prod.outlook.com (2603:1096:4:96::19) MIME-Version: 1.0 Received: from PC80253450.adc.com (58.252.5.73) by HK0PR03CA0109.apcprd03.prod.outlook.com (2603:1096:203:b0::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Tue, 9 Nov 2021 02:55:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a4daefe5-1fe0-4ce2-06bb-08d9a32c537a X-MS-TrafficTypeDiagnostic: SG2PR02MB2699: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: II1WgWJboD8qT7Xc8Gl8N90UBCvxVjuQF+mdVjQ/gA9VSh7xpoOlU+6Dw14Cu6SEgxLMZECgjrIzikmXPZlu55nJ2WA2eLMKiuwnN4qGMex7bCtNisaaqViyL2IRoJFrIjhkBd0WU3h6cZ+CWuTGsQVbKQzSrJ9bT7FCqEqOtGJULTAQCD3HukDlEEAOe3YJ/6WhnBwkouaEf3q/xoFVP5hId2nB8h9cqFW4zGjDhgvV4PvKIz8WTo/Kz7lSuKAJ1kTRRMDyQJIshn3VG6sajqaR9hwjlfmJSxXLLP0DfR3Wxyq1M236fvHR3u6gzKuu/Y5+gHxBVh14bhHKeLS2VmVsdWGNnJ3Rx3Td4fl32RTqBtoucfV8QsjNXt0+nCDFtBaLyUPrt3A4EE52Hc+w/WzkMw8BwmiapyVjiUxqHRbyOaLSwvxMmcc9hNHF9uSO0flok8RVqCw3ZQW+vmziODMQor6RdVjzRi0vLuxfCzmeF+J8qW4kJtwrP45DsALlz8nBgF3zPM5ThWqLUSYa/SDRd/LlIwPcdkQtVzNkiCR/yWygtLLFlwH90r7JitRAftgQNGyaI3BAfvTj0AdLlarVL8l/kn3eROxZrPTxV2V/RUtSj7AHyBOQg+gOMN3M4LBBrXe8/lujnOKYLdDo3IXF6GVTJvLTiFfOS5HsuwgNy5fEoDjZzi9LWG/kEPT0wRw7qAmfLuu8tyWzAI28tpdWsOco362H53TP32bjSrY= 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)(366004)(508600001)(38100700002)(36756003)(6916009)(52116002)(66556008)(38350700002)(6506007)(6486002)(316002)(83380400001)(6512007)(4326008)(2906002)(86362001)(26005)(186003)(2616005)(1076003)(8936002)(5660300002)(956004)(66476007)(6666004)(66946007)(8676002)(11606007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?2bwV9y1UsqybOPMsoErokG3wE9Zhly5Ba1mAirz6XyftAbLJnPfr/HECoci0?= =?us-ascii?Q?D5hVMxQaKwKiG85UzLYy3SnbQQSV3OQe0RdBnfpTVKuU2vzT+lBWj2NupuVC?= =?us-ascii?Q?pTt6tYfapGp3i4Ycz/GxA5cMm3fF9EwRooLv41d7cf7nKmtCiI4p/q6DdoSC?= =?us-ascii?Q?PoZQm6AIYqAShy0B8VhSLNZ73vZfnOoubD4azUpaZKRhPNokBICfx1YTlg0R?= =?us-ascii?Q?rXHR2lLPtAe9KUpECu0mKV+/Spb57YLGmdzH1PjlRvEQm8RaD0xeewI7G4MB?= =?us-ascii?Q?QIaQ5lXKswXlTthyOYukAgCyYR8AnenDB2dU08/eQ2K9HnO2VXLX5mXgi+YE?= =?us-ascii?Q?dyNB+1jrIEeMdePv6J1JBI9imAzVCe3L5TDjsfLmcZ8PJl8BdD0/S6YH6ccL?= =?us-ascii?Q?hlMBfrisqwaRrlL48YSEZg+0ov6XCrtB7jlYTdg82z9y8Fe8RQ29JJ9FegVD?= =?us-ascii?Q?XdujMK75IQMCD3ItSUdEpV7+MFyXpf112kHio9ZT2w4u12HTx85nMQf/qxa6?= =?us-ascii?Q?OGR5PzUIBRM85nBj/lCqvumJuAToSVDa8r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aXorGGOs4jG5vp0K7kXuNptYCqCbZXRIGo11fxWp6/JigSTgIWeHr?= =?us-ascii?Q?VETGRPkpeVRJ5M4wzhFnpEznG5xpBgtFxFIA8dWHiQ3cpt5uHOiMN/nO/gX0?= =?us-ascii?Q?6Br2nYn/VpjYo7bPGhV6Z08vvdieSk5m42Px2CExVBF2shChVrTtjdxvxDUi?= =?us-ascii?Q?u76qJf/PH/hlberVqZuN3hQ=3D?= X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a4daefe5-1fe0-4ce2-06bb-08d9a32c537a X-MS-Exchange-CrossTenant-AuthSource: SG2PR02MB4108.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2021 02:55:02.5489 (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: H6xK90Ev5x5x+6ltvMRsYVYKPBy6A9WDZkeCTPBPosV9nfLtj3avNJ+b5Ln5lUQJf7yFpcP8MZW/exuUq9dIpQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR02MB2699 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Although readpage is a synchronous path, there will be no additional kworker scheduling overhead in non-atomic contexts. So we can add a sysfs node to allow disable sync decompression. Signed-off-by: Huang Jianan --- fs/erofs/internal.h | 2 +- fs/erofs/super.c | 2 +- fs/erofs/sysfs.c | 6 ++++++ fs/erofs/zdata.c | 9 ++++----- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index d0cd712dc222..1ab96878009d 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -60,7 +60,7 @@ struct erofs_mount_opts { #ifdef CONFIG_EROFS_FS_ZIP /* current strategy of how to use managed cache */ unsigned char cache_strategy; - /* strategy of sync decompression (false - auto, true - force on) */ + /* strategy of sync decompression (false - disable, true - force on) */ bool readahead_sync_decompress; /* threshold for decompression synchronously */ diff --git a/fs/erofs/super.c b/fs/erofs/super.c index abc1da5d1719..26585d865503 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -423,7 +423,7 @@ static void erofs_default_options(struct erofs_fs_context *ctx) #ifdef CONFIG_EROFS_FS_ZIP ctx->opt.cache_strategy = EROFS_ZIP_CACHE_READAROUND; ctx->opt.max_sync_decompress_pages = 3; - ctx->opt.readahead_sync_decompress = false; + ctx->opt.readahead_sync_decompress = true; #endif #ifdef CONFIG_EROFS_FS_XATTR set_opt(&ctx->opt, XATTR_USER); diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c index c7685f1a8f34..fe67ed490735 100644 --- a/fs/erofs/sysfs.c +++ b/fs/erofs/sysfs.c @@ -16,6 +16,7 @@ enum { enum { struct_erofs_sb_info, + struct_erofs_mount_opts, }; struct erofs_attr { @@ -55,7 +56,10 @@ static struct erofs_attr erofs_attr_##_name = { \ #define ATTR_LIST(name) (&erofs_attr_##name.attr) +EROFS_RW_ATTR_BOOL(readahead_sync_decompress, erofs_mount_opts); + static struct attribute *erofs_attrs[] = { + ATTR_LIST(readahead_sync_decompress), NULL, }; ATTRIBUTE_GROUPS(erofs); @@ -82,6 +86,8 @@ static unsigned char *__struct_ptr(struct erofs_sb_info *sbi, { if (struct_type == struct_erofs_sb_info) return (unsigned char *)sbi + offset; + if (struct_type == struct_erofs_mount_opts) + return (unsigned char *)&sbi->opt + offset; return NULL; } diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index bcb1b91b234f..ad11333b367a 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -776,8 +776,6 @@ 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; @@ -791,10 +789,9 @@ static void z_erofs_decompress_kickoff(struct z_erofs_decompressqueue *io, if (atomic_add_return(bios, &io->pending_bios)) return; - /* Use workqueue and sync decompression for atomic contexts only */ + /* Use workqueue decompression for atomic contexts only */ if (in_atomic() || irqs_disabled()) { queue_work(z_erofs_workqueue, &io->u.work); - sbi->opt.readahead_sync_decompress = true; return; } z_erofs_decompressqueue_work(&io->u.work); @@ -1454,6 +1451,7 @@ static void z_erofs_pcluster_readmore(struct z_erofs_decompress_frontend *f, static int z_erofs_readpage(struct file *file, struct page *page) { struct inode *const inode = page->mapping->host; + struct erofs_sb_info *const sbi = EROFS_I_SB(inode); struct z_erofs_decompress_frontend f = DECOMPRESS_FRONTEND_INIT(inode); struct page *pagepool = NULL; int err; @@ -1469,7 +1467,8 @@ static int z_erofs_readpage(struct file *file, struct page *page) (void)z_erofs_collector_end(&f.clt); /* if some compressed cluster ready, need submit them anyway */ - z_erofs_runqueue(inode->i_sb, &f, &pagepool, true); + z_erofs_runqueue(inode->i_sb, &f, &pagepool, + sbi->opt.readahead_sync_decompress); if (err) erofs_err(inode->i_sb, "failed to read, err [%d]", err); -- 2.25.1