Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7682025rdb; Thu, 4 Jan 2024 04:38:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IEFM+mlGKGhL53qfBAHOF7lhyJlBL5EPGhxzu7g3FhG/otn7k/AZ3wl65Bwbt3+uObaqVt1 X-Received: by 2002:a05:6870:5d95:b0:203:f56b:cbc7 with SMTP id fu21-20020a0568705d9500b00203f56bcbc7mr520575oab.91.1704371900233; Thu, 04 Jan 2024 04:38:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704371900; cv=none; d=google.com; s=arc-20160816; b=OGI/3jV8QJfFd9bAYyAzdDjF/iwuKrqulKWLrNe8tr/rAaFpguWFq+sMQYHZoU8Vuv BFLFnslvEUU2RXmCRlZs6RzbRqPejmBgrolWUhg15W1e5VXYsTpBblG0E3zmgBlL7xWL eyU/SW/8UddcaRSYdaTLYA1OIl9wVS4hEeVvv7aTanPOLvtS++YZT3aGX0Vnt+s8gxnu 8xoFbeYympA3y68Z/+oOCPStC6vGssVzo8oSQ4YPANBST/DQkF6lwyn6WUPWq0yo/zKq c0fBTB+L7KGKpym8Ayeaec45elPMyS9EHz+rMhsIhVTgF9VL/9ks5P/70NrbRLJI7sJJ 4oxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Hf/WO7dpSxOwRzBOXg5oe62I+hQuDL4PKjYM4SM/3gc=; fh=Q92RwwTbUVQN4QD/806dJwTxYEtqmQ3zlIHOtHM44kc=; b=y8OZa09rQGbrcl8bn/eLsbSD/rE7L3uP3I0X/k/FA3riHbS40iRFuyvdAC3D2/LOEw SIMbpLMVtT1A2zFHpkdNuVeisJ4H4hhYTsN/BX3M5JErNebBfmAYKS9rSRAUOwrX6YGy nh3WvRPsAhiN138tFFDnl/VqpFph05sHXE2WUi/coqOoVWTP1wD/ktwkT5tgkXorxqk5 ZGW4sLyFEDoW3DivlROBuNS44qAAfgSxIECgJou5Ve0Bh99dlg4XvtVYqD3oj7R9pvsr KOximDLRs4bGy2nTf04IC0QI3fBHbb7+XWpcugm1E12kU3zkLXmZkMXnNDcEVd02m8Zl 4OQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=BudWBaX3; spf=pass (google.com: domain of linux-kernel+bounces-16649-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16649-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id fd13-20020a056a002e8d00b006dab9807d4bsi2445316pfb.288.2024.01.04.04.38.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 04:38:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16649-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=BudWBaX3; spf=pass (google.com: domain of linux-kernel+bounces-16649-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16649-linux.lists.archive=gmail.com@vger.kernel.org" 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D704BB23ECC for ; Thu, 4 Jan 2024 12:38:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6D81F22337; Thu, 4 Jan 2024 12:37:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="BudWBaX3" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA34322303 for ; Thu, 4 Jan 2024 12:37:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Received: by mail-oi1-f176.google.com with SMTP id 5614622812f47-3ba14203a34so328556b6e.1 for ; Thu, 04 Jan 2024 04:37:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1704371849; x=1704976649; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Hf/WO7dpSxOwRzBOXg5oe62I+hQuDL4PKjYM4SM/3gc=; b=BudWBaX3rXZ32flH1YDE5MSwR7DrNYSqH9VGDWO4+Q8Dbcjv1ERLA6gUQxGrS640Sk PKEviOs5cGxil6ziJXC8nIi4Ft4AKnlB+aYO8JDuhrAa9lF5UuD760w2M582j30isq+3 IqGjiiSjE+t6Iuhai2axIhLEqUbZYe9gVG/tzzWbRPnbIjcS+3nJhTfouevW2DHFR7U8 Q0YvHZ5jL1OULtv7kALZ6R6FOV8kWJhcRfS4v4er7iaUQd0S/uttoc62azUQfPALoMEE 7xBuRFNGL+0xj6LlJTUDT4B8lQLAw+xEO+FbpeuETIo/IA27imMPEMJGeDDO04e0Facf 2JUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704371849; x=1704976649; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Hf/WO7dpSxOwRzBOXg5oe62I+hQuDL4PKjYM4SM/3gc=; b=ikmGA2JzUpjtPI9HnnVHIVqnOeFpuJ6wEdUMA5Xd3N4jkwO5/6Av1EQeoqXV2eP+Hq E1fb0qJLgwx2TqDyzwMrloTK5yHzHUERAPuSObiSAforIh2imcFhOxMnuIAmO0TRkDVA wsXvLILC58oX3IP2e/TOZkuEAHOFswM7lU5x/M6DzHjcI4QN3UzRYxaqzQZrmGLUFwsZ 4jqK7VcyD79MMhPqEo7bXwkhrw2M+0ylzgk/uqM/p+SmOULijgz6IQqxzFCNAPVg914F VigTuQ7SMvDL9aRoZQQmh/efgd8O1nrDEyJBg+5Czj+5auuxjfB0kJfxzvoCfhDFIiaO E+yw== X-Gm-Message-State: AOJu0YxMqRFRUJUwB4U2jLa1nkIS/gt9PTGWtqR7xUnfYGA5uEbXmXg1 YZDE3vfVg+rSu6Xn2LY4scsSv8NtoW1mvQ== X-Received: by 2002:a05:6808:2918:b0:3bb:d7ff:982d with SMTP id ev24-20020a056808291800b003bbd7ff982dmr462984oib.98.1704371849776; Thu, 04 Jan 2024 04:37:29 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-68-80-239.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.80.239]) by smtp.gmail.com with ESMTPSA id z8-20020ad44148000000b0067f7e41de80sm11660650qvp.46.2024.01.04.04.37.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 04:37:28 -0800 (PST) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1rLMyW-0017pG-9U; Thu, 04 Jan 2024 08:37:28 -0400 Date: Thu, 4 Jan 2024 08:37:28 -0400 From: Jason Gunthorpe To: Shifeng Li Cc: leon@kernel.org, wenglianfa@huawei.com, gustavoars@kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Shifeng Li , "Ding, Hui" Subject: Re: [PATCH] RDMA/device: Fix a race between mad_client and cm_client init Message-ID: <20240104123728.GC50608@ziepe.ca> References: <20240102034335.34842-1-lishifeng@sangfor.com.cn> <20240103184804.GB50608@ziepe.ca> <80cac9fd-7fed-403e-8889-78e2fc7a49b0@sangfor.com.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <80cac9fd-7fed-403e-8889-78e2fc7a49b0@sangfor.com.cn> 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. 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