Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2927259pxk; Sun, 6 Sep 2020 19:59:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEx+4eNFTtYRaQVwy3vrnoHG029AGfGIclHreDHKnfI+nkNQrteJdx8ZZDfsxZFUXqN0C+ X-Received: by 2002:aa7:d4d2:: with SMTP id t18mr19463193edr.55.1599447575476; Sun, 06 Sep 2020 19:59:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599447575; cv=none; d=google.com; s=arc-20160816; b=WahEXkmMUHQSD3JEG8xYK9TMpOzPc+ae9cjgudj4i2h048zlGLaUMe9j5Fwq1WDUSF T//E5lMgZqJWxqo7ItWooQEwVZRaSI3dN+R83EF6E6UbCy/khwnmnnwad9GDDStBtKpF c1cV4Sq9fh2KX2oFXCtWr/aXh2hx5SLwRnUB6a6u5o28gx/g6kEmDkOznazBvEdzALfV PM5xK/DVYGU9gEr3C9E5qZa7S5IeJ5k0VgJAmRJD7nkTr9moDdgEUQQ9/8ZqdlOz1jaS HhwPzNXYMXpf6yOicbnGfkWGT6YfjYpupNfKJNqtaAAZix3hunQzw0G650Slz5qJY5w1 LWsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:from:references:cc:to:subject; bh=V8cA7enjbh48/8eRE2MElq9oDfjEE+NkHjPLBOpS/KQ=; b=bnDzJwPgdCavNTdosyJzu937Oj716vOwT8kk+GzMuScOLbQE6suV75wCT7E82xYaZg 9me2puvmAwdsOYyOcHARSIRaq+yXNKO+gsGmtr6X1KZCtnez/ZmTLsU6znnmegRVwhT/ gUmplc/43pP5/zxcL6XYF9qsY3OurinkLzBRHlImd+cGcrErt/YfOHcQkeVpcoFUxGrA +aOrJ0myvr3UyN7oAgOHmH1ZuBT1A3SNbbG0Ovb7Am10u23vExBqZbnCCNMoHP/X6gQh ESeg2CvGpvXoz0RyWnpROPpoIFUSUTt9P1zOsnvlHuju0DT5lR+WLBh2GUgf7qubCb2m WaGA== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v3si8589465edt.45.2020.09.06.19.59.12; Sun, 06 Sep 2020 19:59:35 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726362AbgIGC6R (ORCPT + 99 others); Sun, 6 Sep 2020 22:58:17 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:33121 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726259AbgIGC6Q (ORCPT ); Sun, 6 Sep 2020 22:58:16 -0400 Received: by mail-pl1-f195.google.com with SMTP id d19so382116pld.0; Sun, 06 Sep 2020 19:58:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=V8cA7enjbh48/8eRE2MElq9oDfjEE+NkHjPLBOpS/KQ=; b=fg0cGWEiECu6rDQGSAuj8VMZlhTfjngG89XnWTG5AFKRaHzkT6Docn7+OUAjX63D5X UxI21wrjfPMBeK4BQKpLdwI4j5fxqODwLex97S1SM6Jb3foTU+zudzK7x8r95nWHeHwV sYjabza7o+Pmb5UTNQ7LGHIEIx1kj9ZLHGcVZpFK5NmwXrHOjTybtM9SSmYHo3Fzwdx9 L0vxl+FS0BWF7nuQ0sHsIa+4liArsm+veNybkla0Wu9r4Q+GX0b65WaP+AS4UKmDbJJD JoJZnaUNdKmQoCyX76ldD2EstoIjuzLi7DweaYQELIrQJsr8pROWFlaTwL+qKRdSCVRn UuDg== X-Gm-Message-State: AOAM530o6UmDPlxzmGKCPQhGVlijIoKgjuk3D4YDOgMEvUi/re57Oz6a 01du6L6SEZEcAJvIeupo4sM= X-Received: by 2002:a17:902:9347:: with SMTP id g7mr18105601plp.200.1599447494672; Sun, 06 Sep 2020 19:58:14 -0700 (PDT) Received: from ?IPv6:2601:647:4000:d7:30fd:ff3e:1f2d:1c1c? ([2601:647:4000:d7:30fd:ff3e:1f2d:1c1c]) by smtp.gmail.com with ESMTPSA id j14sm9790820pgf.76.2020.09.06.19.58.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 06 Sep 2020 19:58:13 -0700 (PDT) Subject: Re: [IB/srpt] c804af2c1d: last_state.test.blktests.exit_code.143 To: Jason Gunthorpe Cc: Sagi Grimberg , Yamin Friedman , kernel test robot , Max Gurtovoy , LKML , Doug Ledford , Jason Gunthorpe , linux-rdma@vger.kernel.org, lkp@lists.01.org References: <20200802060925.GW23458@shao2-debian> <0c42aeb4-23a5-b9d5-bc17-ef58a04db8e8@grimberg.me> <128192ad-05ff-fa8e-14fc-479a115311e0@acm.org> <20200824133019.GH1152540@nvidia.com> From: Bart Van Assche Autocrypt: addr=bvanassche@acm.org; prefer-encrypt=mutual; keydata= mQENBFSOu4oBCADcRWxVUvkkvRmmwTwIjIJvZOu6wNm+dz5AF4z0FHW2KNZL3oheO3P8UZWr LQOrCfRcK8e/sIs2Y2D3Lg/SL7qqbMehGEYcJptu6mKkywBfoYbtBkVoJ/jQsi2H0vBiiCOy fmxMHIPcYxaJdXxrOG2UO4B60Y/BzE6OrPDT44w4cZA9DH5xialliWU447Bts8TJ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0RQDYdwp6/kMEXMdmT oH0F0xB3SQ8WVSXA9rrc4EBvZruWQ+5/zjVrhhfUAx12CzL4oQ9Ro2k45daYaonKTANYG22y //x8dLe2Fv1By4SKGhmzwH87uXxbTJAUxiWIi1np0z3/RDnoVyfmfbbL1DY7zf2hYXLLzsJR mSsED/1nlJ9Oq5fALdNEPgDyPUerqHxcmIub+pF0AzJoYHK5punqpqfGmqPbjxrJLPJfHVKy goMj5DlBMoYqEgpbwdUYkH6QdizJJCur4icy8GUNbisFYABeoJ91pnD4IGei3MTdvINSZI5e Message-ID: <2a2ff3a5-f58e-8246-fd09-87029b562347@acm.org> Date: Sun, 6 Sep 2020 19:58:12 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20200824133019.GH1152540@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-08-24 06:30, Jason Gunthorpe wrote: > On Sun, Aug 23, 2020 at 02:18:41PM -0700, Bart Van Assche wrote:> >> The patch below is sufficient to unbreak blktests. I think that the >> deadlock while unloading rdma_rxe happens because the RDMA core waits for >> all ib_dev references to be dropped before dealloc_driver is called. > > Which is required, yes > >> The rdma_rxe dealloc_driver implementation drops an ib_dev >> reference. > > Where does it do that? I didn't notice it? That last statement was wrong. Anyway, with the following debugging patch applied: diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index c36b4d2b61e0..b976dd30f727 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -332,6 +332,8 @@ struct ib_device *ib_device_get_by_index(const struct net *net, u32 index) */ void ib_device_put(struct ib_device *device) { + WARN(device->warn_on_refcount_drop, "%s refcnt = %d\n", + dev_name(&device->dev), refcount_read(&device->refcount)); if (refcount_dec_and_test(&device->refcount)) complete(&device->unreg_completion); } @@ -1287,7 +1289,10 @@ static void disable_device(struct ib_device *device) /* Pairs with refcount_set in enable_device */ ib_device_put(device); + device->warn_on_refcount_drop = true; +#if 0 wait_for_completion(&device->unreg_completion); +#endif /* * compat devices must be removed after device refcount drops to zero. diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index c868609a4ffa..2d050e3ee55a 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -2704,6 +2704,7 @@ struct ib_device { * registered and cannot be unregistered. */ refcount_t refcount; + bool warn_on_refcount_drop; struct completion unreg_completion; struct work_struct unregistration_work; The following appeared: WARNING: CPU: 5 PID: 1760 at drivers/infiniband/core/device.c:335 ib_device_put+0xf2/0x100 [ib_core] Call Trace: rxe_elem_release+0x76/0x90 [rdma_rxe] rxe_destroy_cq+0x4f/0x70 [rdma_rxe] ib_free_cq_user+0x12b/0x2b0 [ib_core] ib_cq_pool_destroy+0xa8/0x140 [ib_core] __ib_unregister_device+0x9c/0x1c0 [ib_core] ib_unregister_driver+0x181/0x1a0 [ib_core] rxe_module_exit+0x31/0x50 [rdma_rxe] __x64_sys_delete_module+0x22a/0x310 do_syscall_64+0x36/0x80 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Do you agree that the above proves that the hang-on-unload is a regression that has been introduced by the cq-pool patches? Is the patch below a good way to fix this? --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -1454,8 +1454,8 @@ static void __ib_unregister_device(struct ib_device *ib_dev) if (!refcount_read(&ib_dev->refcount)) goto out; - disable_device(ib_dev); ib_cq_pool_destroy(ib_dev); + disable_device(ib_dev); /* Expedite removing unregistered pointers from the hash table */ free_netdevs(ib_dev); Thanks, Bart.