From: Faizal Rahim <faizal.abdul.rahim@linux.intel.com>
To: Vladimir Oltean <vladimir.oltean@nxp.com>,
Vinicius Costa Gomes <vinicius.gomes@intel.com>,
Jamal Hadi Salim <jhs@mojatatu.com>,
Cong Wang <xiyou.wangcong@gmail.com>,
Jiri Pirko <jiri@resnulli.us>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3 net 3/4] net/sched: taprio: fix impacted fields value during cycle time adjustment
Date: Tue, 19 Dec 2023 03:14:52 -0500 [thread overview]
Message-ID: <20231219081453.718489-4-faizal.abdul.rahim@linux.intel.com> (raw)
In-Reply-To: <20231219081453.718489-1-faizal.abdul.rahim@linux.intel.com>
During the cycle time adjustment period, there's a single entry left
from the oper schedule to be executed. As a result, updates are
needed for the affected fields' logic, which did not previously
consider dynamic scheduling.
Fixes: a306a90c8ffe ("net/sched: taprio: calculate tc gate durations")
Signed-off-by: Faizal Rahim <faizal.abdul.rahim@linux.intel.com>
---
net/sched/sch_taprio.c | 44 +++++++++++++++++++++++++++++++++++++++---
1 file changed, 41 insertions(+), 3 deletions(-)
diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
index e70dc69c311f..a3c71be21af2 100644
--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -285,7 +285,8 @@ static void taprio_update_queue_max_sdu(struct taprio_sched *q,
/* TC gate never closes => keep the queueMaxSDU
* selected by the user
*/
- if (sched->max_open_gate_duration[tc] == sched->cycle_time) {
+ if (sched->max_open_gate_duration[tc] == sched->cycle_time &&
+ !sched_switch_pending(sched)) {
max_sdu_dynamic = U32_MAX;
} else {
u32 max_frm_len;
@@ -681,7 +682,8 @@ static void taprio_set_budgets(struct taprio_sched *q,
for (tc = 0; tc < num_tc; tc++) {
/* Traffic classes which never close have infinite budget */
- if (entry->gate_duration[tc] == sched->cycle_time)
+ if (entry->gate_duration[tc] == sched->cycle_time &&
+ !sched_switch_pending(sched))
budget = INT_MAX;
else
budget = div64_u64((u64)entry->gate_duration[tc] * PSEC_PER_NSEC,
@@ -893,6 +895,29 @@ static bool should_restart_cycle(const struct sched_gate_list *oper,
return false;
}
+/* Open gate duration were calculated at the beginning with consideration of
+ * multiple entries. If sched_switch_pending() is active, there's only a single
+ * remaining entry left from oper to run. Update open gate duration based
+ * on this last entry.
+ */
+static void update_open_gate_duration(struct sched_entry *entry,
+ struct sched_gate_list *oper,
+ int num_tc,
+ u64 open_gate_duration)
+{
+ int tc;
+
+ for (tc = 0; tc < num_tc; tc++) {
+ if (entry->gate_mask & BIT(tc)) {
+ entry->gate_duration[tc] = open_gate_duration;
+ oper->max_open_gate_duration[tc] = open_gate_duration;
+ } else {
+ entry->gate_duration[tc] = 0;
+ oper->max_open_gate_duration[tc] = 0;
+ }
+ }
+}
+
static bool should_extend_cycle(const struct sched_gate_list *oper,
ktime_t new_base_time,
ktime_t next_entry_end_time,
@@ -1002,13 +1027,26 @@ static enum hrtimer_restart advance_sched(struct hrtimer *timer)
/* The next entry is the last entry we will run from
* oper, subsequent ones will take from the new admin
*/
+ u64 new_gate_duration =
+ next->interval + oper->cycle_time_correction;
+ struct qdisc_size_table *stab;
+
oper->cycle_end_time = new_base_time;
end_time = new_base_time;
+
+ update_open_gate_duration(next, oper, num_tc,
+ new_gate_duration);
+ rcu_read_lock();
+ stab = rcu_dereference(q->root->stab);
+ taprio_update_queue_max_sdu(q, oper, stab);
+ rcu_read_unlock();
}
}
for (tc = 0; tc < num_tc; tc++) {
- if (next->gate_duration[tc] == oper->cycle_time)
+ if (sched_switch_pending(oper) && (next->gate_mask & BIT(tc)))
+ next->gate_close_time[tc] = end_time;
+ else if (next->gate_duration[tc] == oper->cycle_time)
next->gate_close_time[tc] = KTIME_MAX;
else
next->gate_close_time[tc] = ktime_add_ns(entry->end_time,
--
2.25.1
next prev parent reply other threads:[~2023-12-19 8:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-19 8:14 [PATCH v3 net 0/4] qbv cycle time extension/truncation Faizal Rahim
2023-12-19 8:14 ` [PATCH v3 net 1/4] net/sched: taprio: fix too early schedules switching Faizal Rahim
2023-12-19 8:14 ` [PATCH v3 net 2/4] net/sched: taprio: fix cycle time adjustment for next entry Faizal Rahim
2023-12-19 8:14 ` Faizal Rahim [this message]
2023-12-19 8:14 ` [PATCH v3 net 4/4] net/sched: taprio: get corrected value of cycle_time and interval Faizal Rahim
2023-12-19 16:56 ` [PATCH v3 net 0/4] qbv cycle time extension/truncation Vladimir Oltean
2023-12-20 3:25 ` Abdul Rahim, Faizal
2023-12-21 13:35 ` Vladimir Oltean
2023-12-29 2:15 ` Abdul Rahim, Faizal
2023-12-21 8:52 ` Paolo Abeni
2023-12-21 10:12 ` Abdul Rahim, Faizal
2023-12-19 17:02 ` Eric Dumazet
2023-12-21 5:57 ` Abdul Rahim, Faizal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231219081453.718489-4-faizal.abdul.rahim@linux.intel.com \
--to=faizal.abdul.rahim@linux.intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vinicius.gomes@intel.com \
--cc=vladimir.oltean@nxp.com \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox