Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp10663rdb; Fri, 5 Jan 2024 00:30:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IGH/gmnOzFrJmh7s5kZeEZjXc2KJH2mYJ4bxFteHKTK5VslZ0hyuEEJuc/1X3Oqe/B0MRNA X-Received: by 2002:a05:620a:8413:b0:781:6cf1:a70c with SMTP id pc19-20020a05620a841300b007816cf1a70cmr1767498qkn.106.1704443453426; Fri, 05 Jan 2024 00:30:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704443453; cv=none; d=google.com; s=arc-20160816; b=FMItYe0LD38Ab77RIZ866Y1vsFQTnR/GO/7sjJj5ZEDUmSbTzukmEtPdUPq2Q3c8IT xlwNa5mRPjnqnmQdhhb3/op3wM1jgwIOppoF0X6EMDRj+TUUvL+VGcC26Chu+HZA50Tj D+xkzLwk45+BeKS4spRAPuEJvJ5JtzBHXKp/ZaGVUq4KLKwW3fLM6rNeyn7VO2G04io7 K5LAIzX59GSt6c6E7wv08dp+Er1PBzr8v3BngMxDHb4FuZPqPxsc1lNHJ5t09FJb7JYP xWGLk/V8MYDPDW0D8s+VHgQgcAixRHJkMmAtu3q1rJPVjRoS2TMMCu4l/C7Vd8kfCpIi Uw8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id; bh=3DH+FsZ5Z+Gy/1I3QGgfbCb9H132p94XEqVgHTVKFBU=; fh=IefUlS7O0yyV5bQK/bWmVVomxoaCE31Zx6W8oCzXIW4=; b=FXtTo4ewUtaDvgVq+GiYKFsFbutNqtiBwb4FcnbDj+L4v+hsQVhuRzSsXojgSF3Sso sWBdXydsAVpvXpNAbjx3fF143nZQALJVCgPaabswhA5LiAZE8RYE+j0qxzGYjl6/Olg2 13WxTHwfJxwnBSt0nCxLO8S+u51CCff4lrwC9cSrPcMawt3eWfLrtxB2neT9/idy+7AW fK5vDVOATp+rRwiLI+NAlvEoQE9NWR9IlNFVnlV3SCb59zObGpkM5iElKsdnP71bIynt ISogl+bUiBD2zF5ZFfVckZd2xKV6RHqrMTmbm99fxvU53414kbY8f+v1R/r8Je8moE/W TJLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-17599-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17599-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sangfor.com.cn Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u9-20020a05620a430900b00781b2d54711si1303076qko.452.2024.01.05.00.30.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:30:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17599-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-17599-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17599-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sangfor.com.cn Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2C3E61C21A21 for ; Fri, 5 Jan 2024 08:30:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A7D96219FF; Fri, 5 Jan 2024 08:25:59 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from mail-m127150.qiye.163.com (mail-m127150.qiye.163.com [115.236.127.150]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4D042420E; Fri, 5 Jan 2024 08:25:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sangfor.com.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sangfor.com.cn Received: from [172.23.69.7] (unknown [121.32.254.147]) by mail-m12750.qiye.163.com (Hmail) with ESMTPA id 594FEF20615; Fri, 5 Jan 2024 16:15:19 +0800 (CST) Message-ID: <62db1a02-41b8-44b0-960b-6d6f5bec5d19@sangfor.com.cn> Date: Fri, 5 Jan 2024 16:15:18 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] RDMA/device: Fix a race between mad_client and cm_client init To: Jason Gunthorpe Cc: leon@kernel.org, wenglianfa@huawei.com, gustavoars@kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Shifeng Li , "Ding, Hui" References: <20240102034335.34842-1-lishifeng@sangfor.com.cn> <20240103184804.GB50608@ziepe.ca> <80cac9fd-7fed-403e-8889-78e2fc7a49b0@sangfor.com.cn> <20240104123728.GC50608@ziepe.ca> From: Shifeng Li In-Reply-To: <20240104123728.GC50608@ziepe.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlDQhhIVk8eQxhJHh5MTU8aS1UTARMWGhIXJBQOD1 lXWRgSC1lBWUpJSlVISVVJTk9VSk9MWVdZFhoPEhUdFFlBWU9LSFVKTU9JTE5VSktLVUpCS0tZBg ++ X-HM-Tid: 0a8cd8b0e062b21dkuuu594fef20615 X-HM-MType: 1 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Mkk6Nyo*TDwoIj80Kh8sECgc OiMwFC1VSlVKTEtPT09JTklLSU9JVTMWGhIXVRcSCBMSHR4VHDsIGhUcHRQJVRgUFlUYFUVZV1kS C1lBWUpJSlVISVVJTk9VSk9MWVdZCAFZQUlPT083Bg++ On 2024/1/4 20:37, Jason Gunthorpe wrote: > On Thu, Jan 04, 2024 at 02:48:14PM +0800, Shifeng Li wrote: > >> The root cause is that mad_client and cm_client may init concurrently >> when devices_rwsem write semaphore is downgraded in enable_device_and_get() like: > > That can't be true, the module loader infrastructue ensures those two > things are sequential. > I'm a bit confused how the module loader infrastructue ensures that mad_client.add() and cm_client.add() are sequential. Could you explain in more detail please? We know that the ib_cm driver and mlx5_ib driver can load concurrently. Thanks. > You are trying to say that the post-client fixup stuff will still see > the DEVICE_REGISTERED before it reaches the clients_rwsem lock? > > That probably just says the clients_rwsem should be obtained before > changing the DEVICE_STATE too :\ > > Jason >