subr_prof.c (688ebe120c47c9478446c12022b5e4667c2bff7a) | subr_prof.c (6f1e8c186f9f87a6c385927f111f521470b00fff) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 337 unchanged lines hidden (view full) --- 346#ifndef _SYS_SYSPROTO_H_ 347struct profil_args { 348 caddr_t samples; 349 size_t size; 350 size_t offset; 351 u_int scale; 352}; 353#endif | 1/*- 2 * Copyright (c) 1982, 1986, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 337 unchanged lines hidden (view full) --- 346#ifndef _SYS_SYSPROTO_H_ 347struct profil_args { 348 caddr_t samples; 349 size_t size; 350 size_t offset; 351 u_int scale; 352}; 353#endif |
354/* 355 * MPSAFE 356 */ |
|
354/* ARGSUSED */ 355int 356profil(p, uap) 357 struct proc *p; 358 register struct profil_args *uap; 359{ 360 register struct uprof *upp; 361 int s; | 357/* ARGSUSED */ 358int 359profil(p, uap) 360 struct proc *p; 361 register struct profil_args *uap; 362{ 363 register struct uprof *upp; 364 int s; |
365 int error = 0; |
|
362 | 366 |
363 if (uap->scale > (1 << 16)) 364 return (EINVAL); | 367 mtx_lock(&Giant); 368 369 if (uap->scale > (1 << 16)) { 370 error = EINVAL; 371 goto done2; 372 } |
365 if (uap->scale == 0) { 366 stopprofclock(p); | 373 if (uap->scale == 0) { 374 stopprofclock(p); |
367 return (0); | 375 goto done2; |
368 } 369 upp = &p->p_stats->p_prof; 370 371 /* Block profile interrupts while changing state. */ 372 s = splstatclock(); 373 upp->pr_off = uap->offset; 374 upp->pr_scale = uap->scale; 375 upp->pr_base = uap->samples; 376 upp->pr_size = uap->size; 377 startprofclock(p); 378 splx(s); 379 | 376 } 377 upp = &p->p_stats->p_prof; 378 379 /* Block profile interrupts while changing state. */ 380 s = splstatclock(); 381 upp->pr_off = uap->offset; 382 upp->pr_scale = uap->scale; 383 upp->pr_base = uap->samples; 384 upp->pr_size = uap->size; 385 startprofclock(p); 386 splx(s); 387 |
380 return (0); | 388done2: 389 mtx_unlock(&Giant); 390 return (error); |
381} 382 383/* 384 * Scale is a fixed-point number with the binary point 16 bits 385 * into the value, and is <= 1.0. pc is at most 32 bits, so the 386 * intermediate result is at most 48 bits. 387 */ 388#define PC_TO_INDEX(pc, prof) \ --- 76 unchanged lines hidden --- | 391} 392 393/* 394 * Scale is a fixed-point number with the binary point 16 bits 395 * into the value, and is <= 1.0. pc is at most 32 bits, so the 396 * intermediate result is at most 48 bits. 397 */ 398#define PC_TO_INDEX(pc, prof) \ --- 76 unchanged lines hidden --- |