@@ -9404,20 +9404,14 @@ static int tg_set_cfs_bandwidth(struct task_group *tg, u64 period, u64 quota,
94049404 return 0 ;
94059405}
94069406
9407- static int tg_set_cfs_quota (struct task_group * tg , long cfs_quota_us )
9407+ static long tg_get_cfs_period (struct task_group * tg )
94089408{
9409- u64 quota , period , burst ;
9409+ u64 cfs_period_us ;
94109410
9411- period = ktime_to_ns (tg -> cfs_bandwidth .period );
9412- burst = tg -> cfs_bandwidth .burst ;
9413- if (cfs_quota_us < 0 )
9414- quota = RUNTIME_INF ;
9415- else if ((u64 )cfs_quota_us <= U64_MAX / NSEC_PER_USEC )
9416- quota = (u64 )cfs_quota_us * NSEC_PER_USEC ;
9417- else
9418- return - EINVAL ;
9411+ cfs_period_us = ktime_to_ns (tg -> cfs_bandwidth .period );
9412+ do_div (cfs_period_us , NSEC_PER_USEC );
94199413
9420- return tg_set_cfs_bandwidth ( tg , period , quota , burst ) ;
9414+ return cfs_period_us ;
94219415}
94229416
94239417static long tg_get_cfs_quota (struct task_group * tg )
@@ -9433,6 +9427,16 @@ static long tg_get_cfs_quota(struct task_group *tg)
94339427 return quota_us ;
94349428}
94359429
9430+ static long tg_get_cfs_burst (struct task_group * tg )
9431+ {
9432+ u64 burst_us ;
9433+
9434+ burst_us = tg -> cfs_bandwidth .burst ;
9435+ do_div (burst_us , NSEC_PER_USEC );
9436+
9437+ return burst_us ;
9438+ }
9439+
94369440static int tg_set_cfs_period (struct task_group * tg , long cfs_period_us )
94379441{
94389442 u64 quota , period , burst ;
@@ -9447,14 +9451,20 @@ static int tg_set_cfs_period(struct task_group *tg, long cfs_period_us)
94479451 return tg_set_cfs_bandwidth (tg , period , quota , burst );
94489452}
94499453
9450- static long tg_get_cfs_period (struct task_group * tg )
9454+ static int tg_set_cfs_quota (struct task_group * tg , long cfs_quota_us )
94519455{
9452- u64 cfs_period_us ;
9456+ u64 quota , period , burst ;
94539457
9454- cfs_period_us = ktime_to_ns (tg -> cfs_bandwidth .period );
9455- do_div (cfs_period_us , NSEC_PER_USEC );
9458+ period = ktime_to_ns (tg -> cfs_bandwidth .period );
9459+ burst = tg -> cfs_bandwidth .burst ;
9460+ if (cfs_quota_us < 0 )
9461+ quota = RUNTIME_INF ;
9462+ else if ((u64 )cfs_quota_us <= U64_MAX / NSEC_PER_USEC )
9463+ quota = (u64 )cfs_quota_us * NSEC_PER_USEC ;
9464+ else
9465+ return - EINVAL ;
94569466
9457- return cfs_period_us ;
9467+ return tg_set_cfs_bandwidth ( tg , period , quota , burst ) ;
94589468}
94599469
94609470static int tg_set_cfs_burst (struct task_group * tg , long cfs_burst_us )
@@ -9471,52 +9481,6 @@ static int tg_set_cfs_burst(struct task_group *tg, long cfs_burst_us)
94719481 return tg_set_cfs_bandwidth (tg , period , quota , burst );
94729482}
94739483
9474- static long tg_get_cfs_burst (struct task_group * tg )
9475- {
9476- u64 burst_us ;
9477-
9478- burst_us = tg -> cfs_bandwidth .burst ;
9479- do_div (burst_us , NSEC_PER_USEC );
9480-
9481- return burst_us ;
9482- }
9483-
9484- static s64 cpu_cfs_quota_read_s64 (struct cgroup_subsys_state * css ,
9485- struct cftype * cft )
9486- {
9487- return tg_get_cfs_quota (css_tg (css ));
9488- }
9489-
9490- static int cpu_cfs_quota_write_s64 (struct cgroup_subsys_state * css ,
9491- struct cftype * cftype , s64 cfs_quota_us )
9492- {
9493- return tg_set_cfs_quota (css_tg (css ), cfs_quota_us );
9494- }
9495-
9496- static u64 cpu_cfs_period_read_u64 (struct cgroup_subsys_state * css ,
9497- struct cftype * cft )
9498- {
9499- return tg_get_cfs_period (css_tg (css ));
9500- }
9501-
9502- static int cpu_cfs_period_write_u64 (struct cgroup_subsys_state * css ,
9503- struct cftype * cftype , u64 cfs_period_us )
9504- {
9505- return tg_set_cfs_period (css_tg (css ), cfs_period_us );
9506- }
9507-
9508- static u64 cpu_cfs_burst_read_u64 (struct cgroup_subsys_state * css ,
9509- struct cftype * cft )
9510- {
9511- return tg_get_cfs_burst (css_tg (css ));
9512- }
9513-
9514- static int cpu_cfs_burst_write_u64 (struct cgroup_subsys_state * css ,
9515- struct cftype * cftype , u64 cfs_burst_us )
9516- {
9517- return tg_set_cfs_burst (css_tg (css ), cfs_burst_us );
9518- }
9519-
95209484struct cfs_schedulable_data {
95219485 struct task_group * tg ;
95229486 u64 period , quota ;
@@ -9649,6 +9613,42 @@ static int cpu_cfs_local_stat_show(struct seq_file *sf, void *v)
96499613
96509614 return 0 ;
96519615}
9616+
9617+ static u64 cpu_cfs_period_read_u64 (struct cgroup_subsys_state * css ,
9618+ struct cftype * cft )
9619+ {
9620+ return tg_get_cfs_period (css_tg (css ));
9621+ }
9622+
9623+ static s64 cpu_cfs_quota_read_s64 (struct cgroup_subsys_state * css ,
9624+ struct cftype * cft )
9625+ {
9626+ return tg_get_cfs_quota (css_tg (css ));
9627+ }
9628+
9629+ static u64 cpu_cfs_burst_read_u64 (struct cgroup_subsys_state * css ,
9630+ struct cftype * cft )
9631+ {
9632+ return tg_get_cfs_burst (css_tg (css ));
9633+ }
9634+
9635+ static int cpu_cfs_period_write_u64 (struct cgroup_subsys_state * css ,
9636+ struct cftype * cftype , u64 cfs_period_us )
9637+ {
9638+ return tg_set_cfs_period (css_tg (css ), cfs_period_us );
9639+ }
9640+
9641+ static int cpu_cfs_quota_write_s64 (struct cgroup_subsys_state * css ,
9642+ struct cftype * cftype , s64 cfs_quota_us )
9643+ {
9644+ return tg_set_cfs_quota (css_tg (css ), cfs_quota_us );
9645+ }
9646+
9647+ static int cpu_cfs_burst_write_u64 (struct cgroup_subsys_state * css ,
9648+ struct cftype * cftype , u64 cfs_burst_us )
9649+ {
9650+ return tg_set_cfs_burst (css_tg (css ), cfs_burst_us );
9651+ }
96529652#endif /* CONFIG_CFS_BANDWIDTH */
96539653
96549654#ifdef CONFIG_RT_GROUP_SCHED
@@ -9710,16 +9710,16 @@ static struct cftype cpu_legacy_files[] = {
97109710 },
97119711#endif
97129712#ifdef CONFIG_CFS_BANDWIDTH
9713- {
9714- .name = "cfs_quota_us" ,
9715- .read_s64 = cpu_cfs_quota_read_s64 ,
9716- .write_s64 = cpu_cfs_quota_write_s64 ,
9717- },
97189713 {
97199714 .name = "cfs_period_us" ,
97209715 .read_u64 = cpu_cfs_period_read_u64 ,
97219716 .write_u64 = cpu_cfs_period_write_u64 ,
97229717 },
9718+ {
9719+ .name = "cfs_quota_us" ,
9720+ .read_s64 = cpu_cfs_quota_read_s64 ,
9721+ .write_s64 = cpu_cfs_quota_write_s64 ,
9722+ },
97239723 {
97249724 .name = "cfs_burst_us" ,
97259725 .read_u64 = cpu_cfs_burst_read_u64 ,
0 commit comments