@@ -46,7 +46,6 @@ use libbpf_rs::ProgramInput;
46
46
use libc:: c_char;
47
47
use log:: debug;
48
48
use log:: info;
49
- use log:: warn;
50
49
use plain:: Plain ;
51
50
use scx_stats:: prelude:: * ;
52
51
use scx_utils:: autopower:: { fetch_power_profile, PowerProfile } ;
@@ -231,7 +230,6 @@ impl introspec {
231
230
struct CpuFlatId {
232
231
node_id : usize ,
233
232
llc_pos : usize ,
234
- max_freq : usize ,
235
233
core_pos : usize ,
236
234
cpu_pos : usize ,
237
235
cpu_id : usize ,
@@ -282,12 +280,12 @@ impl fmt::Display for FlatTopology {
282
280
impl FlatTopology {
283
281
/// Build a flat-structured topology
284
282
pub fn new ( ) -> Result < FlatTopology > {
285
- let ( cpu_fids_performance, avg_freq ) = Self :: build_cpu_fids ( false , false ) . unwrap ( ) ;
283
+ let ( cpu_fids_performance, avg_cap ) = Self :: build_cpu_fids ( false , false ) . unwrap ( ) ;
286
284
let ( cpu_fids_powersave, _) = Self :: build_cpu_fids ( true , true ) . unwrap ( ) ;
287
285
288
286
// Note that building compute domain is not dependent to CPU orer
289
287
// so it is okay to use any cpu_fids_*.
290
- let cpdom_map = Self :: build_cpdom ( & cpu_fids_performance, avg_freq ) . unwrap ( ) ;
288
+ let cpdom_map = Self :: build_cpdom ( & cpu_fids_performance, avg_cap ) . unwrap ( ) ;
291
289
292
290
Ok ( FlatTopology {
293
291
cpu_fids_performance,
@@ -317,50 +315,30 @@ impl FlatTopology {
317
315
debug ! ( "{:#?}" , topo) ;
318
316
319
317
// Build a vector of cpu flat ids.
320
- let mut base_freq = 0 ;
321
- let mut avg_freq = 0 ;
318
+ let mut avg_cap = 0 ;
322
319
for ( & node_id, node) in topo. nodes . iter ( ) {
323
320
for ( llc_pos, ( _llc_id, llc) ) in node. llcs . iter ( ) . enumerate ( ) {
324
321
for ( core_pos, ( core_id, core) ) in llc. cores . iter ( ) . enumerate ( ) {
325
322
for ( cpu_pos, ( cpu_id, cpu) ) in core. cpus . iter ( ) . enumerate ( ) {
326
323
let cpu_fid = CpuFlatId {
327
324
node_id,
328
325
llc_pos,
329
- max_freq : cpu. max_freq ,
330
326
core_pos,
331
327
cpu_pos,
332
328
cpu_id : * cpu_id,
333
329
core_id : * core_id,
334
330
l2_id : cpu. l2_id ,
335
331
l3_id : cpu. l3_id ,
336
332
sharing_lvl : 0 ,
337
- cpu_cap : 0 ,
333
+ cpu_cap : cpu . cpu_capacity ,
338
334
} ;
339
335
cpu_fids. push ( RefCell :: new ( cpu_fid) ) ;
340
- if base_freq < cpu. max_freq {
341
- base_freq = cpu. max_freq ;
342
- }
343
- avg_freq += cpu. max_freq ;
336
+ avg_cap += cpu. cpu_capacity ;
344
337
}
345
338
}
346
339
}
347
340
}
348
- avg_freq /= cpu_fids. len ( ) as usize ;
349
-
350
- // Initialize cpu capacity
351
- if base_freq > 0 {
352
- for cpu_fid in cpu_fids. iter_mut ( ) {
353
- let mut cpu_fid = cpu_fid. borrow_mut ( ) ;
354
- cpu_fid. cpu_cap = ( ( cpu_fid. max_freq * 1024 ) / base_freq) as usize ;
355
- }
356
- } else {
357
- // Unfortunately, the frequency information in sysfs seems not
358
- // always correct in some distributions.
359
- for cpu_fid in cpu_fids. iter_mut ( ) {
360
- cpu_fid. borrow_mut ( ) . cpu_cap = 1024 as usize ;
361
- }
362
- warn ! ( "System does not provide proper CPU frequency information." ) ;
363
- }
341
+ avg_cap /= cpu_fids. len ( ) as usize ;
364
342
365
343
// Initialize cpu's hardware resource sharing level
366
344
for ( a_id, cpu_fid_a) in cpu_fids. iter ( ) . enumerate ( ) {
@@ -394,62 +372,62 @@ impl FlatTopology {
394
372
// Sort the cpu_fids
395
373
match ( prefer_smt_core, prefer_little_core) {
396
374
( true , false ) => {
397
- // Sort the cpu_fids by node, llc, ^max_freq , ^sharing_lvl, core, and cpu order
375
+ // Sort the cpu_fids by node, llc, ^cpu_cap , ^sharing_lvl, core, and cpu order
398
376
cpu_fids. sort_by ( |a, b| {
399
377
a. node_id
400
378
. cmp ( & b. node_id )
401
379
. then_with ( || a. llc_pos . cmp ( & b. llc_pos ) )
402
- . then_with ( || b. max_freq . cmp ( & a. max_freq ) )
380
+ . then_with ( || b. cpu_cap . cmp ( & a. cpu_cap ) )
403
381
. then_with ( || b. sharing_lvl . cmp ( & a. sharing_lvl ) )
404
382
. then_with ( || a. core_pos . cmp ( & b. core_pos ) )
405
383
. then_with ( || a. cpu_pos . cmp ( & b. cpu_pos ) )
406
384
} ) ;
407
385
}
408
386
( true , true ) => {
409
- // Sort the cpu_fids by node, llc, max_freq , ^sharing_lvl, core, and cpu order
387
+ // Sort the cpu_fids by node, llc, cpu_cap , ^sharing_lvl, core, and cpu order
410
388
cpu_fids. sort_by ( |a, b| {
411
389
a. node_id
412
390
. cmp ( & b. node_id )
413
391
. then_with ( || a. llc_pos . cmp ( & b. llc_pos ) )
414
- . then_with ( || a. max_freq . cmp ( & b. max_freq ) )
392
+ . then_with ( || a. cpu_cap . cmp ( & b. cpu_cap ) )
415
393
. then_with ( || b. sharing_lvl . cmp ( & a. sharing_lvl ) )
416
394
. then_with ( || a. core_pos . cmp ( & b. core_pos ) )
417
395
. then_with ( || a. cpu_pos . cmp ( & b. cpu_pos ) )
418
396
} ) ;
419
397
}
420
398
( false , false ) => {
421
- // Sort the cpu_fids by cpu, node, llc, ^max_freq , sharing_lvl, and core order
399
+ // Sort the cpu_fids by cpu, node, llc, ^cpu_cap , sharing_lvl, and core order
422
400
cpu_fids. sort_by ( |a, b| {
423
401
a. cpu_pos
424
402
. cmp ( & b. cpu_pos )
425
403
. then_with ( || a. node_id . cmp ( & b. node_id ) )
426
404
. then_with ( || a. llc_pos . cmp ( & b. llc_pos ) )
427
- . then_with ( || b. max_freq . cmp ( & a. max_freq ) )
405
+ . then_with ( || b. cpu_cap . cmp ( & a. cpu_cap ) )
428
406
. then_with ( || a. sharing_lvl . cmp ( & b. sharing_lvl ) )
429
407
. then_with ( || a. core_pos . cmp ( & b. core_pos ) )
430
408
} ) ;
431
409
}
432
410
( false , true ) => {
433
- // Sort the cpu_fids by cpu, node, llc, max_freq , sharing_lvl, and core order
411
+ // Sort the cpu_fids by cpu, node, llc, cpu_cap , sharing_lvl, and core order
434
412
cpu_fids. sort_by ( |a, b| {
435
413
a. cpu_pos
436
414
. cmp ( & b. cpu_pos )
437
415
. then_with ( || a. node_id . cmp ( & b. node_id ) )
438
416
. then_with ( || a. llc_pos . cmp ( & b. llc_pos ) )
439
- . then_with ( || a. max_freq . cmp ( & b. max_freq ) )
417
+ . then_with ( || a. cpu_cap . cmp ( & b. cpu_cap ) )
440
418
. then_with ( || a. sharing_lvl . cmp ( & b. sharing_lvl ) )
441
419
. then_with ( || a. core_pos . cmp ( & b. core_pos ) )
442
420
} ) ;
443
421
}
444
422
}
445
423
446
- Some ( ( cpu_fids, avg_freq ) )
424
+ Some ( ( cpu_fids, avg_cap ) )
447
425
}
448
426
449
427
/// Build a list of compute domains
450
428
fn build_cpdom (
451
429
cpu_fids : & Vec < CpuFlatId > ,
452
- avg_freq : usize ,
430
+ avg_cap : usize ,
453
431
) -> Option < BTreeMap < ComputeDomainKey , ComputeDomainValue > > {
454
432
// Creat a compute domain map
455
433
let mut cpdom_id = 0 ;
@@ -458,7 +436,7 @@ impl FlatTopology {
458
436
let key = ComputeDomainKey {
459
437
node_id : cpu_fid. node_id ,
460
438
llc_pos : cpu_fid. llc_pos ,
461
- is_big : cpu_fid. max_freq >= avg_freq ,
439
+ is_big : cpu_fid. cpu_cap >= avg_cap ,
462
440
} ;
463
441
let mut value;
464
442
match cpdom_map. get ( & key) {
0 commit comments