Received: by 10.192.165.148 with SMTP id m20csp4049531imm; Tue, 8 May 2018 01:56:32 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp6UBV78US7d4u7ZfYLJn2+soxQcKYSH1hwLsa3F6f+AVLGHng6Njam5DzIAoHSG2eBLKt/ X-Received: by 10.98.233.3 with SMTP id j3mr7106668pfh.196.1525769792427; Tue, 08 May 2018 01:56:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525769792; cv=none; d=google.com; s=arc-20160816; b=WcssQoZ15CdCi9KkmIe8l9x8qazE7P9GRi8IjcRl0GCUFoRuj0JErUVy2oM58zOrh3 +0NQ3zUQu/ksznWPBin4h/nJqBpuYk92jKm4y5aPvxdF0JLC4AvQ4MI59ftfo7RMgAHI bk0hqI13nBrLAPmnbIfLpN4ig2m8CJug7P3zJqFtgkbevQTepcWDGm9nxIMh2LyQjw0l tVRY8ksonJnU1Qmf04xqVV6OZBlE8QVYgUms0ZCD6xPJ3Y6gctQLDUska03h5clYWGEl bCIGa8r9p0OjziRbau98H/+iw2wBjkUNnIDvvOlNS16ra+Jm4AxmVbWeRwvZbo6qAzSG yGuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=eAkTyPIRKbezdSEF5DpHkDqh1UXF16HrVnhEry0x/6I=; b=eV0k7nJKabaDvt0Tb/KmWiHja3xvXupOOZHn5+OLmVH0oer+mF/uczfU61V5KGfVcB 6DbpM6bQsldhK/TZ8QVcxX2tXhq3xgvHSxsVLH0pXrwbCz0R53Q/Gk4tAwG4Rx1BnH9d Q8lEEs6KoZZm7raNurG75tBI04el3iUD5YIowwRYa9Kcrv0hvuj4V07zp2Tt9ABYKepS Wv8l+INhOJANvItxF2ZaWOeB4BCjH/EJyuhTyf6SCrYAlr/fU4MAWI9k2Cik5TVtPIdR Lz3y3oXHq4ekKVXs7A7EWUaXbQx6M6jQ7Wfg/9WJ1KtZ2KEW09GbL07Al/FLw5y/waBg VlTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jgei4pA9; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d20-v6si24796863plr.206.2018.05.08.01.56.18; Tue, 08 May 2018 01:56:32 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jgei4pA9; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933519AbeEHIzf (ORCPT + 99 others); Tue, 8 May 2018 04:55:35 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:52731 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932299AbeEHIza (ORCPT ); Tue, 8 May 2018 04:55:30 -0400 Received: by mail-wm0-f54.google.com with SMTP id w194so17420743wmf.2; Tue, 08 May 2018 01:55:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=eAkTyPIRKbezdSEF5DpHkDqh1UXF16HrVnhEry0x/6I=; b=jgei4pA9BVJ3fB36EqJfS4TE+8/h20KDwI7aWIVPDHHasH0jU4IzbPTTrvnBVa9aVg 5t6oz8/c8lWFWAJQRWOwdM+jAJqnciD08Yvc6UfbhBCOUIff8I+iO/i3ZQnVKUTlpsoT 3YgBc6oFXRwVN6YiS9CKwvG6O5wrKeaG0D3GzQSmTOUN1R0u1GKoa7wsspvhGFaAc5EB /T1dxq++u+R+5ntbyJyWnG0M4xPIXyenBw6vYYITlW59uwhr3FTINLyE+1b2ImQyaOq3 lXSuJjQg9kFY7XLg5Iagh+JRY9/YXcAI8zem/v75jNcjm8ta3OeE27i7HDdD2N9LTY1p F1tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=eAkTyPIRKbezdSEF5DpHkDqh1UXF16HrVnhEry0x/6I=; b=WQzH93DH/UQU3qK43JxAzs1BBI74s7aGPYkGQiXLYqgbV74oXgQNb7MeHk1wrSz9jd eujHRqsKdOnJNBQP150vSsg0g8yhD7UKcmYL0NwvKpN1gCZO9wo2XyzJlijHqNbrqbZG mkYd6QcJEG10XRH6btFIexd3LEgEoPRk4P6bLw0MkqHemEL5FxK89xrGxQ/J42WQGXdw TInJwcAyOHDaWRe6XOH3EVvgOyaA11UkjmqiSzioORbAMW1oPKW7L8pdCh2/RtCYV0eD U34wBjKqAgEs3YZEBK20eWixDlt6o8rqKoogh1RR0cUSBf5KhyJkgJoZ8CCqBkQrKi/i ilIA== X-Gm-Message-State: ALKqPwevi4sNVLs1XpJwcJLMgTK2VLS5iGM8pankJgedT6Iiejm+h/Lg v6ZjoFWAjor+xte0jid7Whc= X-Received: by 10.28.74.13 with SMTP id x13mr2617292wma.150.1525769728368; Tue, 08 May 2018 01:55:28 -0700 (PDT) Received: from gmail.com (51B6778B.dsl.pool.telekom.hu. [81.182.119.139]) by smtp.gmail.com with ESMTPSA id 132-v6sm13321754wmp.15.2018.05.08.01.55.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 May 2018 01:55:27 -0700 (PDT) Date: Tue, 8 May 2018 10:55:14 +0200 From: Alexandru Moise <00moses.alexander00@gmail.com> To: Yanjun Zhu Cc: monis@mellanox.com, dledford@redhat.com, jgg@ziepe.ca, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] nvmet,rxe: defer ip datagram sending to tasklet Message-ID: <20180508085436.GA1201@gmail.com> References: <20180507205858.GA11664@gmail.com> <562873bf-075c-f148-c528-dddf188113c2@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <562873bf-075c-f148-c528-dddf188113c2@oracle.com> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 08, 2018 at 11:09:18AM +0800, Yanjun Zhu wrote: > > > On 2018/5/8 4:58, Alexandru Moise wrote: > > This addresses 3 separate problems: > > > > 1. When using NVME over Fabrics we may end up sending IP > > packets in interrupt context, we should defer this work > > to a tasklet. > > > > [ 50.939957] WARNING: CPU: 3 PID: 0 at kernel/softirq.c:161 __local_bh_enable_ip+0x1f/0xa0 > > [ 50.942602] CPU: 3 PID: 0 Comm: swapper/3 Kdump: loaded Tainted: G W 4.17.0-rc3-ARCH+ #104 > > [ 50.945466] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-20171110_100015-anatol 04/01/2014 > > [ 50.948163] RIP: 0010:__local_bh_enable_ip+0x1f/0xa0 > > [ 50.949631] RSP: 0018:ffff88009c183900 EFLAGS: 00010006 > > [ 50.951029] RAX: 0000000080010403 RBX: 0000000000000200 RCX: 0000000000000001 > > [ 50.952636] RDX: 0000000000000000 RSI: 0000000000000200 RDI: ffffffff817e04ec > > [ 50.954278] RBP: ffff88009c183910 R08: 0000000000000001 R09: 0000000000000614 > > [ 50.956000] R10: ffffea00021d5500 R11: 0000000000000001 R12: ffffffff817e04ec > > [ 50.957779] R13: 0000000000000000 R14: ffff88009566f400 R15: ffff8800956c7000 > > [ 50.959402] FS: 0000000000000000(0000) GS:ffff88009c180000(0000) knlGS:0000000000000000 > > [ 50.961552] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > > [ 50.963798] CR2: 000055c4ec0ccac0 CR3: 0000000002209001 CR4: 00000000000606e0 > > [ 50.966121] Call Trace: > > [ 50.966845] > > [ 50.967497] __dev_queue_xmit+0x62d/0x690 > > [ 50.968722] dev_queue_xmit+0x10/0x20 > > [ 50.969894] neigh_resolve_output+0x173/0x190 > > [ 50.971244] ip_finish_output2+0x2b8/0x370 > > [ 50.972527] ip_finish_output+0x1d2/0x220 > > [ 50.973785] ? ip_finish_output+0x1d2/0x220 > > [ 50.975010] ip_output+0xd4/0x100 > > [ 50.975903] ip_local_out+0x3b/0x50 > > [ 50.976823] rxe_send+0x74/0x120 > > [ 50.977702] rxe_requester+0xe3b/0x10b0 > > [ 50.978881] ? ip_local_deliver_finish+0xd1/0xe0 > > [ 50.980260] rxe_do_task+0x85/0x100 > > [ 50.981386] rxe_run_task+0x2f/0x40 > > [ 50.982470] rxe_post_send+0x51a/0x550 > > [ 50.983591] nvmet_rdma_queue_response+0x10a/0x170 > > [ 50.985024] __nvmet_req_complete+0x95/0xa0 > > [ 50.986287] nvmet_req_complete+0x15/0x60 > > [ 50.987469] nvmet_bio_done+0x2d/0x40 > > [ 50.988564] bio_endio+0x12c/0x140 > > [ 50.989654] blk_update_request+0x185/0x2a0 > > [ 50.990947] blk_mq_end_request+0x1e/0x80 > > [ 50.991997] nvme_complete_rq+0x1cc/0x1e0 > > [ 50.993171] nvme_pci_complete_rq+0x117/0x120 > > [ 50.994355] __blk_mq_complete_request+0x15e/0x180 > > [ 50.995988] blk_mq_complete_request+0x6f/0xa0 > > [ 50.997304] nvme_process_cq+0xe0/0x1b0 > > [ 50.998494] nvme_irq+0x28/0x50 > > [ 50.999572] __handle_irq_event_percpu+0xa2/0x1c0 > > [ 51.000986] handle_irq_event_percpu+0x32/0x80 > > [ 51.002356] handle_irq_event+0x3c/0x60 > > [ 51.003463] handle_edge_irq+0x1c9/0x200 > > [ 51.004473] handle_irq+0x23/0x30 > > [ 51.005363] do_IRQ+0x46/0xd0 > > [ 51.006182] common_interrupt+0xf/0xf > > [ 51.007129] > > > > 2. Work must always be offloaded to tasklet when using NVMEoF in order to > > solve lock ordering between neigh->ha_lock seqlock and the nvme queue lock: > > > > [ 77.833783] Possible interrupt unsafe locking scenario: > > [ 77.833783] > > [ 77.835831] CPU0 CPU1 > > [ 77.837129] ---- ---- > > [ 77.838313] lock(&(&n->ha_lock)->seqcount); > > [ 77.839550] local_irq_disable(); > > [ 77.841377] lock(&(&nvmeq->q_lock)->rlock); > > [ 77.843222] lock(&(&n->ha_lock)->seqcount); > > [ 77.845178] > > [ 77.846298] lock(&(&nvmeq->q_lock)->rlock); > > [ 77.847986] > > [ 77.847986] *** DEADLOCK *** > > > > 3. Same goes for the lock ordering between sch->q.lock and nvme queue lock: > > > > [ 47.634271] Possible interrupt unsafe locking scenario: > > [ 47.634271] > > [ 47.636452] CPU0 CPU1 > > [ 47.637861] ---- ---- > > [ 47.639285] lock(&(&sch->q.lock)->rlock); > > [ 47.640654] local_irq_disable(); > > [ 47.642451] lock(&(&nvmeq->q_lock)->rlock); > > [ 47.644521] lock(&(&sch->q.lock)->rlock); > > [ 47.646480] > > [ 47.647263] lock(&(&nvmeq->q_lock)->rlock); > > [ 47.648492] > > [ 47.648492] *** DEADLOCK *** > > > > Using NVMEoF after this patch seems to finally be stable, without it, > > rxe eventually deadlocks the whole system and causes RCU stalls. > > > > Signed-off-by: Alexandru Moise <00moses.alexander00@gmail.com> > > --- > > v2->v3: Abandoned the idea of just offloading work to tasklet in irq > > context. NVMEoF needs the work to always be offloaded in order to > > function. I am unsure how large an impact this has on other rxe users. > > > > drivers/infiniband/sw/rxe/rxe_verbs.c | 12 ++---------- > > 1 file changed, 2 insertions(+), 10 deletions(-) > > > > diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c > > index 2cb52fd48cf1..564453060c54 100644 > > --- a/drivers/infiniband/sw/rxe/rxe_verbs.c > > +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c > > @@ -761,7 +761,6 @@ static int rxe_post_send_kernel(struct rxe_qp *qp, struct ib_send_wr *wr, > > unsigned int mask; > > unsigned int length = 0; > > int i; > > - int must_sched; > > while (wr) { > > mask = wr_opcode_mask(wr->opcode, qp); > > @@ -791,14 +790,7 @@ static int rxe_post_send_kernel(struct rxe_qp *qp, struct ib_send_wr *wr, > > wr = wr->next; > > } > > - /* > > - * Must sched in case of GSI QP because ib_send_mad() hold irq lock, > > - * and the requester call ip_local_out_sk() that takes spin_lock_bh. > > - */ > > - must_sched = (qp_type(qp) == IB_QPT_GSI) || > > - (queue_count(qp->sq.queue) > 1); > > - > > - rxe_run_task(&qp->req.task, must_sched); > > + rxe_run_task(&qp->req.task, 1); > > if (unlikely(qp->req.state == QP_STATE_ERROR)) > > rxe_run_task(&qp->comp.task, 1); > > @@ -822,7 +814,7 @@ static int rxe_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, > > if (qp->is_user) { > > /* Utilize process context to do protocol processing */ > > - rxe_run_task(&qp->req.task, 0); > > + rxe_run_task(&qp->req.task, 1); > Hi, > > From your description, it seems that all the problems are caused by NVME > kernel. > > Am I correct? > > It seems that this block handles process context. If we keep > "rxe_run_task(&qp->req.task, 0);", > > Do all the problems still occur? You are right, it seems that only rxe_post_send_kernel() needs to be patched. If I keep "rxe_run_task(&qp->req.task, 0);" in rxe_post_send() I can't get rxe to hang. Will send a v4 with just rxe_post_send_kernel() patched. Thanks, ../Alex > > Zhu Yanjun > > > > return 0; > > } else > > return rxe_post_send_kernel(qp, wr, bad_wr); >