aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/scripts/python
diff options
context:
space:
mode:
authorMike Snitzer <snitzer@redhat.com>2015-07-21 13:20:46 -0400
committerMike Snitzer <snitzer@redhat.com>2015-07-26 17:39:19 -0400
commit0a927c2f02a2437a57679527e42ab7cbfa14efb1 (patch)
tree8f183be070a38128a229e6de03be47d6e03977ac /tools/perf/scripts/python
parentcbfe8fa6cd672011c755c3cd85c9ffd4e2d10a6f (diff)
dm thin: return -ENOSPC when erroring retry list due to out of data space
Otherwise -EIO would be returned when -ENOSPC should be used consistently. Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions
7321cac2'>1da177e4c3f
b012d346c0e
1da177e4c3f


07031e14c11
ece8a684c75
07031e14c11

c309b917cab
1da177e4c3f


97d1f15b7ef
1da177e4c3f

22b8ce94708
1da177e4c3f
22b8ce94708


1da177e4c3f

ece8a684c75
b3da2a73ff5
ece8a684c75







b3da2a73ff5



a75acf850ca
1da177e4c3f
dfaa9c94b13






07031e14c11








dfaa9c94b13
1da177e4c3f









ce05fcc30ea
1da177e4c3f
22b8ce94708
1ad82fd547c
22b8ce94708
1ad82fd547c
1da177e4c3f

22b8ce94708
22b8ce94708
c309b917cab


acd895795d3

b62f495dad0
22b8ce94708


b62f495dad0

22b8ce94708






c309b917cab
22b8ce94708
1da177e4c3f


1ad82fd547c
e041c683412


1ad82fd547c

1da177e4c3f
e041c683412
1da177e4c3f
1ad82fd547c

1da177e4c3f

e041c683412
1da177e4c3f




e041c683412
1da177e4c3f

1ad82fd547c
1da177e4c3f
e041c683412
1da177e4c3f
1ad82fd547c
1da177e4c3f
1ad82fd547c
1da177e4c3f
e041c683412
1da177e4c3f
1ad82fd547c
1da177e4c3f
1ad82fd547c
1da177e4c3f

1ad82fd547c
1da177e4c3f
1ad82fd547c







1da177e4c3f
1ad82fd547c
1da177e4c3f

1ad82fd547c
1da177e4c3f
1ad82fd547c
1da177e4c3f

1ad82fd547c
1da177e4c3f
1ad82fd547c







1da177e4c3f

1da177e4c3f

1ad82fd547c
1da177e4c3f







1ad82fd547c
1da177e4c3f





fbd568a3e61
1da177e4c3f
1da177e4c3f
1da177e4c3f
1da177e4c3f























ece8a684c75

1da177e4c3f

















97d1f15b7ef
1da177e4c3f

15c8b6c1aaa
1da177e4c3f











97d1f15b7ef
1da177e4c3f





97d1f15b7ef
1da177e4c3f

15c8b6c1aaa
1da177e4c3f



97d1f15b7ef
1da177e4c3f

ece8a684c75
1da177e4c3f















ece8a684c75




1da177e4c3f



ece8a684c75
1da177e4c3f


ece8a684c75
1da177e4c3f




ece8a684c75





1da177e4c3f








8419641450e
1da177e4c3f






8bb7844286f
1da177e4c3f


6484eb3e2a8
4199cfa02b9
fbd98167e65
1da177e4c3f




6484eb3e2a8
4199cfa02b9
fbd98167e65
1da177e4c3f




1ad82fd547c
1da177e4c3f




8bb7844286f
c309b917cab

1da177e4c3f

8bb7844286f
1da177e4c3f
8bb7844286f
c309b917cab

1da177e4c3f













1da177e4c3f


02316067852
1da177e4c3f
ece8a684c75
1da177e4c3f





ece8a684c75
1da177e4c3f

bbe1a59b3a3

7d12e780e00
1da177e4c3f
7d12e780e00

1da177e4c3f

c309b917cab

1da177e4c3f




583a22e7c15
1da177e4c3f
1da177e4c3f
583a22e7c15
1da177e4c3f
583a22e7c15







1da177e4c3f

583a22e7c15

1da177e4c3f
c309b917cab
583a22e7c15
1da177e4c3f
c309b917cab

1da177e4c3f
c309b917cab

583a22e7c15

c309b917cab


1da177e4c3f

583a22e7c15







1da177e4c3f

1da177e4c3f
583a22e7c15
1da177e4c3f












1ad82fd547c
1da177e4c3f









1ad82fd547c
064b022c7ad
1da177e4c3f


1ad82fd547c
1da177e4c3f















1ad82fd547c
1da177e4c3f















15ad7cdcfd7
1da177e4c3f




60a51513208
1da177e4c3f


22b8ce94708
1da177e4c3f






6484eb3e2a8
fbd98167e65

1da177e4c3f



6484eb3e2a8
fbd98167e65

1da177e4c3f







d59dd4620fb
15c8b6c1aaa
1da177e4c3f



















8419641450e
1da177e4c3f





22b8ce94708
c33fff0afbe

