All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: Tao Cui <cui.tao@linux.dev>
Cc: "Michal Koutný" <mkoutny@suse.com>,
	linux-rdma@vger.kernel.org, cgroups@vger.kernel.org,
	netdev@vger.kernel.org, linux-s390@vger.kernel.org,
	linux-kselftest@vger.kernel.org, jgg@ziepe.ca, leon@kernel.org,
	parav@nvidia.com, mbloch@nvidia.com, cmeiohas@nvidia.com,
	roman.gushchin@linux.dev, bvanassche@acm.org,
	zyjzyj2000@gmail.com, shuah@kernel.org, tj@kernel.org,
	hannes@cmpxchg.org, alibuda@linux.alibaba.com,
	dust.li@linux.alibaba.com, sidraya@linux.ibm.com,
	wenjia@linux.ibm.com
Subject: Re: [PATCH rdma-next 08/13] RDMA/cgroup: Scope rdma cgroup device visibility to the net namespace
Date: Tue, 14 Jul 2026 09:39:53 +0200	[thread overview]
Message-ID: <alXmwzDASDFaeVNZ@FV6GYCPJ69> (raw)
In-Reply-To: <2fc297ce-7259-4410-9d86-ccc32485622f@linux.dev>

Tue, Jul 14, 2026 at 04:28:01AM +0200, cui.tao@linux.dev wrote:
>
>
>在 2026/7/13 17:34, Jiri Pirko 写道:
>> Thu, Jul 09, 2026 at 03:04:23PM +0200, mkoutny@suse.com wrote:
>>> Hi.
>>>
>>> On Thu, Jul 09, 2026 at 11:55:27AM +0200, Jiri Pirko <jiri@resnulli.us> wrote:
>>>> index 993446ab66d0..4523c1884d67 100644
>>>> --- a/Documentation/admin-guide/cgroup-v2.rst
>>>> +++ b/Documentation/admin-guide/cgroup-v2.rst
>>>> @@ -2752,6 +2752,13 @@ RDMA
>>>>  The "rdma" controller regulates the distribution and accounting of
>>>>  RDMA resources.
>>>>  
>>>> +When RDMA devices are isolated per network namespace (exclusive mode),
>>>> +device names are unique only within a network namespace. The device lines
>>>> +below are therefore scoped to the reading or writing process's network
>>>> +namespace: only devices accessible from that namespace are listed, and a
>>>> +limit is applied to the device of that name in that namespace. Configure
>>>> +limits from the same network namespace as the workloads.
>>>
>>> OK.
>>>
>>>> --- a/include/linux/cgroup_rdma.h
>>>> +++ b/include/linux/cgroup_rdma.h
>>>> @@ -7,6 +7,7 @@
>>>>  #define _CGROUP_RDMA_H
>>>>  
>>>>  #include <linux/cgroup.h>
>>>> +#include <net/net_namespace.h>
>>>>  
>>>>  enum rdmacg_resource_type {
>>>>  	RDMACG_RESOURCE_HCA_HANDLE,
>>>> @@ -34,6 +35,15 @@ struct rdmacg_device {
>>>>  	struct list_head	dev_node;
>>>>  	struct list_head	rpools;
>>>>  	char			*name;
>>>> +	/*
>>>> +	 * Net namespace the device belongs to. @netns_shared mirrors
>>>> +	 * ib_devices_shared_netns: when true the device is visible from every
>>>> +	 * net namespace (shared mode); otherwise @net is the only namespace
>>>> +	 * that may see and configure it. @netns_shared is updated when the
>>>> +	 * sharing mode changes, so use {READ,WRITE}_ONCE() to access it.
>>>> +	 */
>>>> +	possible_net_t		net;
>>>> +	bool			netns_shared;
>>>
>>> Any reason to store the netns_shared split per device? (IIUC, it's a
>>> global parameter.)
>> 
>> No reason, changed.
>> 
>Hi Jiri,
>
>A question on the v2 you mentioned to Michal.
>
>Once netns_shared stops being cached per rdmacg_device,
>rdmacg_device_visible() in kernel/cgroup/rdma.c still needs the current
>sharing mode, whose authoritative value lives in the IB core
>(ib_devices_shared_netns). How do you plan to expose it there without
>the generic cgroup controller reaching back into drivers/infiniband/?
>Exporting the global, or keeping an IB-side update hook, both feel a bit
>awkward; it would be good to see which direction you took.

Exposing this from ib side is not doable, as IB may be compiled as a
module. So what I do is I intrododuce "static bool rdmacg_netns_shared"
in cgroup/rdma.c and exported function rdmacg_set_netns_shared() to set
it from IB.


>
>On the mechanism itself: it's the right call that rdmacg_try_charge()
>stays out of the scoping. Charging takes the rdmacg_device pointer
>directly (no name lookup), and a task can only charge a device it
>already holds a handle to, so applying visibility there would be wrong.
>The scoping deliberately touches only the name-based lookup (the write
>path) and the enumeration (read/show) paths -- worth keeping that
>invariant in mind so a later patch doesn't grow the filter.
>
>Thanks,
>Tao> Thanks!
>> 
>>>
>>> Thanks,
>>> Michal
>> 
>> 
>> 
>

  reply	other threads:[~2026-07-14  7:39 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09  9:55 [PATCH rdma-next 00/13] RDMA: Make device names unique per net namespace Jiri Pirko
2026-07-09  9:55 ` [PATCH rdma-next 01/13] RDMA/core: Pass the net namespace to the device name lookups Jiri Pirko
2026-07-09  9:55 ` [PATCH rdma-next 02/13] RDMA/core: Handle device name conflicts when changing net namespace Jiri Pirko
2026-07-10  9:56   ` sashiko-bot
2026-07-13 12:32     ` Jiri Pirko
2026-07-09  9:55 ` [PATCH rdma-next 03/13] RDMA/core: Support renaming a device when changing its " Jiri Pirko
2026-07-10  9:56   ` sashiko-bot
2026-07-13 12:17     ` Jiri Pirko
2026-07-09  9:55 ` [PATCH rdma-next 04/13] RDMA/nldev: Report net namespace move errors through extack Jiri Pirko
2026-07-09  9:55 ` [PATCH rdma-next 05/13] RDMA/nldev: Allow setting the device name while changing net namespace Jiri Pirko
2026-07-09  9:55 ` [PATCH rdma-next 06/13] net/smc: Look up the pnetid ib device within the " Jiri Pirko
2026-07-10  9:56   ` sashiko-bot
2026-07-09  9:55 ` [PATCH rdma-next 07/13] RDMA/srp: Make the SRP sysfs class net namespace aware Jiri Pirko
2026-07-09  9:55 ` [PATCH rdma-next 08/13] RDMA/cgroup: Scope rdma cgroup device visibility to the net namespace Jiri Pirko
2026-07-09 13:04   ` Michal Koutný
2026-07-13  9:34     ` Jiri Pirko
2026-07-14  2:28       ` Tao Cui
2026-07-14  7:39         ` Jiri Pirko [this message]
2026-07-10  9:56   ` sashiko-bot
2026-07-14 11:39     ` Jiri Pirko
2026-07-09  9:55 ` [PATCH rdma-next 09/13] RDMA/cma: Document that CM configfs cannot be net namespace scoped Jiri Pirko
2026-07-09  9:55 ` [PATCH rdma-next 10/13] RDMA/core: Document the SELinux ibendport net namespace limitation Jiri Pirko
2026-07-09  9:55 ` [PATCH rdma-next 11/13] RDMA/core: Make device names unique per net namespace Jiri Pirko
2026-07-09  9:55 ` [PATCH rdma-next 12/13] RDMA/rxe: Implement disassociate_ucontext callback Jiri Pirko
2026-07-10  4:21   ` Zhu Yanjun
2026-07-10  9:56   ` sashiko-bot
2026-07-13 13:24     ` Jiri Pirko
2026-07-09  9:55 ` [PATCH rdma-next 13/13] RDMA/selftests: Add rxe_netns_names test Jiri Pirko
2026-07-10  4:24   ` Zhu Yanjun
2026-07-13  8:58     ` Jiri Pirko
2026-07-10  9:56   ` sashiko-bot
2026-07-13 13:35     ` Jiri Pirko
2026-07-10 23:51   ` yanjun.zhu
2026-07-13  9:02     ` Jiri Pirko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alXmwzDASDFaeVNZ@FV6GYCPJ69 \
    --to=jiri@resnulli.us \
    --cc=alibuda@linux.alibaba.com \
    --cc=bvanassche@acm.org \
    --cc=cgroups@vger.kernel.org \
    --cc=cmeiohas@nvidia.com \
    --cc=cui.tao@linux.dev \
    --cc=dust.li@linux.alibaba.com \
    --cc=hannes@cmpxchg.org \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=mkoutny@suse.com \
    --cc=netdev@vger.kernel.org \
    --cc=parav@nvidia.com \
    --cc=roman.gushchin@linux.dev \
    --cc=shuah@kernel.org \
    --cc=sidraya@linux.ibm.com \
    --cc=tj@kernel.org \
    --cc=wenjia@linux.ibm.com \
    --cc=zyjzyj2000@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.