// SPDX-License-Identifier: GPL-2.0-only /* * 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, * Nadia Yvette Chambers, Oracle, July 2004 * Amortized hit count accounting via per-cpu open-addressed hashtables * to resolve timer interrupt livelocks, Nadia Yvette Chambers, * Oracle, 2004
*/
/* * This function accesses profiling information. The returned data is * binary: the sampling step and the actual contents of the profile * buffer. Use of the program readprofile is recommended in order to * get meaningful info out of these data.
*/ static ssize_t
read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
{ unsignedlong p = *ppos;
ssize_t read; char *pnt; unsignedlong sample_step = 1UL << prof_shift;
if (p >= (prof_len+1)*sizeof(unsignedint)) return 0; if (count > (prof_len+1)*sizeof(unsignedint) - p)
count = (prof_len+1)*sizeof(unsignedint) - p;
read = 0;
/* default is to not implement this call */ int __weak setup_profiling_timer(unsigned mult)
{ return -EINVAL;
}
/* * Writing to /proc/profile resets the counters * * Writing a 'profiling multiplier' value into it also re-sets the profiling * interrupt frequency, on architectures that support this.
*/ static ssize_t write_profile(struct file *file, constchar __user *buf,
size_t count, loff_t *ppos)
{ #ifdef CONFIG_SMP if (count == sizeof(int)) { unsignedint multiplier;
if (copy_from_user(&multiplier, buf, sizeof(int))) return -EFAULT;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.