1ad82fd547c
1da177e4c3f
1da177e4c3f





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628














                                                                         






                           
                          
                        

                          
                         
                         
                       









                                                                      
                                                         


                                          
 
                          

                           
                                   


                                                                 
                                        

                       
                            
 


                                            

                
                                                        
                        







                                                                        



                                                                               
                                                               
                                          






                                                                           








                                                                      
                                            









                                                                           
                            
 
                         
                     
                         
 

                                                   
                                                 
 


                                                           

                                                       
                                                                     


                         

                                                                            






                                            
                                        
                       


                                 
 


                                                  

                                                
 
                                                                   
 

                                                  

                
                                                                       




                                          
                                                                        

 
                                                   
 
                                                                      
 
                                         
 
                                                     
 
                                                                        
 
                                           
 
                                                                            

                          
 
                       







                                                        
         
 

                   
                                          
 
                                                                              

                          
 
                       







                                                         

         

                   
                                            







                                                      
                                       





                                                         
                                                                         
 
                                         
 























                                                                     

                                                                      

















                                                                         
                                        

                                                 
                                                     











                                                                             
                                          





                                              
                                        

                                                 
                                                     



                                                                             
                                          

 
                                                             















                                                                              




                                                                    



                                                     
                                                            


                                                       
                                                           




                                                           





                                                               








                                                                   
                                                                      






                                                                          
                                   


                                                         
                                                           
                                                                
                                           




                                                                               
                                                           
                                                                
                                           




                                                                               
         




                                                                       
                               

                                                            

                             
                                    
                      
                             

                                                              













                                                                               


                                                        
                                            
 
                                                             





                                                                         
                                                                 

                        

                                
                           
 

                                              

                                                

                                                                




                                                            
                           
                        
 
                                                               
 







                                                                          

 

                                                             
 
                                
                
 

                                                       
 

                                                           

                                                       


                                    

 







                                                               

                                                              
                                            
                                                                                   












                                                                             
                  









                                                              
                                                               
                                       


                                                         
                                                  















                                                                            
                                                                  















                                                                  
                                                               




                                        
                                     


 
                                   






                                            
                                                   

                                                                       



                                                                           
                                                   

                                                                       







                                                                           
                 
                                          



















                                                                               
                                                                             





                                     
                               

                                                            
                   
                         





                                                      
/*
 *  linux/kernel/profile.c
 *  Simple profiling. Manages a direct-mapped profile hit count buffer,
 *  with configurable resolution, support for restricting the cpus on
 *  which profiling is done, and switching between cpu time and
 *  schedule() calls via kernel command line parameters passed at boot.
 *
 *  Scheduler profiling support, Arjan van de Ven and Ingo Molnar,
 *	Red Hat, July 2004
 *  Consolidation of architecture support code for profiling,
 *	William Irwin, Oracle, July 2004
 *  Amortized hit count accounting via per-cpu open-addressed hashtables
 *	to resolve timer interrupt livelocks, William Irwin, Oracle, 2004
 */

#include <linux/module.h>
#include <linux/profile.h>
#include <linux/bootmem.h>
#include <linux/notifier.h>
#include <linux/mm.h>
#include <linux/cpumask.h>
#include <linux/cpu.h>
#include <linux/highmem.h>
#include <linux/mutex.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <asm/sections.h>
#include <asm/irq_regs.h>
#include <asm/ptrace.h>

struct profile_hit {
	u32 pc, hits;
};
#define PROFILE_GRPSHIFT	3
#define PROFILE_GRPSZ		(1 << PROFILE_GRPSHIFT)
#define NR_PROFILE_HIT		(PAGE_SIZE/sizeof(struct profile_hit))
#define NR_PROFILE_GRP		(NR_PROFILE_HIT/PROFILE_GRPSZ)

/* Oprofile timer tick hook */
static int (*timer_hook)(struct pt_regs *) __read_mostly;

static atomic_t *prof_buffer;
static unsigned long prof_len, prof_shift;

int prof_on __read_mostly;
EXPORT_SYMBOL_GPL(prof_on);

static cpumask_var_t prof_cpu_mask;
#ifdef CONFIG_SMP
static DEFINE_PER_CPU(struct profile_hit *[2], cpu_profile_hits);
static DEFINE_PER_CPU(int, cpu_profile_flip);
static DEFINE_MUTEX(profile_flip_mutex);
#endif /* CONFIG_SMP */

