From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-186.mta0.migadu.com (out-186.mta0.migadu.com [91.218.175.186]) (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 6FEF137DAA2 for ; Tue, 14 Jul 2026 02:28:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.186 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783996105; cv=none; b=HheAK7MxhVSmwkNy5Cwq2TIds8pTlZhHlr8SZpgECVv7y68K69hpya5+xHbDnU79pqKf5d/GsiLjp9mHmgk8EqFvXrlMeRUK/63bNQrVJ0JMMsVReYUgF7Gcwk8W4Y1jMyg/j+7CMXOH1h6ViDduHS76La3uavEc0GykD1ZM9q4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783996105; c=relaxed/simple; bh=DPob54I1nbTw2wNBi+c15m+C3BjzsQ+0vrOEP0bfYTU=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=BkxIkVn4Wa6nEoW6wkC9sPAzIpd8r4cDjzIgIv2o21FJclwfZvhXIj3d3a5r9R25RI/gQdqR5q8bX+6lLufiFBY7j5m5OX4jhe10AUtcWb6AR1Afg8bkO07RRY36LAvLL8cOw58rmwR3t2auYBhH4VEHX20K+ZmRNrVkQh1Ucjw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=UAvlqFgG; arc=none smtp.client-ip=91.218.175.186 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="UAvlqFgG" Message-ID: <2fc297ce-7259-4410-9d86-ccc32485622f@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1783996091; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pV3N8ci8r9hi8imLNZSBGOdl04OdEpOXZ6SSHiqXk5A=; b=UAvlqFgG5sK6uHIpqOjMOSfEyjTOZBOfU4QTZytAffqSoboIdx5RvOIGplJnE+wfOm95+7 BbWTnmRJq1+JHKmZBx3JMX4XMx/BVPmeuKg0+fWOSFBZDn4i5t6CUYSli0i2kgBw+968JY UaHvObFa/8QryPmpRJsqX2chq35H+eE= Date: Tue, 14 Jul 2026 10:28:01 +0800 Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Cc: cui.tao@linux.dev, 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 To: Jiri Pirko , =?UTF-8?Q?Michal_Koutn=C3=BD?= References: <20260709095532.855647-1-jiri@resnulli.us> <20260709095532.855647-9-jiri@resnulli.us> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Tao Cui In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 在 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 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 >>> +#include >>> >>> 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. 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 > > >