@@ -9414,20 +9414,14 @@ static int tg_set_cfs_bandwidth(struct task_group *tg, u64 period, u64 quota,
94149414 return 0 ;
94159415}
94169416
9417- static int tg_set_cfs_quota (struct task_group * tg , long cfs_quota_us )
9417+ static long tg_get_cfs_period (struct task_group * tg )
94189418{
9419- u64 quota , period , burst ;
9419+ u64 cfs_period_us ;
94209420
9421- period = ktime_to_ns (tg -> cfs_bandwidth .period );
9422- burst = tg -> cfs_bandwidth .burst ;
9423- if (cfs_quota_us < 0 )
9424- quota = RUNTIME_INF ;
9425- else if ((u64 )cfs_quota_us <= U64_MAX / NSEC_PER_USEC )
9426- quota = (u64 )cfs_quota_us * NSEC_PER_USEC ;
9427- else
9428- return - EINVAL ;
9421+ cfs_period_us = ktime_to_ns (tg -> cfs_bandwidth .period );
9422+ do_div (cfs_period_us , NSEC_PER_USEC );
94299423
9430- return tg_set_cfs_bandwidth ( tg , period , quota , burst ) ;
9424+ return cfs_period_us ;
94319425}
94329426
94339427static long tg_get_cfs_quota (struct task_group * tg )
@@ -9443,6 +9437,16 @@ static long tg_get_cfs_quota(struct task_group *tg)
94439437 return quota_us ;
94449438}
94459439
9440+ static long tg_get_cfs_burst (struct task_group * tg )
9441+ {
9442+ u64 burst_us ;
9443+
9444+ burst_us = tg -> cfs_bandwidth .burst ;
9445+ do_div (burst_us , NSEC_PER_USEC );
9446+
9447+ return burst_us ;
9448+ }
9449+
94469450static int tg_set_cfs_period (struct task_group * tg , long cfs_period_us )
94479451{
94489452 u64 quota , period , burst ;
@@ -9457,14 +9461,20 @@ static int tg_set_cfs_period(struct task_group *tg, long cfs_period_us)
94579461 return tg_set_cfs_bandwidth (tg , period , quota , burst );
94589462}
94599463
9460- static long tg_get_cfs_period (struct task_group * tg )
9464+ static int tg_set_cfs_quota (struct task_group * tg , long cfs_quota_us )
94619465{
9462- u64 cfs_period_us ;
9466+ u64 quota , period , burst ;
94639467
9464- cfs_period_us = ktime_to_ns (tg -> cfs_bandwidth .period );
9465- do_div (cfs_period_us , NSEC_PER_USEC );
9468+ period = ktime_to_ns (tg -> cfs_bandwidth .period );
9469+ burst = tg -> cfs_bandwidth .burst ;
9470+ if (cfs_quota_us < 0 )
9471+ quota = RUNTIME_INF ;
9472+ else if ((u64 )cfs_quota_us <= U64_MAX / NSEC_PER_USEC )
9473+ quota = (u64 )cfs_quota_us * NSEC_PER_USEC ;
9474+ else
9475+ return - EINVAL ;
94669476
9467- return cfs_period_us ;
9477+ return tg_set_cfs_bandwidth ( tg , period , quota , burst ) ;
94689478}
94699479
94709480static int tg_set_cfs_burst (struct task_group * tg , long cfs_burst_us )
@@ -9481,52 +9491,6 @@ static int tg_set_cfs_burst(struct task_group *tg, long cfs_burst_us)
94819491 return tg_set_cfs_bandwidth (tg , period , quota , burst );
94829492}
94839493
9484- static long tg_get_cfs_burst (struct task_group * tg )
9485- {
9486- u64 burst_us ;
9487-
9488- burst_us = tg -> cfs_bandwidth .burst ;
9489- do_div (burst_us , NSEC_PER_USEC );
9490-
9491- return burst_us ;
9492- }
9493-
9494- static s64 cpu_cfs_quota_read_s64 (struct cgroup_subsys_state * css ,
9495- struct cftype * cft )
9496- {
9497- return tg_get_cfs_quota (css_tg (css ));
9498- }
9499-
9500- static int cpu_cfs_quota_write_s64 (struct cgroup_subsys_state * css ,
9501- struct cftype * cftype , s64 cfs_quota_us )
9502- {
9503- return tg_set_cfs_quota (css_tg (css ), cfs_quota_us );
9504- }
9505-
9506- static u64 cpu_cfs_period_read_u64 (struct cgroup_subsys_state * css ,
9507- struct cftype * cft )
9508- {
9509- return tg_get_cfs_period (css_tg (css ));
9510- }
9511-
9512- static int cpu_cfs_period_write_u64 (struct cgroup_subsys_state * css ,
9513- struct cftype * cftype , u64 cfs_period_us )
9514- {
9515- return tg_set_cfs_period (css_tg (css ), cfs_period_us );
9516- }
9517-
9518- static u64 cpu_cfs_burst_read_u64 (struct cgroup_subsys_state * css ,
9519- struct cftype * cft )
9520- {
9521- return tg_get_cfs_burst (css_tg (css ));
9522- }
9523-
9524- static int cpu_cfs_burst_write_u64 (struct cgroup_subsys_state * css ,
9525- struct cftype * cftype , u64 cfs_burst_us )
9526- {
9527- return tg_set_cfs_burst (css_tg (css ), cfs_burst_us );
9528- }
9529-
95309494struct cfs_schedulable_data {
95319495 struct task_group * tg ;
95329496 u64 period , quota ;
@@ -9659,6 +9623,42 @@ static int cpu_cfs_local_stat_show(struct seq_file *sf, void *v)
96599623
96609624 return 0 ;
96619625}
9626+
9627+ static u64 cpu_cfs_period_read_u64 (struct cgroup_subsys_state * css ,
9628+ struct cftype * cft )
9629+ {
9630+ return tg_get_cfs_period (css_tg (css ));
9631+ }
9632+
9633+ static s64 cpu_cfs_quota_read_s64 (struct cgroup_subsys_state * css ,
9634+ struct cftype * cft )
9635+ {
9636+ return tg_get_cfs_quota (css_tg (css ));
9637+ }
9638+
9639+ static u64 cpu_cfs_burst_read_u64 (struct cgroup_subsys_state * css ,
9640+ struct cftype * cft )
9641+ {
9642+ return tg_get_cfs_burst (css_tg (css ));
9643+ }
9644+
9645+ static int cpu_cfs_period_write_u64 (struct cgroup_subsys_state * css ,
9646+ struct cftype * cftype , u64 cfs_period_us )
9647+ {
9648+ return tg_set_cfs_period (css_tg (css ), cfs_period_us );
9649+ }
9650+
9651+ static int cpu_cfs_quota_write_s64 (struct cgroup_subsys_state * css ,
9652+ struct cftype * cftype , s64 cfs_quota_us )
9653+ {
9654+ return tg_set_cfs_quota (css_tg (css ), cfs_quota_us );
9655+ }
9656+
9657+ static int cpu_cfs_burst_write_u64 (struct cgroup_subsys_state * css ,
9658+ struct cftype * cftype , u64 cfs_burst_us )
9659+ {
9660+ return tg_set_cfs_burst (css_tg (css ), cfs_burst_us );
9661+ }
96629662#endif /* CONFIG_CFS_BANDWIDTH */
96639663
96649664#ifdef CONFIG_RT_GROUP_SCHED
@@ -9720,16 +9720,16 @@ static struct cftype cpu_legacy_files[] = {
97209720 },
97219721#endif
97229722#ifdef CONFIG_CFS_BANDWIDTH
9723- {
9724- .name = "cfs_quota_us" ,
9725- .read_s64 = cpu_cfs_quota_read_s64 ,
9726- .write_s64 = cpu_cfs_quota_write_s64 ,
9727- },
97289723 {
97299724 .name = "cfs_period_us" ,
97309725 .read_u64 = cpu_cfs_period_read_u64 ,
97319726 .write_u64 = cpu_cfs_period_write_u64 ,
97329727 },
9728+ {
9729+ .name = "cfs_quota_us" ,
9730+ .read_s64 = cpu_cfs_quota_read_s64 ,
9731+ .write_s64 = cpu_cfs_quota_write_s64 ,
9732+ },
97339733 {
97349734 .name = "cfs_burst_us" ,
97359735 .read_u64 = cpu_cfs_burst_read_u64 ,
0 commit comments