| From 2b9c6753c9b35c06952583aae7a404942dfaa506 Mon Sep 17 00:00:00 2001 |
| From: Sasha Levin <sashal@kernel.org> |
| Date: Tue, 15 Apr 2025 15:11:41 +0300 |
| Subject: vxlan: Do not treat dst cache initialization errors as fatal |
| |
| From: Ido Schimmel <idosch@nvidia.com> |
| |
| [ Upstream commit 20c76dadc783759fd3819d289c72be590660cc8b ] |
| |
| FDB entries are allocated in an atomic context as they can be added from |
| the data path when learning is enabled. |
| |
| After converting the FDB hash table to rhashtable, the insertion rate |
| will be much higher (*) which will entail a much higher rate of per-CPU |
| allocations via dst_cache_init(). |
| |
| When adding a large number of entries (e.g., 256k) in a batch, a small |
| percentage (< 0.02%) of these per-CPU allocations will fail [1]. This |
| does not happen with the current code since the insertion rate is low |
| enough to give the per-CPU allocator a chance to asynchronously create |
| new chunks of per-CPU memory. |
| |
| Given that: |
| |
| a. Only a small percentage of these per-CPU allocations fail. |
| |
| b. The scenario where this happens might not be the most realistic one. |
| |
| c. The driver can work correctly without dst caches. The dst_cache_*() |
| APIs first check that the dst cache was properly initialized. |
| |
| d. The dst caches are not always used (e.g., 'tos inherit'). |
| |
| It seems reasonable to not treat these allocation failures as fatal. |
| |
| Therefore, do not bail when dst_cache_init() fails and suppress warnings |
| by specifying '__GFP_NOWARN'. |
| |
| [1] percpu: allocation failed, size=40 align=8 atomic=1, atomic alloc failed, no space left |
| |
| (*) 97% reduction in average latency of vxlan_fdb_update() when adding |
| 256k entries in a batch. |
| |
| Reviewed-by: Petr Machata <petrm@nvidia.com> |
| Signed-off-by: Ido Schimmel <idosch@nvidia.com> |
| Link: https://patch.msgid.link/20250415121143.345227-14-idosch@nvidia.com |
| Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org> |
| Signed-off-by: Paolo Abeni <pabeni@redhat.com> |
| Signed-off-by: Sasha Levin <sashal@kernel.org> |
| --- |
| drivers/net/vxlan.c | 8 ++++---- |
| 1 file changed, 4 insertions(+), 4 deletions(-) |
| |
| diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c |
| index 7105ac37f341e..18844bac9375e 100644 |
| --- a/drivers/net/vxlan.c |
| +++ b/drivers/net/vxlan.c |
| @@ -681,10 +681,10 @@ static int vxlan_fdb_append(struct vxlan_fdb *f, |
| if (rd == NULL) |
| return -ENOMEM; |
| |
| - if (dst_cache_init(&rd->dst_cache, GFP_ATOMIC)) { |
| - kfree(rd); |
| - return -ENOMEM; |
| - } |
| + /* The driver can work correctly without a dst cache, so do not treat |
| + * dst cache initialization errors as fatal. |
| + */ |
| + dst_cache_init(&rd->dst_cache, GFP_ATOMIC | __GFP_NOWARN); |
| |
| rd->remote_ip = *ip; |
| rd->remote_port = port; |
| -- |
| 2.39.5 |
| |