@@ -9404,20 +9404,14 @@ static int tg_set_cfs_bandwidth(struct task_group *tg, u64 period, u64 quota,
9404
9404
return 0 ;
9405
9405
}
9406
9406
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 )
9408
9408
{
9409
- u64 quota , period , burst ;
9409
+ u64 cfs_period_us ;
9410
9410
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 );
9419
9413
9420
- return tg_set_cfs_bandwidth ( tg , period , quota , burst ) ;
9414
+ return cfs_period_us ;
9421
9415
}
9422
9416
9423
9417
static long tg_get_cfs_quota (struct task_group * tg )
@@ -9433,6 +9427,16 @@ static long tg_get_cfs_quota(struct task_group *tg)
9433
9427
return quota_us ;
9434
9428
}
9435
9429
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
+
9436
9440
static int tg_set_cfs_period (struct task_group * tg , long cfs_period_us )
9437
9441
{
9438
9442
u64 quota , period , burst ;
@@ -9447,14 +9451,20 @@ static int tg_set_cfs_period(struct task_group *tg, long cfs_period_us)
9447
9451
return tg_set_cfs_bandwidth (tg , period , quota , burst );
9448
9452
}
9449
9453
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 )
9451
9455
{
9452
- u64 cfs_period_us ;
9456
+ u64 quota , period , burst ;
9453
9457
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 ;
9456
9466
9457
- return cfs_period_us ;
9467
+ return tg_set_cfs_bandwidth ( tg , period , quota , burst ) ;
9458
9468
}
9459
9469
9460
9470
static 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)
9471
9481
return tg_set_cfs_bandwidth (tg , period , quota , burst );
9472
9482
}
9473
9483
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
-
9520
9484
struct cfs_schedulable_data {
9521
9485
struct task_group * tg ;
9522
9486
u64 period , quota ;
@@ -9649,6 +9613,42 @@ static int cpu_cfs_local_stat_show(struct seq_file *sf, void *v)
9649
9613
9650
9614
return 0 ;
9651
9615
}
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
+ }
9652
9652
#endif /* CONFIG_CFS_BANDWIDTH */
9653
9653
9654
9654
#ifdef CONFIG_RT_GROUP_SCHED
@@ -9710,16 +9710,16 @@ static struct cftype cpu_legacy_files[] = {
9710
9710
},
9711
9711
#endif
9712
9712
#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
- },
9718
9713
{
9719
9714
.name = "cfs_period_us" ,
9720
9715
.read_u64 = cpu_cfs_period_read_u64 ,
9721
9716
.write_u64 = cpu_cfs_period_write_u64 ,
9722
9717
},
9718
+ {
9719
+ .name = "cfs_quota_us" ,
9720
+ .read_s64 = cpu_cfs_quota_read_s64 ,
9721
+ .write_s64 = cpu_cfs_quota_write_s64 ,
9722
+ },
9723
9723
{
9724
9724
.name = "cfs_burst_us" ,
9725
9725
.read_u64 = cpu_cfs_burst_read_u64 ,
0 commit comments