From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8FDE324C671; Mon, 10 Feb 2025 19:52:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739217141; cv=none; b=TWs6eEnxa7RbcXjsS2Gngy1VSZAoE7w3DQjBqYuGHAbnCS0GTS+6yok74J2/FKVTZ132LHmb4Q1lI24/OnCInm1DXUL+kMZMO2ip8oBE5Lh/wluQRAYBg9Huc4YWEtEFxzacP2w7acfnfjO2JTvJ/8W/EtJR938XYsepscvsJao= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739217141; c=relaxed/simple; bh=eMbxPuWu6z1a5TgdGwnSavZW0+EQ98YYaSFxR7zGbl8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gQNcnUnRtlvG9dAsfS8Oo5athEyMahFMB3X+m9Eig7nNHphH5EfeAXVoWxAD23O2ZpQVjQyCCtqV0mCu1YGu3TwFNfran4bfORWnvciHRUhiK57nSdZJFnFFqy4GgEn299G5xG1fY0gaBlblgyVgOh/qmUzRSSDtu2LvjLgPAgI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ACIhIMQK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ACIhIMQK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17C20C4CED1; Mon, 10 Feb 2025 19:52:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739217141; bh=eMbxPuWu6z1a5TgdGwnSavZW0+EQ98YYaSFxR7zGbl8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ACIhIMQKGnXkxrhhH458DUMhh90xayTEvDNTyGhfvUq2oegVOLIrQOdQwSEt6ObLh 28RPWflZVGWdyqucTbKI66ZFOK0m15AJ9vWgPP4/TRAKiw207SBiAGSKQZt1LmNMEI J3reUvppkCrx58jjdviKatNd4TK+++aI60n4KBHmVOq+uXu8vonTIMyyHBFGql1b7Y CDYpsnHiq4FiKCDcBUCGJDdG5yWSSw6KCSDACTZqfgUGYysNoAz2Ozo+Gz/kfeYkhT inVBkMc5AvvrAYNtciLVMh88iqK8+9ZLdUZbLM6wPxrSZUPzAXokeUK0hIN2rVqGrD dPJLm62HI9NbA== Date: Mon, 10 Feb 2025 19:52:17 +0000 From: Simon Horman To: "Matthieu Baerts (NGI0)" Cc: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next v3 12/15] mptcp: pm: reuse sending nlmsg code in get_addr Message-ID: <20250210195217.GZ554665@kernel.org> References: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-0-71753ed957de@kernel.org> <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-12-71753ed957de@kernel.org> Precedence: bulk X-Mailing-List: netdev@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: <20250207-net-next-mptcp-pm-misc-cleanup-2-v3-12-71753ed957de@kernel.org> On Fri, Feb 07, 2025 at 02:59:30PM +0100, Matthieu Baerts (NGI0) wrote: > From: Geliang Tang > > The netlink messages are sent both in mptcp_pm_nl_get_addr() and > mptcp_userspace_pm_get_addr(), this makes the code somewhat repetitive. > This is because the netlink PM and userspace PM use different locks to > protect the address entry that needs to be sent via the netlink message. > The former uses rcu read lock, and the latter uses msk->pm.lock. > > The current get_addr() flow looks like this: > > lock(); > entry = get_entry(); > send_nlmsg(entry); > unlock(); > > After holding the lock, get the entry from the list, send the entry, and > finally release the lock. > > This patch changes the process by getting the entry while holding the lock, > then making a copy of the entry so that the lock can be released. Finally, > the copy of the entry is sent without locking: > > lock(); > entry = get_entry(); > *copy = *entry; > unlock(); > > send_nlmsg(copy); > > This way we can reuse the send_nlmsg() code in get_addr() interfaces > between the netlink PM and userspace PM. They only need to implement their > own get_addr() interfaces to hold the different locks, get the entry from > the different lists, then release the locks. > > Signed-off-by: Geliang Tang > Reviewed-by: Matthieu Baerts (NGI0) > Signed-off-by: Matthieu Baerts (NGI0) Reviewed-by: Simon Horman