From patchwork Wed Feb 16 09:30:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12748313 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 C4CEDC433F5 for ; Wed, 16 Feb 2022 09:30:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232223AbiBPJa6 (ORCPT ); Wed, 16 Feb 2022 04:30:58 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:43306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232213AbiBPJaz (ORCPT ); Wed, 16 Feb 2022 04:30:55 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2043.outbound.protection.outlook.com [40.107.236.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BB532599E9 for ; Wed, 16 Feb 2022 01:30:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cd8IM2f+vEMRYWSYU1wq0LrFdM2GXFP3I2v2vyboLabgpF5hXqbFvoIi74lgCigZdRAuuEYbmiIOQxSWjbGbw0ytxdQeUFtWdlbeFUqzjc4lERZj26zrr5RjfqPwqLcdk5YqnsnXdwb9nDKAunRQCPtogvfoDN2CPSOcFvQzB5yTOrrMxCCNhLI4GhPTX4tepiUKJbCVyerJB+81ltlowKh6M6EB0Rk8CFVQs8quH2IGnva9f1cZTs5sFIP+IgzmrIjZmpTnFqJd22+fXFPuEFWhJVWniBZv/T+m4VgKbbsrQht/LpA+A3+PM0+/Df9Wr8WFsc0hu1nC87S6VTJzcg== 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=/7aWx8BWDS3RIVpIZmra8ab7iZb4TKZYUcObP6a3PcE=; b=UKNWw4d++WzVuFAERpynnsYGqu1JfTwcJ/1upir+PHVrsH4ZYQNpl8+GogKVUC3gZFxsUD6qf5oAb6gxIBDQJSGHL/bCDeuxs9cHE0kJYvph7xaUXxQ2hBuGYY+zi/YUpN5kefveroDGnFbO2COneeGx+m7pESTjCoz9YJOMt4KA/d3cyKe5vg5LRHwc/Pwzhvi9pRT364kDe7D76R/zTyMOYq2vGwBSpV9bPIoKn+0XBTG7L8T/aLCjUPNITtZ/jEdkd3b0+HfyDJ4Ieb0i1gc0JzeQQAimyEaxHLmq2EokdRkHVoJ3D+8TFUg+2YNlBWQaP4A17QoadcusTN8Urw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=wdc.com 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=/7aWx8BWDS3RIVpIZmra8ab7iZb4TKZYUcObP6a3PcE=; b=ikUGpxRQvdja21erJkYL2yJFR//gVFzK6/ol4JbrRxOpAHEk8V2rc5+Tl8szxTWOwO9iXnXjRXucn7qLcdwL6xxAVmvm/OFdm3udEilK5nDNK/EboGA0yBwBZRtv/T8ke0+RQTo/PJDCeoo9BwA5pYMxF8MMsAa4Yq09zhIffPKWf6qOh59FOuRs3xR43HUzCIjjNUtvty6J0XuKfSUzUkO1YJwN3MRSkuxnU4Kj9LR53bRmSmKViyou+HGtZKuAK6pJ+IsprWZc82ytsZoIqQZN8C+VK2O9mrN8j8Z6VuWJwRSDVgKSuETTmuBMGsH0E0ir2e7KTSgLgonP5fVqOA== Received: from MW4PR04CA0219.namprd04.prod.outlook.com (2603:10b6:303:87::14) by BN8PR12MB4628.namprd12.prod.outlook.com (2603:10b6:408:a8::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.14; Wed, 16 Feb 2022 09:30:41 +0000 Received: from CO1NAM11FT009.eop-nam11.prod.protection.outlook.com (2603:10b6:303:87:cafe::2f) by MW4PR04CA0219.outlook.office365.com (2603:10b6:303:87::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16 via Frontend Transport; Wed, 16 Feb 2022 09:30:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) 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 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.238) by CO1NAM11FT009.mail.protection.outlook.com (10.13.175.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4975.11 via Frontend Transport; Wed, 16 Feb 2022 09:30:40 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 16 Feb 2022 09:30:39 +0000 Received: from dev.nvidia.com (10.126.231.35) 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.9; Wed, 16 Feb 2022 01:30:38 -0800 From: Chaitanya Kulkarni To: CC: , , , , Chaitanya Kulkarni Subject: [PATCH 1/2] null_blk: remove hardcoded alloc_cmd() parameter Date: Wed, 16 Feb 2022 01:30:19 -0800 Message-ID: <20220216093020.175351-2-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220216093020.175351-1-kch@nvidia.com> References: <20220216093020.175351-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b44ff2f8-b2c1-4c5a-e4a9-08d9f12eff4f X-MS-TrafficTypeDiagnostic: BN8PR12MB4628:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dmNXZjGvM1Fqq/SZ7Qpol3YQEUX0bGG5Xtsj9CxfZ3SX3v3IYEgwG73207U7cN2mOueNbkHPTugwGx+DPOSbxqfDWUcJt24vdYh7OyUAwIIvwDNkikIeyJpGb1dciLdrZaesfWDYQ23o/PkrF3NdiE6yIa9fDVvoZQ0IPqC1usuLi1HxPNW7vk00B05+htCIXXVDL7wUZWsqlpOpZEMQhiMLMX/1HzVDUAIt9m0ucQWYqA7vZ/D2NmtIFRpcP7gMJJhMMzoe52qWlypSIH29xpR01WpabY9fmk2HvuQCiqoOrH4Jma0pnh8mDCphY49xB/F3O3rWKEHzyPq7QqGw6nt/ToD1am6zAfxXYKXD2jYc1AkdYjAU+KbLvtEvGSMfPbBwozHjqvypnUbUmQ+cD7B8y2lf0zRnFWOvZMIIEGWO8BTeAruQUe8/9Z9NPva8++n4p6BEvQmcqbrzCsJZpx4A9zat2hHxBnGN0cjyH+5PhG+STO0FMIGbYghPthdSEcqBxmHaQDcqJGLNQIx+sMAcZgdgo65Z9BwIzEu3UvB3fy10e9K2pHPEELRilF3HE4q4wBxo+k/gvk9UxNZGp+EJoQuumGiNcTI5p5XOfNkC7LeEA0ZvAYJpdSgz43eOX6B9vTb5ly8Z/QMFW+qojaHgtmWR52dPS+lhwOykVa62snDqhOSLvWrcUpWwwOJAkCVI4LNVVHD2KSNgbfLzfQ== X-Forefront-Antispam-Report: CIP:12.22.5.238;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(54906003)(40460700003)(2906002)(316002)(6916009)(8676002)(5660300002)(4326008)(36860700001)(83380400001)(47076005)(82310400004)(356005)(508600001)(336012)(1076003)(186003)(107886003)(426003)(2616005)(26005)(81166007)(70586007)(8936002)(70206006)(16526019)(36756003)(7696005)(6666004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 09:30:40.2757 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b44ff2f8-b2c1-4c5a-e4a9-08d9f12eff4f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.238];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT009.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB4628 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Only caller of alloc_cmd() is null_submit_bio() unconditionally sets second parameter to true & that is statically hard-coded in null_blk. There is no point in having statically hardcoded function parameter. Remove the unnecessary parameter can_wait and adjust the code so it can retain existing behavior of waiting when we don't get valid nullb_cmd from __alloc_cmd() in alloc_cmd(). The restructured code avoids multiple return statements, multiple calls to __alloc_cmd() and resulting a fast path call to prepare_to_wait() due to removal of first alloc_cmd() call. Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk/main.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 13004beb48ca..d78fc3edb22e 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -719,26 +719,23 @@ static struct nullb_cmd *__alloc_cmd(struct nullb_queue *nq) return NULL; } -static struct nullb_cmd *alloc_cmd(struct nullb_queue *nq, int can_wait) +static struct nullb_cmd *alloc_cmd(struct nullb_queue *nq) { struct nullb_cmd *cmd; DEFINE_WAIT(wait); - cmd = __alloc_cmd(nq); - if (cmd || !can_wait) - return cmd; - do { - prepare_to_wait(&nq->wait, &wait, TASK_UNINTERRUPTIBLE); + /* + * This avoids multiple return statements, multiple calls to + * __alloc_cmd() and a fast path call to prepare_to_wait(). + */ cmd = __alloc_cmd(nq); if (cmd) - break; - + return cmd; + prepare_to_wait(&nq->wait, &wait, TASK_UNINTERRUPTIBLE); io_schedule(); + finish_wait(&nq->wait, &wait); } while (1); - - finish_wait(&nq->wait, &wait); - return cmd; } static void end_cmd(struct nullb_cmd *cmd) @@ -1478,7 +1475,7 @@ static void null_submit_bio(struct bio *bio) struct nullb_queue *nq = nullb_to_queue(nullb); struct nullb_cmd *cmd; - cmd = alloc_cmd(nq, 1); + cmd = alloc_cmd(nq); cmd->bio = bio; null_handle_cmd(cmd, sector, nr_sectors, bio_op(bio)); From patchwork Wed Feb 16 09:30:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12748314 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 E858EC433F5 for ; Wed, 16 Feb 2022 09:31:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232213AbiBPJbM (ORCPT ); Wed, 16 Feb 2022 04:31:12 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:45160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232226AbiBPJbL (ORCPT ); Wed, 16 Feb 2022 04:31:11 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2062.outbound.protection.outlook.com [40.107.243.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E906A25BD7A for ; Wed, 16 Feb 2022 01:30:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jNaIG5qwl7Tc6pUkItQz6s3diIHXstRsGe0MMcqSFQuTf1otnhWVI8LgBi2Zc8gaLrntyOAddD0WgesafjcuG8Om+pYrA3+Cfl8Ssrihh9aNUaZuCNnqfnHQ1/3SDC4FgLwq6iJY8ldq8UbBaygpN7NhkoFmrTzHVjgoeSlOjvr4dW674BmuHdPJ3lNgNsU9JVAArH9QEN9le2h59PpxdXMLjTdxMF4GpT+4cJxmKmL0e1RjBUjWBuOcj9NXDSjbMc2F+S2cH3xUm064mM046l+XR+kdBc3VdyHiNkPytlw5YFru6GcvBducqhe60tG7VjrJgXHH1FBsP7LQ9yLE0g== 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=z0JXwLE5ow7VXE722TKghz2cdmCWTL1yer0j6O9ddoM=; b=Gk+vGz+dsy2jrQJO1AazCytxxj2F/5LcQubiGZbj3+3FY4ZW1jr21qB9CZx+nNUyfYKWa6R2V0JBP8g1hv/SpxAtmI8kzk3zhJGJbDUwEJAFDZ8oaS3QO3auUtPMC09JADZkJEnJXQHWS7dtdk2yNkFXbJZbIqaP4lq4XaeiV0ny8ylVh6NGasbZ9iAH1wbyUf46cLh1b6ayVqpMylIT7RlEs1kG6xue76P9+kaVuiEt9vzbpUFUixtktGxWNars6kXC4opvxiVDRryLcfCWuQKwcOPpbFBJ0nigDzBWq7Ypu4mqeddX8gW/dqsP5xQqi7dhZyNSG9plAyaxiLYkgw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=wdc.com 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=z0JXwLE5ow7VXE722TKghz2cdmCWTL1yer0j6O9ddoM=; b=fsjT/uOfO7T1M3e4U3L9xF4Gb6sDlN0y34pB5QljHXMRmy5aZFs8yTCRGJJobeWu657VZ59qSba7fu1Yqq7TjyzhbcmbqPfFS7tctmd8AeiyHP9t6ANWxf+pixb3/Fq0mf55qNMioEPCUr7VAv1w53D9CWcErJQvLX5sZex5kFb9JFyUr4Ecylcr1R31ccsSb0xIUk2Vb/3I/uL52r5VmKaZdpx42envrw52HBu/h1wFXep/ME4zkkgPvuuihZSnk9/zxnTRWCGotw+tToFJh3sI8tVElFMhfzoqgreA4aFUnHXBH3tfQRWmv1UJrvBNUfBEwGmCwm1rtD8qXpzlPA== Received: from MW4PR04CA0103.namprd04.prod.outlook.com (2603:10b6:303:83::18) by DM5PR12MB1403.namprd12.prod.outlook.com (2603:10b6:3:79::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.12; Wed, 16 Feb 2022 09:30:52 +0000 Received: from CO1NAM11FT015.eop-nam11.prod.protection.outlook.com (2603:10b6:303:83:cafe::f1) by MW4PR04CA0103.outlook.office365.com (2603:10b6:303:83::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.18 via Frontend Transport; Wed, 16 Feb 2022 09:30:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) 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 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.238) by CO1NAM11FT015.mail.protection.outlook.com (10.13.175.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4975.11 via Frontend Transport; Wed, 16 Feb 2022 09:30:51 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 16 Feb 2022 09:30:50 +0000 Received: from dev.nvidia.com (10.126.231.35) 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.9; Wed, 16 Feb 2022 01:30:49 -0800 From: Chaitanya Kulkarni To: CC: , , , , Chaitanya Kulkarni Subject: [PATCH 2/2] null_blk: remove local var & init cmd in alloc_cmd Date: Wed, 16 Feb 2022 01:30:20 -0800 Message-ID: <20220216093020.175351-3-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220216093020.175351-1-kch@nvidia.com> References: <20220216093020.175351-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: be134ae1-fae6-4917-1fa7-08d9f12f0603 X-MS-TrafficTypeDiagnostic: DM5PR12MB1403:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p2BWdAVh8pIHskc1AJ2jgIVkrMc3FtOV7Jl1RuOrgChf8/XeZeoXMpmbdDuw7oRtE0gHaOQHs9GklD+l/kJD+7WZVS+dyUDHQPKhUBS9sInQlQaLAn0fyWGgJ4knkD/5V+UVMFUeL6CFGN91LqWV3viIVGl5W+PA/bM0qRZO+MZ5j7Sw7kMpIMgAlPBoFmgo/RdZVZydsBHOCgcnKX2CQzcV9mD/IDvgSg5XK9dphB+Jb0ehWRkBfuqkwuNgMbvxXuKUSMzHqQXpnRn+omPo/orvx0rQqj5K2EmZ56CAO2ZMMZb9sUN9+jK3EFGxOhPNqZH9XmPDhZuvpe8s6uS4G+9j6AKt2OMOyactvIr3LlqQd6bsevguABeJ6J6eEGJZLMXniWJaXGyXDzqMcx0iHUYQVr/MVROsZmz3AuOGJzVw6KMV6tRJk8JR3YP0ADphh6RW/1UHzXV3WRCURaFFy/yXk3A/gx7Bi5rECGhqQJrWi3EUxxYW2B16wDKW4/RxrYznIRcUVUDMxpTcHcsn7FMDBqNgwVeMU+5LgzRVnF+dHdsa/7rQ9OxGsK3ipG1OOLXrkv5fNvkiG34j5BzWhE8bGFnE7Uqiq7I5GLEwIA2mMi7zsk/fwjMB3MHiM3YYDdaR5sjpB9yNnp9859otv/cX4dGRDSm7MXJ2kAIvuDk8kZWHGolGD+Gj8ve0zSpVQnhGEiTvPGl5kiAfgtbGLA== X-Forefront-Antispam-Report: CIP:12.22.5.238;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(8676002)(81166007)(356005)(5660300002)(8936002)(4326008)(70206006)(2906002)(40460700003)(36756003)(70586007)(508600001)(7696005)(83380400001)(6666004)(6916009)(316002)(47076005)(36860700001)(54906003)(26005)(186003)(336012)(2616005)(16526019)(426003)(1076003)(107886003)(82310400004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2022 09:30:51.5010 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: be134ae1-fae6-4917-1fa7-08d9f12f0603 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.238];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT015.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1403 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Follow the pattern what we have in bio_alloc() to set the structure members in the structure allocation function in alloc_cmd() and pass bio to initialize newly allocated cmd->bio member. Follow the pattern in copy_to_nullb() to use result of one function call (null_cache_active()) to be used as a parameter to another function call (null_insert_page()), use result of alloc_cmd() as a first parameter to the null_handle_cmd() in null_submit_bio() function. This allow us to remove the local variable cmd on stack in null_submit_bio() that is in fast path. Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk/main.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index d78fc3edb22e..e19340f686a8 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -719,7 +719,7 @@ static struct nullb_cmd *__alloc_cmd(struct nullb_queue *nq) return NULL; } -static struct nullb_cmd *alloc_cmd(struct nullb_queue *nq) +static struct nullb_cmd *alloc_cmd(struct nullb_queue *nq, struct bio *bio) { struct nullb_cmd *cmd; DEFINE_WAIT(wait); @@ -730,8 +730,10 @@ static struct nullb_cmd *alloc_cmd(struct nullb_queue *nq) * __alloc_cmd() and a fast path call to prepare_to_wait(). */ cmd = __alloc_cmd(nq); - if (cmd) + if (cmd) { + cmd->bio = bio; return cmd; + } prepare_to_wait(&nq->wait, &wait, TASK_UNINTERRUPTIBLE); io_schedule(); finish_wait(&nq->wait, &wait); @@ -1473,12 +1475,8 @@ static void null_submit_bio(struct bio *bio) sector_t nr_sectors = bio_sectors(bio); struct nullb *nullb = bio->bi_bdev->bd_disk->private_data; struct nullb_queue *nq = nullb_to_queue(nullb); - struct nullb_cmd *cmd; - - cmd = alloc_cmd(nq); - cmd->bio = bio; - null_handle_cmd(cmd, sector, nr_sectors, bio_op(bio)); + null_handle_cmd(alloc_cmd(nq, bio), sector, nr_sectors, bio_op(bio)); } static bool should_timeout_request(struct request *rq)