@@ -501,45 +501,21 @@ static void domain_add_cpu_ctrl(int cpu, struct rdt_resource *r)
501501 }
502502}
503503
504- static void domain_add_cpu_mon (int cpu , struct rdt_resource * r )
504+ static void l3_mon_domain_setup (int cpu , int id , struct rdt_resource * r , struct list_head * add_pos )
505505{
506- int id = get_domain_id_from_scope (cpu , r -> mon_scope );
507- struct list_head * add_pos = NULL ;
508506 struct rdt_hw_mon_domain * hw_dom ;
509- struct rdt_domain_hdr * hdr ;
510507 struct rdt_mon_domain * d ;
511508 struct cacheinfo * ci ;
512509 int err ;
513510
514- lockdep_assert_held (& domain_list_lock );
515-
516- if (id < 0 ) {
517- pr_warn_once ("Can't find monitor domain id for CPU:%d scope:%d for resource %s\n" ,
518- cpu , r -> mon_scope , r -> name );
519- return ;
520- }
521-
522- hdr = resctrl_find_domain (& r -> mon_domains , id , & add_pos );
523- if (hdr ) {
524- if (!domain_header_is_valid (hdr , RESCTRL_MON_DOMAIN , r -> rid ))
525- return ;
526- d = container_of (hdr , struct rdt_mon_domain , hdr );
527-
528- cpumask_set_cpu (cpu , & d -> hdr .cpu_mask );
529- /* Update the mbm_assign_mode state for the CPU if supported */
530- if (r -> mon .mbm_cntr_assignable )
531- resctrl_arch_mbm_cntr_assign_set_one (r );
532- return ;
533- }
534-
535511 hw_dom = kzalloc_node (sizeof (* hw_dom ), GFP_KERNEL , cpu_to_node (cpu ));
536512 if (!hw_dom )
537513 return ;
538514
539515 d = & hw_dom -> d_resctrl ;
540516 d -> hdr .id = id ;
541517 d -> hdr .type = RESCTRL_MON_DOMAIN ;
542- d -> hdr .rid = r -> rid ;
518+ d -> hdr .rid = RDT_RESOURCE_L3 ;
543519 ci = get_cpu_cacheinfo_level (cpu , RESCTRL_L3_CACHE );
544520 if (!ci ) {
545521 pr_warn_once ("Can't find L3 cache for CPU:%d resource %s\n" , cpu , r -> name );
@@ -549,10 +525,6 @@ static void domain_add_cpu_mon(int cpu, struct rdt_resource *r)
549525 d -> ci_id = ci -> id ;
550526 cpumask_set_cpu (cpu , & d -> hdr .cpu_mask );
551527
552- /* Update the mbm_assign_mode state for the CPU if supported */
553- if (r -> mon .mbm_cntr_assignable )
554- resctrl_arch_mbm_cntr_assign_set_one (r );
555-
556528 arch_mon_domain_online (r , d );
557529
558530 if (arch_domain_mbm_alloc (r -> mon .num_rmid , hw_dom )) {
@@ -570,6 +542,38 @@ static void domain_add_cpu_mon(int cpu, struct rdt_resource *r)
570542 }
571543}
572544
545+ static void domain_add_cpu_mon (int cpu , struct rdt_resource * r )
546+ {
547+ int id = get_domain_id_from_scope (cpu , r -> mon_scope );
548+ struct list_head * add_pos = NULL ;
549+ struct rdt_domain_hdr * hdr ;
550+
551+ lockdep_assert_held (& domain_list_lock );
552+
553+ if (id < 0 ) {
554+ pr_warn_once ("Can't find monitor domain id for CPU:%d scope:%d for resource %s\n" ,
555+ cpu , r -> mon_scope , r -> name );
556+ return ;
557+ }
558+
559+ hdr = resctrl_find_domain (& r -> mon_domains , id , & add_pos );
560+ if (hdr )
561+ cpumask_set_cpu (cpu , & hdr -> cpu_mask );
562+
563+ switch (r -> rid ) {
564+ case RDT_RESOURCE_L3 :
565+ /* Update the mbm_assign_mode state for the CPU if supported */
566+ if (r -> mon .mbm_cntr_assignable )
567+ resctrl_arch_mbm_cntr_assign_set_one (r );
568+ if (!hdr )
569+ l3_mon_domain_setup (cpu , id , r , add_pos );
570+ break ;
571+ default :
572+ pr_warn_once ("Unknown resource rid=%d\n" , r -> rid );
573+ break ;
574+ }
575+ }
576+
573577static void domain_add_cpu (int cpu , struct rdt_resource * r )
574578{
575579 if (r -> alloc_capable )
0 commit comments