From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B656CA9EAF for ; Thu, 24 Oct 2019 16:02:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 13ED621872 for ; Thu, 24 Oct 2019 16:02:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571932979; bh=cxz8+k2D7UrOm8kMp6GMoDjjc8TnljYRXSJ9UNnCC1E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=tuSG31ZiqUc+kr8d5xOzHyeRgy9UZJh3FwBAw0wIgXvI1qsp+dAOtJ9lJUZmd4I1p OSJmJhS2b58wh4zaXJxaZOeIkpH28D5+qrAzv3sEnp8zWWuXqiyBdUDqVvLuHClAlO x44TzVGnMegFxVNW7g2Ag4Z0ZYBViezRdR4NLb1Q= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392660AbfJXQC6 (ORCPT ); Thu, 24 Oct 2019 12:02:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:49024 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389313AbfJXQC6 (ORCPT ); Thu, 24 Oct 2019 12:02:58 -0400 Received: from localhost (unknown [77.137.89.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E5DC22064A; Thu, 24 Oct 2019 16:02:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571932977; bh=cxz8+k2D7UrOm8kMp6GMoDjjc8TnljYRXSJ9UNnCC1E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fezX2o6l2AqDsYphJzTbfPa1PI7xP3THMqpNWnLe1hc3b07dFJhcWQbdCMKmh7JPK t4ZV44epOpLNkxoiZw/YpCs6PuTDaGLbj3O2mInuXADN8iFeldCGXZNDVmQl4rQqd7 6TK+/YzcsXlZsA9VwN+br+FHFpUABy/nybUO5xhA= Date: Thu, 24 Oct 2019 19:02:52 +0300 From: Leon Romanovsky To: Jason Gunthorpe Cc: Doug Ledford , Parav Pandit , RDMA mailing list Subject: Re: [PATCH rdma-next] IB/core: Avoid deadlock during netlink message handling Message-ID: <20191024160252.GS4853@unreal> References: <20191015080733.18625-1-leon@kernel.org> <20191024131743.GA24174@ziepe.ca> <20191024132607.GR4853@unreal> <20191024135017.GT23952@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191024135017.GT23952@ziepe.ca> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org On Thu, Oct 24, 2019 at 10:50:17AM -0300, Jason Gunthorpe wrote: > On Thu, Oct 24, 2019 at 04:26:07PM +0300, Leon Romanovsky wrote: > > On Thu, Oct 24, 2019 at 10:17:43AM -0300, Jason Gunthorpe wrote: > > > On Tue, Oct 15, 2019 at 11:07:33AM +0300, Leon Romanovsky wrote: > > > > > > > diff --git a/drivers/infiniband/core/netlink.c b/drivers/infiniband/core/netlink.c > > > > index 81dbd5f41bed..a3507b8be569 100644 > > > > +++ b/drivers/infiniband/core/netlink.c > > > > @@ -42,9 +42,12 @@ > > > > #include > > > > #include "core_priv.h" > > > > > > > > -static DEFINE_MUTEX(rdma_nl_mutex); > > > > static struct { > > > > - const struct rdma_nl_cbs *cb_table; > > > > + const struct rdma_nl_cbs __rcu *cb_table; > > > > + /* Synchronizes between ongoing netlink commands and netlink client > > > > + * unregistration. > > > > + */ > > > > + struct srcu_struct unreg_srcu; > > > > > > A srcu in every index is serious overkill for this. Lets just us a > > > rwsem: > > > > I liked previous variant more than rwsem, but it is Parav's patch. > > Why? srcu is a huge data structure and slow on unregister The unregister time is not so important for those IB/core modules. I liked SRCU because it doesn't have *_ONCE() macros and smb_* calls. Maybe wrong here, but the extra advantage of SRCU is that we are already using that mechanism in uverbs and my assumption that SRCU will greatly enjoy shared grace period. Thanks > > Jason