netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 00/17] Refactor classifier API to work with chain/classifiers without rtnl lock
@ 2018-11-12  7:55 Vlad Buslov
  2018-11-12  7:55 ` [PATCH net-next 01/17] net: sched: refactor mini_qdisc_pair_swap() to use workqueue Vlad Buslov
                   ` (16 more replies)
  0 siblings, 17 replies; 35+ messages in thread
From: Vlad Buslov @ 2018-11-12  7:55 UTC (permalink / raw)
  To: netdev; +Cc: jhs, xiyou.wangcong, jiri, davem, ast, daniel, Vlad Buslov

Currently, all netlink protocol handlers for updating rules, actions and
qdiscs are protected with single global rtnl lock which removes any
possibility for parallelism. This patch set is a third step to remove
rtnl lock dependency from TC rules update path.

Recently, new rtnl registration flag RTNL_FLAG_DOIT_UNLOCKED was added.
Handlers registered with this flag are called without RTNL taken. End
goal is to have rule update handlers(RTM_NEWTFILTER, RTM_DELTFILTER,
etc.) to be registered with UNLOCKED flag to allow parallel execution.
However, there is no intention to completely remove or split rtnl lock
itself. This patch set addresses specific problems in implementation of
classifiers API that prevent its control path from being executed
concurrently, and completes refactoring of cls API rules update handlers
by removing rtnl lock dependency from code that handles chains and
classifiers. Rules update handlers are registered with
RTNL_FLAG_DOIT_UNLOCKED flag.

This patch set substitutes global rtnl lock dependency on rules update
path in cls API by extending its data structures with following locks:
- tcf_block with 'lock' spinlock. It is used to protect block state, and
  life-time management fields of chains on the block (chain->refcnt,
  chain->action_refcnt, chain->explicitly crated, etc.).
- tcf_chain with 'filter_chain_lock' spinlock, that is used to protect
  list of classifier instances attached to chain.
- tcf_proto with 'lock' spinlock that is intended to be used to
  synchronize access to classifiers that support unlocked execution.

Chain0 head change callbacks can be sleeping and cannot be protected by
block spinlock. To solve this issue, sleeping miniqp swap function (used
as head change callback by ingress and clsact Qdiscs) is refactored to
offload sleeping operations to workqueue. New ordered workqueue
'tc_proto_workqueue' is created in cls_api to be used by miniqp and for
tcf_proto deallocation, which is also moved to workqueue to prevent
deallocation of tp's that are still in use by block. Performing both
miniqp swap and tp deallocation on same ordered workqueue ensures that
any pending head change requests involving tp are completed before the
tp is deallocated.

Classifiers are extended with reference counting to accommodate parallel
access by unlocked cls API. Classifier ops structure is extended with
additional 'put' function to allow reference counting of filters and
intended to be used by classifiers that implement rtnl-unlocked API.
Users of classifiers and individual filter instances are modified to
always hold reference while working with them.

Classifiers that support unlocked execution still need to know the
status of rtnl lock, so their API is extended with additional
'rtnl_held' argument that is used to indicate that caller holds rtnl
lock.

Vlad Buslov (17):
  net: sched: refactor mini_qdisc_pair_swap() to use workqueue
  net: sched: protect block state with spinlock
  net: sched: refactor tc_ctl_chain() to use block->lock
  net: sched: protect block->chain0 with block->lock
  net: sched: traverse chains in block with tcf_get_next_chain()
  net: sched: protect chain template accesses with block lock
  net: sched: lock the chain when accessing filter_chain list
  net: sched: introduce reference counting for tcf proto
  net: sched: traverse classifiers in chain with tcf_get_next_proto()
  net: sched: refactor tp insert/delete for concurrent execution
  net: sched: prevent insertion of new classifiers during chain flush
  net: sched: track rtnl lock status when validating extensions
  net: sched: extend proto ops with 'put' callback
  net: sched: extend proto ops to support unlocked classifiers
  net: sched: add flags to Qdisc class ops struct
  net: sched: conditionally take rtnl lock on rules update path
  net: sched: unlock rules update API

 include/net/pkt_cls.h     |   6 +-
 include/net/sch_generic.h |  73 +++-
 net/sched/cls_api.c       | 919 +++++++++++++++++++++++++++++++++++++---------
 net/sched/cls_basic.c     |  14 +-
 net/sched/cls_bpf.c       |  15 +-
 net/sched/cls_cgroup.c    |  13 +-
 net/sched/cls_flow.c      |  15 +-
 net/sched/cls_flower.c    |  16 +-
 net/sched/cls_fw.c        |  15 +-
 net/sched/cls_matchall.c  |  16 +-
 net/sched/cls_route.c     |  14 +-
 net/sched/cls_rsvp.h      |  16 +-
 net/sched/cls_tcindex.c   |  17 +-
 net/sched/cls_u32.c       |  14 +-
 net/sched/sch_api.c       |  10 +-
 net/sched/sch_generic.c   |  37 +-
 net/sched/sch_ingress.c   |   4 +
 17 files changed, 955 insertions(+), 259 deletions(-)

