Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp243545imm; Tue, 15 May 2018 00:41:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr1tQsOHx/Q4epWH+mJmpi5PVwMt/qRFKvFVj7MgaQ1fpNNcRX/wxOEnJ9ZB3+Linko41SJ X-Received: by 2002:a63:3347:: with SMTP id z68-v6mr10992341pgz.171.1526370084439; Tue, 15 May 2018 00:41:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526370084; cv=none; d=google.com; s=arc-20160816; b=TVeFBZ+0yr+8/5yuhfr5w+57vvQ0Y5M7/fPQIxnLS9aSrtZdXMkJjRgBdks5WyaZbG jy4OfTBZE2FekhDtKVGhjCdR8NrXnIpbCFhijr8t67rEj5zAcDdJrmUwVlKRjFMx/o4m bAp40d0y7G8QXQNvf2NPSuWl5qChtZB+ErMXTUkhxm80KcqDxW7C6btuJgwF8heLSM9V fOy+z8tB06Bko7j8W5DHMR2hlonm8JFZzLTFuZrFf2jjaIpQICL4gOT31XI8cCyBnAlp gmLeRtMhcmAjV7QXX8z6+z3gHOb9ZGf/KXVqMt8m7nLMwrrUqbqDs1JhdJpM2ZdBh3RF 6JTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=/j/vRUTRZQJXVVm/XZgBFs2UlsBSVt+g7GpD2pvFyzw=; b=jiojNuz4IQsyolCpdPoQSaJf+eCK6iUCpM5Ru8mBsdGHVE5pcRc2FvxlR/Ytbq5/M9 TmlYnW2Rr89QjlCn8zuOwKJtkrI74uoe59/K7/JxGB2/LUKQKjTHRL851iFtXT3Re38a dERPNHJdrn0SP+XPRbnHnevFd03aOJBXJTJnZ4PA6kD7Inguy4cahafPwONt8onNmxWQ u/Nm21xqShkeFz18cttVRmlv6mWQ8o9Of5DHf8QzFL/IHI6FzbgaBTr2VaThIp4uSXfN M+HbJ8Fq62lqlm5bfMtvZt/AsXvgXT2macjX/0CbL6qD8UUcZjX3RXPlcN/hg2N0NSd5 iNWA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 69-v6si11293971pfv.135.2018.05.15.00.41.10; Tue, 15 May 2018 00:41:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752317AbeEOHkz (ORCPT + 99 others); Tue, 15 May 2018 03:40:55 -0400 Received: from mx2.suse.de ([195.135.220.15]:42986 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752196AbeEOHkw (ORCPT ); Tue, 15 May 2018 03:40:52 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 88DECAF0B; Tue, 15 May 2018 07:40:50 +0000 (UTC) From: Johannes Thumshirn To: Keith Busch Cc: Sagi Grimberg , Christoph Hellwig , Linux NVMe Mailinglist , Linux Kernel Mailinglist , Hannes Reinecke , Johannes Thumshirn Subject: [PATCH 4/5] nvmet: use atomic allocations when allocating fc requests Date: Tue, 15 May 2018 09:40:42 +0200 Message-Id: <20180515074043.22843-5-jthumshirn@suse.de> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180515074043.22843-1-jthumshirn@suse.de> References: <20180515074043.22843-1-jthumshirn@suse.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org fcloop_fcp_req() runs with the hctx_lock (a rcu_read_lock() locked section) held, so memory allocations done in this context have to be atomic. This fixes the follwing lockdep complaint: [ 9.753313] BUG: sleeping function called from invalid context at mm/slab.h:421 [ 9.754518] in_atomic(): 1, irqs_disabled(): 0, pid: 1420, name: nvme [ 9.755613] 3 locks held by nvme/1420: [ 9.756221] #0: (ptrval) (nvmf_dev_mutex){+.+.}, at: nvmf_dev_write+0x6a/0xb7d [nvme_fabrics] [ 9.757575] #1: (ptrval) (nvmf_transports_rwsem){++++}, at: nvmf_dev_write+0x6e5/0xb7d [nvme_fabrics] [ 9.759000] #2: (ptrval) (rcu_read_lock){....}, at: hctx_lock+0x56/0xd0 [ 9.760141] CPU: 2 PID: 1420 Comm: nvme Not tainted 4.17.0-rc5+ #883 [ 9.761078] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014 [ 9.762624] Call Trace: [ 9.763021] dump_stack+0x78/0xb3 [ 9.763505] ___might_sleep+0x227/0x250 [ 9.764115] kmem_cache_alloc_trace+0x1ae/0x270 [ 9.764793] fcloop_fcp_req+0x32/0x1a0 [nvme_fcloop] [ 9.765561] nvme_fc_start_fcp_op.part.39+0x193/0x4c0 [nvme_fc] [ 9.766480] blk_mq_dispatch_rq_list+0x7f/0x4a0 [ 9.767163] ? blk_mq_flush_busy_ctxs+0xa8/0xf0 [ 9.767871] blk_mq_sched_dispatch_requests+0x16e/0x170 [ 9.768644] __blk_mq_run_hw_queue+0x79/0xd0 [ 9.769294] __blk_mq_delay_run_hw_queue+0x11c/0x160 [ 9.770012] blk_mq_run_hw_queue+0x63/0xc0 [ 9.770667] blk_mq_sched_insert_request+0xb2/0x140 [ 9.771399] blk_execute_rq+0x64/0xc0 [ 9.771990] __nvme_submit_sync_cmd+0x63/0xd0 [nvme_core] [ 9.772765] nvmf_connect_admin_queue+0x11e/0x190 [nvme_fabrics] [ 9.773659] ? mark_held_locks+0x6b/0x90 [ 9.774798] nvme_fc_create_association+0x35b/0x970 [nvme_fc] [ 9.775631] nvme_fc_create_ctrl+0x5d2/0x830 [nvme_fc] [ 9.776423] nvmf_dev_write+0x92d/0xb7d [nvme_fabrics] [ 9.777188] __vfs_write+0x21/0x130 [ 9.777725] ? selinux_file_permission+0xe9/0x140 [ 9.778417] ? security_file_permission+0x2f/0xb0 [ 9.779158] vfs_write+0xbd/0x1c0 [ 9.779644] ksys_write+0x40/0xa0 [ 9.780184] ? do_syscall_64+0xd/0x190 [ 9.780736] do_syscall_64+0x51/0x190 [ 9.781281] entry_SYSCALL_64_after_hwframe+0x49/0xbe Signed-off-by: Johannes Thumshirn --- drivers/nvme/target/fcloop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvme/target/fcloop.c b/drivers/nvme/target/fcloop.c index 34712def81b1..d2209c60f95f 100644 --- a/drivers/nvme/target/fcloop.c +++ b/drivers/nvme/target/fcloop.c @@ -509,7 +509,7 @@ fcloop_fcp_req(struct nvme_fc_local_port *localport, if (!rport->targetport) return -ECONNREFUSED; - tfcp_req = kzalloc(sizeof(*tfcp_req), GFP_KERNEL); + tfcp_req = kzalloc(sizeof(*tfcp_req), GFP_ATOMIC); if (!tfcp_req) return -ENOMEM; -- 2.16.3