From patchwork Fri May 12 08:29:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13238845 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7F45C77B7C for ; Fri, 12 May 2023 08:30:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240058AbjELIap (ORCPT ); Fri, 12 May 2023 04:30:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240207AbjELIam (ORCPT ); Fri, 12 May 2023 04:30:42 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B3231157B for ; Fri, 12 May 2023 01:30:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V6HzSewevdMRuP1ly6zW5fMPvwvUMO9Wk9X4X3d5B/pk7PXxgOIVB974Uw9XxRoQGhSOApNqCkCkqa4JlO97z076vccjdF04THpa4bCZ2LC9zTe/Lnx1AN8R4MH1r3a6oGJkYh0KxZKvfOatPYQlr3tZJEgwFC2QjW6bvfjdHEtzp5DHm/dZc20s9Ns8oIFN/A8+jDOeu+/W1rp6UPzD4flmxmBYHVForckkDB5iYdPklqfd02eOyni4fZ5d4VDwB8OUgCzVADA8BhSJIOTgZgau29L8JQAzbDmEmMJUcBRYkt4jesKuRLqVLB4NMim6k6PKULxYvfAgKaSju0xbtg== 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=xcBIOFVwsOJwwiiiwT2wHt88eI+LSq1jKSPeXcH5azs=; b=LG+n1U7MhOMI1HqPWh2Ax3Cs8g2BKwFMgW/1sGUFLaWjXgzWZKLZEIWp/DUfkI17A7NAp2RUwFBHwF+rkIi1oSA/WLD/8v+JXxCd0LGvGGhBemHba/a6xYfLzLi+9/M5v+D632Xa7Q1MGvVA/mWrVmreCRgks03PLnfegSN/6UyVIGxO3TFpxQITXYCLsUGXO9IDJMxHWiggq/BNatKYPT/LXH/17n34rj3DgMzrmqvWgEGea/KEi0IICjB19wQ8mxVrk7PsPJyzIwbzEYJgmeEG07ztDP57+t60RXQrzsLTDx2TXhkx3e1zTa1S4aweXMyamtD82axon+IEVhPJ7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xcBIOFVwsOJwwiiiwT2wHt88eI+LSq1jKSPeXcH5azs=; b=eJYfgE6uBcazTjehLybrfyE1pAD1B5XhWJQaJ/hJHp0oEy4xhkvGJq3uPivZSqn56PIpO2EIARgmKvbL5m1bgbuCl4Qtmaoj1i4AS+Z6OG70JJoTUoBTOkx6sswjs+i1fqG8IcwRpN6E//VEGmXWdo4anzOiszbzMxiOhhE9I03y9aUNzrU6NbAHalJgVjsYsJpOcYk/GNJezuj49pcSvdb81NzvBH9A28q/umBGrFJBD6ROawKSeravADC4Dj2sT0AZ+X8918FXt1DzJBnkaIZO0J4ux/P1DqUzazNPOq/aKUgK6T6aOjQ4osfNEpNbp91p2ztlPeoUKoevDPiRUA== Received: from BYAPR06CA0057.namprd06.prod.outlook.com (2603:10b6:a03:14b::34) by SN7PR12MB6791.namprd12.prod.outlook.com (2603:10b6:806:268::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.32; Fri, 12 May 2023 08:30:33 +0000 Received: from DM6NAM11FT030.eop-nam11.prod.protection.outlook.com (2603:10b6:a03:14b:cafe::8) by BYAPR06CA0057.outlook.office365.com (2603:10b6:a03:14b::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.24 via Frontend Transport; Fri, 12 May 2023 08:30:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT030.mail.protection.outlook.com (10.13.172.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.24 via Frontend Transport; Fri, 12 May 2023 08:30:32 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Fri, 12 May 2023 01:30:16 -0700 Received: from dev.nvidia.com (10.126.230.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Fri, 12 May 2023 01:30:15 -0700 From: Chaitanya Kulkarni To: , CC: , , Chaitanya Kulkarni Subject: [PATCH 1/3] zram: allow user to set QUEUE_FLAG_NOWAIT Date: Fri, 12 May 2023 01:29:56 -0700 Message-ID: <20230512082958.6550-2-kch@nvidia.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230512082958.6550-1-kch@nvidia.com> References: <20230512082958.6550-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT030:EE_|SN7PR12MB6791:EE_ X-MS-Office365-Filtering-Correlation-Id: 22f93c43-16b1-4970-4dd2-08db52c326c9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EyTrWy5dWAsS51uKAtqWhjJ9RkPe1Ju5aEzHVxsS0NSOMqXzXaEtRo8bTXgEeaDhQ554EygkQMVnjN1mk9xDC1HLDzt6tKueQLXB+kr1cX+lgHD7RfcJjBCizKKxwfANF9rD1zHstARKj+ia1PDpa6YD7QG1BTZkjagLb/PmqyUCQfoEkSef7qiu/ujV6fPREW6sjS3bgYbwIdMuHw5X3kILTb01pNDMCigADlx4KxEh/YxQ2umuixivqi1v+HfOvrGuz6bfSt/5o1FcFzYjEvOQCUHGcA0EfOZivKDIujuQMD4zVZVXAHnd8v10sq9KRMilSp+9WhhdAA3cuoeEcQle5+D6/bfMbQ8x1UW7nZGb8tSE9P1E7bay8zzpe3F1bQ5FLfNs2P9Y0DovNqfMY9xHTAVbjXkYIl48+nJl1WYaDQXnvnaZFNFzBliX5JYYWkLZbZYVCDQ5rzPmTpKo+dbNLHHDNWXxd/jQA+eSbXnKT5tPwrcmY4QnO6Ft9qEXrzkiy7Ma4FxMcFjuL0voBcz8ryPg90LpUL+nn/r2GP3Q1Z64xR1CGwVbmaLyK6OeLnDD/5Z6WaT34+4hAuM6psQXFNQXML9L2zwg+3uGHoYT6E05O9CPXQiJ5nHFUFsM6WsFk9+Nnk408Ryky4L1yl7aINyi1knqib7XDGQ1ol/0k0MLSA4BsBV22BqmUJF42SvwEycOuDZxcpso0uNGuQ== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(136003)(346002)(376002)(396003)(39860400002)(451199021)(46966006)(36840700001)(40470700004)(40460700003)(70586007)(36756003)(4326008)(478600001)(316002)(70206006)(7696005)(110136005)(54906003)(356005)(2616005)(426003)(336012)(186003)(83380400001)(1076003)(107886003)(36860700001)(26005)(6666004)(47076005)(40480700001)(2906002)(41300700001)(5660300002)(82310400005)(16526019)(82740400003)(8676002)(8936002)(7636003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2023 08:30:32.4321 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 22f93c43-16b1-4970-4dd2-08db52c326c9 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT030.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6791 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Allow user to set the QUEUE_FLAG_NOWAIT optionally using module parameter to retain the default behaviour. Also, update respective allocation flags in the write path. Following are the performance numbers with io_uring fio engine for random read, note that device has been populated fully with randwrite workload before taking these numbers :- * linux-block (for-next) # grep IOPS zram*fio | column -t default-nowait-off-1.fio: read: IOPS=802k, BW=3133MiB/s default-nowait-off-2.fio: read: IOPS=796k, BW=3111MiB/s default-nowait-off-3.fio: read: IOPS=796k, BW=3108MiB/s nowait-on-1.fio: read: IOPS=857k, BW=3346MiB/s nowait-on-2.fio: read: IOPS=857k, BW=3347MiB/s nowait-on-3.fio: read: IOPS=858k, BW=3353MiB/s * linux-block (for-next) # grep cpu zram*fio | column -t default-nowait-off-1.fio: cpu : usr=5.82%, sys=13.54%, ctx=36301915 default-nowait-off-2.fio: cpu : usr=5.84%, sys=13.03%, ctx=37781937 default-nowait-off-3.fio: cpu : usr=5.84%, sys=12.90%, ctx=37492533 nowait-on-1.fio: cpu : usr=1.74%, sys=97.62%, ctx=24068, nowait-on-2.fio: cpu : usr=1.74%, sys=97.57%, ctx=24674, nowait-on-3.fio: cpu : usr=1.76%, sys=97.59%, ctx=24725, Signed-off-by: Chaitanya Kulkarni --- drivers/block/zram/zram_drv.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index f6d90f1ba5cf..b2e419f15f71 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -36,6 +36,10 @@ #include "zram_drv.h" +static bool g_nowait; +module_param_named(nowait, g_nowait, bool, 0444); +MODULE_PARM_DESC(nowait, "set QUEUE_FLAG_NOWAIT. Default: False"); + static DEFINE_IDR(zram_index_idr); /* idr index must be protected */ static DEFINE_MUTEX(zram_index_mutex); @@ -1540,9 +1544,10 @@ static int zram_write_page(struct zram *zram, struct page *page, u32 index) static int zram_bvec_write_partial(struct zram *zram, struct bio_vec *bvec, u32 index, int offset, struct bio *bio) { - struct page *page = alloc_page(GFP_NOIO); + struct page *page; int ret; + page = alloc_page(bio->bi_opf & REQ_NOWAIT ? GFP_NOWAIT : GFP_NOIO); if (!page) return -ENOMEM; @@ -2215,6 +2220,8 @@ static int zram_add(void) /* zram devices sort of resembles non-rotational disks */ blk_queue_flag_set(QUEUE_FLAG_NONROT, zram->disk->queue); blk_queue_flag_set(QUEUE_FLAG_SYNCHRONOUS, zram->disk->queue); + if (g_nowait) + blk_queue_flag_set(QUEUE_FLAG_NOWAIT, zram->disk->queue); /* * To ensure that we always get PAGE_SIZE aligned From patchwork Fri May 12 08:29:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13238846 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0B50C77B7F for ; Fri, 12 May 2023 08:31:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239781AbjELIbR (ORCPT ); Fri, 12 May 2023 04:31:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239907AbjELIbQ (ORCPT ); Fri, 12 May 2023 04:31:16 -0400 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2064.outbound.protection.outlook.com [40.107.101.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E599F106C3 for ; Fri, 12 May 2023 01:30:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wiir7C05sW+Li0Vrn9vl2gfszZtUiu6ntQG+NZyURexOAqqGpIcW/olW0OWygtKCsYlDo0m1lryRubgwKp3oMAVxQpOxOhgSOeHK0b+7KIaaZMhSQOhVgn3ed2fckJqtK+v68IAtWfS9iDroeeP8nklQo3JBYCLSRp3CxZhmUX1t3ip+XJMnrGM7ZEev2PPEuD5pzI/azUbSk8g5uJGgO/4FTeDUcsZTgsKYXh6tyjhqqSUYdd3/ohfN8iFogmzNeNdK7qpPgDgrschrSVzdz/NIRUMDNeIDBVHeYKO2XtfDXEcTZTIeB5jXc+lWuYokR75OLmgERD6Ys+Yb9jg2dQ== 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=8wv6rUVhlGfBXmUi0AdfQomrvvsc310WLhnIb5sAlKc=; b=LhWLcwQp5TwzIfSMjJKyU1LeJ9aXgTWIWYC9EqHlZyZk433k2sffUD1yRQ68I+QyCVKgIpIAOmAamNXuUh03gBF6XLF2X3kCt1yce0YgwsYCEwWLVxWr/qU1326X9ZuPSy+e8+9lqbplUEdwDy3OanmXwJGhP7bDvhRIVr8oY4ttC3Nr23Cd+oPgHL/FUgS/c4voKNUXFqm9NmbS+04Iz5kW8USWxbx6fE5jc3bXCXf/PLedLBlTjJ/Vm239txfFSvc11i/lFaZXIY3kfWa10UbGPvD9TSIVCqDduL9cVvLJucIVi0WW+Fkw/S7V/IlDkzROVnuu8XsQMWqMVtvSsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8wv6rUVhlGfBXmUi0AdfQomrvvsc310WLhnIb5sAlKc=; b=TZWA144KIIRrCr+RvU1MEePO6HSiJabXYt59ee0XV+f1h2LCia7/6ctUcfs8/xSbSfeGhv4vpAEZhy1SOv/UEEnqTH+SOpoLNFhP9yyH0P+4uRtz4dkM0krqg+L0eM8ECD8ZPlsbczBH3sa7jRqaHajX8hVjhAu+mzE4OQWIeMDtxXjWA0267RO1R5a3/VsrD4wlqHR5IbaRqAxEL/wPkudNKckMAf7ZrpZBVAm+TwLkEYecdQxv+gk2xa3hizF3MJ0jYZR7s40xJc3HjGFXCm2JVneA47yVqfFaLhUZqjpTOxNihjY4qCNz/0vLoH02Brb08H+6cAkVI4CUCr7GFg== Received: from BN9PR03CA0662.namprd03.prod.outlook.com (2603:10b6:408:10e::7) by SJ1PR12MB6027.namprd12.prod.outlook.com (2603:10b6:a03:48a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.23; Fri, 12 May 2023 08:30:44 +0000 Received: from BN8NAM11FT092.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10e:cafe::11) by BN9PR03CA0662.outlook.office365.com (2603:10b6:408:10e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.24 via Frontend Transport; Fri, 12 May 2023 08:30:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BN8NAM11FT092.mail.protection.outlook.com (10.13.176.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.24 via Frontend Transport; Fri, 12 May 2023 08:30:44 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Fri, 12 May 2023 01:30:27 -0700 Received: from dev.nvidia.com (10.126.231.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Fri, 12 May 2023 01:30:27 -0700 From: Chaitanya Kulkarni To: , CC: , , Chaitanya Kulkarni Subject: [PATCH 2/3] zram: consolidate zram_bio_read()_zram_bio_write() Date: Fri, 12 May 2023 01:29:57 -0700 Message-ID: <20230512082958.6550-3-kch@nvidia.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230512082958.6550-1-kch@nvidia.com> References: <20230512082958.6550-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.37] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT092:EE_|SJ1PR12MB6027:EE_ X-MS-Office365-Filtering-Correlation-Id: 8ff18cd3-235a-498a-3d25-08db52c32df6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AAcfP6PbtwKx/M3mls0l7Iwh87y7ERv2di2KHI7egrJeDp71+nDffkLnlO4jFmqZ7HGICjNFgfUGBNbZASsYnEgyX1bNa/O4hpsC7UfoHnckSKpFqoxM/DzPkRSPPHtYfRR6uTIeMFbphqlRySgicjLigdF/ace0ReaJGno55eGzRXwmG8DoYIp0XMBh+vzX8PfiIAsvpNdrVQtpMacrrX+tELe5DkO25r6glF7Pj880tmpnE7tBuD5iASuI/bZv0ixglCMVU/7oxTzGK8txpQR/Ap9ivTvWW7/kdzMlyGJ4npKGPyRVVv03uE6uZS11EK87JYLb/50LAVauOUPY9yzZGlb+d3R5wyf6m2G8OwsMOqw7bPTYVEX7x2tOT69ORuJD6VXASdAIGtf2h0z1nw7MrveUfhFflbJqFno24Hp6kJCbVdh440R9OzeLSZHrzFV7wg8wKtov5rxKnmXb9mlaPpSHyrjAtEvJeF+nLnnC1b5t347ev+/8u6MnZpGPrW9UggpAPbMfFliphAB2Hp41s7uguUpg8cc55+USuoT+gRmdR38P1tGCjkrIJrGFArxU9Rh6iQ18L0+6zzk3d4Nu59EVoQFcQB+gnx8XawGl9OzDTa5TGNrmqF1zbS0VMPRjmJwjtfvgwN/o8r8iifue9d0g0tRSqSOqHkFqecGpckcuTfu5Gl02IzH93X7eK5U3DWYkEIZvjSrPMaRw1e5pskgt1dhV5Q4ITbDF/EKFlsf41kaNN2Nya07Iu+se X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(39860400002)(376002)(396003)(451199021)(40470700004)(36840700001)(46966006)(82740400003)(7636003)(356005)(426003)(336012)(26005)(83380400001)(40480700001)(1076003)(2616005)(186003)(16526019)(47076005)(36860700001)(107886003)(2906002)(8676002)(5660300002)(8936002)(36756003)(478600001)(40460700003)(54906003)(110136005)(7696005)(6666004)(41300700001)(316002)(70586007)(4326008)(70206006)(82310400005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2023 08:30:44.4394 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8ff18cd3-235a-498a-3d25-08db52c32df6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT092.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6027 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org zram_bio_read() and zram_bio_write() are 26 lines rach and share most of the code except call to zram_bdev_read() and zram_bvec_write() calls. Consolidate code into single zram_bio_rw() to remove the duplicate code and an extra function that is only needed for 2 lines of code :- 1c1 < static void zram_bio_read(struct zram *zram, struct bio *bio) --- > static void zram_bio_write(struct zram *zram, struct bio *bio) 13,14c13,14 < if (zram_bvec_read(zram, &bv, index, offset, bio) < 0) { < atomic64_inc(&zram->stats.failed_reads); --- > if (zram_bvec_write(zram, &bv, index, offset, bio) < 0) { > atomic64_inc(&zram->stats.failed_writes); 18d17 < flush_dcache_page(bv.bv_page); diff stats with this patch :- drivers/block/zram/zram_drv.c | 53 ++++++++++++----------------------- 1 file changed, 18 insertions(+), 35 deletions(-) Signed-off-by: Chaitanya Kulkarni --- drivers/block/zram/zram_drv.c | 53 ++++++++++++----------------------- 1 file changed, 18 insertions(+), 35 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index b2e419f15f71..fc37419b3735 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1873,38 +1873,12 @@ static void zram_bio_discard(struct zram *zram, struct bio *bio) bio_endio(bio); } -static void zram_bio_read(struct zram *zram, struct bio *bio) -{ - struct bvec_iter iter; - struct bio_vec bv; - unsigned long start_time; - - start_time = bio_start_io_acct(bio); - bio_for_each_segment(bv, bio, iter) { - u32 index = iter.bi_sector >> SECTORS_PER_PAGE_SHIFT; - u32 offset = (iter.bi_sector & (SECTORS_PER_PAGE - 1)) << - SECTOR_SHIFT; - - if (zram_bvec_read(zram, &bv, index, offset, bio) < 0) { - atomic64_inc(&zram->stats.failed_reads); - bio->bi_status = BLK_STS_IOERR; - break; - } - flush_dcache_page(bv.bv_page); - - zram_slot_lock(zram, index); - zram_accessed(zram, index); - zram_slot_unlock(zram, index); - } - bio_end_io_acct(bio, start_time); - bio_endio(bio); -} - -static void zram_bio_write(struct zram *zram, struct bio *bio) +static void zram_bio_rw(struct zram *zram, struct bio *bio) { struct bvec_iter iter; struct bio_vec bv; unsigned long start_time; + int ret; start_time = bio_start_io_acct(bio); bio_for_each_segment(bv, bio, iter) { @@ -1912,10 +1886,21 @@ static void zram_bio_write(struct zram *zram, struct bio *bio) u32 offset = (iter.bi_sector & (SECTORS_PER_PAGE - 1)) << SECTOR_SHIFT; - if (zram_bvec_write(zram, &bv, index, offset, bio) < 0) { - atomic64_inc(&zram->stats.failed_writes); - bio->bi_status = BLK_STS_IOERR; - break; + if (op_is_write(bio_op(bio))) { + ret = zram_bvec_write(zram, &bv, index, offset, bio); + if (ret < 0) { + atomic64_inc(&zram->stats.failed_writes); + bio->bi_status = BLK_STS_IOERR; + break; + } + } else { + ret = zram_bvec_read(zram, &bv, index, offset, bio); + if (ret < 0) { + atomic64_inc(&zram->stats.failed_reads); + bio->bi_status = BLK_STS_IOERR; + break; + } + flush_dcache_page(bv.bv_page); } zram_slot_lock(zram, index); @@ -1935,10 +1920,8 @@ static void zram_submit_bio(struct bio *bio) switch (bio_op(bio)) { case REQ_OP_READ: - zram_bio_read(zram, bio); - break; case REQ_OP_WRITE: - zram_bio_write(zram, bio); + zram_bio_rw(zram, bio); break; case REQ_OP_DISCARD: case REQ_OP_WRITE_ZEROES: From patchwork Fri May 12 08:29:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13238847 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D278FC77B7F for ; Fri, 12 May 2023 08:31:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239907AbjELIbd (ORCPT ); Fri, 12 May 2023 04:31:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239803AbjELIbc (ORCPT ); Fri, 12 May 2023 04:31:32 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2080.outbound.protection.outlook.com [40.107.223.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8578C10E63 for ; Fri, 12 May 2023 01:30:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V7HC3NXh2pRqkxPhKoQ4DeC7gKPbXPlFRtULkeQozJpjQ/xJc/DrnNbVeL/SDkOW8derTMITpaltyjFEVwoyh55rBIPnOMtvIOHBHrgoEWXUXyhQcYJ0R1ZS2JpDoHo8wZn8Sl0V4VaqpXim2kZrq72yzMznz42SlOXN/3TwEWLWLlcA3VOHFvopvxi5BOmuL31qZq3PushMVFSo5wzvxKSNqb8n4PXZ7XCjvo8Xwa4PHBhxComAUEADfcF6SXgqmaU0kFO6OxKJINchM6MLK4QvIRF8yhiue6NraORThTerXTTfmLIhNYyMhQVK7UrKyfbIadUrEgl17sZUzKgmwQ== 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=VEss8p2RQeb1WIxNaWZtnb3ov20xDwsu0v0+V918nxY=; b=bQK2esEbUxnKQumjY0c3oIjRwzQWn+41CVJi/X6E8u/0/DDcfm7mAnSwVkbcrVmISRfXrXBxc5h+kDom8bN8t0R6OAixo5IicMAZqbHKNEMzQIhsEiDkOZT/ZqyOACm330NZJPBPzPXYPNT+LKjU54zkLzTqn7OW3KOXC966yCksEX52wY5e71bEVV25SDTG/Kepkljz1VMXdOuZfvY4X6G2TPdl9xEn76ieybKb9BV9TVxfq6euwpzN3ZGypnVdkafy+LSImuglIcHsEVoUaMUNVBXLdpDxdDAlr9IrzY57msaOQ/otSZcULlEumj26yE8O/orEDpuTopooLhfN/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VEss8p2RQeb1WIxNaWZtnb3ov20xDwsu0v0+V918nxY=; b=JYP1YtC6RFxmJwXxIUY4DwYU2LG06JEoF8PLxk4yi5S+oZaw2Nms+53evUuqyIaFswxEhHxjB0PhKrXgBSsqh+ma2iFx9Nu6OPQf9xMeWYHNiOVaJEi6AmyYTOk5O01oOcqmJ2Uge6XkrnO6B6zW3XCvlyDfy2d+y8FnThiyuw2dNWzgpy3UIK1aQUqM9Gqul9f1nJOGrZX5ovsJNWPkRCPHkXchh2bX+ixP0hqwl53YXu7fP2JC3tyPMDFAdXan71vihdPI1ssf02s/Lj2+SZbuN/3VDV9B2txE9PzTsgYRXPqY26P0Fhcgq40qi2qaIMfXwEUuSZjaAZafSs3NxQ== Received: from DM6PR07CA0071.namprd07.prod.outlook.com (2603:10b6:5:74::48) by MN0PR12MB5908.namprd12.prod.outlook.com (2603:10b6:208:37c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.32; Fri, 12 May 2023 08:30:53 +0000 Received: from DM6NAM11FT003.eop-nam11.prod.protection.outlook.com (2603:10b6:5:74:cafe::39) by DM6PR07CA0071.outlook.office365.com (2603:10b6:5:74::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.24 via Frontend Transport; Fri, 12 May 2023 08:30:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT003.mail.protection.outlook.com (10.13.173.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.20 via Frontend Transport; Fri, 12 May 2023 08:30:53 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Fri, 12 May 2023 01:30:38 -0700 Received: from dev.nvidia.com (10.126.230.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Fri, 12 May 2023 01:30:38 -0700 From: Chaitanya Kulkarni To: , CC: , , Chaitanya Kulkarni Subject: [PATCH 3/3] zram: add flush_dcache_page() call for write Date: Fri, 12 May 2023 01:29:58 -0700 Message-ID: <20230512082958.6550-4-kch@nvidia.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230512082958.6550-1-kch@nvidia.com> References: <20230512082958.6550-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT003:EE_|MN0PR12MB5908:EE_ X-MS-Office365-Filtering-Correlation-Id: b98df24e-dd3d-4d88-a6fb-08db52c3335e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JMAAJuHiMLewcXajsRAJXOP719Qj0SbQyrpaG6bybsuamJ3vTgk9gzVFlcNsQL5i1zn4myhuHbxxGQb3kiodKELAehLt0smmI+1XP85k2BtXOxyDcVBDKvmF4V0rO5jEsTcBBh2uYMWMuitCg/J4Aou/jKVPY7ZyrYiSJ4PRVHfpHxTzLqiZN1ekPFPR/uLjsY3j9Mj4THAPzCyDfZHJRekpUG4/vOrbbW5aodl/1OP9VbvxBuDOrj+WgCrjMmm0/JTG8WvPaejhTU1WAizPVOiVpZIGG8GsiyjNbi1+lWIsXAuKzMP84QGGkCDhvnB8N3cQtbDbqkoF92oGzX+nb2nnF8Fya2RDYLAGjxzioqRWopUGiw33GHBVmRlvKZwldN72j7FXSsald0/UadfrHCk0qRzZOPA3Qw1jXSVUKQ0UQDzowrmy4KXcGw0AScTtZJzCb+pBmOx4jHWR1rEKXg8Qwrkm6Ob399pGEfALTexf8STseJksVk6hizhWuPZFfxMFWgWQxowy1n/feYK2xjwqQRtAgh1Arm1np9Um3D9a7+phULMkZwzeY3lRmxCadHEWB3xNqpPZN0K1m4keLha1L0vzy1Nq8oQRWlpVgQC/sL5f9nfDbH2J7RsMRVcK4IPYFQtgEl/mvGCkGrygg4fNt9xh9WQl+B1xkS0V4Tt/U1jSjA+ORDi/OkiJC/KdR/iCAEk+IpaYWkkxRs0QUw== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(136003)(346002)(39860400002)(376002)(396003)(451199021)(40470700004)(46966006)(36840700001)(4744005)(2906002)(336012)(36860700001)(5660300002)(4326008)(36756003)(41300700001)(8936002)(8676002)(316002)(110136005)(478600001)(54906003)(70206006)(70586007)(6666004)(40460700003)(82310400005)(83380400001)(7636003)(82740400003)(1076003)(47076005)(7696005)(107886003)(40480700001)(426003)(16526019)(186003)(2616005)(26005)(356005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2023 08:30:53.5592 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b98df24e-dd3d-4d88-a6fb-08db52c3335e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT003.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5908 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Just like we have a call flush_dcache_read() after zrma_bvec_read(), add missing flush_dcache_page() call before zram_bdev_write() in order to handle the cache congruency of the kernel and userspace mappings of page for REQ_OP_WRITE handling. Signed-off-by: Chaitanya Kulkarni --- drivers/block/zram/zram_drv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index fc37419b3735..a7954ae80d40 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1887,6 +1887,7 @@ static void zram_bio_rw(struct zram *zram, struct bio *bio) SECTOR_SHIFT; if (op_is_write(bio_op(bio))) { + flush_dcache_page(bv.bv_page); ret = zram_bvec_write(zram, &bv, index, offset, bio); if (ret < 0) { atomic64_inc(&zram->stats.failed_writes);