From patchwork Tue May 9 23:50:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuxuan Luo X-Patchwork-Id: 1779144 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=mAWg4XXl; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QGFLM6Q5cz214S for ; Wed, 10 May 2023 09:51:39 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1pwX7F-0007Xv-V7; Tue, 09 May 2023 23:51:33 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1pwX7A-0007Rw-Nj for kernel-team@lists.ubuntu.com; Tue, 09 May 2023 23:51:28 +0000 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 78C863F481 for ; Tue, 9 May 2023 23:51:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1683676288; bh=Hd2NphSrvf/2wCL0Q7bjMnFTfSeNesU1E2UeLP2MqT8=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mAWg4XXlQXegxW5IT1Jr1IMZqk/jbQmMpLV0ntvnsWNV9mrMtmO5q1pjNDiwn+/K+ ceTDltvzhliO5eaN/cMpgw7J6y2XeXdxHharCkWIj3RR8tDxDPJihbkOQD6zsQ+G+Q 5bn6IAUPgc1R9WD/PxO/nm1g1Jp4eOY5xk0KCiTV3sFxOnlsP5dqAqi+u8YZOPSq1y VONe5WcMrBbHPTBWkj5Ea2xNiDi0Wya+iAxZ5OSHnZBVk4ovLISuDn/Z2692B4lR00 nRWyGJY1zQoD90UW4WKtw+/hU2g78Md1ym/YNb6X2gf4SI2HCaM9hn5zBob0fDECsv VCtt6Avflbk6A== Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-50bcb45f749so6116323a12.2 for ; Tue, 09 May 2023 16:51:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683676288; x=1686268288; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Hd2NphSrvf/2wCL0Q7bjMnFTfSeNesU1E2UeLP2MqT8=; b=a0zunYXQhKR2BSo+3dr/QlJ8BZztJGF517ZKMSLpoEdsJnp1Wi37Xl2UTCf0u/XNNm dBbERtr8ChJYfMO5KAP1M3IUYWQTMwKCLjpm2FVXBN8xKKWJiRRKY5QLJyufrIj1jROQ /0H92A6CGXSGMN2vw964gIpkvJkk0+bQdZbjfvHzCY22Ijr3f6FoVPlU5mYNZUFPOQMe klTfdkczcrEYd9ig3sT260wdZ716vmtfCgCXCv2cXOzVeaOLzY7QrWQutnleolrinyOq QGmxnQ1t5fKo8c1fLotpnP7bctxe21CIB6ZxbzwZl0ALP6WajfkJtNLJuaOkD6giORyt YCqg== X-Gm-Message-State: AC+VfDyCH4+V248dWiA+GgCERx4blsrIn05Q6uVbRYELXUUYITe5CARQ v3UZ7cg8QAYD2vTfzknBEokaYNAl0Us+s9AsqZplIJ/WuLhf/pUFqVG5YP02LpUN6rUh8ElUdWH z/AS8pB52fiECtqr9/Sv4GZsEbWHTeLmeM4HAEMwaD6u+3REKmQ== X-Received: by 2002:a05:6402:74e:b0:508:3b1f:e6b5 with SMTP id p14-20020a056402074e00b005083b1fe6b5mr12950710edy.15.1683676287840; Tue, 09 May 2023 16:51:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6IUE/KBEx3sOlpnCLPi8fzN5FWCU+GeKVuxZzA0aTlxKbZjAFV5zlmzm25WlChpcxR7kqe3g== X-Received: by 2002:a05:6402:74e:b0:508:3b1f:e6b5 with SMTP id p14-20020a056402074e00b005083b1fe6b5mr12950705edy.15.1683676287588; Tue, 09 May 2023 16:51:27 -0700 (PDT) Received: from localhost.localdomain ([2001:67c:1562:8007::aac:4795]) by smtp.gmail.com with ESMTPSA id p15-20020aa7cc8f000000b0050bcca2e459sm1295429edt.8.2023.05.09.16.51.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 16:51:27 -0700 (PDT) From: Yuxuan Luo To: kernel-team@lists.ubuntu.com Subject: [SRU][Focal][PATCH 3/3] net: sched: extract qstats update code into functions Date: Tue, 9 May 2023 19:50:43 -0400 Message-Id: <20230509235043.69974-6-yuxuan.luo@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230509235043.69974-1-yuxuan.luo@canonical.com> References: <20230509235043.69974-1-yuxuan.luo@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Vlad Buslov Extract common code that increments cpu_qstats counters into standalone act API functions. Change hardware offloaded actions that use percpu counter allocation to use the new functions instead of accessing cpu_qstats directly. This commit doesn't change functionality. Signed-off-by: Vlad Buslov Acked-by: Jiri Pirko Signed-off-by: David S. Miller (cherry picked from commit 26b537a88ca5b7399c7ab0656e06dbd9da9513c1) Signed-off-by: Yuxuan Luo --- include/net/act_api.h | 15 +++++++++++++++ net/sched/act_csum.c | 2 +- net/sched/act_ct.c | 2 +- net/sched/act_gact.c | 2 +- net/sched/act_mirred.c | 2 +- net/sched/act_vlan.c | 2 +- 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/include/net/act_api.h b/include/net/act_api.h index 4dabe4730f00f..d9f9ae3803d58 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h @@ -186,6 +186,21 @@ int tcf_action_dump(struct sk_buff *skb, struct tc_action *actions[], int bind, int ref); int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int); int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int); +static inline struct gnet_stats_queue * +tcf_action_get_qstats(struct tc_action *a) +{ + return this_cpu_ptr(a->cpu_qstats); +} + +static inline void tcf_action_inc_drop_qstats(struct tc_action *a) +{ + qstats_drop_inc(this_cpu_ptr(a->cpu_qstats)); +} + +static inline void tcf_action_inc_overlimit_qstats(struct tc_action *a) +{ + qstats_overlimit_inc(this_cpu_ptr(a->cpu_qstats)); +} int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int); int tcf_action_check_ctrlact(int action, struct tcf_proto *tp, diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c index fa1b1fd10c441..a88f39c118194 100644 --- a/net/sched/act_csum.c +++ b/net/sched/act_csum.c @@ -621,7 +621,7 @@ static int tcf_csum_act(struct sk_buff *skb, const struct tc_action *a, return action; drop: - qstats_drop_inc(this_cpu_ptr(p->common.cpu_qstats)); + tcf_action_inc_drop_qstats(&p->common); action = TC_ACT_SHOT; goto out; } diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c index 02d4491991b5e..2fbb7d08007dd 100644 --- a/net/sched/act_ct.c +++ b/net/sched/act_ct.c @@ -486,7 +486,7 @@ static int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a, return retval; drop: - qstats_drop_inc(this_cpu_ptr(a->cpu_qstats)); + tcf_action_inc_drop_qstats(&c->common); return TC_ACT_SHOT; } diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c index faf68a44b8451..c80b8220845e5 100644 --- a/net/sched/act_gact.c +++ b/net/sched/act_gact.c @@ -161,7 +161,7 @@ static int tcf_gact_act(struct sk_buff *skb, const struct tc_action *a, #endif bstats_cpu_update(this_cpu_ptr(gact->common.cpu_bstats), skb); if (action == TC_ACT_SHOT) - qstats_drop_inc(this_cpu_ptr(gact->common.cpu_qstats)); + tcf_action_inc_drop_qstats(&gact->common); tcf_lastuse_update(&gact->tcf_tm); diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c index bfed9b6ebe32d..88018b4ad57ba 100644 --- a/net/sched/act_mirred.c +++ b/net/sched/act_mirred.c @@ -324,7 +324,7 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a, err = tcf_mirred_forward(want_ingress, skb2); if (err) { out: - qstats_overlimit_inc(this_cpu_ptr(m->common.cpu_qstats)); + tcf_action_inc_overlimit_qstats(&m->common); if (tcf_mirred_is_act_redirect(m_eaction)) retval = TC_ACT_SHOT; } diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c index 7dc76c68ec52d..65cbc1a2738e7 100644 --- a/net/sched/act_vlan.c +++ b/net/sched/act_vlan.c @@ -88,7 +88,7 @@ static int tcf_vlan_act(struct sk_buff *skb, const struct tc_action *a, return action; drop: - qstats_drop_inc(this_cpu_ptr(v->common.cpu_qstats)); + tcf_action_inc_drop_qstats(&v->common); return TC_ACT_SHOT; }