@@ -100,7 +100,7 @@ static void fmeter_markevent(struct fmeter *fmp)
100
100
}
101
101
102
102
/* Process any previous ticks, then return current value. */
103
- int fmeter_getrate (struct fmeter * fmp )
103
+ static int fmeter_getrate (struct fmeter * fmp )
104
104
{
105
105
int val ;
106
106
@@ -161,7 +161,7 @@ static int update_relax_domain_level(struct cpuset *cs, s64 val)
161
161
return 0 ;
162
162
}
163
163
164
- int cpuset_write_s64 (struct cgroup_subsys_state * css , struct cftype * cft ,
164
+ static int cpuset_write_s64 (struct cgroup_subsys_state * css , struct cftype * cft ,
165
165
s64 val )
166
166
{
167
167
struct cpuset * cs = css_cs (css );
@@ -187,7 +187,7 @@ int cpuset_write_s64(struct cgroup_subsys_state *css, struct cftype *cft,
187
187
return retval ;
188
188
}
189
189
190
- s64 cpuset_read_s64 (struct cgroup_subsys_state * css , struct cftype * cft )
190
+ static s64 cpuset_read_s64 (struct cgroup_subsys_state * css , struct cftype * cft )
191
191
{
192
192
struct cpuset * cs = css_cs (css );
193
193
cpuset_filetype_t type = cft -> private ;
@@ -372,3 +372,191 @@ int validate_change_legacy(struct cpuset *cur, struct cpuset *trial)
372
372
out :
373
373
return ret ;
374
374
}
375
+
376
+ static u64 cpuset_read_u64 (struct cgroup_subsys_state * css , struct cftype * cft )
377
+ {
378
+ struct cpuset * cs = css_cs (css );
379
+ cpuset_filetype_t type = cft -> private ;
380
+
381
+ switch (type ) {
382
+ case FILE_CPU_EXCLUSIVE :
383
+ return is_cpu_exclusive (cs );
384
+ case FILE_MEM_EXCLUSIVE :
385
+ return is_mem_exclusive (cs );
386
+ case FILE_MEM_HARDWALL :
387
+ return is_mem_hardwall (cs );
388
+ case FILE_SCHED_LOAD_BALANCE :
389
+ return is_sched_load_balance (cs );
390
+ case FILE_MEMORY_MIGRATE :
391
+ return is_memory_migrate (cs );
392
+ case FILE_MEMORY_PRESSURE_ENABLED :
393
+ return cpuset_memory_pressure_enabled ;
394
+ case FILE_MEMORY_PRESSURE :
395
+ return fmeter_getrate (& cs -> fmeter );
396
+ case FILE_SPREAD_PAGE :
397
+ return is_spread_page (cs );
398
+ case FILE_SPREAD_SLAB :
399
+ return is_spread_slab (cs );
400
+ default :
401
+ BUG ();
402
+ }
403
+
404
+ /* Unreachable but makes gcc happy */
405
+ return 0 ;
406
+ }
407
+
408
+ static int cpuset_write_u64 (struct cgroup_subsys_state * css , struct cftype * cft ,
409
+ u64 val )
410
+ {
411
+ struct cpuset * cs = css_cs (css );
412
+ cpuset_filetype_t type = cft -> private ;
413
+ int retval = 0 ;
414
+
415
+ cpus_read_lock ();
416
+ cpuset_lock ();
417
+ if (!is_cpuset_online (cs )) {
418
+ retval = - ENODEV ;
419
+ goto out_unlock ;
420
+ }
421
+
422
+ switch (type ) {
423
+ case FILE_CPU_EXCLUSIVE :
424
+ retval = update_flag (CS_CPU_EXCLUSIVE , cs , val );
425
+ break ;
426
+ case FILE_MEM_EXCLUSIVE :
427
+ retval = update_flag (CS_MEM_EXCLUSIVE , cs , val );
428
+ break ;
429
+ case FILE_MEM_HARDWALL :
430
+ retval = update_flag (CS_MEM_HARDWALL , cs , val );
431
+ break ;
432
+ case FILE_SCHED_LOAD_BALANCE :
433
+ retval = update_flag (CS_SCHED_LOAD_BALANCE , cs , val );
434
+ break ;
435
+ case FILE_MEMORY_MIGRATE :
436
+ retval = update_flag (CS_MEMORY_MIGRATE , cs , val );
437
+ break ;
438
+ case FILE_MEMORY_PRESSURE_ENABLED :
439
+ cpuset_memory_pressure_enabled = !!val ;
440
+ break ;
441
+ case FILE_SPREAD_PAGE :
442
+ retval = update_flag (CS_SPREAD_PAGE , cs , val );
443
+ break ;
444
+ case FILE_SPREAD_SLAB :
445
+ retval = update_flag (CS_SPREAD_SLAB , cs , val );
446
+ break ;
447
+ default :
448
+ retval = - EINVAL ;
449
+ break ;
450
+ }
451
+ out_unlock :
452
+ cpuset_unlock ();
453
+ cpus_read_unlock ();
454
+ return retval ;
455
+ }
456
+
457
+ /*
458
+ * for the common functions, 'private' gives the type of file
459
+ */
460
+
461
+ struct cftype legacy_files [] = {
462
+ {
463
+ .name = "cpus" ,
464
+ .seq_show = cpuset_common_seq_show ,
465
+ .write = cpuset_write_resmask ,
466
+ .max_write_len = (100U + 6 * NR_CPUS ),
467
+ .private = FILE_CPULIST ,
468
+ },
469
+
470
+ {
471
+ .name = "mems" ,
472
+ .seq_show = cpuset_common_seq_show ,
473
+ .write = cpuset_write_resmask ,
474
+ .max_write_len = (100U + 6 * MAX_NUMNODES ),
475
+ .private = FILE_MEMLIST ,
476
+ },
477
+
478
+ {
479
+ .name = "effective_cpus" ,
480
+ .seq_show = cpuset_common_seq_show ,
481
+ .private = FILE_EFFECTIVE_CPULIST ,
482
+ },
483
+
484
+ {
485
+ .name = "effective_mems" ,
486
+ .seq_show = cpuset_common_seq_show ,
487
+ .private = FILE_EFFECTIVE_MEMLIST ,
488
+ },
489
+
490
+ {
491
+ .name = "cpu_exclusive" ,
492
+ .read_u64 = cpuset_read_u64 ,
493
+ .write_u64 = cpuset_write_u64 ,
494
+ .private = FILE_CPU_EXCLUSIVE ,
495
+ },
496
+
497
+ {
498
+ .name = "mem_exclusive" ,
499
+ .read_u64 = cpuset_read_u64 ,
500
+ .write_u64 = cpuset_write_u64 ,
501
+ .private = FILE_MEM_EXCLUSIVE ,
502
+ },
503
+
504
+ {
505
+ .name = "mem_hardwall" ,
506
+ .read_u64 = cpuset_read_u64 ,
507
+ .write_u64 = cpuset_write_u64 ,
508
+ .private = FILE_MEM_HARDWALL ,
509
+ },
510
+
511
+ {
512
+ .name = "sched_load_balance" ,
513
+ .read_u64 = cpuset_read_u64 ,
514
+ .write_u64 = cpuset_write_u64 ,
515
+ .private = FILE_SCHED_LOAD_BALANCE ,
516
+ },
517
+
518
+ {
519
+ .name = "sched_relax_domain_level" ,
520
+ .read_s64 = cpuset_read_s64 ,
521
+ .write_s64 = cpuset_write_s64 ,
522
+ .private = FILE_SCHED_RELAX_DOMAIN_LEVEL ,
523
+ },
524
+
525
+ {
526
+ .name = "memory_migrate" ,
527
+ .read_u64 = cpuset_read_u64 ,
528
+ .write_u64 = cpuset_write_u64 ,
529
+ .private = FILE_MEMORY_MIGRATE ,
530
+ },
531
+
532
+ {
533
+ .name = "memory_pressure" ,
534
+ .read_u64 = cpuset_read_u64 ,
535
+ .private = FILE_MEMORY_PRESSURE ,
536
+ },
537
+
538
+ {
539
+ .name = "memory_spread_page" ,
540
+ .read_u64 = cpuset_read_u64 ,
541
+ .write_u64 = cpuset_write_u64 ,
542
+ .private = FILE_SPREAD_PAGE ,
543
+ },
544
+
545
+ {
546
+ /* obsolete, may be removed in the future */
547
+ .name = "memory_spread_slab" ,
548
+ .read_u64 = cpuset_read_u64 ,
549
+ .write_u64 = cpuset_write_u64 ,
550
+ .private = FILE_SPREAD_SLAB ,
551
+ },
552
+
553
+ {
554
+ .name = "memory_pressure_enabled" ,
555
+ .flags = CFTYPE_ONLY_ON_ROOT ,
556
+ .read_u64 = cpuset_read_u64 ,
557
+ .write_u64 = cpuset_write_u64 ,
558
+ .private = FILE_MEMORY_PRESSURE_ENABLED ,
559
+ },
560
+
561
+ { } /* terminate */
562
+ };
0 commit comments