Skip to contentSkip to conversation

Finding the namespace of a struct ib_device

DISCUSSION Ka-Cheong Poon 5 participants 48 messages Sep 3, 2020 – Oct 19, 2020 InfiniBand

lore
Share & tools
lore
#0 lore raw

When a struct ib_client's add() function is called. is there a supported method to find out the namespace of the passed in struct ib_device? There is rdma_dev_access_netns() but it does not return the namespace. It seems that it needs to have something like the following.

struct net *rdma_dev_to_netns(struct ib_device *ib_dev)

{
       return read_pnet(&ib_dev->coredev.rdma_net);
}

Comments?

Thanks.

Signature · 2 lines
K. Poon
[email protected]
#1 lore raw
Quoted 6 lines · Ka-Cheong Poon

When a struct ib_client's add() function is called. is there a supported method to find out the namespace of the passed in struct ib_device? There is rdma_dev_access_netns() but it does not return the namespace. It seems that it needs to have something like the following.

Quoted 6 lines

struct net *rdma_dev_to_netns(struct ib_device *ib_dev)

{
       return read_pnet(&ib_dev->coredev.rdma_net);
}

Comments?

I suppose, but why would something need this?

Jason

#2 lore raw
Quoted 7 lines · Jason Gunthorpe
Quoted 6 lines · Ka-Cheong Poon

When a struct ib_client's add() function is called. is there a supported method to find out the namespace of the passed in struct ib_device? There is rdma_dev_access_netns() but it does not return the namespace. It seems that it needs to have something like the following.

Quoted 8 lines
Quoted 6 lines

struct net *rdma_dev_to_netns(struct ib_device *ib_dev)

{
        return read_pnet(&ib_dev->coredev.rdma_net);
}

Comments?

I suppose, but why would something need this?

If the client needs to allocate stuff for the namespace related to that device, it needs to know the namespace of that device. Then when that namespace is deleted, the client can clean up those related stuff as the client's namespace exit function can be called before the remove() function is triggered in rdma_dev_exit_net(). Without knowing the namespace of that device, coordination cannot be done.

Signature · 2 lines
K. Poon
[email protected]
#3 lore raw
Quoted 18 lines · Ka-Cheong Poon
Quoted 7 lines · Jason Gunthorpe
Quoted 6 lines · Ka-Cheong Poon

When a struct ib_client's add() function is called. is there a supported method to find out the namespace of the passed in struct ib_device? There is rdma_dev_access_netns() but it does not return the namespace. It seems that it needs to have something like the following.

Quoted 8 lines
Quoted 6 lines

struct net *rdma_dev_to_netns(struct ib_device *ib_dev)

{
        return read_pnet(&ib_dev->coredev.rdma_net);
}

Comments?

I suppose, but why would something need this?

Quoted 8 lines

If the client needs to allocate stuff for the namespace related to that device, it needs to know the namespace of that device. Then when that namespace is deleted, the client can clean up those related stuff as the client's namespace exit function can be called before the remove() function is triggered in rdma_dev_exit_net(). Without knowing the namespace of that device, coordination cannot be done.

Since each device can only be in one namespace, why would a client ever need to allocate at a level more granular than a device?

Jason

#4 lore raw
Quoted 28 lines · Jason Gunthorpe
Quoted 18 lines · Ka-Cheong Poon
Quoted 7 lines · Jason Gunthorpe
Quoted 6 lines · Ka-Cheong Poon

When a struct ib_client's add() function is called. is there a supported method to find out the namespace of the passed in struct ib_device? There is rdma_dev_access_netns() but it does not return the namespace. It seems that it needs to have something like the following.

Quoted 8 lines
Quoted 6 lines

struct net *rdma_dev_to_netns(struct ib_device *ib_dev)

{
         return read_pnet(&ib_dev->coredev.rdma_net);
}

Comments?

I suppose, but why would something need this?

Quoted 8 lines

If the client needs to allocate stuff for the namespace related to that device, it needs to know the namespace of that device. Then when that namespace is deleted, the client can clean up those related stuff as the client's namespace exit function can be called before the remove() function is triggered in rdma_dev_exit_net(). Without knowing the namespace of that device, coordination cannot be done.

Quoted 2 lines

Since each device can only be in one namespace, why would a client ever need to allocate at a level more granular than a device?

A client wants to have namespace specific info. If the device belongs to a namespace, it wants to associate those info with that device. When a namespace is deleted, the info will need to be deleted. You can consider the info as associated with both a namespace and a device.

Signature · 2 lines
K. Poon
[email protected]
#5 lore raw
Quoted 33 lines · Ka-Cheong Poon
Quoted 28 lines · Jason Gunthorpe
Quoted 18 lines · Ka-Cheong Poon
Quoted 7 lines · Jason Gunthorpe
Quoted 6 lines · Ka-Cheong Poon

When a struct ib_client's add() function is called. is there a supported method to find out the namespace of the passed in struct ib_device? There is rdma_dev_access_netns() but it does not return the namespace. It seems that it needs to have something like the following.

Quoted 8 lines
Quoted 6 lines

struct net *rdma_dev_to_netns(struct ib_device *ib_dev)

{
         return read_pnet(&ib_dev->coredev.rdma_net);
}

Comments?

I suppose, but why would something need this?

Quoted 8 lines

If the client needs to allocate stuff for the namespace related to that device, it needs to know the namespace of that device. Then when that namespace is deleted, the client can clean up those related stuff as the client's namespace exit function can be called before the remove() function is triggered in rdma_dev_exit_net(). Without knowing the namespace of that device, coordination cannot be done.

Quoted 2 lines

Since each device can only be in one namespace, why would a client ever need to allocate at a level more granular than a device?

Quoted 5 lines

A client wants to have namespace specific info. If the device belongs to a namespace, it wants to associate those info with that device. When a namespace is deleted, the info will need to be deleted. You can consider the info as associated with both a namespace and a device.

Can you be more specific about which info you are talking about? And what is the client that is net namespace-aware from one side, but from another separate data between them "manually"?

Thanks

Quoted 7 lines

--
K. Poon
[email protected]

#6 lore raw
Quoted 34 lines · Leon Romanovsky
Quoted 33 lines · Ka-Cheong Poon
Quoted 30 lines · Jason Gunthorpe
Quoted 18 lines · Ka-Cheong Poon
Quoted 7 lines · Jason Gunthorpe
Quoted 6 lines · Ka-Cheong Poon

When a struct ib_client's add() function is called. is there a supported method to find out the namespace of the passed in struct ib_device? There is rdma_dev_access_netns() but it does not return the namespace. It seems that it needs to have something like the following.

Quoted 8 lines
Quoted 6 lines

struct net *rdma_dev_to_netns(struct ib_device *ib_dev)

{
          return read_pnet(&ib_dev->coredev.rdma_net);
}

Comments?

I suppose, but why would something need this?

Quoted 8 lines

If the client needs to allocate stuff for the namespace related to that device, it needs to know the namespace of that device. Then when that namespace is deleted, the client can clean up those related stuff as the client's namespace exit function can be called before the remove() function is triggered in rdma_dev_exit_net(). Without knowing the namespace of that device, coordination cannot be done.

Since each device can only be in one namespace, why would a client ever need to allocate at a level more granular than a device?

Quoted 7 lines
Quoted 5 lines

A client wants to have namespace specific info. If the device belongs to a namespace, it wants to associate those info with that device. When a namespace is deleted, the info will need to be deleted. You can consider the info as associated with both a namespace and a device.

Can you be more specific about which info you are talking about?

Actually, a lot of info can be both namespace and device specific. For example, a client wants to have a different PD allocation policy with a device when used in different namespaces.

Quoted 2 lines

And what is the client that is net namespace-aware from one side, but from another separate data between them "manually"?

Could you please elaborate what is meant by "namespace aware from one side but from another separate data between them manually"? I understand what namespace aware means. But it is not clear what is meant by "separating data manually". Do you mean having different behavior in different namespaces? If this is the case, there is nothing special here. An admin may choose to have different behavior in different namespaces. There is nothing manual going on in the client code.

Signature · 2 lines
K. Poon
[email protected]
#7 lore raw
Quoted 53 lines · Ka-Cheong Poon
Quoted 34 lines · Leon Romanovsky
Quoted 33 lines · Ka-Cheong Poon
Quoted 30 lines · Jason Gunthorpe
Quoted 18 lines · Ka-Cheong Poon
Quoted 7 lines · Jason Gunthorpe
Quoted 6 lines · Ka-Cheong Poon

When a struct ib_client's add() function is called. is there a supported method to find out the namespace of the passed in struct ib_device? There is rdma_dev_access_netns() but it does not return the namespace. It seems that it needs to have something like the following.

Quoted 8 lines
Quoted 6 lines

struct net *rdma_dev_to_netns(struct ib_device *ib_dev)

{
          return read_pnet(&ib_dev->coredev.rdma_net);
}

Comments?

I suppose, but why would something need this?

Quoted 8 lines

If the client needs to allocate stuff for the namespace related to that device, it needs to know the namespace of that device. Then when that namespace is deleted, the client can clean up those related stuff as the client's namespace exit function can be called before the remove() function is triggered in rdma_dev_exit_net(). Without knowing the namespace of that device, coordination cannot be done.

Since each device can only be in one namespace, why would a client ever need to allocate at a level more granular than a device?

Quoted 7 lines
Quoted 5 lines

A client wants to have namespace specific info. If the device belongs to a namespace, it wants to associate those info with that device. When a namespace is deleted, the info will need to be deleted. You can consider the info as associated with both a namespace and a device.

Can you be more specific about which info you are talking about?

Actually, a lot of info can be both namespace and device specific. For example, a client wants to have a different PD allocation policy with a device when used in different namespaces.

Quoted 2 lines

And what is the client that is net namespace-aware from one side, but from another separate data between them "manually"?

Quoted 8 lines

Could you please elaborate what is meant by "namespace aware from one side but from another separate data between them manually"? I understand what namespace aware means. But it is not clear what is meant by "separating data manually". Do you mean having different behavior in different namespaces? If this is the case, there is nothing special here. An admin may choose to have different behavior in different namespaces. There is nothing manual going on in the client code.

We are talking about net-namespaces, and as we wrote above, the ib_device that supports such namespace can exist only in a single one

The client that implemented such support can check its namespace while "client->add" is called. It should be equal to be seen by ib_device.

See:
rdma_dev_change_netns ->
enable_device_and_get ->

		add_client_context ->
			client->add(device)

"Manual" means that client will store results of first client->add call (in init_net NS) and will use globally stored data for other NS, which is not netdev way to work with namespaces. The expectation that they are separated without shared data between.

Thanks

Quoted 7 lines

--
K. Poon
[email protected]

#8 lore raw
Quoted 66 lines · Leon Romanovsky
Quoted 53 lines · Ka-Cheong Poon
Quoted 34 lines · Leon Romanovsky
Quoted 33 lines · Ka-Cheong Poon
Quoted 30 lines · Jason Gunthorpe
Quoted 18 lines · Ka-Cheong Poon
Quoted 7 lines · Jason Gunthorpe
Quoted 6 lines · Ka-Cheong Poon

When a struct ib_client's add() function is called. is there a supported method to find out the namespace of the passed in struct ib_device? There is rdma_dev_access_netns() but it does not return the namespace. It seems that it needs to have something like the following.

Quoted 8 lines
Quoted 6 lines

struct net *rdma_dev_to_netns(struct ib_device *ib_dev)

{
           return read_pnet(&ib_dev->coredev.rdma_net);
}

Comments?

I suppose, but why would something need this?

Quoted 8 lines

If the client needs to allocate stuff for the namespace related to that device, it needs to know the namespace of that device. Then when that namespace is deleted, the client can clean up those related stuff as the client's namespace exit function can be called before the remove() function is triggered in rdma_dev_exit_net(). Without knowing the namespace of that device, coordination cannot be done.

Since each device can only be in one namespace, why would a client ever need to allocate at a level more granular than a device?

