4b1a631b8a
This patch introduces the out-of-band (oob) core monitoring functions. The functions are similar to the channel manager functions. There are function to add and remove cores from the list of cores being monitored. There is a function to initialise the monitor setup, run the monitor thread, and exit the monitor. The monitor thread runs in it's own lcore, and is separate functionality to the channel monitor which is epoll based. THis thread is timer based. It loops through all monitored cores, calculates the branch ratio, scales up or down the core, then sleeps for an interval (~250 uS). The method it uses to read the branch counters is a pread on the /dev/cpu/x/msr file, so the 'msr' kernel module needs to be loaded. Also, since the msr.h file has been made unavailable in recent kernels, we have #defines for the relevant MSRs included in the code. The makefile has a switch for x86 and non-x86 platforms, and compiles stub function for non-x86 platforms. Signed-off-by: David Hunt <david.hunt@intel.com> Acked-by: Radu Nicolau <radu.nicolau@intel.com>
69 lines
1.0 KiB
C
69 lines
1.0 KiB
C
/* SPDX-License-Identifier: BSD-3-Clause
|
|
* Copyright(c) 2018 Intel Corporation
|
|
*/
|
|
|
|
#ifndef OOB_MONITOR_H_
|
|
#define OOB_MONITOR_H_
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/**
|
|
* Setup the Branch Monitor resources required to initialize epoll.
|
|
* Must be called first before calling other functions.
|
|
*
|
|
* @return
|
|
* - 0 on success.
|
|
* - Negative on error.
|
|
*/
|
|
int branch_monitor_init(void);
|
|
|
|
/**
|
|
* Run the OOB branch monitor, loops forever on on epoll_wait.
|
|
*
|
|
*
|
|
* @return
|
|
* None
|
|
*/
|
|
void run_branch_monitor(void);
|
|
|
|
/**
|
|
* Exit the OOB Branch Monitor.
|
|
*
|
|
* @return
|
|
* None
|
|
*/
|
|
void branch_monitor_exit(void);
|
|
|
|
/**
|
|
* Add a core to the list of cores to monitor.
|
|
*
|
|
* @param core
|
|
* Core Number
|
|
*
|
|
* @return
|
|
* - 0 on success.
|
|
* - Negative on error.
|
|
*/
|
|
int add_core_to_monitor(int core);
|
|
|
|
/**
|
|
* Remove a previously added core from core list.
|
|
*
|
|
* @param core
|
|
* Core Number
|
|
*
|
|
* @return
|
|
* - 0 on success.
|
|
* - Negative on error.
|
|
*/
|
|
int remove_core_from_monitor(int core);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
|
|
#endif /* OOB_MONITOR_H_ */
|