From patchwork Fri Aug 10 17:51:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlad Buslov X-Patchwork-Id: 956364 Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41nCPv2qsrz9s5b for ; Sat, 11 Aug 2018 03:52:35 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728562AbeHJUXO (ORCPT ); Fri, 10 Aug 2018 16:23:14 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:46919 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728400AbeHJUXN (ORCPT ); Fri, 10 Aug 2018 16:23:13 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from vladbu@mellanox.com) with ESMTPS (AES256-SHA encrypted); 10 Aug 2018 20:55:55 +0300 Received: from reg-r-vrt-018-180.mtr.labs.mlnx (reg-r-vrt-018-180.mtr.labs.mlnx [10.213.18.180]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w7AHqKqR027609; Fri, 10 Aug 2018 20:52:20 +0300 From: Vlad Buslov To: netdev@vger.kernel.org Cc: davem@davemloft.net, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, pablo@netfilter.org, kadlec@blackhole.kfki.hu, fw@strlen.de, ast@kernel.org, daniel@iogearbox.net, edumazet@google.com, keescook@chromium.org, marcelo.leitner@gmail.com, Vlad Buslov Subject: [PATCH net-next v2 00/15] Remove rtnl lock dependency from all action implementations Date: Fri, 10 Aug 2018 20:51:40 +0300 Message-Id: <1533923515-5664-1-git-send-email-vladbu@mellanox.com> X-Mailer: git-send-email 2.7.5 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 second 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 tc actions that prevent their control path from being executed concurrently. Additional changes are required to refactor classifiers API and individual classifiers for parallel execution. This patch set lays groundwork to eventually register rule update handlers as rtnl-unlocked. Action API is already prepared for parallel execution with previous patch set, which means that action ops that use action API for their implementation do not require additional modifications. (delete, search, etc.) Action API implements concurrency-safe reference counting and guarantees that cleanup/delete is called only once, after last reference to action is released. The goal of this change is to update specific actions APIs that access action private state directly, in order to be independent from external locking. General approach is to re-use existing tcf_lock spinlock (used by some action implementation to synchronize control path with data path) to protect action private state from concurrent modification. If action has rcu-protected pointer, tcf spinlock is used to protect its update code, instead of relying on rtnl lock. Some actions need to determine rtnl mutex status in order to release it. For example, ife action can load additional kernel modules(meta ops) and must make sure that no locks are held during module load. In such cases 'rtnl_held' argument is used to conditionally release rtnl mutex. Changes from V1 to V2: - Patch 12: - new patch - Patch 14: - refactor gen_new_estimator() to reuse stats_lock when re-assigning rate estimator statistics pointer - Remove mirred and tunnel_key helper function changes. (to be submitted and standalone patch) Vlad Buslov (15): net: sched: act_bpf: remove dependency on rtnl lock net: sched: act_csum: remove dependency on rtnl lock net: sched: act_gact: remove dependency on rtnl lock net: sched: act_ife: remove dependency on rtnl lock net: sched: act_ipt: remove dependency on rtnl lock net: sched: act_pedit: remove dependency on rtnl lock net: sched: act_sample: remove dependency on rtnl lock net: sched: act_simple: remove dependency on rtnl lock net: sched: act_skbmod: remove dependency on rtnl lock net: sched: act_tunnel_key: remove dependency on rtnl lock net: sched: act_vlan: remove dependency on rtnl lock net: sched: extend action ops with put_dev callback net: sched: act_mirred: remove dependency on rtnl lock net: core: protect rate estimator statistics pointer with lock net: sched: act_police: remove dependency on rtnl lock include/net/act_api.h | 1 + include/net/gen_stats.h | 4 +-- net/core/gen_estimator.c | 21 ++++++----- net/sched/act_bpf.c | 10 ++++-- net/sched/act_csum.c | 24 ++++++++----- net/sched/act_gact.c | 10 ++++-- net/sched/act_ife.c | 40 +++++++++++++-------- net/sched/act_ipt.c | 3 ++ net/sched/act_mirred.c | 88 ++++++++++++++++++++++++++++++++-------------- net/sched/act_pedit.c | 40 ++++++++++----------- net/sched/act_police.c | 9 +++-- net/sched/act_sample.c | 12 +++++-- net/sched/act_simple.c | 6 +++- net/sched/act_skbmod.c | 14 +++++--- net/sched/act_tunnel_key.c | 26 +++++++------- net/sched/act_vlan.c | 27 +++++++------- net/sched/cls_api.c | 1 + 17 files changed, 214 insertions(+), 122 deletions(-)