]> git.baikalelectronics.ru Git - kernel.git/commit
netdevsim: fib: Convert the current occupancy to an atomic variable
authorAmit Cohen <amcohen@nvidia.com>
Mon, 1 Feb 2021 19:47:48 +0000 (21:47 +0200)
committerJakub Kicinski <kuba@kernel.org>
Wed, 3 Feb 2021 01:45:58 +0000 (17:45 -0800)
commit2afa2289dee72e5986a8f5be546cad90bae744a6
tree86a488e8a78dc95c1edf426dbab131b7e0f22dbe
parent76a6f27c939e2c704decf38f3765d5f9c7ecaa1d
netdevsim: fib: Convert the current occupancy to an atomic variable

When route is added/deleted, the appropriate counter is increased/decreased
to maintain number of routes.

User can limit the number of routes and then according to the appropriate
counter, adding more routes than the limitation is forbidden.

Currently, there is one lock which protects hashtable, list and accounting.

Handling the counters will be performed from both atomic context and
non-atomic context, while the hashtable and the list will be used only from
non-atomic context and therefore will be protected by a separate lock.

Protect accounting by using an atomic variable, so lock is not needed.

v2:
* Use atomic64_sub() in nsim_nexthop_account()'s error path

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/netdevsim/fib.c