~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/include/asm/resctrl.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/x86/include/asm/resctrl.h (Architecture ppc) and /arch/i386/include/asm-i386/resctrl.h (Architecture i386)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 
  2 #ifndef _ASM_X86_RESCTRL_H                        
  3 #define _ASM_X86_RESCTRL_H                        
  4                                                   
  5 #ifdef CONFIG_X86_CPU_RESCTRL                     
  6                                                   
  7 #include <linux/sched.h>                          
  8 #include <linux/jump_label.h>                     
  9                                                   
 10 /*                                                
 11  * This value can never be a valid CLOSID, and    
 12  * (closid, rmid) pair to an index and back. O    
 13  * needed. The index is a software defined val    
 14  */                                               
 15 #define X86_RESCTRL_EMPTY_CLOSID         ((u32    
 16                                                   
 17 /**                                               
 18  * struct resctrl_pqr_state - State cache for     
 19  * @cur_rmid:           The cached Resource Mo    
 20  * @cur_closid: The cached Class Of Service ID    
 21  * @default_rmid:       The user assigned Reso    
 22  * @default_closid:     The user assigned cach    
 23  *                                                
 24  * The upper 32 bits of MSR_IA32_PQR_ASSOC con    
 25  * lower 10 bits rmid. The update to MSR_IA32_    
 26  * contains both parts, so we need to cache th    
 27  * stores the user configured per cpu CLOSID a    
 28  *                                                
 29  * The cache also helps to avoid pointless upd    
 30  * not change.                                    
 31  */                                               
 32 struct resctrl_pqr_state {                        
 33         u32                     cur_rmid;         
 34         u32                     cur_closid;       
 35         u32                     default_rmid;     
 36         u32                     default_closid    
 37 };                                                
 38                                                   
 39 DECLARE_PER_CPU(struct resctrl_pqr_state, pqr_    
 40                                                   
 41 extern bool rdt_alloc_capable;                    
 42 extern bool rdt_mon_capable;                      
 43                                                   
 44 DECLARE_STATIC_KEY_FALSE(rdt_enable_key);         
 45 DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key)    
 46 DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key);     
 47                                                   
 48 static inline bool resctrl_arch_alloc_capable(    
 49 {                                                 
 50         return rdt_alloc_capable;                 
 51 }                                                 
 52                                                   
 53 static inline void resctrl_arch_enable_alloc(v    
 54 {                                                 
 55         static_branch_enable_cpuslocked(&rdt_a    
 56         static_branch_inc_cpuslocked(&rdt_enab    
 57 }                                                 
 58                                                   
 59 static inline void resctrl_arch_disable_alloc(    
 60 {                                                 
 61         static_branch_disable_cpuslocked(&rdt_    
 62         static_branch_dec_cpuslocked(&rdt_enab    
 63 }                                                 
 64                                                   
 65 static inline bool resctrl_arch_mon_capable(vo    
 66 {                                                 
 67         return rdt_mon_capable;                   
 68 }                                                 
 69                                                   
 70 static inline void resctrl_arch_enable_mon(voi    
 71 {                                                 
 72         static_branch_enable_cpuslocked(&rdt_m    
 73         static_branch_inc_cpuslocked(&rdt_enab    
 74 }                                                 
 75                                                   
 76 static inline void resctrl_arch_disable_mon(vo    
 77 {                                                 
 78         static_branch_disable_cpuslocked(&rdt_    
 79         static_branch_dec_cpuslocked(&rdt_enab    
 80 }                                                 
 81                                                   
 82 /*                                                
 83  * __resctrl_sched_in() - Writes the task's CL    
 84  *                                                
 85  * Following considerations are made so that t    
 86  * on scheduler hot path:                         
 87  * - This will stay as no-op unless we are run    
 88  *   which supports resource control or monito    
 89  *   mounting the resctrl file system.            
 90  * - Caches the per cpu CLOSid/RMID values and    
 91  *   when a task with a different CLOSid/RMID     
 92  * - We allocate RMIDs/CLOSids globally in ord    
 93  *   simple as possible.                          
 94  * Must be called with preemption disabled.       
 95  */                                               
 96 static inline void __resctrl_sched_in(struct t    
 97 {                                                 
 98         struct resctrl_pqr_state *state = this    
 99         u32 closid = state->default_closid;       
100         u32 rmid = state->default_rmid;           
101         u32 tmp;                                  
102                                                   
103         /*                                        
104          * If this task has a closid/rmid assi    
105          * Else use the closid/rmid assigned t    
106          */                                       
107         if (static_branch_likely(&rdt_alloc_en    
108                 tmp = READ_ONCE(tsk->closid);     
109                 if (tmp)                          
110                         closid = tmp;             
111         }                                         
112                                                   
113         if (static_branch_likely(&rdt_mon_enab    
114                 tmp = READ_ONCE(tsk->rmid);       
115                 if (tmp)                          
116                         rmid = tmp;               
117         }                                         
118                                                   
119         if (closid != state->cur_closid || rmi    
120                 state->cur_closid = closid;       
121                 state->cur_rmid = rmid;           
122                 wrmsr(MSR_IA32_PQR_ASSOC, rmid    
123         }                                         
124 }                                                 
125                                                   
126 static inline unsigned int resctrl_arch_round_    
127 {                                                 
128         unsigned int scale = boot_cpu_data.x86    
129                                                   
130         /* h/w works in units of "boot_cpu_dat    
131         val /= scale;                             
132         return val * scale;                       
133 }                                                 
134                                                   
135 static inline void resctrl_arch_set_closid_rmi    
136                                                   
137 {                                                 
138         WRITE_ONCE(tsk->closid, closid);          
139         WRITE_ONCE(tsk->rmid, rmid);              
140 }                                                 
141                                                   
142 static inline bool resctrl_arch_match_closid(s    
143 {                                                 
144         return READ_ONCE(tsk->closid) == closi    
145 }                                                 
146                                                   
147 static inline bool resctrl_arch_match_rmid(str    
148                                            u32    
149 {                                                 
150         return READ_ONCE(tsk->rmid) == rmid;      
151 }                                                 
152                                                   
153 static inline void resctrl_sched_in(struct tas    
154 {                                                 
155         if (static_branch_likely(&rdt_enable_k    
156                 __resctrl_sched_in(tsk);          
157 }                                                 
158                                                   
159 static inline void resctrl_arch_rmid_idx_decod    
160 {                                                 
161         *rmid = idx;                              
162         *closid = X86_RESCTRL_EMPTY_CLOSID;       
163 }                                                 
164                                                   
165 static inline u32 resctrl_arch_rmid_idx_encode    
166 {                                                 
167         return rmid;                              
168 }                                                 
169                                                   
170 /* x86 can always read an rmid, nothing needs     
171 struct rdt_resource;                              
172 static inline void *resctrl_arch_mon_ctx_alloc    
173 {                                                 
174         might_sleep();                            
175         return NULL;                              
176 };                                                
177                                                   
178 static inline void resctrl_arch_mon_ctx_free(s    
179                                              v    
180                                                   
181 void resctrl_cpu_detect(struct cpuinfo_x86 *c)    
182                                                   
183 #else                                             
184                                                   
185 static inline void resctrl_sched_in(struct tas    
186 static inline void resctrl_cpu_detect(struct c    
187                                                   
188 #endif /* CONFIG_X86_CPU_RESCTRL */               
189                                                   
190 #endif /* _ASM_X86_RESCTRL_H */                   
191                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php