Skip to content

Commit 037be03

Browse files
vedangpatel1davem330
authored andcommitted
taprio: calculate cycle_time when schedule is installed
cycle time for a particular schedule is calculated only when it is first installed. So, it makes sense to just calculate it once right after the 'cycle_time' parameter has been parsed and store it in cycle_time. Signed-off-by: Vedang Patel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d14d2b2 commit 037be03

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

net/sched/sch_taprio.c

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,6 @@ static void switch_schedules(struct taprio_sched *q,
108108
*admin = NULL;
109109
}
110110

111-
static ktime_t get_cycle_time(struct sched_gate_list *sched)
112-
{
113-
struct sched_entry *entry;
114-
ktime_t cycle = 0;
115-
116-
if (sched->cycle_time != 0)
117-
return sched->cycle_time;
118-
119-
list_for_each_entry(entry, &sched->entries, list)
120-
cycle = ktime_add_ns(cycle, entry->interval);
121-
122-
sched->cycle_time = cycle;
123-
124-
return cycle;
125-
}
126-
127111
static int taprio_enqueue(struct sk_buff *skb, struct Qdisc *sch,
128112
struct sk_buff **to_free)
129113
{
@@ -524,6 +508,15 @@ static int parse_taprio_schedule(struct nlattr **tb,
524508
if (err < 0)
525509
return err;
526510

511+
if (!new->cycle_time) {
512+
struct sched_entry *entry;
513+
ktime_t cycle = 0;
514+
515+
list_for_each_entry(entry, &new->entries, list)
516+
cycle = ktime_add_ns(cycle, entry->interval);
517+
new->cycle_time = cycle;
518+
}
519+
527520
return 0;
528521
}
529522

@@ -605,7 +598,7 @@ static int taprio_get_start_time(struct Qdisc *sch,
605598
return 0;
606599
}
607600

608-
cycle = get_cycle_time(sched);
601+
cycle = sched->cycle_time;
609602

610603
/* The qdisc is expected to have at least one sched_entry. Moreover,
611604
* any entry must have 'interval' > 0. Thus if the cycle time is zero,
@@ -632,7 +625,7 @@ static void setup_first_close_time(struct taprio_sched *q,
632625
first = list_first_entry(&sched->entries,
633626
struct sched_entry, list);
634627

635-
cycle = get_cycle_time(sched);
628+
cycle = sched->cycle_time;
636629

637630
/* FIXME: find a better place to do this */
638631
sched->cycle_close_time = ktime_add_ns(base, cycle);

0 commit comments

Comments
 (0)