Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 fixes from Ingo Molnar:
"Two documentation updates, plus a debugging annotation fix"

* 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/crash: Update the stale comment in reserve_crashkernel()
x86/irq, trace: Add __irq_entry annotation to x86's platform IRQ handlers
Documentation, x86, resctrl: Recommend locking for resctrlfs

+144 -22
+114
Documentation/x86/intel_rdt_ui.txt
··· 212 212 kernel and the tasks running there get 50% of the cache. 213 213 214 214 # echo C0 > p0/cpus 215 + 216 + 4) Locking between applications 217 + 218 + Certain operations on the resctrl filesystem, composed of read/writes 219 + to/from multiple files, must be atomic. 220 + 221 + As an example, the allocation of an exclusive reservation of L3 cache 222 + involves: 223 + 224 + 1. Read the cbmmasks from each directory 225 + 2. Find a contiguous set of bits in the global CBM bitmask that is clear 226 + in any of the directory cbmmasks 227 + 3. Create a new directory 228 + 4. Set the bits found in step 2 to the new directory "schemata" file 229 + 230 + If two applications attempt to allocate space concurrently then they can 231 + end up allocating the same bits so the reservations are shared instead of 232 + exclusive. 233 + 234 + To coordinate atomic operations on the resctrlfs and to avoid the problem 235 + above, the following locking procedure is recommended: 236 + 237 + Locking is based on flock, which is available in libc and also as a shell 238 + script command 239 + 240 + Write lock: 241 + 242 + A) Take flock(LOCK_EX) on /sys/fs/resctrl 243 + B) Read/write the directory structure. 244 + C) funlock 245 + 246 + Read lock: 247 + 248 + A) Take flock(LOCK_SH) on /sys/fs/resctrl 249 + B) If success read the directory structure. 250 + C) funlock 251 + 252 + Example with bash: 253 + 254 + # Atomically read directory structure 255 + $ flock -s /sys/fs/resctrl/ find /sys/fs/resctrl 256 + 257 + # Read directory contents and create new subdirectory 258 + 259 + $ cat create-dir.sh 260 + find /sys/fs/resctrl/ > output.txt 261 + mask = function-of(output.txt) 262 + mkdir /sys/fs/resctrl/newres/ 263 + echo mask > /sys/fs/resctrl/newres/schemata 264 + 265 + $ flock /sys/fs/resctrl/ ./create-dir.sh 266 + 267 + Example with C: 268 + 269 + /* 270 + * Example code do take advisory locks 271 + * before accessing resctrl filesystem 272 + */ 273 + #include <sys/file.h> 274 + #include <stdlib.h> 275 + 276 + void resctrl_take_shared_lock(int fd) 277 + { 278 + int ret; 279 + 280 + /* take shared lock on resctrl filesystem */ 281 + ret = flock(fd, LOCK_SH); 282 + if (ret) { 283 + perror("flock"); 284 + exit(-1); 285 + } 286 + } 287 + 288 + void resctrl_take_exclusive_lock(int fd) 289 + { 290 + int ret; 291 + 292 + /* release lock on resctrl filesystem */ 293 + ret = flock(fd, LOCK_EX); 294 + if (ret) { 295 + perror("flock"); 296 + exit(-1); 297 + } 298 + } 299 + 300 + void resctrl_release_lock(int fd) 301 + { 302 + int ret; 303 + 304 + /* take shared lock on resctrl filesystem */ 305 + ret = flock(fd, LOCK_UN); 306 + if (ret) { 307 + perror("flock"); 308 + exit(-1); 309 + } 310 + } 311 + 312 + void main(void) 313 + { 314 + int fd, ret; 315 + 316 + fd = open("/sys/fs/resctrl", O_DIRECTORY); 317 + if (fd == -1) { 318 + perror("open"); 319 + exit(-1); 320 + } 321 + resctrl_take_shared_lock(fd); 322 + /* code to read directory contents */ 323 + resctrl_release_lock(fd); 324 + 325 + resctrl_take_exclusive_lock(fd); 326 + /* code to read and write directory contents */ 327 + resctrl_release_lock(fd); 328 + }
+4 -4
arch/x86/kernel/apic/apic.c
··· 1865 1865 "should never happen.\n", vector, smp_processor_id()); 1866 1866 } 1867 1867 1868 - __visible void smp_spurious_interrupt(struct pt_regs *regs) 1868 + __visible void __irq_entry smp_spurious_interrupt(struct pt_regs *regs) 1869 1869 { 1870 1870 entering_irq(); 1871 1871 __smp_spurious_interrupt(~regs->orig_ax); 1872 1872 exiting_irq(); 1873 1873 } 1874 1874 1875 - __visible void smp_trace_spurious_interrupt(struct pt_regs *regs) 1875 + __visible void __irq_entry smp_trace_spurious_interrupt(struct pt_regs *regs) 1876 1876 { 1877 1877 u8 vector = ~regs->orig_ax; 1878 1878 ··· 1923 1923 1924 1924 } 1925 1925 1926 - __visible void smp_error_interrupt(struct pt_regs *regs) 1926 + __visible void __irq_entry smp_error_interrupt(struct pt_regs *regs) 1927 1927 { 1928 1928 entering_irq(); 1929 1929 __smp_error_interrupt(regs); 1930 1930 exiting_irq(); 1931 1931 } 1932 1932 1933 - __visible void smp_trace_error_interrupt(struct pt_regs *regs) 1933 + __visible void __irq_entry smp_trace_error_interrupt(struct pt_regs *regs) 1934 1934 { 1935 1935 entering_irq(); 1936 1936 trace_error_apic_entry(ERROR_APIC_VECTOR);
+1 -1
arch/x86/kernel/apic/vector.c
··· 559 559 __send_cleanup_vector(data); 560 560 } 561 561 562 - asmlinkage __visible void smp_irq_move_cleanup_interrupt(void) 562 + asmlinkage __visible void __irq_entry smp_irq_move_cleanup_interrupt(void) 563 563 { 564 564 unsigned vector, me; 565 565
+2 -2
arch/x86/kernel/cpu/mcheck/mce_amd.c
··· 816 816 deferred_error_int_vector(); 817 817 } 818 818 819 - asmlinkage __visible void smp_deferred_error_interrupt(void) 819 + asmlinkage __visible void __irq_entry smp_deferred_error_interrupt(void) 820 820 { 821 821 entering_irq(); 822 822 __smp_deferred_error_interrupt(); 823 823 exiting_ack_irq(); 824 824 } 825 825 826 - asmlinkage __visible void smp_trace_deferred_error_interrupt(void) 826 + asmlinkage __visible void __irq_entry smp_trace_deferred_error_interrupt(void) 827 827 { 828 828 entering_irq(); 829 829 trace_deferred_error_apic_entry(DEFERRED_ERROR_VECTOR);
+4 -2
arch/x86/kernel/cpu/mcheck/therm_throt.c
··· 396 396 smp_thermal_vector(); 397 397 } 398 398 399 - asmlinkage __visible void smp_thermal_interrupt(struct pt_regs *regs) 399 + asmlinkage __visible void __irq_entry 400 + smp_thermal_interrupt(struct pt_regs *regs) 400 401 { 401 402 entering_irq(); 402 403 __smp_thermal_interrupt(); 403 404 exiting_ack_irq(); 404 405 } 405 406 406 - asmlinkage __visible void smp_trace_thermal_interrupt(struct pt_regs *regs) 407 + asmlinkage __visible void __irq_entry 408 + smp_trace_thermal_interrupt(struct pt_regs *regs) 407 409 { 408 410 entering_irq(); 409 411 trace_thermal_apic_entry(THERMAL_APIC_VECTOR);
+2 -2
arch/x86/kernel/cpu/mcheck/threshold.c
··· 23 23 mce_threshold_vector(); 24 24 } 25 25 26 - asmlinkage __visible void smp_threshold_interrupt(void) 26 + asmlinkage __visible void __irq_entry smp_threshold_interrupt(void) 27 27 { 28 28 entering_irq(); 29 29 __smp_threshold_interrupt(); 30 30 exiting_ack_irq(); 31 31 } 32 32 33 - asmlinkage __visible void smp_trace_threshold_interrupt(void) 33 + asmlinkage __visible void __irq_entry smp_trace_threshold_interrupt(void) 34 34 { 35 35 entering_irq(); 36 36 trace_threshold_apic_entry(THRESHOLD_APIC_VECTOR);
+2 -2
arch/x86/kernel/irq.c
··· 264 264 x86_platform_ipi_callback(); 265 265 } 266 266 267 - __visible void smp_x86_platform_ipi(struct pt_regs *regs) 267 + __visible void __irq_entry smp_x86_platform_ipi(struct pt_regs *regs) 268 268 { 269 269 struct pt_regs *old_regs = set_irq_regs(regs); 270 270 ··· 315 315 } 316 316 #endif 317 317 318 - __visible void smp_trace_x86_platform_ipi(struct pt_regs *regs) 318 + __visible void __irq_entry smp_trace_x86_platform_ipi(struct pt_regs *regs) 319 319 { 320 320 struct pt_regs *old_regs = set_irq_regs(regs); 321 321
+3 -2
arch/x86/kernel/irq_work.c
··· 9 9 #include <linux/hardirq.h> 10 10 #include <asm/apic.h> 11 11 #include <asm/trace/irq_vectors.h> 12 + #include <linux/interrupt.h> 12 13 13 14 static inline void __smp_irq_work_interrupt(void) 14 15 { ··· 17 16 irq_work_run(); 18 17 } 19 18 20 - __visible void smp_irq_work_interrupt(struct pt_regs *regs) 19 + __visible void __irq_entry smp_irq_work_interrupt(struct pt_regs *regs) 21 20 { 22 21 ipi_entering_ack_irq(); 23 22 __smp_irq_work_interrupt(); 24 23 exiting_irq(); 25 24 } 26 25 27 - __visible void smp_trace_irq_work_interrupt(struct pt_regs *regs) 26 + __visible void __irq_entry smp_trace_irq_work_interrupt(struct pt_regs *regs) 28 27 { 29 28 ipi_entering_ack_irq(); 30 29 trace_irq_work_entry(IRQ_WORK_VECTOR);
+3 -1
arch/x86/kernel/setup.c
··· 575 575 /* 0 means: find the address automatically */ 576 576 if (crash_base <= 0) { 577 577 /* 578 - * kexec want bzImage is below CRASH_KERNEL_ADDR_MAX 578 + * Set CRASH_ADDR_LOW_MAX upper bound for crash memory, 579 + * as old kexec-tools loads bzImage below that, unless 580 + * "crashkernel=size[KMG],high" is specified. 579 581 */ 580 582 crash_base = memblock_find_in_range(CRASH_ALIGN, 581 583 high ? CRASH_ADDR_HIGH_MAX
+9 -6
arch/x86/kernel/smp.c
··· 259 259 scheduler_ipi(); 260 260 } 261 261 262 - __visible void smp_reschedule_interrupt(struct pt_regs *regs) 262 + __visible void __irq_entry smp_reschedule_interrupt(struct pt_regs *regs) 263 263 { 264 264 ack_APIC_irq(); 265 265 __smp_reschedule_interrupt(); ··· 268 268 */ 269 269 } 270 270 271 - __visible void smp_trace_reschedule_interrupt(struct pt_regs *regs) 271 + __visible void __irq_entry smp_trace_reschedule_interrupt(struct pt_regs *regs) 272 272 { 273 273 /* 274 274 * Need to call irq_enter() before calling the trace point. ··· 292 292 inc_irq_stat(irq_call_count); 293 293 } 294 294 295 - __visible void smp_call_function_interrupt(struct pt_regs *regs) 295 + __visible void __irq_entry smp_call_function_interrupt(struct pt_regs *regs) 296 296 { 297 297 ipi_entering_ack_irq(); 298 298 __smp_call_function_interrupt(); 299 299 exiting_irq(); 300 300 } 301 301 302 - __visible void smp_trace_call_function_interrupt(struct pt_regs *regs) 302 + __visible void __irq_entry 303 + smp_trace_call_function_interrupt(struct pt_regs *regs) 303 304 { 304 305 ipi_entering_ack_irq(); 305 306 trace_call_function_entry(CALL_FUNCTION_VECTOR); ··· 315 314 inc_irq_stat(irq_call_count); 316 315 } 317 316 318 - __visible void smp_call_function_single_interrupt(struct pt_regs *regs) 317 + __visible void __irq_entry 318 + smp_call_function_single_interrupt(struct pt_regs *regs) 319 319 { 320 320 ipi_entering_ack_irq(); 321 321 __smp_call_function_single_interrupt(); 322 322 exiting_irq(); 323 323 } 324 324 325 - __visible void smp_trace_call_function_single_interrupt(struct pt_regs *regs) 325 + __visible void __irq_entry 326 + smp_trace_call_function_single_interrupt(struct pt_regs *regs) 326 327 { 327 328 ipi_entering_ack_irq(); 328 329 trace_call_function_single_entry(CALL_FUNCTION_SINGLE_VECTOR);