/* SPDX-License-Identifier: GPL-2.0 */ /* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * Authors: Waiman Long <waiman.long@hpe.com>
*/
/* * When CONFIG_LOCK_EVENT_COUNTS is enabled, event counts of different * types of locks will be reported under the <debugfs>/lock_event_counts/ * directory. See lock_events_list.h for the list of available locking * events. * * Writing to the special ".reset_counts" file will reset all the above * locking event counts. This is a very slow operation and so should not * be done frequently. * * These event counts are implemented as per-cpu variables which are * summed and computed whenever the corresponding debugfs files are read. This * minimizes added overhead making the counts usable even in a production * environment.
*/ staticconstchar * const lockevent_names[lockevent_num + 1] = {
if (pv_on < 0)
pv_on = !pv_is_native_spin_unlock(); /* * Skip PV qspinlock events on bare metal.
*/ if (!pv_on && !memcmp(name, "pv_", 3)) returntrue; returnfalse;
} #else staticinlinebool skip_lockevent(constchar *name)
{ returnfalse;
} #endif
/* * Initialize debugfs for the locking event counts.
*/ staticint __init init_lockevent_counts(void)
{ struct dentry *d_counts = debugfs_create_dir(LOCK_EVENTS_DIR, NULL); int i;
if (IS_ERR(d_counts)) goto out;
/* * Create the debugfs files * * As reading from and writing to the stat files can be slow, only * root is allowed to do the read/write to limit impact to system * performance.
*/ for (i = 0; i < lockevent_num; i++) { if (skip_lockevent(lockevent_names[i])) continue; if (IS_ERR(debugfs_create_file(lockevent_names[i], 0400, d_counts,
(void *)(long)i, &fops_lockevent))) goto fail_undo;
}
if (IS_ERR(debugfs_create_file(lockevent_names[LOCKEVENT_reset_cnts], 0200,
d_counts, (void *)(long)LOCKEVENT_reset_cnts,
&fops_lockevent))) goto fail_undo;
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.