-- 
2.7.5

^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2018-11-15 20:34 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-12  7:55 [PATCH net-next 00/17] Refactor classifier API to work with chain/classifiers without rtnl lock Vlad Buslov
2018-11-12  7:55 ` [PATCH net-next 01/17] net: sched: refactor mini_qdisc_pair_swap() to use workqueue Vlad Buslov
2018-11-12 17:28   ` David Miller
2018-11-13 13:13     ` Vlad Buslov
2018-11-13 16:08       ` David Miller
2018-11-12  7:55 ` [PATCH net-next 02/17] net: sched: protect block state with spinlock Vlad Buslov
2018-11-12 17:28   ` David Miller
2018-11-13 10:07     ` Stefano Brivio
2018-11-13 13:28       ` Vlad Buslov
2018-11-12  7:55 ` [PATCH net-next 03/17] net: sched: refactor tc_ctl_chain() to use block->lock Vlad Buslov
2018-11-12  7:55 ` [PATCH net-next 04/17] net: sched: protect block->chain0 with block->lock Vlad Buslov
2018-11-12  7:55 ` [PATCH net-next 05/17] net: sched: traverse chains in block with tcf_get_next_chain() Vlad Buslov
2018-11-12  7:55 ` [PATCH net-next 06/17] net: sched: protect chain template accesses with block lock Vlad Buslov
2018-11-12  7:55 ` [PATCH net-next 07/17] net: sched: lock the chain when accessing filter_chain list Vlad Buslov
2018-11-12  7:55 ` [PATCH net-next 08/17] net: sched: introduce reference counting for tcf proto Vlad Buslov
2018-11-12  7:55 ` [PATCH net-next 09/17] net: sched: traverse classifiers in chain with tcf_get_next_proto() Vlad Buslov
2018-11-12  7:55 ` [PATCH net-next 10/17] net: sched: refactor tp insert/delete for concurrent execution Vlad Buslov
2018-11-12  7:55 ` [PATCH net-next 11/17] net: sched: prevent insertion of new classifiers during chain flush Vlad Buslov
2018-11-12  7:55 ` [PATCH net-next 12/17] net: sched: track rtnl lock status when validating extensions Vlad Buslov
2018-11-12  7:55 ` [PATCH net-next 13/17] net: sched: extend proto ops with 'put' callback Vlad Buslov
2018-11-12  7:55 ` [PATCH net-next 14/17] net: sched: extend proto ops to support unlocked classifiers Vlad Buslov
2018-11-12  7:55 ` [PATCH net-next 15/17] net: sched: add flags to Qdisc class ops struct Vlad Buslov
2018-11-12  7:55 ` [PATCH net-next 16/17] net: sched: conditionally take rtnl lock on rules update path Vlad Buslov
2018-11-13  9:40   ` Stefano Brivio
2018-11-13 13:25     ` Vlad Buslov
2018-11-13 13:40       ` Stefano Brivio
2018-11-13 13:58         ` Vlad Buslov
2018-11-13 15:53           ` Stefano Brivio
2018-11-13 16:57             ` Stefano Brivio
2018-11-12  7:55 ` [PATCH net-next 17/17] net: sched: unlock rules update API Vlad Buslov
2018-11-12 17:30   ` David Miller
2018-11-13 13:46     ` Vlad Buslov
2018-11-14  6:44       ` Jiri Pirko
2018-11-14 16:45         ` Vlad Buslov
2018-11-15 10:20           ` Jiri Pirko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).