int profile_setup(char *str)
{
	static char schedstr[] = "schedule";
	static char sleepstr[] = "sleep";
	static char kvmstr[] = "kvm";
	int par;

	if (!strncmp(str, sleepstr, strlen(sleepstr))) {
#ifdef CONFIG_SCHEDSTATS
		prof_on = SLEEP_PROFILING;
		if (str[strlen(sleepstr)] == ',')
			str += strlen(sleepstr) + 1;
		if (get_option(&str, &par))
			prof_shift = par;
		printk(KERN_INFO
			"kernel sleep profiling enabled (shift: %ld)\n",
			prof_shift);
#else
		printk(KERN_WARNING
			"kernel sleep profiling requires CONFIG_SCHEDSTATS\n");
#endif /* CONFIG_SCHEDSTATS */
	} else if (!strncmp(str, schedstr, strlen(schedstr))) {
		prof_on = SCHED_PROFILING;
		if (str[strlen(schedstr)] == ',')
			str += strlen(schedstr) + 1;
		if (get_option(&str, &par))
			prof_shift = par;
		printk(KERN_INFO
			"kernel schedule profiling enabled (shift: %ld)\n",
			prof_shift);
	} else if (!strncmp(str, kvmstr, strlen(kvmstr))) {
		prof_on = KVM_PROFILING;
		if (str[strlen(kvmstr)] == ',')
			str += strlen(kvmstr) + 1;
		if (get_option(&str, &par))
			prof_shift = par;
		printk(KERN_INFO
			"kernel KVM profiling enabled (shift: %ld)\n",
			prof_shift);
	} else if (get_option(&str, &par)) {
		prof_shift = par;
		prof_on = CPU_PROFILING;
		printk(KERN_INFO "kernel profiling enabled (shift: %ld)\n",
			prof_shift);
	}
	return 1;
}
__setup("profile=", profile_setup);


int __ref profile_init(void)
{
	int buffer_bytes;
	if (!prof_on)
		return 0;

	/* only text is profiled */
	prof_len = (_etext - _stext) >> prof_shift;
	buffer_bytes = prof_len*sizeof(atomic_t);

	if (!alloc_cpumask_var(&prof_cpu_mask, GFP_KERNEL))
		return -ENOMEM;

	cpumask_copy(prof_cpu_mask, cpu_possible_mask);

	prof_buffer = kzalloc(buffer_bytes, GFP_KERNEL|__GFP_NOWARN);
	if (prof_buffer)
		return 0;

	prof_buffer = alloc_pages_exact(buffer_bytes,
					GFP_KERNEL|__GFP_ZERO|__GFP_NOWARN);
	if (prof_buffer)
		return 0;

	prof_buffer = vmalloc(buffer_bytes);
	if (prof_buffer)
		return 0;

	free_cpumask_var(prof_cpu_mask);
	return -ENOMEM;
}

/* Profile event notifications */

static BLOCKING_NOTIFIER_HEAD(task_exit_notifier);
static ATOMIC_NOTIFIER_HEAD(task_free_notifier);
static BLOCKING_NOTIFIER_HEAD(munmap_notifier);

void profile_task_exit(struct task_struct *task)
{
	blocking_notifier_call_chain(&task_exit_notifier, 0, task);
}

int profile_handoff_task(struct task_struct *task)
{
	int ret;
	ret = atomic_notifier_call_chain(&task_free_notifier, 0, task);
	return (ret == NOTIFY_OK) ? 1 : 0;
}

void profile_munmap(unsigned long addr)
{
	blocking_notifier_call_chain(&munmap_notifier, 0, (void *)addr);
}

int task_handoff_register(struct notifier_block *n)
{
	return atomic_notifier_chain_register(&task_free_notifier, n);
}
EXPORT_SYMBOL_GPL(task_handoff_register);

int task_handoff_unregister(struct notifier_block *n)
{
	return atomic_notifier_chain_unregister(&task_free_notifier, n);
}
EXPORT_SYMBOL_GPL(task_handoff_unregister);

int profile_event_register(enum profile_type type, struct notifier_block *n)
{
	int err = -EINVAL;

	switch (type) {
	case PROFILE_TASK_EXIT:
		err = blocking_notifier_chain_register(
				&task_exit_notifier, n);
		break;
	case PROFILE_MUNMAP:
		err = blocking_notifier_chain_register(
				&munmap_notifier, n);
		break;
	}

	return err;
}
EXPORT_SYMBOL_GPL(profile_event_register);

int profile_event_unregister(enum profile_type type, struct notifier_block *n)
{
	int err = -EINVAL;

	switch (type) {
	case PROFILE_TASK_EXIT:
		err = blocking_notifier_chain_unregister(
				&task_exit_notifier, n);
		break;
	case PROFILE_MUNMAP:
		err = blocking_notifier_chain_unregister(
				&munmap_notifier, n);
		break;
	}

	return err;
}
EXPORT_SYMBOL_GPL(profile_event_unregister);

int register_timer_hook(int (*hook)(struct pt_regs *))
{
	if (timer_hook)
		return -EBUSY;
	timer_hook = hook;
	return 0;
}
EXPORT_SYMBOL_GPL(register_timer_hook);

void unregister_timer_hook(int (*hook)(struct pt_regs *))
{
	WARN_ON(hook != timer_hook);
	timer_hook = NULL;
	/* make sure all CPUs see the NULL hook */
	synchronize_sched();  /* Allow ongoing interrupts to complete. */
}
EXPORT_SYMBOL_GPL(unregister_timer_hook);


#ifdef CONFIG_SMP
/*
 * Each cpu has a pair of open-addressed hashtables for pending
 * profile hits. read_profile() IPI's all cpus to request them
 * to flip buffers and flushes their contents to prof_buffer itself.
 * Flip requests are serialized by the profile_flip_mutex. The sole