Quoted 7 lines
Quoted 5 lines

A client wants to have namespace specific info. If the device belongs to a namespace, it wants to associate those info with that device. When a namespace is deleted, the info will need to be deleted. You can consider the info as associated with both a namespace and a device.

Can you be more specific about which info you are talking about?

Actually, a lot of info can be both namespace and device specific. For example, a client wants to have a different PD allocation policy with a device when used in different namespaces.

Quoted 2 lines

And what is the client that is net namespace-aware from one side, but from another separate data between them "manually"?

Quoted 8 lines

Could you please elaborate what is meant by "namespace aware from one side but from another separate data between them manually"? I understand what namespace aware means. But it is not clear what is meant by "separating data manually". Do you mean having different behavior in different namespaces? If this is the case, there is nothing special here. An admin may choose to have different behavior in different namespaces. There is nothing manual going on in the client code.

We are talking about net-namespaces, and as we wrote above, the ib_device that supports such namespace can exist only in a single one

Quoted 8 lines

The client that implemented such support can check its namespace while "client->add" is called. It should be equal to be seen by ib_device.

See:
rdma_dev_change_netns ->
enable_device_and_get ->

		add_client_context ->
			client->add(device)

This is the original question. How does the client's add() function know the namespace of device? What is your suggestion in finding the net namespace of device at add() time?

Quoted 4 lines

"Manual" means that client will store results of first client->add call (in init_net NS) and will use globally stored data for other NS, which is not netdev way to work with namespaces. The expectation that they are separated without shared data between.

It is not clear why client needs to use globally stored data for other net namespaces. When an RDMA device is moved from init_net to another net namespace, the client's remove() function is called first, and then the client's add() function is called. If a client can know the net namespace of a device when add()/remove() is called, it can use namespace specific data storage. It does not need to store namespace specific data in a global store. The original question is how to find out the net namespace of a device.

Signature · 2 lines
K. Poon
[email protected]
#9 lore raw
Quoted 77 lines · Ka-Cheong Poon
Quoted 66 lines · Leon Romanovsky
Quoted 53 lines · Ka-Cheong Poon
Quoted 34 lines · Leon Romanovsky
Quoted 33 lines · Ka-Cheong Poon
Quoted 30 lines · Jason Gunthorpe
Quoted 18 lines · Ka-Cheong Poon
Quoted 7 lines · Jason Gunthorpe
Quoted 6 lines · Ka-Cheong Poon

When a struct ib_client's add() function is called. is there a supported method to find out the namespace of the passed in struct ib_device? There is rdma_dev_access_netns() but it does not return the namespace. It seems that it needs to have something like the following.

Quoted 8 lines
Quoted 6 lines

struct net *rdma_dev_to_netns(struct ib_device *ib_dev)

{
           return read_pnet(&ib_dev->coredev.rdma_net);
}

Comments?

I suppose, but why would something need this?

Quoted 8 lines

If the client needs to allocate stuff for the namespace related to that device, it needs to know the namespace of that device. Then when that namespace is deleted, the client can clean up those related stuff as the client's namespace exit function can be called before the remove() function is triggered in rdma_dev_exit_net(). Without knowing the namespace of that device, coordination cannot be done.

Since each device can only be in one namespace, why would a client ever need to allocate at a level more granular than a device?

Quoted 7 lines
Quoted 5 lines

A client wants to have namespace specific info. If the device belongs to a namespace, it wants to associate those info with that device. When a namespace is deleted, the info will need to be deleted. You can consider the info as associated with both a namespace and a device.

Can you be more specific about which info you are talking about?

Actually, a lot of info can be both namespace and device specific. For example, a client wants to have a different PD allocation policy with a device when used in different namespaces.

Quoted 2 lines

And what is the client that is net namespace-aware from one side, but from another separate data between them "manually"?

Quoted 8 lines

Could you please elaborate what is meant by "namespace aware from one side but from another separate data between them manually"? I understand what namespace aware means. But it is not clear what is meant by "separating data manually". Do you mean having different behavior in different namespaces? If this is the case, there is nothing special here. An admin may choose to have different behavior in different namespaces. There is nothing manual going on in the client code.

We are talking about net-namespaces, and as we wrote above, the ib_device that supports such namespace can exist only in a single one

Quoted 8 lines

The client that implemented such support can check its namespace while "client->add" is called. It should be equal to be seen by ib_device.

See:
rdma_dev_change_netns ->
enable_device_and_get ->

		add_client_context ->
			client->add(device)
Quoted 3 lines

This is the original question. How does the client's add() function know the namespace of device? What is your suggestion in finding the net namespace of device at add() time?

As I wrote above, "It should be equal to be seen by ib_device.", check net namespace of your client.

Thanks

#10 lore raw
Quoted 78 lines · Leon Romanovsky
Quoted 77 lines · Ka-Cheong Poon
Quoted 74 lines · Leon Romanovsky
Quoted 53 lines · Ka-Cheong Poon
Quoted 34 lines · Leon Romanovsky
Quoted 33 lines · Ka-Cheong Poon
Quoted 30 lines · Jason Gunthorpe
Quoted 18 lines · Ka-Cheong Poon
Quoted 7 lines · Jason Gunthorpe
Quoted 6 lines · Ka-Cheong Poon

When a struct ib_client's add() function is called. is there a supported method to find out the namespace of the passed in struct ib_device? There is rdma_dev_access_netns() but it does not return the namespace. It seems that it needs to have something like the following.

Quoted 8 lines
Quoted 6 lines

struct net *rdma_dev_to_netns(struct ib_device *ib_dev)

{
            return read_pnet(&ib_dev->coredev.rdma_net);
}

Comments?

I suppose, but why would something need this?

Quoted 8 lines

If the client needs to allocate stuff for the namespace related to that device, it needs to know the namespace of that device. Then when that namespace is deleted, the client can clean up those related stuff as the client's namespace exit function can be called before the remove() function is triggered in rdma_dev_exit_net(). Without knowing the namespace of that device, coordination cannot be done.

Since each device can only be in one namespace, why would a client ever need to allocate at a level more granular than a device?

Quoted 7 lines
Quoted 5 lines

A client wants to have namespace specific info. If the device belongs to a namespace, it wants to associate those info with that device. When a namespace is deleted, the info will need to be deleted. You can consider the info as associated with both a namespace and a device.

Can you be more specific about which info you are talking about?

Actually, a lot of info can be both namespace and device specific. For example, a client wants to have a different PD allocation policy with a device when used in different namespaces.

Quoted 2 lines

And what is the client that is net namespace-aware from one side, but from another separate data between them "manually"?

Quoted 8 lines

Could you please elaborate what is meant by "namespace aware from one side but from another separate data between them manually"? I understand what namespace aware means. But it is not clear what is meant by "separating data manually". Do you mean having different behavior in different namespaces? If this is the case, there is nothing special here. An admin may choose to have different behavior in different namespaces. There is nothing manual going on in the client code.

We are talking about net-namespaces, and as we wrote above, the ib_device that supports such namespace can exist only in a single one

The client that implemented such support can check its namespace while "client->add" is called. It should be equal to be seen by ib_device.

See:

   rdma_dev_change_netns ->
   	enable_device_and_get ->
		add_client_context ->
			client->add(device)
Quoted 6 lines
Quoted 3 lines

This is the original question. How does the client's add() function know the namespace of device? What is your suggestion in finding the net namespace of device at add() time?

As I wrote above, "It should be equal to be seen by ib_device.", check net namespace of your client.

Could you please be more specific? A client calls ib_register_client() to register with the RDMA framework. Then when a device is added, the client's add() function is called with the struct ib_device. How does the client find out the namespace "seen by the ib_device"? Do you mean that there is a variant of ib_register_client() which can take a net namespace as parameter? Or is there a variant of struct ib_client which has a net namespace field? Or? Thanks.

Signature · 2 lines
K. Poon
[email protected]
#11 lore raw
Quoted 87 lines · Ka-Cheong Poon
Quoted 78 lines · Leon Romanovsky
Quoted 77 lines · Ka-Cheong Poon
Quoted 74 lines · Leon Romanovsky
Quoted 53 lines · Ka-Cheong Poon
Quoted 34 lines · Leon Romanovsky
Quoted 33 lines · Ka-Cheong Poon
Quoted 30 lines · Jason Gunthorpe
Quoted 18 lines · Ka-Cheong Poon
Quoted 7 lines · Jason Gunthorpe
Quoted 6 lines · Ka-Cheong Poon

When a struct ib_client's add() function is called. is there a supported method to find out the namespace of the passed in struct ib_device? There is rdma_dev_access_netns() but it does not return the namespace. It seems that it needs to have something like the following.

Quoted 8 lines
Quoted 6 lines

struct net *rdma_dev_to_netns(struct ib_device *ib_dev)

{
            return read_pnet(&ib_dev->coredev.rdma_net);
}

Comments?

I suppose, but why would something need this?

Quoted 8 lines

If the client needs to allocate stuff for the namespace related to that device, it needs to know the namespace of that device. Then when that namespace is deleted, the client can clean up those related stuff as the client's namespace exit function can be called before the remove() function is triggered in rdma_dev_exit_net(). Without knowing the namespace of that device, coordination cannot be done.

Since each device can only be in one namespace, why would a client ever need to allocate at a level more granular than a device?

Quoted 7 lines
Quoted 5 lines

A client wants to have namespace specific info. If the device belongs to a namespace, it wants to associate those info with that device. When a namespace is deleted, the info will need to be deleted. You can consider the info as associated with both a namespace and a device.

Can you be more specific about which info you are talking about?

Actually, a lot of info can be both namespace and device specific. For example, a client wants to have a different PD allocation policy with a device when used in different namespaces.

Quoted 2 lines

And what is the client that is net namespace-aware from one side, but from another separate data between them "manually"?

Quoted 8 lines

Could you please elaborate what is meant by "namespace aware from one side but from another separate data between them manually"? I understand what namespace aware means. But it is not clear what is meant by "separating data manually". Do you mean having different behavior in different namespaces? If this is the case, there is nothing special here. An admin may choose to have different behavior in different namespaces. There is nothing manual going on in the client code.

We are talking about net-namespaces, and as we wrote above, the ib_device that supports such namespace can exist only in a single one

The client that implemented such support can check its namespace while "client->add" is called. It should be equal to be seen by ib_device.

See:

   rdma_dev_change_netns ->
   	enable_device_and_get ->
		add_client_context ->
			client->add(device)
Quoted 6 lines
Quoted 3 lines

This is the original question. How does the client's add() function know the namespace of device? What is your suggestion in finding the net namespace of device at add() time?

As I wrote above, "It should be equal to be seen by ib_device.", check net namespace of your client.

Quoted 7 lines

Could you please be more specific? A client calls ib_register_client() to register with the RDMA framework. Then when a device is added, the client's add() function is called with the struct ib_device. How does the client find out the namespace "seen by the ib_device"? Do you mean that there is a variant of ib_register_client() which can take a net namespace as parameter? Or is there a variant of struct ib_client which has a net namespace field? Or? Thanks.

"Do you mean that there is a variant of ib_register_client() which can take a net namespace as parameter?"

No, it doesn't exist but it is easy to extend and IMHO the right thing to do.

Thanks

#12 lore raw
Quoted 96 lines · Leon Romanovsky
Quoted 87 lines · Ka-Cheong Poon
Quoted 78 lines · Leon Romanovsky
Quoted 77 lines · Ka-Cheong Poon
Quoted 74 lines · Leon Romanovsky
Quoted 53 lines · Ka-Cheong Poon
Quoted 34 lines · Leon Romanovsky
Quoted 33 lines · Ka-Cheong Poon
Quoted 30 lines · Jason Gunthorpe
Quoted 18 lines · Ka-Cheong Poon
Quoted 7 lines · Jason Gunthorpe
Quoted 6 lines · Ka-Cheong Poon

