From patchwork Fri Dec 1 20:43:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13476377 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mojatatu-com.20230601.gappssmtp.com header.i=@mojatatu-com.20230601.gappssmtp.com header.b="fPGZbfrT" Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 785A3FF for ; Fri, 1 Dec 2023 12:43:42 -0800 (PST) Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-5c2066accc5so774452a12.3 for ; Fri, 01 Dec 2023 12:43:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1701463422; x=1702068222; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8DGOijOKJdOqvHyhZyvR9Q5yxUXm8+4SFnahsPvs8Go=; b=fPGZbfrTlvKf3PNzLCrQsBhYLasWLJxEwJiFSFGFeIw2ijrvDsnXNsZEvE9CLOm6Eo Eg72GLKQihneFC4sF3mJmyAAKrN+3OJA+8EbRGyY/n5Fl6002mnAqyxe60bRJKuFKnDp wvazwTqjVlAQePhUlNzxhK+X4595LXXeZouNsf5g1lYZGq/SmsgU3aQL3Z17UwH0W9HJ S5sIaIgp1CGjYDg7px3f484+G2yFmcfS9HktCT3gghduW7UENxB8aPRy4U2wDLdmhGfu iNtrhALnolO/Mt7IJjUvaPapQDXjFvDAwvjhiSB59ZcpJy+Z2merJ/c8VT8sGUZIS9pO xKYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701463422; x=1702068222; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8DGOijOKJdOqvHyhZyvR9Q5yxUXm8+4SFnahsPvs8Go=; b=H+0BqRM2tIWjQu+/L9ei1jrB0QeuV5ZFouj5eKs45/jryZP0g5pLFbGpkNAEuLetCX MYXT0Bw1F+C5IqHiuqrDQhv/p2LTWtQQbxqaEnz8G0EJRZfSrvdifYGzyAb6NoCvbK5e zclPkLePHn6QmW2xqZwMDgtwkdxJxgnRcqBd+cGbI9H+0mLLlkMduD70JIWCRPecX+f4 Wyey+wFqGNYNAryYa9BspD12IUEKO/3tCptlC0d8iiuXKoHnhJeIpqTXgukgEx0+M0/2 bfEqvJdEhaaL28YUbWF0TmmcbOmoid8LHsxn6zN9zbRhVFpNQSfiYotFZXBwlwXhrgdV sPow== X-Gm-Message-State: AOJu0YyYYqXPUNmx7RL9LpOgsgTt1/HUsAFCWYsqTEOjDvRtSQjvV4dO BVQRdU+qzHRZH8x753xvNaJ+o2Tx1UT0CTwgA+0= X-Google-Smtp-Source: AGHT+IEPklOggGhqkFhQ2Qsk3hdLlT/9jsyZdFT2aiWhHYupt/kHX/YivRA4EodBCfr+4zoVrZPmBg== X-Received: by 2002:a17:90a:f016:b0:286:6cc0:8867 with SMTP id bt22-20020a17090af01600b002866cc08867mr110028pjb.84.1701463421817; Fri, 01 Dec 2023 12:43:41 -0800 (PST) Received: from rogue-one.tail33bf8.ts.net ([201.17.86.134]) by smtp.gmail.com with ESMTPSA id mz18-20020a17090b379200b002865683a7c8sm1933467pjb.25.2023.12.01.12.43.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 12:43:41 -0800 (PST) From: Pedro Tammela To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, marcelo.leitner@gmail.com, vladbu@nvidia.com, Victor Nogueira , Pedro Tammela Subject: [PATCH net-next 1/4] rtnl: add helper to check if rtnl group has listeners Date: Fri, 1 Dec 2023 17:43:11 -0300 Message-Id: <20231201204314.220543-2-pctammela@mojatatu.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231201204314.220543-1-pctammela@mojatatu.com> References: <20231201204314.220543-1-pctammela@mojatatu.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jamal Hadi Salim As of today, rtnl code creates a new skb and unconditionally fills and broadcasts it to the relevant group. For most operations this is okay and doesn't waste resources in general. When operations are done without the rtnl_lock, as in tc-flower, such skb allocation, message fill and no-op broadcasting can happen in all cores of the system, which contributes to system pressure and wastes precious cpu cycles when no one will receive the built message. Introduce this helper so rtnetlink operations can simply check if someone is listening and then proceed if necessary. Signed-off-by: Jamal Hadi Salim Signed-off-by: Victor Nogueira Signed-off-by: Pedro Tammela --- include/linux/rtnetlink.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index 3d6cf306cd55..a7d757e96c55 100644 --- a/include/linux/rtnetlink.h +++ b/include/linux/rtnetlink.h @@ -130,4 +130,11 @@ extern int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, extern void rtnl_offload_xstats_notify(struct net_device *dev); +static inline int rtnl_has_listeners(const struct net *net, u32 group) +{ + struct sock *rtnl = net->rtnl; + + return netlink_has_listeners(rtnl, group); +} + #endif /* __LINUX_RTNETLINK_H */ From patchwork Fri Dec 1 20:43:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13476378 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mojatatu-com.20230601.gappssmtp.com header.i=@mojatatu-com.20230601.gappssmtp.com header.b="VuQRjOYP" Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 162A2FF for ; Fri, 1 Dec 2023 12:43:46 -0800 (PST) Received: by mail-il1-x135.google.com with SMTP id e9e14a558f8ab-35942cb9ef4so8741085ab.3 for ; Fri, 01 Dec 2023 12:43:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1701463425; x=1702068225; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gJegg0KXpT9FOB7cbGUhiBOosv4mMjWt9zehWWNUU+4=; b=VuQRjOYP7oTXK2aOElG5bmM1b1+gaRh+GGYb/NMz5D7RN6/49lYI2MY/vOaFB6WIiu YmAMWJt0ig0k4f0mPvm7IQvoFKMYGMu7E56LFTUTVpEvVtEXZFnFRd0XYlXkmBvBWvK8 EZBPLExs7A9o6ClykTpAkfirKs6kFqz9P3jTKV6k+Yu5tIdUNcD76yMn8+VhWYh3X6hZ 1WewDgiIfLPMWxoepPotNUg8ffizkdIhnx2p4hDoRqlgdHa40AN9g774PBgMUbpK3qxE Niu3U2clNsxG19cRRgtAimEcsAL8DYf6jbBxCRDXaIDP+5/glWrL4ocj7pKsORqB84Cd rheQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701463425; x=1702068225; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gJegg0KXpT9FOB7cbGUhiBOosv4mMjWt9zehWWNUU+4=; b=rVGi3zi1v19iIiYKbymlQIzE+/9kRS0QQaLE8p+KlBlxxgtjFuf+YlWc1AYbDC/0fO OZtTbhih9+AfGQAaYIsKmcS6BpfskB8SAz6WKTNZzYTbvILzgGThoHSsgcJu20PcBoF9 S8ZoMMLnW8DtKPeTuZMeymxPNS20pcodqROu1m/MWsVtJaJi/poNPru1ADD4VyP9n6IT hKCHr8K+WS8mJq4kykayreEUUx2lH0gjaAdU/LKXVLl4JOfMo+wKS7McKzhUpzWP1KMo mcpZqGr7GteSnLLzYUQTVSs4doqIn/jmlXQFHSZBl9pVLGUHFePg6qPvQMJa2zsB9GCy p4EA== X-Gm-Message-State: AOJu0Yzz3ZK4SCFmzXneDIIqqvSVAD2Ec1MADGveJOzhDOxCROLH0Fvc jHBWysIXK16tMKE67eH5XLL6iDnqJ/TwGIRmEWA= X-Google-Smtp-Source: AGHT+IGXc4YBOPkuG86H1KTSVJKATjQz9dfgtQ7eJNOsf0CCfHTFRTwqO5peOlIACyRe54zFAT0/Pg== X-Received: by 2002:a05:6e02:c66:b0:35d:59a2:2e3 with SMTP id f6-20020a056e020c6600b0035d59a202e3mr84556ilj.131.1701463425212; Fri, 01 Dec 2023 12:43:45 -0800 (PST) Received: from rogue-one.tail33bf8.ts.net ([201.17.86.134]) by smtp.gmail.com with ESMTPSA id mz18-20020a17090b379200b002865683a7c8sm1933467pjb.25.2023.12.01.12.43.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 12:43:44 -0800 (PST) From: Pedro Tammela To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, marcelo.leitner@gmail.com, vladbu@nvidia.com, Victor Nogueira , Pedro Tammela Subject: [PATCH net-next 2/4] net/sched: add helper to check if a notification is needed Date: Fri, 1 Dec 2023 17:43:12 -0300 Message-Id: <20231201204314.220543-3-pctammela@mojatatu.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231201204314.220543-1-pctammela@mojatatu.com> References: <20231201204314.220543-1-pctammela@mojatatu.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Victor Nogueira Building on the rtnl_has_listeners helper, add the tc_should_notify helper to check if we can bail out early in the tc notification routines. Signed-off-by: Victor Nogueira Signed-off-by: Pedro Tammela --- include/net/pkt_cls.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index a76c9171db0e..39c24cf30984 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -1065,4 +1065,9 @@ static inline void tc_skb_ext_tc_disable(void) { } #define tc_skb_ext_tc_enabled() false #endif +static inline bool tc_should_notify(const struct net *net, u16 nlflags) +{ + return (nlflags & NLM_F_ECHO) || rtnl_has_listeners(net, RTNLGRP_TC); +} + #endif From patchwork Fri Dec 1 20:43:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13476379 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mojatatu-com.20230601.gappssmtp.com header.i=@mojatatu-com.20230601.gappssmtp.com header.b="05AjA+KM" Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E48A10C2 for ; Fri, 1 Dec 2023 12:43:49 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-2864a74f297so1682259a91.2 for ; Fri, 01 Dec 2023 12:43:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1701463428; x=1702068228; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3fvX/TGxfozRCM/n8ckwHzCI9nP403SfPlaIPxthkm4=; b=05AjA+KMWh1bfymqsWCliUyFeQLFIGA197YphozIeXfAFOoAwCK6X+8j/riicDySix dA5t/3oUTkztUHIrMP+9RcVa90nWeAOoiamYwGHBvcomzpbbh98m39EV91FZt73XmARp hkSypLlH1EHkZeSuYdgIvGLq1ukGc9ma/16TJfcGk8noeToLJN1a18sw/St62E1EK6Wc b/Fq0VnRBDBnYvwFTE6d08y9U5iM7i0fYT/9SNhLliOAX4u0m+3xbOVbGqew9N+mMJzo ACPiO9Iwm4ovAPW5csMDRpUQoExJVkM/RZdmFLyFdOCZlOBLAXw8yICBNkQ8qPSfm478 8auQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701463428; x=1702068228; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3fvX/TGxfozRCM/n8ckwHzCI9nP403SfPlaIPxthkm4=; b=aaPt7c5F0s5XXjRtMBz4+xJuqER9T8mhgHpwNezWj34cczmQ+88nhwrMRANg3T5YmY texf5OCXvWSdfLu42WPSL19zV0Jw0tY4isDILnnRKnBEfWcSRGA4wFQPIO2k05VmLxL/ XS588zQHVobq4BGYYvupOW0NiPr9RBrXiiNqW3ueAwN8Pboqol7xh+0/Zht3UuXU5O7u DRNUGH+ZerEBqA1abZ7MtUw+9VfUUHPkSuCzB1LeGAQbZ3yatbqig+AvNA2O59gIMGWn 54llHj2to2GwJ40Ngi/wYpziHxc13GIG/7rPZ+RhJuhPW1p0RF/AuYD/Cxx5L6lWGx3k GZ2g== X-Gm-Message-State: AOJu0YyKtTh/5WRxtn4+LeX74xBn1uJJ+cYcxKqkIte9Ocs2i5mN2K6c uzlEQm8nbYq5hjiYfm6aIsCty+gzW5ymdQA5o4A= X-Google-Smtp-Source: AGHT+IHcRT+e+Mp5G4AHV3rfLT5rtblpoQQfd3NtPHFcXEKMmLjLbmdibKNI+aSsRGbMXxqKmsf8yg== X-Received: by 2002:a17:90a:8a93:b0:286:6cc1:5fce with SMTP id x19-20020a17090a8a9300b002866cc15fcemr97523pjn.81.1701463428378; Fri, 01 Dec 2023 12:43:48 -0800 (PST) Received: from rogue-one.tail33bf8.ts.net ([201.17.86.134]) by smtp.gmail.com with ESMTPSA id mz18-20020a17090b379200b002865683a7c8sm1933467pjb.25.2023.12.01.12.43.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 12:43:48 -0800 (PST) From: Pedro Tammela To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, marcelo.leitner@gmail.com, vladbu@nvidia.com, Pedro Tammela Subject: [PATCH net-next 3/4] net/sched: act_api: conditional notification of events Date: Fri, 1 Dec 2023 17:43:13 -0300 Message-Id: <20231201204314.220543-4-pctammela@mojatatu.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231201204314.220543-1-pctammela@mojatatu.com> References: <20231201204314.220543-1-pctammela@mojatatu.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org As of today tc-action events are unconditionally built and sent to RTNLGRP_TC. As with the introduction of tc_should_notify we can check before-hand if they are really needed. Signed-off-by: Pedro Tammela --- net/sched/act_api.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/net/sched/act_api.c b/net/sched/act_api.c index c39252d61ebb..2570f9702eeb 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -1791,6 +1791,13 @@ tcf_reoffload_del_notify(struct net *net, struct tc_action *action) struct sk_buff *skb; int ret; + if (!tc_should_notify(net, 0)) { + ret = tcf_idr_release_unsafe(action); + if (ret == ACT_P_DELETED) + module_put(ops->owner); + return ret; + } + skb = alloc_skb(attr_size <= NLMSG_GOODSIZE ? NLMSG_GOODSIZE : attr_size, GFP_KERNEL); if (!skb) @@ -1877,6 +1884,13 @@ tcf_del_notify(struct net *net, struct nlmsghdr *n, struct tc_action *actions[], int ret; struct sk_buff *skb; + if (!tc_should_notify(net, n->nlmsg_flags)) { + ret = tcf_action_delete(net, actions); + if (ret < 0) + NL_SET_ERR_MSG(extack, "Failed to delete TC action"); + return ret; + } + skb = alloc_skb(attr_size <= NLMSG_GOODSIZE ? NLMSG_GOODSIZE : attr_size, GFP_KERNEL); if (!skb) @@ -1956,6 +1970,9 @@ tcf_add_notify(struct net *net, struct nlmsghdr *n, struct tc_action *actions[], { struct sk_buff *skb; + if (!tc_should_notify(net, n->nlmsg_flags)) + return 0; + skb = alloc_skb(attr_size <= NLMSG_GOODSIZE ? NLMSG_GOODSIZE : attr_size, GFP_KERNEL); if (!skb) From patchwork Fri Dec 1 20:43:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13476380 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mojatatu-com.20230601.gappssmtp.com header.i=@mojatatu-com.20230601.gappssmtp.com header.b="OXl2Q+lW" Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 678E8F1 for ; Fri, 1 Dec 2023 12:43:52 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1ce3084c2d1so8605275ad.3 for ; Fri, 01 Dec 2023 12:43:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1701463431; x=1702068231; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4QeFqkq5Sm15ECcIa5VGRkWrRM1DnWBwp0NyD4pxGB4=; b=OXl2Q+lWMuOB3XyL8jkO0jsJRpB7K9m/ThDkcowFyOXB9pannVr+sujzuxFw4cQekE mHQNA9tj8BUg+6N8dguhm8UQ+dZ5oirCDDzNjWw9VgKCz7XHydb9sqzz6ogTBFds5OE6 7JreCoycxg0J52JCn53G4xXPq8Qa+nC647ZrXt2n+E589ApkmZ3ZusE4+TmuyeB7Uh6y yAGAqi3E6aFMKYjmSS+hKyEyMnYdHteCHKHbL6j4+vnB2iKc6uQrni/M6S0uRIvgddPr IOGv9Em1bYmFBIYFYQPDZXURpEGdt/5Pycx55EAN5STCyrkJeMCtZKktCWXOFzDixzN9 G+Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701463431; x=1702068231; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4QeFqkq5Sm15ECcIa5VGRkWrRM1DnWBwp0NyD4pxGB4=; b=dzCG5gL8H7ZTQfTQJa5fXPZ3E3ZQuRmLMM4qBEOwXBhkmGX1dwfJcx74XeaRnnGZwk uFUUXkHLb4qtJvVJpSm/2QJBDo4AjV1kRDd60L6xN+T76ed/qMfrVUjAfdHUW6Zj8RJq fJCeIIu8Ghct55P3XecSpiy3xSwtHxVvoZGUN/FTyzaTtAaZalr/0uC22BVgFDI5A3hU dZ9IrhxV1r71RHPPvlaG8HjJlgk64p3fGQ4iTbwmglfADBFK69UmQHCdarWN2NqWPsbg esHKRK6UPWp4AJ7WGa8JW5UvbSUoEjscDqTSHeRGmGG8qLUp2Jl+0KvFdlwRKd+cnHAr qDOQ== X-Gm-Message-State: AOJu0Ywb5FhN1RjaRsJeKQhj59wd/McXo6AX/h5uYdl7oCuzii9iDGgz UGW+RyiJ8jf/0piTtafJkvPlW5ETCMh3ukav228= X-Google-Smtp-Source: AGHT+IFMccKgHG5WESJQgWVrd2H6he8nKBnXWT5AAwThNXZM66534JfaBtCpBH6UK58eA7ylT7A9dw== X-Received: by 2002:a17:902:f811:b0:1cf:a5a0:5f85 with SMTP id ix17-20020a170902f81100b001cfa5a05f85mr113075plb.25.1701463431601; Fri, 01 Dec 2023 12:43:51 -0800 (PST) Received: from rogue-one.tail33bf8.ts.net ([201.17.86.134]) by smtp.gmail.com with ESMTPSA id mz18-20020a17090b379200b002865683a7c8sm1933467pjb.25.2023.12.01.12.43.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 12:43:51 -0800 (PST) From: Pedro Tammela To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, marcelo.leitner@gmail.com, vladbu@nvidia.com, Pedro Tammela Subject: [PATCH net-next 4/4] net/sched: cls_api: conditional notification of events Date: Fri, 1 Dec 2023 17:43:14 -0300 Message-Id: <20231201204314.220543-5-pctammela@mojatatu.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231201204314.220543-1-pctammela@mojatatu.com> References: <20231201204314.220543-1-pctammela@mojatatu.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org As of today tc-filter/chain events are unconditionally built and sent to RTNLGRP_TC. As with the introduction of tc_should_notify we can check before-hand if they are really needed. This will help to alleviate system pressure when filters are concurrently added without the rtnl lock as in tc-flower. Signed-off-by: Pedro Tammela --- net/sched/cls_api.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 1976bd163986..e99df0543c91 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -2053,6 +2053,9 @@ static int tfilter_notify(struct net *net, struct sk_buff *oskb, u32 portid = oskb ? NETLINK_CB(oskb).portid : 0; int err = 0; + if (!unicast && !tc_should_notify(net, n->nlmsg_flags)) + return 0; + skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL); if (!skb) return -ENOBUFS; @@ -2082,6 +2085,9 @@ static int tfilter_del_notify(struct net *net, struct sk_buff *oskb, u32 portid = oskb ? NETLINK_CB(oskb).portid : 0; int err; + if (!unicast && !tc_should_notify(net, n->nlmsg_flags)) + return tp->ops->delete(tp, fh, last, rtnl_held, extack); + skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL); if (!skb) return -ENOBUFS; @@ -2906,6 +2912,9 @@ static int tc_chain_notify(struct tcf_chain *chain, struct sk_buff *oskb, struct sk_buff *skb; int err = 0; + if (!unicast && !tc_should_notify(net, flags)) + return 0; + skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL); if (!skb) return -ENOBUFS; @@ -2935,6 +2944,9 @@ static int tc_chain_notify_delete(const struct tcf_proto_ops *tmplt_ops, struct net *net = block->net; struct sk_buff *skb; + if (!unicast && !tc_should_notify(net, flags)) + return 0; + skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL); if (!skb) return -ENOBUFS;