From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 D5EE03EF649 for ; Tue, 14 Jul 2026 07:39:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784014803; cv=none; b=UBX/nudkrAliDQgSNMs/riaNjAmWng+yJFSnHCKKuNon/SmCFytUJ2Wqy4QdHJ97X1/gDtGbwLv+SZQH4m0NzwrGZhdYOp6dgboNNR+JNubAXOEtKokI3qstkgUFZSqDP58cLrfg1LLG186wFOmckJm6pnOE5v4x3uoKAotIUKs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784014803; c=relaxed/simple; bh=Ii4QglIlNfk2AF9Ta5Xci6IGgX7bNyNYfS9+14rJzNM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tzMRmTdAWT8eJaalzdkTwFAvSnDDLwtzByQmj9/Y+p9G4lMqvmBvU+/P5DSVqkjGvx2Q5QIZaRrH0iNtSkIHBdzIzrDeMltSpT/+ren8vnLKhyVSu15UaDyTEwULW4JL1/g4+F+qVH53+mpCGBf5Vh0lD319WGweAFRiQU1c9SI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us; spf=none smtp.mailfrom=resnulli.us; dkim=pass (2048-bit key) header.d=resnulli-us.20251104.gappssmtp.com header.i=@resnulli-us.20251104.gappssmtp.com header.b=MXGbOTxb; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=resnulli.us Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20251104.gappssmtp.com header.i=@resnulli-us.20251104.gappssmtp.com header.b="MXGbOTxb" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-493b77b150aso4641995e9.2 for ; Tue, 14 Jul 2026 00:39:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20251104.gappssmtp.com; s=20251104; t=1784014798; x=1784619598; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=7C5iWjcphG9+X8eLvvIf+CpqUo2Z4rnWqlw/CwVzzuA=; b=MXGbOTxb/bWGnJSaW6/5X7OBDtdY5cRnC3WhClHMgp+BSOmlZyRVXImcF77gCuruCm JABkSDaLE4PVCwElIQtzeRBaqXfMR3PpBt6qPdPC5uBXSlyAuFjCMHaLLjfp0Mt7swqP as9OJpiGN+iybBbWENmIMOzoGxLznGHJzWF3KkEYSRddBIqZlhxs1IgNh5COjZRpafJa VsA3ozpE/9f7aJ7SPQkdjW7lQxqUD0sNDYZYhXNmaNxtXjaSjL+h8DSkLZ828gGWtcT0 Rln1x8RKDBYr+cxoGWwi6+x6sb7xkooEkMGJHt+njcSi4vLJZlcWfPoK9ojLCvFIP0Zv lhSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784014798; x=1784619598; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=7C5iWjcphG9+X8eLvvIf+CpqUo2Z4rnWqlw/CwVzzuA=; b=cmC9oSuHfaV1/luYFQyzkHX4Jx4snGc3bd2beLdweRm7B07cEWzSKAO9vH4wWV9sBf 4+8/JkiZTCYC7REH7R+s2QrmzQqFx82fMlWlV5RQmrStCLUlf+1e3GFch1ZschIg01XN JFXBFJZTnlXZH5ninZX4cDL0eBnvM75JpXjx0hfOtOsCLjdxNY8TwDuD94MMLSbxQlIs RSfi68Zpf6EM+ZvhOcNcx5bTjmZrJ8pJEktMYKLASJBKAfGFZLSfmVIJfqbbVm18API5 Pfc9tAOCuiB1TGa4d9DAHsDN61zDVDTh9IMsGZTbD+V7hnip0Cg3YT2MXrzuBdVDmYz1 DGFQ== X-Forwarded-Encrypted: i=1; AHgh+RrIGf4SuxtjEPjSqSurXlLh7qdAaFepSuE3Uc+cDawuPiXVhPROZ0awDRVnfT2QMgnA9/dGuSA=@vger.kernel.org X-Gm-Message-State: AOJu0YzAE2k6h+g1AECQzntbmpPtxpYh0zLSf0TCfMNHy9YUJ6VaNB/X TTIuUZCJ/sCJDPXVmmDIki5Pah2UBFqQqvqfkKe0fkdWqSjs/sabParRdgfOVCjb5mY= X-Gm-Gg: AfdE7ckJGsXOeAR4BDv7pZLymB7ov/u/8Q+imvWxnh3cMpLcNiGExAV/TpxgnxzteyC M/1KQKSHiNYh4R6336R84bZiGi3VeX4uP9fOKbU5lm+ZUZo18bxMArQv+J5WttgzgEB4gLXZdQG LFCoxzTNSXlolbmF3hMgVZrggRJGbKU4bAYWtybAXoqqbKYYQqxVI2vgoPp1pozjbLRGqB+IRfG DBvSBcPCWWCIRHJDM8SmjyvXKjijxA60TCeEJOw0wt0zFPqCyytZAhZFFkJoxngLfxJAESStSOo /B60+dDH2gkLL4Q+VMqtwE46+Wri1FM5pqp8eJvEAu/ZBpcL6LYliu1LxHNgLj+oK953kqeMU3G TzpEJqC4TmrmXETAUbYe4vdbaQcyKaL2NC00iPPqLcFqALLZaJfdPXWX9rbHKgB0QJytJshRHgy +fcdH8q0xgRlatiEc6w9PJYQ== X-Received: by 2002:a05:600c:1f87:b0:493:f870:fbf0 with SMTP id 5b1f17b1804b1-493f88b3693mr153093885e9.34.1784014797971; Tue, 14 Jul 2026 00:39:57 -0700 (PDT) Received: from localhost ([140.209.217.211]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4950a322bcbsm63449225e9.9.2026.07.14.00.39.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2026 00:39:57 -0700 (PDT) Date: Tue, 14 Jul 2026 09:39:53 +0200 From: Jiri Pirko To: Tao Cui Cc: Michal =?utf-8?Q?Koutn=C3=BD?= , 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 Message-ID: References: <20260709095532.855647-1-jiri@resnulli.us> <20260709095532.855647-9-jiri@resnulli.us> <2fc297ce-7259-4410-9d86-ccc32485622f@linux.dev> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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 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. 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 >> >> >> >