When a struct ib_client's add() function is called. is there a supported method to find out the namespace of the passed in struct ib_device? There is rdma_dev_access_netns() but it does not return the namespace. It seems that it needs to have something like the following.

Quoted 8 lines
Quoted 6 lines

struct net *rdma_dev_to_netns(struct ib_device *ib_dev)

{
             return read_pnet(&ib_dev->coredev.rdma_net);
}

Comments?

I suppose, but why would something need this?

Quoted 8 lines

If the client needs to allocate stuff for the namespace related to that device, it needs to know the namespace of that device. Then when that namespace is deleted, the client can clean up those related stuff as the client's namespace exit function can be called before the remove() function is triggered in rdma_dev_exit_net(). Without knowing the namespace of that device, coordination cannot be done.

Since each device can only be in one namespace, why would a client ever need to allocate at a level more granular than a device?

Quoted 7 lines
Quoted 5 lines

A client wants to have namespace specific info. If the device belongs to a namespace, it wants to associate those info with that device. When a namespace is deleted, the info will need to be deleted. You can consider the info as associated with both a namespace and a device.

Can you be more specific about which info you are talking about?

Actually, a lot of info can be both namespace and device specific. For example, a client wants to have a different PD allocation policy with a device when used in different namespaces.

Quoted 2 lines

And what is the client that is net namespace-aware from one side, but from another separate data between them "manually"?

Quoted 8 lines

Could you please elaborate what is meant by "namespace aware from one side but from another separate data between them manually"? I understand what namespace aware means. But it is not clear what is meant by "separating data manually". Do you mean having different behavior in different namespaces? If this is the case, there is nothing special here. An admin may choose to have different behavior in different namespaces. There is nothing manual going on in the client code.

We are talking about net-namespaces, and as we wrote above, the ib_device that supports such namespace can exist only in a single one

The client that implemented such support can check its namespace while "client->add" is called. It should be equal to be seen by ib_device.

See:

    rdma_dev_change_netns ->
    	enable_device_and_get ->
		add_client_context ->
			client->add(device)
Quoted 6 lines
Quoted 3 lines

This is the original question. How does the client's add() function know the namespace of device? What is your suggestion in finding the net namespace of device at add() time?

As I wrote above, "It should be equal to be seen by ib_device.", check net namespace of your client.

Quoted 7 lines

Could you please be more specific? A client calls ib_register_client() to register with the RDMA framework. Then when a device is added, the client's add() function is called with the struct ib_device. How does the client find out the namespace "seen by the ib_device"? Do you mean that there is a variant of ib_register_client() which can take a net namespace as parameter? Or is there a variant of struct ib_client which has a net namespace field? Or? Thanks.

Quoted 5 lines

"Do you mean that there is a variant of ib_register_client() which can take a net namespace as parameter?"

No, it doesn't exist but it is easy to extend and IMHO the right thing to do.

This may require a number of changes and the way a client interacts with the current RDMA framework. For example, currently a client registers once using one struct ib_client and gets device notifications for all namespaces and devices. Suppose there is rdma_[un]register_net_client(), it may need to require a client to use a different struct ib_client to register for each net namespace. And struct ib_client probably needs to have a field to store the net namespace. Probably all those client interaction functions will need to be modified. Since the clients xarray is global, more clients may mean performance implication, such as it takes longer to go through the whole clients xarray.

There are probably many other subtle changes required. It may turn out to be not so straight forward. Is this community willing the take such changes? I can take a stab at it if the community really thinks that this is preferred.

Thanks.

Signature · 2 lines
K. Poon
[email protected]
#13 lore raw

RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 11 lines · Ka-Cheong Poon

This may require a number of changes and the way a client interacts with the current RDMA framework.  For example, currently a client registers once using one struct ib_client and gets device notifications for all namespaces and devices.  Suppose there is rdma_[un]register_net_client(), it may need to require a client to use a different struct ib_client to register for each net namespace.  And struct ib_client probably needs to have a field to store the net namespace.  Probably all those client interaction functions will need to be modified.  Since the clients xarray is global, more clients may mean performance implication, such as it takes longer to go through the whole clients xarray.

Quoted 3 lines

There are probably many other subtle changes required.  It may turn out to be not so straight forward.  Is this community willing the take such changes? I can take a stab at it if the community really thinks that this is preferred.

Attached is a diff of a prototype for the above. This exercise is to see what needs to be done to have a more network namespace aware interface for RDMA client registration.

Currently, there are ib_[un]register_client(). Under the RDMA namespace exclusive mode, all RDMA devices are assigned to the init_net namespace initially. A kernel module uses this interface to register with the RDMA subsystem. When a device is assigned to a namespace, the client's registered remove upcall is called with the device as the parameter (this is removing from the init_net namespace). Then the client's add upcall is called with the device as the parameter (this is assigning to the new namespace). When that namespace is removed (*), a similar sequence of events happen, a remove upcall (removing from the namespace) is followed by add upcall (assigning back to the init_net namespace). All the RDMA clients are stored in a global struct xarray called clients (in device.c) and each client is assigned a client ID.

This exercise adds the rdma_[un]register_net_client() for those clients which want to have more separation between different namespaces. This interface takes a struct net parameter. A kernel module uses this to indicate that it is only interested in the RDMA events related to the given network namespace. Suppose a client uses init_net as the parameter. In the above example when a device is assigned to a namespace, only the client's remove upcall is called (removing from the init_net namespace). The add upcall is not followed. Then when the namespace is removed, the client's add upcall is called (re-assigning back to the init_net namespace). Suppose a client uses a specific namespace as the parameter. When a device is assigned to that specific namespace, the client's add upcall is called. When the client unregisters with RDMA (or when the namespace is going away), the client's remove upcall is called. The RDMA clients are stored in each namespace's struct rdma_dev_net and each client is assigned a client ID in that namespace (this means that it is unique only in that namespace but not unique globally among all namespaces).

This seemingly simple exercise turned out to be not so simple because of the need to keep the existing interface with the existing behavior. So only when a client uses the new interface, the behavior is changed to what is described above. There should be no change of behavior to any existing RDMA client. There are several obstacles to overcome for this change. One difficulty is the global client ID since a lot of code rely on this ID as an index the both the global clients xarray and individual device's client_data xarray. Detailed changes are in the attached diff if folks are interested.

Note that the new interface has one obvious issue, it does not make much sense in RDMA shared network namespace mode. In the shared mode, all devices are associated with init_net. So if a client uses the new interface to register a specific namespace other than init_net, it will never get any upcall. This and the difficulties in adding a seemingly simple interface makes me wonder about the following questions.

Is the RDMA shared namespace mode the preferred mode to use as it is the default mode? Is it expected that a client knows the running mode before interacting with the RDMA subsystem? Is a client not supposed to differentiate different namespaces? Besides the current add client upcall, another example related to this is about event handling. Suppose a client calls rdma_create_id() to create listeners in different namespaces but with the same event handler. A new connection comes in and the event handler is called for an RDMA_CM_EVENT_CONNECT_REQUEST event. There is no obvious namespace info regarding the event. It seems that the only way to find out the namespace info is to use the context of struct rdma_cm_id. The client must somehow add the namespace info to the context since the subsystem does not provide any help. Is this the assumed solution? BTW, this exercise still does not remove the need to have rdma_dev_to_netns() as the add upcall does not provide any namespace info. Given all these questions, the rdma_[un]register_net_client() do not seem to fit in the current way in interacting with the RDMA subsystem unfortunately.

Thanks.

(*) Note that in __rdma_create_id(), it does a get_net(net) to put a
reference on a namespace. Suppose a kernel module calls rdma_create_id() in its namespace .init function to create an RDMA listener and calls rdma_destroy_id() in its namespace .exit function to destroy it. Since __rdma_create_id() adds a reference to a namespace, when a sys admin deletes a namespace (say ip netns del ...), the namespace won't be deleted because of this reference. And the module will not release this reference until its .exit function is called only when the namespace is deleted. To resolve this issue, in the diff (in __rdma_create_id()), I did something similar to the kern check in sk_alloc().

Signature · 2 lines
K. Poon
[email protected]
drivers/infiniband/core/cma.c +10 -2
index 7f0e91e92968..15eb91eee200 100644
@@ -873,7 +873,10 @@ struct rdma_cm_id *__rdma_create_id(struct net *net,
 	INIT_LIST_HEAD(&id_priv->listen_list);
 	INIT_LIST_HEAD(&id_priv->mc_list);
 	get_random_bytes(&id_priv->seq_num, sizeof id_priv->seq_num);
-	id_priv->id.route.addr.dev_addr.net = get_net(net);
+	if (caller)
+		id_priv->id.route.addr.dev_addr.net = net;
+	else
+		id_priv->id.route.addr.dev_addr.net = get_net(net);
 	id_priv->seq_num &= 0x00ffffff;
 
 	return &id_priv->id;
@@ -1819,8 +1822,12 @@ static void cma_leave_mc_groups(struct rdma_id_private *id_priv)
 static void _destroy_id(struct rdma_id_private *id_priv,
 			enum rdma_cm_state state)
 {
+	bool rel_net = true;
+
 	cma_cancel_operation(id_priv, state);
 
+	if (id_priv->res.kern_name)
+		rel_net = false;
 	rdma_restrack_del(&id_priv->res);
 	if (id_priv->cma_dev) {
 		if (rdma_cap_ib_cm(id_priv->id.device, 1)) {
@@ -1846,7 +1853,8 @@ static void _destroy_id(struct rdma_id_private *id_priv,
 	if (id_priv->id.route.addr.dev_addr.sgid_attr)
 		rdma_put_gid_attr(id_priv->id.route.addr.dev_addr.sgid_attr);
 
-	put_net(id_priv->id.route.addr.dev_addr.net);
+	if (rel_net)
+		put_net(id_priv->id.route.addr.dev_addr.net);
 	kfree(id_priv);
 }
 
drivers/infiniband/core/core_priv.h +5 -0
index a1e6a67b2c4a..3c6c3cd516f3 100644
@@ -66,6 +66,11 @@ struct rdma_dev_net {
 	struct sock *nl_sock;
 	possible_net_t net;
 	u32 id;
+
+	u32			rdn_highest_client_id;
+	struct xarray		rdn_clients;
+	struct rw_semaphore	rdn_clients_rwsem;
+
 };
 
 extern const struct attribute_group ib_dev_attr_group;
drivers/infiniband/core/device.c +248 -67

614 lines not on this page · raw message

include/rdma/ib_verbs.h +11 -1
index c0b2fa7e9b95..1f3f497a870a 100644
@@ -2729,6 +2729,9 @@ struct ib_device {
 	char iw_ifname[IFNAMSIZ];
 	u32 iw_driver_flags;
 	u32 lag_flags;
+
+	/* Also protected by client_data_rwsem */
+	struct xarray			net_client_data;
 };
 
 struct ib_client_nl_info;
@@ -2770,6 +2773,7 @@ struct ib_client {
 
 	/* kverbs are not required by the client */
 	u8 no_kverbs_req:1;
+	u8 net_client:1;
 };
 
 /*
@@ -2807,6 +2811,9 @@ void ib_unregister_device_queued(struct ib_device *ib_dev);
 int ib_register_client   (struct ib_client *client);
 void ib_unregister_client(struct ib_client *client);
 
+int rdma_register_net_client(struct net *net, struct ib_client *client);
+void rdma_unregister_net_client(struct net *net, struct ib_client *client);
+
 void __rdma_block_iter_start(struct ib_block_iter *biter,
 			     struct scatterlist *sglist,
 			     unsigned int nents,
@@ -2852,7 +2859,10 @@ rdma_block_iter_dma_address(struct ib_block_iter *biter)
 static inline void *ib_get_client_data(struct ib_device *device,
 				       struct ib_client *client)
 {
-	return xa_load(&device->client_data, client->client_id);
+	if (client->net_client) 
+		return xa_load(&device->net_client_data, client->client_id);
+	else
+		return xa_load(&device->client_data, client->client_id);
 }
 void  ib_set_client_data(struct ib_device *device, struct ib_client *client,
 			 void *data);
#14 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 13 lines · Ka-Cheong Poon
Quoted 11 lines · Ka-Cheong Poon

This may require a number of changes and the way a client interacts with the current RDMA framework.  For example, currently a client registers once using one struct ib_client and gets device notifications for all namespaces and devices.  Suppose there is rdma_[un]register_net_client(), it may need to require a client to use a different struct ib_client to register for each net namespace.  And struct ib_client probably needs to have a field to store the net namespace.  Probably all those client interaction functions will need to be modified.  Since the clients xarray is global, more clients may mean performance implication, such as it takes longer to go through the whole clients xarray.

Quoted 8 lines
Quoted 3 lines

There are probably many other subtle changes required.  It may turn out to be not so straight forward.  Is this community willing the take such changes? I can take a stab at it if the community really thinks that this is preferred.

Attached is a diff of a prototype for the above. This exercise is to see what needs to be done to have a more network namespace aware interface for RDMA client registration.

An RDMA device is either in all namespaces or in a single namespace. If a client has some interest in only some namespaces then it should check the namespace during client registration and not register if it isn't interested. No need to change anything in the core code.

Quoted 2 lines

Is the RDMA shared namespace mode the preferred mode to use as it is the default mode?

Shared is the legacy mode, modern systems should switch to namespace mode at early boot

Quoted 2 lines

Is it expected that a client knows the running mode before interacting with the RDMA subsystem?

Why would a client care?

Quoted 1 line

Is a client not supposed to differentiate different namespaces?

None do today.

Quoted 4 lines

A new connection comes in and the event handler is called for an RDMA_CM_EVENT_CONNECT_REQUEST event. There is no obvious namespace info regarding the event. It seems that the only way to find out the namespace info is to use the context of struct rdma_cm_id.

The rdma_cm_id has only a single namespace, the ULP knows what it is because it created it. A listening ID can't spawn new IDs in different namespaces.

Quoted 4 lines

(*) Note that in __rdma_create_id(), it does a get_net(net) to put a
reference on a namespace. Suppose a kernel module calls rdma_create_id() in its namespace .init function to create an RDMA listener and calls rdma_destroy_id() in its namespace .exit function to destroy it.

Yes, namespaces remain until all objects touching them are deleted.

It seems like a ULP error to drive cm_id lifetime entirely from the per-net stuff.

This would be similar to creating a socket in the kernel.

Quoted 6 lines

__rdma_create_id() adds a reference to a namespace, when a sys admin deletes a namespace (say ip netns del ...), the namespace won't be deleted because of this reference. And the module will not release this reference until its .exit function is called only when the namespace is deleted. To resolve this issue, in the diff (in __rdma_create_id()), I did something similar to the kern check in sk_alloc().

What you are running into is there is no kernel user of net namespaces, all current ULPs exclusively use the init_net.

Without an example of what that is supposed to be like it is hard to really have a discussion. You should reference other TCP in the kernel to see if someone has figured out how to make this work for TCP. It should be basically the same.

Jason

#15 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 23 lines · Jason Gunthorpe
Quoted 13 lines · Ka-Cheong Poon
Quoted 11 lines · Ka-Cheong Poon

This may require a number of changes and the way a client interacts with the current RDMA framework.  For example, currently a client registers once using one struct ib_client and gets device notifications for all namespaces and devices.  Suppose there is rdma_[un]register_net_client(), it may need to require a client to use a different struct ib_client to register for each net namespace.  And struct ib_client probably needs to have a field to store the net namespace.  Probably all those client interaction functions will need to be modified.  Since the clients xarray is global, more clients may mean performance implication, such as it takes longer to go through the whole clients xarray.

Quoted 8 lines
Quoted 3 lines

There are probably many other subtle changes required.  It may turn out to be not so straight forward.  Is this community willing the take such changes? I can take a stab at it if the community really thinks that this is preferred.

Attached is a diff of a prototype for the above. This exercise is to see what needs to be done to have a more network namespace aware interface for RDMA client registration.

Quoted 5 lines

An RDMA device is either in all namespaces or in a single namespace. If a client has some interest in only some namespaces then it should check the namespace during client registration and not register if it isn't interested. No need to change anything in the core code.

After the aforementioned check on a namespace, what can the client do? It still needs to use the existing ib_register_client() to register with RDMA subsystem. And after registration, it will get notifications for all add/remove upcalls on devices not related to the namespace it is interested in. The client can work around this if there is a supported way to find out the namespace of a device, hence the original proposal of having rdma_dev_to_netns().

Quoted 5 lines
Quoted 2 lines

Is the RDMA shared namespace mode the preferred mode to use as it is the default mode?

Shared is the legacy mode, modern systems should switch to namespace mode at early boot

Thanks for the clarification. I originally thought that the shared mode was for supporting a large number of namespaces. In the exclusive mode, a device needs to be assigned to a namespace for that namespace to use it. If there are a large number of namespaces, there won't be enough devices to assign to all of them (e.g. the hardware I have access to only supports up to 24 VFs). The shared mode can be used in this case. Could you please explain what needs to be done to support a large number of namespaces in exclusive mode?

BTW, if exclusive mode is the future, it may make sense to have something like rdma_[un]register_net_client().

Quoted 4 lines
Quoted 2 lines

Is it expected that a client knows the running mode before interacting with the RDMA subsystem?

Why would a client care?

Because it may want to behave differently. For example, in shared mode, it may want to create shadow device structure to hold per namespace info for a device. But in exclusive mode, a device can only be in one namespace, there is no need to have such shadow device structure.

Quoted 3 lines
Quoted 1 line

Is a client not supposed to differentiate different namespaces?

None do today.

This is probably the case as calling rdma_create_id() in kernel can disallow a namespace to be deleted. There must be no client doing that right now. My code is using RDMA in a namespace, hence I'd like to understand more about the RDMA subsystem's namespace support. For example, what is the reason that the cma_wq is a global queue shared by all namespaces instead of per namespace? Is it expected that the work load will be low enough for all namespaces such that they will not interfere with each other?

Quoted 8 lines
Quoted 4 lines

A new connection comes in and the event handler is called for an RDMA_CM_EVENT_CONNECT_REQUEST event. There is no obvious namespace info regarding the event. It seems that the only way to find out the namespace info is to use the context of struct rdma_cm_id.

The rdma_cm_id has only a single namespace, the ULP knows what it is because it created it. A listening ID can't spawn new IDs in different namespaces.

The problem is that the handler is not given the listener's rdma_cm_id when it is called. It is only given the new rdma_cm_id. Do you mean that there is a way to find out the listener's rdma_cm_id given the new rdma_cm_id? But even if the listener's rdma_cm_id can be found, what is the mechanism to find out the namespace of that listener's namespace in the handler? The client may compare that pointer with every listeners it creates. Is there a better way?

Quoted 9 lines
Quoted 4 lines

(*) Note that in __rdma_create_id(), it does a get_net(net) to put a
reference on a namespace. Suppose a kernel module calls rdma_create_id() in its namespace .init function to create an RDMA listener and calls rdma_destroy_id() in its namespace .exit function to destroy it.

Yes, namespaces remain until all objects touching them are deleted.

It seems like a ULP error to drive cm_id lifetime entirely from the per-net stuff.

It is not an ULP error. While there are many reasons to delete a listener, it is not necessary for the listener to die unless the namespace is going away.

Quoted 1 line

This would be similar to creating a socket in the kernel.

Right and a kernel socket does not prevent a namespace to be deleted.

Quoted 7 lines
Quoted 6 lines

__rdma_create_id() adds a reference to a namespace, when a sys admin deletes a namespace (say ip netns del ...), the namespace won't be deleted because of this reference. And the module will not release this reference until its .exit function is called only when the namespace is deleted. To resolve this issue, in the diff (in __rdma_create_id()), I did something similar to the kern check in sk_alloc().

Quoted 7 lines

What you are running into is there is no kernel user of net namespaces, all current ULPs exclusively use the init_net.

Without an example of what that is supposed to be like it is hard to really have a discussion. You should reference other TCP in the kernel to see if someone has figured out how to make this work for TCP. It should be basically the same.

The kern check in sk_alloc() decides whether to hold a reference on the namespace. What is in the diff follows the same mechanism.

Signature · 2 lines
K. Poon
[email protected]
#16 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 7 lines · Ka-Cheong Poon

After the aforementioned check on a namespace, what can the client do? It still needs to use the existing ib_register_client() to register with RDMA subsystem. And after registration, it will get notifications for all add/remove upcalls on devices not related to the namespace it is interested in. The client can work around this if there is a supported way to find out the namespace of a device, hence the original proposal of having rdma_dev_to_netns().

Yes, the client would have to check the netns and abort client registration.

Arguably many of our current clients are wrong in this area since they only work on init_net anyhow.

It would make sense to introduce a rdma_dev_to_netns() and use it to block clients on ULPs that use the CM outside init_net.

Quoted 6 lines

that namespace to use it. If there are a large number of namespaces, there won't be enough devices to assign to all of them (e.g. the hardware I have access to only supports up to 24 VFs). The shared mode can be used in this case. Could you please explain what needs to be done to support a large number of namespaces in exclusive mode?

Modern HW supports many more than 24 VFs, this is the expected interface

Quoted 2 lines

BTW, if exclusive mode is the future, it may make sense to have something like rdma_[un]register_net_client().

I don't think we need this

Quoted 11 lines
Quoted 8 lines
Quoted 4 lines

A new connection comes in and the event handler is called for an RDMA_CM_EVENT_CONNECT_REQUEST event. There is no obvious namespace info regarding the event. It seems that the only way to find out the namespace info is to use the context of struct rdma_cm_id.

The rdma_cm_id has only a single namespace, the ULP knows what it is because it created it. A listening ID can't spawn new IDs in different namespaces.

The problem is that the handler is not given the listener's rdma_cm_id when it is called. It is only given the new rdma_cm_id.

The new cm_id starts with the same ->context as the listener, the ULP should use this to pass any data, such as the namespace.

Quoted 6 lines
Quoted 2 lines

It seems like a ULP error to drive cm_id lifetime entirely from the per-net stuff.

It is not an ULP error. While there are many reasons to delete a listener, it is not necessary for the listener to die unless the namespace is going away.

It certainly currently is.

I'm skeptical ULPs should be doing per-ns stuff like that. A ns aware ULP should fundamentally be linked to some FD and the ns to use should derived from the process that FD is linked to. Keeping per-ns stuff seems wrong.

Jason

#17 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 9 lines · Jason Gunthorpe
Quoted 7 lines · Ka-Cheong Poon

After the aforementioned check on a namespace, what can the client do? It still needs to use the existing ib_register_client() to register with RDMA subsystem. And after registration, it will get notifications for all add/remove upcalls on devices not related to the namespace it is interested in. The client can work around this if there is a supported way to find out the namespace of a device, hence the original proposal of having rdma_dev_to_netns().

Quoted 8 lines

Yes, the client would have to check the netns and abort client registration.

Arguably many of our current clients are wrong in this area since they only work on init_net anyhow.

It would make sense to introduce a rdma_dev_to_netns() and use it to block clients on ULPs that use the CM outside init_net.

Will send a simple patch for this.

Quoted 9 lines
Quoted 6 lines

that namespace to use it. If there are a large number of namespaces, there won't be enough devices to assign to all of them (e.g. the hardware I have access to only supports up to 24 VFs). The shared mode can be used in this case. Could you please explain what needs to be done to support a large number of namespaces in exclusive mode?

Modern HW supports many more than 24 VFs, this is the expected interface

Do you have a ballpark on how many VFs are supported? Is it in the range of many thousands?

BTW, while the shared mode is still here, can there be a simple way for a client to find out which mode the RDMA subsystem is using?

Quoted 14 lines
Quoted 2 lines

BTW, if exclusive mode is the future, it may make sense to have something like rdma_[un]register_net_client().

I don't think we need this

Quoted 9 lines
Quoted 8 lines
Quoted 4 lines

A new connection comes in and the event handler is called for an RDMA_CM_EVENT_CONNECT_REQUEST event. There is no obvious namespace info regarding the event. It seems that the only way to find out the namespace info is to use the context of struct rdma_cm_id.

The rdma_cm_id has only a single namespace, the ULP knows what it is because it created it. A listening ID can't spawn new IDs in different namespaces.

Quoted 5 lines
Quoted 2 lines

The problem is that the handler is not given the listener's rdma_cm_id when it is called. It is only given the new rdma_cm_id.

The new cm_id starts with the same ->context as the listener, the ULP should use this to pass any data, such as the namespace.

This is what I suspected as mentioned in the previous email. But this makes it inconvenient if the context is already used for something else.

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

It seems like a ULP error to drive cm_id lifetime entirely from the per-net stuff.

It is not an ULP error. While there are many reasons to delete a listener, it is not necessary for the listener to die unless the namespace is going away.

Quoted 6 lines

It certainly currently is.

I'm skeptical ULPs should be doing per-ns stuff like that. A ns aware ULP should fundamentally be linked to some FD and the ns to use should derived from the process that FD is linked to. Keeping per-ns stuff seems wrong.

It is a kernel module. Which FD are you referring to? It is unclear why a kernel module must associate itself with a user space FD. Is there a particular reason that rdma_create_id() needs to behave differently than sock_create_kern() in this regard?

While discussing about per namespace stuff, what is the reason that the cma_wq is a global shared by all namespaces instead of per namespace? Is there a problem to have a per namespace cma_wq?

Signature · 2 lines
K. Poon
[email protected]
#18 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 8 lines · Ka-Cheong Poon
Quoted 7 lines · Jason Gunthorpe
Quoted 6 lines

that namespace to use it. If there are a large number of namespaces, there won't be enough devices to assign to all of them (e.g. the hardware I have access to only supports up to 24 VFs). The shared mode can be used in this case. Could you please explain what needs to be done to support a large number of namespaces in exclusive mode?

Quoted 5 lines
Quoted 2 lines

Modern HW supports many more than 24 VFs, this is the expected interface

Do you have a ballpark on how many VFs are supported? Is it in the range of many thousands?

Yes

Quoted 2 lines

BTW, while the shared mode is still here, can there be a simple way for a client to find out which mode the RDMA subsystem is using?

Return NULL for the namespace

Quoted 6 lines
Quoted 2 lines

The new cm_id starts with the same ->context as the listener, the ULP should use this to pass any data, such as the namespace.

This is what I suspected as mentioned in the previous email. But this makes it inconvenient if the context is already used for something else.

Don't see why. the context should be allocated memory, so the ULP can put several things lin there.

Quoted 11 lines
Quoted 4 lines

I'm skeptical ULPs should be doing per-ns stuff like that. A ns aware ULP should fundamentally be linked to some FD and the ns to use should derived from the process that FD is linked to. Keeping per-ns stuff seems wrong.

It is a kernel module. Which FD are you referring to? It is unclear why a kernel module must associate itself with a user space FD. Is there a particular reason that rdma_create_id() needs to behave differently than sock_create_kern() in this regard?

Somehow the kernel module has to be commanded to use this namespace, and generally I expect that command to be connected to FD.

We don't have many use cases where the kernel operates namespaces independently..

Quoted 3 lines

While discussing about per namespace stuff, what is the reason that the cma_wq is a global shared by all namespaces instead of per namespace? Is there a problem to have a per namespace cma_wq?

Why would we want to do that?

Jason

#19 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 15 lines · Jason Gunthorpe
Quoted 8 lines · Ka-Cheong Poon
Quoted 7 lines · Jason Gunthorpe
Quoted 6 lines

that namespace to use it. If there are a large number of namespaces, there won't be enough devices to assign to all of them (e.g. the hardware I have access to only supports up to 24 VFs). The shared mode can be used in this case. Could you please explain what needs to be done to support a large number of namespaces in exclusive mode?

Quoted 5 lines
Quoted 2 lines

Modern HW supports many more than 24 VFs, this is the expected interface

Do you have a ballpark on how many VFs are supported? Is it in the range of many thousands?

Quoted 6 lines

Yes

Quoted 2 lines

BTW, while the shared mode is still here, can there be a simple way for a client to find out which mode the RDMA subsystem is using?

Return NULL for the namespace

OK, will add that to rdma_dev_to_netns().

Quoted 16 lines
Quoted 6 lines
Quoted 2 lines

The new cm_id starts with the same ->context as the listener, the ULP should use this to pass any data, such as the namespace.

This is what I suspected as mentioned in the previous email. But this makes it inconvenient if the context is already used for something else.

Don't see why. the context should be allocated memory, so the ULP can put several things lin there.

Quoted 6 lines
Quoted 4 lines

I'm skeptical ULPs should be doing per-ns stuff like that. A ns aware ULP should fundamentally be linked to some FD and the ns to use should derived from the process that FD is linked to. Keeping per-ns stuff seems wrong.

Quoted 8 lines
Quoted 5 lines

It is a kernel module. Which FD are you referring to? It is unclear why a kernel module must associate itself with a user space FD. Is there a particular reason that rdma_create_id() needs to behave differently than sock_create_kern() in this regard?

Somehow the kernel module has to be commanded to use this namespace, and generally I expect that command to be connected to FD.

It is an unnecessary restriction on what a kernel module can do. Is it a problem if a kernel module initiates its own RDMA connection for doing various stuff in a namespace? Any kernel module can initiate a TCP connection to do various stuff without worrying about namespace deletion problem. It does not cause a problem AFAICT. If the module needs to make sure that the namespace does not go away, it can add its own reference. Is there a particular reason that RDMA subsystem needs to behave differently?

Quoted 2 lines

We don't have many use cases where the kernel operates namespaces independently..

FWIW, I am adding code to do that. It works fine using TCP kernel socket. It has the namespace deletion problem with RDMA connection.

Quoted 5 lines
Quoted 3 lines

While discussing about per namespace stuff, what is the reason that the cma_wq is a global shared by all namespaces instead of per namespace? Is there a problem to have a per namespace cma_wq?

Why would we want to do that?

For scalability and namespace separation reasons as cma_wq is single threaded. For example, there can be many work to be done in one namespace. But this should not have an adverse effect on other namespaces (as long as there are resources available).

Signature · 2 lines
K. Poon
[email protected]
#20 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 6 lines · Ka-Cheong Poon
Quoted 6 lines
Quoted 5 lines

It is a kernel module. Which FD are you referring to? It is unclear why a kernel module must associate itself with a user space FD. Is there a particular reason that rdma_create_id() needs to behave differently than sock_create_kern() in this regard?

Quoted 7 lines
Quoted 2 lines

Somehow the kernel module has to be commanded to use this namespace, and generally I expect that command to be connected to FD.

It is an unnecessary restriction on what a kernel module can do. Is it a problem if a kernel module initiates its own RDMA connection for doing various stuff in a namespace?

Yes, someone has to apply policy to authorize this. Kernel modules randomly running around using security objects is not OK.

Kernel modules should not be doing networking unless commanded to by userspace.

Quoted 6 lines

Any kernel module can initiate a TCP connection to do various stuff without worrying about namespace deletion problem. It does not cause a problem AFAICT. If the module needs to make sure that the namespace does not go away, it can add its own reference. Is there a particular reason that RDMA subsystem needs to behave differently?

We don't have those kinds of ULPs.

Quoted 4 lines

For scalability and namespace separation reasons as cma_wq is single threaded. For example, there can be many work to be done in one namespace. But this should not have an adverse effect on other namespaces (as long as there are resources available).

This is a design issue of the cma_wq, it can be reworked to not need single threaded, nothing to do with namespaces

Jason

#21 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 11 lines · Jason Gunthorpe
Quoted 10 lines · Ka-Cheong Poon
Quoted 8 lines
Quoted 5 lines

It is a kernel module. Which FD are you referring to? It is unclear why a kernel module must associate itself with a user space FD. Is there a particular reason that rdma_create_id() needs to behave differently than sock_create_kern() in this regard?

Somehow the kernel module has to be commanded to use this namespace, and generally I expect that command to be connected to FD.

Quoted 6 lines
Quoted 3 lines

It is an unnecessary restriction on what a kernel module can do. Is it a problem if a kernel module initiates its own RDMA connection for doing various stuff in a namespace?

Yes, someone has to apply policy to authorize this. Kernel modules randomly running around using security objects is not OK.

The policy is to allow this. It is not random stuff. Can the RDMA subsystem support it?

Quoted 2 lines

Kernel modules should not be doing networking unless commanded to by userspace.

It is still not clear why this is an issue with RDMA connection, but not with general kernel socket. It is not random networking. There is a purpose.

Quoted 8 lines
Quoted 6 lines

Any kernel module can initiate a TCP connection to do various stuff without worrying about namespace deletion problem. It does not cause a problem AFAICT. If the module needs to make sure that the namespace does not go away, it can add its own reference. Is there a particular reason that RDMA subsystem needs to behave differently?

We don't have those kinds of ULPs.

So if the reason of the current rdma_create_id() behavior is that there is no such user, I am adding one. It should be clear that this difference between kernel socket and rdma_create_id() causes a problem in namespace handling.

Quoted 7 lines
Quoted 4 lines

For scalability and namespace separation reasons as cma_wq is single threaded. For example, there can be many work to be done in one namespace. But this should not have an adverse effect on other namespaces (as long as there are resources available).

This is a design issue of the cma_wq, it can be reworked to not need single threaded, nothing to do with namespaces

As mentioned, there are at least two parts. The above is on scalability. There is also the namespace separation reason. The goal is to make sure that processing of one namespace should not have unwanted (positive nor negative) effect on processing of other namespaces. If the cma_wq is re-designed, number of namespaces should be one input parameter on creating how many threads and other resources allocation/scheduling. One cma_wq per namespace is the simplest allocation.

Signature · 2 lines
K. Poon
[email protected]
#22 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 16 lines · Ka-Cheong Poon
Quoted 15 lines · Jason Gunthorpe
Quoted 13 lines · Ka-Cheong Poon
Quoted 8 lines
Quoted 5 lines

It is a kernel module. Which FD are you referring to? It is unclear why a kernel module must associate itself with a user space FD. Is there a particular reason that rdma_create_id() needs to behave differently than sock_create_kern() in this regard?

Somehow the kernel module has to be commanded to use this namespace, and generally I expect that command to be connected to FD.

It is an unnecessary restriction on what a kernel module can do. Is it a problem if a kernel module initiates its own RDMA connection for doing various stuff in a namespace?

Quoted 5 lines
Quoted 2 lines

Yes, someone has to apply policy to authorize this. Kernel modules randomly running around using security objects is not OK.

The policy is to allow this. It is not random stuff. Can the RDMA subsystem support it?

allow everything is not a policy

Quoted 6 lines
Quoted 2 lines

Kernel modules should not be doing networking unless commanded to by userspace.

It is still not clear why this is an issue with RDMA connection, but not with general kernel socket. It is not random networking. There is a purpose.

It is a problem with sockets too, how do the socket users trigger their socket usages? AFAIK all cases originate with userspace

Quoted 4 lines

So if the reason of the current rdma_create_id() behavior is that there is no such user, I am adding one. It should be clear that this difference between kernel socket and rdma_create_id() causes a problem in namespace handling.

It would be helpful to understand how that works, as I've said I don't think a kernel module should open listening sockets/cm_ids on every namespace without being told to do this.

Quoted 4 lines

If the cma_wq is re-designed, number of namespaces should be one input parameter on creating how many threads and other resources allocation/scheduling. One cma_wq per namespace is the simplest allocation.

no, it will just run all CM_IDs concurrently on all processors.

Namespaces are not cgroups, we don't guarentee anything about resource consumption for namespaces.

Jason

#23 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 17 lines · Jason Gunthorpe
Quoted 16 lines · Ka-Cheong Poon
Quoted 15 lines · Jason Gunthorpe
Quoted 13 lines · Ka-Cheong Poon
Quoted 8 lines
Quoted 5 lines

It is a kernel module. Which FD are you referring to? It is unclear why a kernel module must associate itself with a user space FD. Is there a particular reason that rdma_create_id() needs to behave differently than sock_create_kern() in this regard?

Somehow the kernel module has to be commanded to use this namespace, and generally I expect that command to be connected to FD.

It is an unnecessary restriction on what a kernel module can do. Is it a problem if a kernel module initiates its own RDMA connection for doing various stuff in a namespace?

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Yes, someone has to apply policy to authorize this. Kernel modules randomly running around using security objects is not OK.

The policy is to allow this. It is not random stuff. Can the RDMA subsystem support it?

allow everything is not a policy

It is not allowing everything. It is the simple case that a kernel module can have a listener without the namespace issue. Kernel socket does not have this problem.

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

Kernel modules should not be doing networking unless commanded to by userspace.

It is still not clear why this is an issue with RDMA connection, but not with general kernel socket. It is not random networking. There is a purpose.

It is a problem with sockets too, how do the socket users trigger their socket usages? AFAIK all cases originate with userspace

A user starts a namespace. The module is loaded for servicing requests. The module starts a listener. The user deletes the namespace. This scenario will have everything cleaned up properly if the listener is a kernel socket. This is not the case with RDMA.

Quoted 8 lines
Quoted 4 lines

So if the reason of the current rdma_create_id() behavior is that there is no such user, I am adding one. It should be clear that this difference between kernel socket and rdma_create_id() causes a problem in namespace handling.

It would be helpful to understand how that works, as I've said I don't think a kernel module should open listening sockets/cm_ids on every namespace without being told to do this.

The issue is not about starting a listener. The issue is on namespace deletion.

Signature · 2 lines
K. Poon
[email protected]
#24 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 7 lines · Ka-Cheong Poon
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

Kernel modules should not be doing networking unless commanded to by userspace.

It is still not clear why this is an issue with RDMA connection, but not with general kernel socket. It is not random networking. There is a purpose.

Quoted 8 lines
Quoted 2 lines

It is a problem with sockets too, how do the socket users trigger their socket usages? AFAIK all cases originate with userspace

A user starts a namespace. The module is loaded for servicing requests. The module starts a listener. The user deletes the namespace. This scenario will have everything cleaned up properly if the listener is a kernel socket. This is not the case with RDMA.

Please point to reputable code in upstream doing this

Jason

#25 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 12 lines · Jason Gunthorpe
Quoted 10 lines · Ka-Cheong Poon
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

Kernel modules should not be doing networking unless commanded to by userspace.

It is still not clear why this is an issue with RDMA connection, but not with general kernel socket. It is not random networking. There is a purpose.

It is a problem with sockets too, how do the socket users trigger their socket usages? AFAIK all cases originate with userspace

Quoted 7 lines
Quoted 5 lines

A user starts a namespace. The module is loaded for servicing requests. The module starts a listener. The user deletes the namespace. This scenario will have everything cleaned up properly if the listener is a kernel socket. This is not the case with RDMA.

Please point to reputable code in upstream doing this

It is not clear what "reputable" here really means. If it just means something in kernel, then nearly all, if not all, Internet protocols code in kernel create a control kernel socket for every network namespaces. That socket is deleted in the per namespace exit function. If it explicitly means listening socket, AFS and TIPC in kernel do that for every namespaces. That socket is deleted in the per namespace exit function.

It is very common for a network protocol to have something like this for protocol processing. It is not clear why RDMA subsystem behaves differently and forbids this common practice. Could you please elaborate the issues this practice has such that the RDMA subsystem cannot support it?

Signature · 2 lines
K. Poon
[email protected]
#26 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 30 lines · Ka-Cheong Poon
Quoted 12 lines · Jason Gunthorpe
Quoted 10 lines · Ka-Cheong Poon
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

Kernel modules should not be doing networking unless commanded to by userspace.

It is still not clear why this is an issue with RDMA connection, but not with general kernel socket. It is not random networking. There is a purpose.

It is a problem with sockets too, how do the socket users trigger their socket usages? AFAIK all cases originate with userspace

Quoted 7 lines
Quoted 5 lines

A user starts a namespace. The module is loaded for servicing requests. The module starts a listener. The user deletes the namespace. This scenario will have everything cleaned up properly if the listener is a kernel socket. This is not the case with RDMA.

Please point to reputable code in upstream doing this

It is not clear what "reputable" here really means. If it just means something in kernel, then nearly all, if not all, Internet protocols code in kernel create a control kernel socket for every network namespaces. That socket is deleted in the per namespace exit function. If it explicitly means listening socket, AFS and TIPC in kernel do that for every namespaces. That socket is deleted in the per namespace exit function.

Quoted 5 lines

It is very common for a network protocol to have something like this for protocol processing. It is not clear why RDMA subsystem behaves differently and forbids this common practice. Could you please elaborate the issues this practice has such that the RDMA subsystem cannot support it?

Just curious, are we talking about theoretical thing here or do you have concrete and upstream ULP code to present?

Thanks

Quoted 8 lines

--
K. Poon
[email protected]

#27 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 31 lines · Leon Romanovsky
Quoted 30 lines · Ka-Cheong Poon
Quoted 12 lines · Jason Gunthorpe
Quoted 10 lines · Ka-Cheong Poon
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

Kernel modules should not be doing networking unless commanded to by userspace.

It is still not clear why this is an issue with RDMA connection, but not with general kernel socket. It is not random networking. There is a purpose.

It is a problem with sockets too, how do the socket users trigger their socket usages? AFAIK all cases originate with userspace

Quoted 7 lines
Quoted 5 lines

A user starts a namespace. The module is loaded for servicing requests. The module starts a listener. The user deletes the namespace. This scenario will have everything cleaned up properly if the listener is a kernel socket. This is not the case with RDMA.

Please point to reputable code in upstream doing this

It is not clear what "reputable" here really means. If it just means something in kernel, then nearly all, if not all, Internet protocols code in kernel create a control kernel socket for every network namespaces. That socket is deleted in the per namespace exit function. If it explicitly means listening socket, AFS and TIPC in kernel do that for every namespaces. That socket is deleted in the per namespace exit function.

Quoted 8 lines
Quoted 5 lines

It is very common for a network protocol to have something like this for protocol processing. It is not clear why RDMA subsystem behaves differently and forbids this common practice. Could you please elaborate the issues this practice has such that the RDMA subsystem cannot support it?

Just curious, are we talking about theoretical thing here or do you have concrete and upstream ULP code to present?

As I mentioned in a previous email, I have running code. Otherwise, why would I go to such great length to find out what is missing in the RDMA subsystem in supporting kernel namespace usage.

Signature · 2 lines
K. Poon
[email protected]
#28 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 38 lines · Ka-Cheong Poon
Quoted 37 lines · Leon Romanovsky
Quoted 35 lines · Ka-Cheong Poon
Quoted 12 lines · Jason Gunthorpe
Quoted 10 lines · Ka-Cheong Poon
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

Kernel modules should not be doing networking unless commanded to by userspace.

It is still not clear why this is an issue with RDMA connection, but not with general kernel socket. It is not random networking. There is a purpose.

It is a problem with sockets too, how do the socket users trigger their socket usages? AFAIK all cases originate with userspace

Quoted 7 lines
Quoted 5 lines

A user starts a namespace. The module is loaded for servicing requests. The module starts a listener. The user deletes the namespace. This scenario will have everything cleaned up properly if the listener is a kernel socket. This is not the case with RDMA.

Please point to reputable code in upstream doing this

It is not clear what "reputable" here really means. If it just means something in kernel, then nearly all, if not all, Internet protocols code in kernel create a control kernel socket for every network namespaces. That socket is deleted in the per namespace exit function. If it explicitly means listening socket, AFS and TIPC in kernel do that for every namespaces. That socket is deleted in the per namespace exit function.

It is very common for a network protocol to have something like this for protocol processing. It is not clear why RDMA subsystem behaves differently and forbids this common practice. Could you please elaborate the issues this practice has such that the RDMA subsystem cannot support it?

Quoted 8 lines
Quoted 2 lines

Just curious, are we talking about theoretical thing here or do you have concrete and upstream ULP code to present?

As I mentioned in a previous email, I have running code. Otherwise, why would I go to such great length to find out what is missing in the RDMA subsystem in supporting kernel namespace usage.

So why don't you post this running code?

Thanks

Quoted 8 lines

--
K. Poon
[email protected]

#29 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 43 lines · Leon Romanovsky
Quoted 42 lines · Ka-Cheong Poon
Quoted 39 lines · Leon Romanovsky
Quoted 30 lines · Ka-Cheong Poon
Quoted 12 lines · Jason Gunthorpe
Quoted 10 lines · Ka-Cheong Poon
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

Kernel modules should not be doing networking unless commanded to by userspace.

It is still not clear why this is an issue with RDMA connection, but not with general kernel socket. It is not random networking. There is a purpose.

It is a problem with sockets too, how do the socket users trigger their socket usages? AFAIK all cases originate with userspace

Quoted 7 lines
Quoted 5 lines

A user starts a namespace. The module is loaded for servicing requests. The module starts a listener. The user deletes the namespace. This scenario will have everything cleaned up properly if the listener is a kernel socket. This is not the case with RDMA.

Please point to reputable code in upstream doing this

It is not clear what "reputable" here really means. If it just means something in kernel, then nearly all, if not all, Internet protocols code in kernel create a control kernel socket for every network namespaces. That socket is deleted in the per namespace exit function. If it explicitly means listening socket, AFS and TIPC in kernel do that for every namespaces. That socket is deleted in the per namespace exit function.

Quoted 5 lines

It is very common for a network protocol to have something like this for protocol processing. It is not clear why RDMA subsystem behaves differently and forbids this common practice. Could you please elaborate the issues this practice has such that the RDMA subsystem cannot support it?

Just curious, are we talking about theoretical thing here or do you have concrete and upstream ULP code to present?

Quoted 6 lines
Quoted 4 lines

As I mentioned in a previous email, I have running code. Otherwise, why would I go to such great length to find out what is missing in the RDMA subsystem in supporting kernel namespace usage.

So why don't you post this running code?

Will it change the listening RDMA endpoint started by the module from "rogue" to normal? This is the fundamental problem. This is the reason I ask why the RDMA subsystem behaves like this in the first place. If the reason is just that there is no existing user, it is fine. Unexpectedly, the reason turns out to be that no kernel module is allowed to create its own RDMA endpoint without a corresponding user space file descriptor and/or some form of user space interaction. This is a very serious restriction on how the RDMA subsystem can be used by any kernel module. This has to be sorted out first.

Note that namespace does not really play a role in this "rogue" reasoning. The init_net is also a namespace. The "rogue" reasoning means that no kernel module should start a listening RDMA endpoint by itself with or without any extra namespaces. In fact, to conform to this reasoning, the "right" thing to do would be to change the code already in upstream to get rid of the listening RDMA endpoint in init_net!

Signature · 2 lines
K. Poon
[email protected]
#30 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 6 lines · Ka-Cheong Poon

Note that namespace does not really play a role in this "rogue" reasoning. The init_net is also a namespace. The "rogue" reasoning means that no kernel module should start a listening RDMA endpoint by itself with or without any extra namespaces. In fact, to conform to this reasoning, the "right" thing to do would be to change the code already in upstream to get rid of the listening RDMA endpoint in init_net!

Actually I think they all already need user co-ordination?

- NFS, user has to setup and load exports
- Storage Targets, user has to setup the target
- IPoIB, user has to set the link up

etc.

Each of those could provide the anchor to learn the namespace.

Jason

#31 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 14 lines · Jason Gunthorpe
Quoted 6 lines · Ka-Cheong Poon

Note that namespace does not really play a role in this "rogue" reasoning. The init_net is also a namespace. The "rogue" reasoning means that no kernel module should start a listening RDMA endpoint by itself with or without any extra namespaces. In fact, to conform to this reasoning, the "right" thing to do would be to change the code already in upstream to get rid of the listening RDMA endpoint in init_net!

Actually I think they all already need user co-ordination?

Quoted 7 lines

- NFS, user has to setup and load exports
- Storage Targets, user has to setup the target
- IPoIB, user has to set the link up

etc.

Each of those could provide the anchor to learn the namespace.

My two cents, and worth every penny:

I think the NFSD listener is net namespace-aware. I vaguely recall that a user administrative program (maybe rpc.nfsd?) requests an NFS service listener in a particular namespace.

Should work the same for sockets and listener QPs. For RPC-over-RDMA, a struct net argument is passed in from the generic code:

66 static struct svcxprt_rdma *svc_rdma_create_xprt(struct svc_serv *serv,
67 struct net *net);
68 static struct svc_xprt *svc_rdma_create(struct svc_serv *serv,

 69                                         struct net *net,
 70                                         struct sockaddr *sa, int salen,
 71                                         int flags);

And that struct net is then passed on to rdma_create_id().

--
Chuck Lever

#32 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 31 lines · Chuck Lever
Quoted 14 lines · Jason Gunthorpe
Quoted 6 lines · Ka-Cheong Poon

Note that namespace does not really play a role in this "rogue" reasoning. The init_net is also a namespace. The "rogue" reasoning means that no kernel module should start a listening RDMA endpoint by itself with or without any extra namespaces. In fact, to conform to this reasoning, the "right" thing to do would be to change the code already in upstream to get rid of the listening RDMA endpoint in init_net!

Actually I think they all already need user co-ordination?

Quoted 7 lines

- NFS, user has to setup and load exports
- Storage Targets, user has to setup the target
- IPoIB, user has to set the link up

etc.

Each of those could provide the anchor to learn the namespace.

My two cents, and worth every penny:

I think the NFSD listener is net namespace-aware. I vaguely recall that a user administrative program (maybe rpc.nfsd?) requests an NFS service listener in a particular namespace.

Should work the same for sockets and listener QPs. For RPC-over-RDMA, a struct net argument is passed in from the generic code:

Quoted 8 lines

66 static struct svcxprt_rdma *svc_rdma_create_xprt(struct svc_serv *serv,
67 struct net *net);
68 static struct svc_xprt *svc_rdma_create(struct svc_serv *serv,

 69                                         struct net *net,
 70                                         struct sockaddr *sa, int salen,
 71                                         int flags);

And that struct net is then passed on to rdma_create_id().

Yes

It might help Ka-Cheong to explore how NFS should work

Jason

#33 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

In reply to Jason Gunthorpe
Quoted 10 lines · Jason Gunthorpe
Quoted 6 lines · Ka-Cheong Poon

Note that namespace does not really play a role in this "rogue" reasoning. The init_net is also a namespace. The "rogue" reasoning means that no kernel module should start a listening RDMA endpoint by itself with or without any extra namespaces. In fact, to conform to this reasoning, the "right" thing to do would be to change the code already in upstream to get rid of the listening RDMA endpoint in init_net!

Actually I think they all already need user co-ordination?

Quoted 7 lines

- NFS, user has to setup and load exports
- Storage Targets, user has to setup the target
- IPoIB, user has to set the link up

etc.

Each of those could provide the anchor to learn the namespace.

It is unclear how this is related to the question at hand. It is not about learning the namespace. A kernel module knows when a namespace is created. There is no need to learn it. The question is creating a kernel RDMA endpoint in a namespace without adding a reference to that namespace. The analogy to the daemon scenario is that a daemon starts a socket endpoint at start up. No one calls that endpoint "rogue". Why is that a kernel module should not start a socket endpoint at start up? Why is that socket endpoint "rogue"? The reason is still not being given.

As I mentioned before, this is a very serious restriction on how the RDMA subsystem can be used in a namespace environment by kernel module. The reason given for this restriction is that any kernel socket without a corresponding user space file descriptor is "rogue". All Internet protocol code create a kernel socket without user interaction. Are they all "rogue"?

Signature · 2 lines
K. Poon
[email protected]
#34 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 6 lines · Ka-Cheong Poon

As I mentioned before, this is a very serious restriction on how the RDMA subsystem can be used in a namespace environment by kernel module. The reason given for this restriction is that any kernel socket without a corresponding user space file descriptor is "rogue". All Internet protocol code create a kernel socket without user interaction. Are they all "rogue"?

You should work with Chuck to make NFS use namespaces properly and then you can propose what changes might be needed with a proper justification.

The rules for lifetime on IB clients are tricky, and the interaction with namespaces makes it all a lot more murky.

Jason

#35 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Hi Jason-

Quoted 10 lines · Jason Gunthorpe
Quoted 6 lines · Ka-Cheong Poon

As I mentioned before, this is a very serious restriction on how the RDMA subsystem can be used in a namespace environment by kernel module. The reason given for this restriction is that any kernel socket without a corresponding user space file descriptor is "rogue". All Internet protocol code create a kernel socket without user interaction. Are they all "rogue"?

Quoted 3 lines

You should work with Chuck to make NFS use namespaces properly and then you can propose what changes might be needed with a proper justification.

The NFS server code already uses namespaces for creating listener endpoints, already has a user space component that drives the creation of listeners, and already passes an appropriate struct net to rdma_create_id. As far as I am aware, it is namespace-aware and -friendly all the way down to rdma_create_id().

What more needs to be done?

Quoted 2 lines

The rules for lifetime on IB clients are tricky, and the interaction with namespaces makes it all a lot more murky.

I think what Ka-cheong is asking is for a detailed explanation of these lifetime rules so we can understand why rdma_create_id bumps the namespace reference count.

--
Chuck Lever
[email protected]

#36 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 16 lines · Chuck Lever

Hi Jason-

Quoted 10 lines · Jason Gunthorpe
Quoted 6 lines · Ka-Cheong Poon

As I mentioned before, this is a very serious restriction on how the RDMA subsystem can be used in a namespace environment by kernel module. The reason given for this restriction is that any kernel socket without a corresponding user space file descriptor is "rogue". All Internet protocol code create a kernel socket without user interaction. Are they all "rogue"?

Quoted 3 lines

You should work with Chuck to make NFS use namespaces properly and then you can propose what changes might be needed with a proper justification.

Quoted 7 lines

The NFS server code already uses namespaces for creating listener endpoints, already has a user space component that drives the creation of listeners, and already passes an appropriate struct net to rdma_create_id. As far as I am aware, it is namespace-aware and -friendly all the way down to rdma_create_id().

What more needs to be done?

I have no idea, if you are able to pass a namespace all the way down to the listening cm_id and everything works right (I'm skeptical) then there is nothing more to worry about - why are we having this thread?

Quoted 6 lines
Quoted 2 lines

The rules for lifetime on IB clients are tricky, and the interaction with namespaces makes it all a lot more murky.

I think what Ka-cheong is asking is for a detailed explanation of these lifetime rules so we can understand why rdma_create_id bumps the namespace reference count.

It is because the CM has no code to revoke a CM ID before the namespace goes away and the pointer becomes invalid.

Jason

#37 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 27 lines · Jason Gunthorpe
Quoted 22 lines · Chuck Lever

Hi Jason-

Quoted 10 lines · Jason Gunthorpe
Quoted 6 lines · Ka-Cheong Poon

As I mentioned before, this is a very serious restriction on how the RDMA subsystem can be used in a namespace environment by kernel module. The reason given for this restriction is that any kernel socket without a corresponding user space file descriptor is "rogue". All Internet protocol code create a kernel socket without user interaction. Are they all "rogue"?

Quoted 3 lines

You should work with Chuck to make NFS use namespaces properly and then you can propose what changes might be needed with a proper justification.

The NFS server code already uses namespaces for creating listener endpoints, already has a user space component that drives the creation of listeners, and already passes an appropriate struct net to rdma_create_id. As far as I am aware, it is namespace-aware and -friendly all the way down to rdma_create_id().

Quoted 5 lines
Quoted 1 line

What more needs to be done?

I have no idea, if you are able to pass a namespace all the way down to the listening cm_id and everything works right (I'm skeptical) then there is nothing more to worry about - why are we having this thread?

The thread is about RDS, not NFS. NFS has some useful examples to crib, but it's not the main point.

I don't think NFS/RDMA namespacing works today, but it's not because NFS isn't ready. I agree that is another thread.

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

The rules for lifetime on IB clients are tricky, and the interaction with namespaces makes it all a lot more murky.

I think what Ka-cheong is asking is for a detailed explanation of these lifetime rules so we can understand why rdma_create_id bumps the namespace reference count.

It is because the CM has no code to revoke a CM ID before the namespace goes away and the pointer becomes invalid.

Is it just a question of "no-one has yet written this code" or is there a deeper technical reason why this has not been done?

--
Chuck Lever
[email protected]

#38 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 33 lines · Chuck Lever
Quoted 27 lines · Jason Gunthorpe
Quoted 22 lines · Chuck Lever

Hi Jason-

Quoted 10 lines · Jason Gunthorpe
Quoted 6 lines · Ka-Cheong Poon

As I mentioned before, this is a very serious restriction on how the RDMA subsystem can be used in a namespace environment by kernel module. The reason given for this restriction is that any kernel socket without a corresponding user space file descriptor is "rogue". All Internet protocol code create a kernel socket without user interaction. Are they all "rogue"?

Quoted 3 lines

You should work with Chuck to make NFS use namespaces properly and then you can propose what changes might be needed with a proper justification.

The NFS server code already uses namespaces for creating listener endpoints, already has a user space component that drives the creation of listeners, and already passes an appropriate struct net to rdma_create_id. As far as I am aware, it is namespace-aware and -friendly all the way down to rdma_create_id().

Quoted 5 lines
Quoted 1 line

What more needs to be done?

I have no idea, if you are able to pass a namespace all the way down to the listening cm_id and everything works right (I'm skeptical) then there is nothing more to worry about - why are we having this thread?

Quoted 5 lines

The thread is about RDS, not NFS. NFS has some useful examples to crib, but it's not the main point.

I don't think NFS/RDMA namespacing works today, but it's not because NFS isn't ready. I agree that is another thread.

Exactly, so instead of talking about RDS stuff without any patches, let's talk about NFS with patches - if you can make NFS work then I assume RDS will be happy.

NFS has an established model for using namespaces that the other transports uses, so I'd rather focus on this.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

The rules for lifetime on IB clients are tricky, and the interaction with namespaces makes it all a lot more murky.

I think what Ka-cheong is asking is for a detailed explanation of these lifetime rules so we can understand why rdma_create_id bumps the namespace reference count.

Quoted 5 lines
Quoted 2 lines

It is because the CM has no code to revoke a CM ID before the namespace goes away and the pointer becomes invalid.

Is it just a question of "no-one has yet written this code" or is there a deeper technical reason why this has not been done?

It is hard to know without spending a big deep look at this stuff.

Jason

#39 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 38 lines · Jason Gunthorpe
Quoted 33 lines · Chuck Lever
Quoted 32 lines · Jason Gunthorpe
Quoted 16 lines · Chuck Lever

Hi Jason-

Quoted 10 lines · Jason Gunthorpe
Quoted 6 lines · Ka-Cheong Poon

As I mentioned before, this is a very serious restriction on how the RDMA subsystem can be used in a namespace environment by kernel module. The reason given for this restriction is that any kernel socket without a corresponding user space file descriptor is "rogue". All Internet protocol code create a kernel socket without user interaction. Are they all "rogue"?

Quoted 3 lines

You should work with Chuck to make NFS use namespaces properly and then you can propose what changes might be needed with a proper justification.

Quoted 7 lines

The NFS server code already uses namespaces for creating listener endpoints, already has a user space component that drives the creation of listeners, and already passes an appropriate struct net to rdma_create_id. As far as I am aware, it is namespace-aware and -friendly all the way down to rdma_create_id().

What more needs to be done?

I have no idea, if you are able to pass a namespace all the way down to the listening cm_id and everything works right (I'm skeptical) then there is nothing more to worry about - why are we having this thread?

Quoted 7 lines
Quoted 5 lines

The thread is about RDS, not NFS. NFS has some useful examples to crib, but it's not the main point.

I don't think NFS/RDMA namespacing works today, but it's not because NFS isn't ready. I agree that is another thread.

Exactly, so instead of talking about RDS stuff without any patches,

Roger that. Maybe Ka-Cheong and team can propose some patches to help the discussion along.

Quoted 2 lines

let's talk about NFS with patches - if you can make NFS work then I assume RDS will be happy.

Perhaps not a valid assumption :-)

NFS is a traditional client-server model, and has a user space tool that drives the creation of endpoints, just as you expect.

With RDS, listener endpoints are not visible in user space. They are a globally-managed shared resource, more like network interfaces than listener sockets.

Therefore I think the approach is going to be "one RDS listener per net namespace". The problem Ka-Cheong is trying to address is how to manage the destruction of a listener-namespace pair. The extra reference count on the cm_id is pinning the namespace so it cannot be destroyed.

Quoted 2 lines

NFS has an established model for using namespaces that the other transports uses, so I'd rather focus on this.

Understood, but it doesn't seem like there is enough useful overlap between the NFS and RDS usage scenarios. With NFS, I would expect an explicit listener shutdown from userland prior to namespace destruction.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

The rules for lifetime on IB clients are tricky, and the interaction with namespaces makes it all a lot more murky.

I think what Ka-cheong is asking is for a detailed explanation of these lifetime rules so we can understand why rdma_create_id bumps the namespace reference count.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

It is because the CM has no code to revoke a CM ID before the namespace goes away and the pointer becomes invalid.

Is it just a question of "no-one has yet written this code" or is there a deeper technical reason why this has not been done?

It is hard to know without spending a big deep look at this stuff.

Fair enough.

--
Chuck Lever
[email protected]

#40 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 5 lines · Chuck Lever

Therefore I think the approach is going to be "one RDS listener per net namespace". The problem Ka-Cheong is trying to address is how to manage the destruction of a listener-namespace pair. The extra reference count on the cm_id is pinning the namespace so it cannot be destroyed.

I really don't think this idea of just loading a kernel module and it immediately creates a network visibile listening socket in every namespace is very good.

Quoted 4 lines

Understood, but it doesn't seem like there is enough useful overlap between the NFS and RDS usage scenarios. With NFS, I would expect an explicit listener shutdown from userland prior to namespace destruction.

Yes, because namespaces are fundamentally supposed to be anchored in the processes inside the namespace.

Having the kernel jump in and start opening holes as soon as a namespace is created is just wrong.

At a bare minimum the listener should not exist until something in the namespace is willing to work with RDS.

Jason

#41 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 16 lines · Jason Gunthorpe
Quoted 5 lines · Chuck Lever

Therefore I think the approach is going to be "one RDS listener per net namespace". The problem Ka-Cheong is trying to address is how to manage the destruction of a listener-namespace pair. The extra reference count on the cm_id is pinning the namespace so it cannot be destroyed.

I really don't think this idea of just loading a kernel module and it immediately creates a network visibile listening socket in every namespace is very good.

Quoted 7 lines
Quoted 4 lines

Understood, but it doesn't seem like there is enough useful overlap between the NFS and RDS usage scenarios. With NFS, I would expect an explicit listener shutdown from userland prior to namespace destruction.

Yes, because namespaces are fundamentally supposed to be anchored in the processes inside the namespace.

Aye, the container model.

Quoted 5 lines

Having the kernel jump in and start opening holes as soon as a namespace is created is just wrong.

At a bare minimum the listener should not exist until something in the namespace is willing to work with RDS.

I was thinking that too, but I'm not sure if that change would have ramifications to existing RDS applications. There's quite a bit of legacy to deal with.

An alternative would be to add a user daemon to RDS to manage the listener lifecycle, rather than having the endpoint created by module load. That might help the listener-namespace destruction issue, and should be entirely application-transparent.

--
Chuck Lever
[email protected]

#42 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

In reply to Jason Gunthorpe
Quoted 8 lines · Jason Gunthorpe

Yes, because namespaces are fundamentally supposed to be anchored in the processes inside the namespace.

Having the kernel jump in and start opening holes as soon as a namespace is created is just wrong.

At a bare minimum the listener should not exist until something in the namespace is willing to work with RDS.

As I mentioned in a previous email, starting is not the problem. It is the problem of deleting a namespace. Using what is suggested above, it means that there needs to be an explicit shutdown in addition to the normal shutdown of a namespace. It is not clear why this is necessary. The additional reference by rdma_create_id() puts an unnecessary restriction on what a kernel module can do. Without this reference, if a kernel module wants to use, say a one-to-one/many mapping model to user space socket as suggested above, it can do that. And if a kernel module does not want to use this model, it can also choose to do that. It is not clear why such a restriction must be enforced in RDMA subsystem while there is no such restriction using kernel socket.

Signature · 2 lines
K. Poon
[email protected]
#43 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 8 lines · Ka-Cheong Poon
Quoted 6 lines · Jason Gunthorpe

Yes, because namespaces are fundamentally supposed to be anchored in the processes inside the namespace.

Having the kernel jump in and start opening holes as soon as a namespace is created is just wrong.

Quoted 6 lines
Quoted 2 lines

At a bare minimum the listener should not exist until something in the namespace is willing to work with RDS.

As I mentioned in a previous email, starting is not the problem. It is the problem of deleting a namespace.

Starting and ending are symmetric. When the last thing inside the namespace stops needing RDS then RDS should close down the cm_id's.

Jason

#44 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 17 lines · Jason Gunthorpe
Quoted 12 lines · Ka-Cheong Poon
Quoted 8 lines · Jason Gunthorpe

Yes, because namespaces are fundamentally supposed to be anchored in the processes inside the namespace.

Having the kernel jump in and start opening holes as soon as a namespace is created is just wrong.

At a bare minimum the listener should not exist until something in the namespace is willing to work with RDS.

Quoted 5 lines
Quoted 2 lines

As I mentioned in a previous email, starting is not the problem. It is the problem of deleting a namespace.

Starting and ending are symmetric. When the last thing inside the namespace stops needing RDS then RDS should close down the cm_id's.

Unfortunately, cluster heartbeat requires the RDS listener endpoint to continue after the last RDS user goes away, if the container continues to exist.

IMO having an explicit RDS start-up and shutdown apart from namespace creation and deletion is a cleaner approach. On a multi-tenant system with many containers, some of those containers will want RDS listeners and some will not. RDS should not assume that every net namespace needs or wants to have a listener.

--
Chuck Lever

#45 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 20 lines · Chuck Lever
Quoted 20 lines · Jason Gunthorpe
Quoted 14 lines · Ka-Cheong Poon
Quoted 8 lines · Jason Gunthorpe

Yes, because namespaces are fundamentally supposed to be anchored in the processes inside the namespace.

Having the kernel jump in and start opening holes as soon as a namespace is created is just wrong.

At a bare minimum the listener should not exist until something in the namespace is willing to work with RDS.

As I mentioned in a previous email, starting is not the problem. It is the problem of deleting a namespace.

Quoted 6 lines
Quoted 2 lines

Starting and ending are symmetric. When the last thing inside the namespace stops needing RDS then RDS should close down the cm_id's.

Unfortunately, cluster heartbeat requires the RDS listener endpoint to continue after the last RDS user goes away, if the container continues to exist.

What purpose is the heartbeat if nobody is listening for RDS stuff inside the net namespace anyhow?

Quoted 5 lines

IMO having an explicit RDS start-up and shutdown apart from namespace creation and deletion is a cleaner approach. On a multi-tenant system with many containers, some of those containers will want RDS listeners and some will not. RDS should not assume that every net namespace needs or wants to have a listener.

Right

Jason

#46 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

In reply to Ka-Cheong Poon
Quoted 22 lines · Ka-Cheong Poon
Quoted 12 lines · Jason Gunthorpe
Quoted 10 lines · Ka-Cheong Poon
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

Kernel modules should not be doing networking unless commanded to by userspace.

It is still not clear why this is an issue with RDMA connection, but not with general kernel socket. It is not random networking. There is a purpose.

It is a problem with sockets too, how do the socket users trigger their socket usages? AFAIK all cases originate with userspace

Quoted 7 lines
Quoted 5 lines

A user starts a namespace. The module is loaded for servicing requests. The module starts a listener. The user deletes the namespace. This scenario will have everything cleaned up properly if the listener is a kernel socket. This is not the case with RDMA.

Please point to reputable code in upstream doing this

Quoted 7 lines

It is not clear what "reputable" here really means. If it just means something in kernel, then nearly all, if not all, Internet protocols code in kernel create a control kernel socket for every network namespaces. That socket is deleted in the per namespace exit function. If it explicitly means listening socket, AFS and TIPC in kernel do that for every namespaces. That socket is deleted in the per namespace exit function.

AFS and TIPC are not exactly well reviewed mainstream areas.

Quoted 5 lines

It is very common for a network protocol to have something like this for protocol processing. It is not clear why RDMA subsystem behaves differently and forbids this common practice. Could you please elaborate the issues this practice has such that the RDMA subsystem cannot support it?

The kernel should not have rouge listening sockets just because a model is loaded. Creation if listening kernel side sockets should be triggered by userspace.

Jason

#47 lore raw

Re: RDMA subsystem namespace related questions (was Re: Finding the namespace of a struct ib_device)

Quoted 31 lines · Jason Gunthorpe
Quoted 22 lines · Ka-Cheong Poon
Quoted 12 lines · Jason Gunthorpe
Quoted 10 lines · Ka-Cheong Poon
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

Kernel modules should not be doing networking unless commanded to by userspace.

It is still not clear why this is an issue with RDMA connection, but not with general kernel socket. It is not random networking. There is a purpose.

It is a problem with sockets too, how do the socket users trigger their socket usages? AFAIK all cases originate with userspace

Quoted 7 lines
Quoted 5 lines

A user starts a namespace. The module is loaded for servicing requests. The module starts a listener. The user deletes the namespace. This scenario will have everything cleaned up properly if the listener is a kernel socket. This is not the case with RDMA.

Please point to reputable code in upstream doing this

Quoted 7 lines

It is not clear what "reputable" here really means. If it just means something in kernel, then nearly all, if not all, Internet protocols code in kernel create a control kernel socket for every network namespaces. That socket is deleted in the per namespace exit function. If it explicitly means listening socket, AFS and TIPC in kernel do that for every namespaces. That socket is deleted in the per namespace exit function.

Quoted 1 line

AFS and TIPC are not exactly well reviewed mainstream areas.

How about all the other Internet protocol code? They all create a kernel socket without user interaction. If it is using rdma_create_id(), it will prevent a namespace from being deleted.

Quoted 9 lines
Quoted 5 lines

It is very common for a network protocol to have something like this for protocol processing. It is not clear why RDMA subsystem behaves differently and forbids this common practice. Could you please elaborate the issues this practice has such that the RDMA subsystem cannot support it?

The kernel should not have rouge listening sockets just because a model is loaded. Creation if listening kernel side sockets should be triggered by userspace.

It is unclear why the socket is "rogue". A sys admin loads a kernel module for a reason. It cannot be randomly loaded by itself. In this respect, it is not different from a user space daemon. No one will describe a listening socket started by a daemon when it starts as "rogue". Why is a listening socket started by a kernel module "rogue"? If a user is remote, without the listening socket, how can anything work in the first place?

Signature · 2 lines
K. Poon
[email protected]