Skip to content

Commit

Permalink
PMCTrack v3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jcsaezal committed Mar 26, 2023
1 parent d527059 commit 881e7b8
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 18 deletions.
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@ PMCTrack is an open-source OS-oriented performance monitoring tool for GNU/Linux

Despite being an OS-oriented tool, PMCTrack still allows the gathering of PMC values from user space, enabling kernel developers to carry out the necessary offline analysis and debugging to assist them during the OS-level design process. In addition, the tool provides both the OS and the userspace PMCTrack components with other insightful metrics available in modern processors that are not directly exposed as PMCs, such as cache occupancy or energy consumption.

[![Analytics](https://ga-beacon.appspot.com/UA-76163836-1/github-pmctrack/readme)](http://pmctrack.dacya.ucm.es)

## Project Contributors

* Juan Carlos Saez Alcaide (<[email protected]>) - Creator of PMCTrack and main maintainer
* Adrián García García (aka [@Mizadri](https://github.com/mizadri))
* Carlos Bilbao (aka [@Zildj1an](https://github.com/Zildj1an))
* Lazaro Clemen Palafox (aka [@lz-palafox](https://github.com/lz-palafox))
* Jaime Sáez de Buruaga Brouns (aka [@jaimesaez97](https://github.com/jaimesaez97))
* Carlos Bilbao (aka [@Zildj1an](https://github.com/Zildj1an))

## Past Contributors

* Adrián García García (aka [@Mizadri](https://github.com/mizadri))
* Jorge Casas Hernan
* Abel Serrano Juste (aka [@Akronix](https://github.com/Akronix))
* Germán Franco Dorca
Expand All @@ -30,10 +28,19 @@ Despite being an OS-oriented tool, PMCTrack still allows the gathering of PMC va

## System requirements

Starting from version v2.0, PMCTrack works with vanilla Linux kernels, and, in this case, Linux kernel v5.9.x and above are highly recommended to enjoy the full functionality of the tool. For earlier versions of PMCTrack, a patched Linux kernel must be installed on the machine. A number of kernel patches for various Linux versions can be found in the `src/kernel-patches` directory. The name of each patch file encodes the Linux kernel version where the patch must be applied to as well as the processor architecture supported. The format is as follows:
Starting from PMCTrack's v2.0, and thanks to the development efforts behind the [PMCSched](https://pmctrack-linux.github.io/pmcsched/) project, PMCTrack now works with vanilla Linux kernels. Specifically, Linux kernel v5.9.x and above are highly recommended to enjoy the full functionality of the tool, including the new [PMCSched subsystem](https://pmctrack-linux.github.io/pmcsched/).

For platforms not officially supporting kernel versions newer than v5.8.x (such as the Odroid-XU4 board), a patched Linux kernel must be installed on the machine.

#### Patching the kernel (legacy systems and older PMCTrack versions)

A number of kernel patches for various Linux versions can be found in the `src/kernel-patches` directory. The name of each patch file encodes the Linux kernel version where the patch must be applied to as well as the processor architecture supported. The format is as follows:

pmctrack_linux-<kernel_version>_<architecture>.patch


If a patch is not available for the desired kernel version, a custom patch can be easily created with git. More information on this can be found in this [tutorial](https://pmctrack-linux.github.io//migrating-patches).

To apply the patch run the following command from the root directory of the kernel sources:

```
Expand All @@ -45,7 +52,9 @@ To build the kernel for PMCTrack, the following option must be enabled when conf
CONFIG_PMCTRACK=y


The kernel headers for the patched Linux version must be installed on the system as well. This is necessary for a successful out-of-tree build of PMCTrack's kernel module. An out-of-tree-ready Makefile can be found in the sources for the different flavors of the kernel module.
#### Additional requirements

The kernel headers for the current Linux version must be installed on the system as well. This is necessary for a successful out-of-tree build of PMCTrack's kernel module. An out-of-tree-ready Makefile can be found in the sources for the different flavors of the kernel module.

Most PMCTrack user-level components are written in C, and do not depend on any external library, (beyond the libc, of course). A separate Makefile is provided for _libpmctrack_ as well as for the various command-line tools. As such, it should be straightforward to build these software components on most Linux distributions.

Expand Down Expand Up @@ -163,7 +172,7 @@ Now kernel-level and user-level components can be easily built with the `pmctrac
*** BUILD PROCESS COMPLETED SUCCESSFULLY ***


The `pmctrack-manager` retrieves key information from the system and builds the command-line tools as well as the different flavors of the PMCTrack kernel module compatible with the current platform. If the build fails, build errors can be found in the `build.log` file created in the current directory.
The `pmctrack-manager` command retrieves key information from the system and builds the command-line tools as well as the different flavors of the PMCTrack kernel module compatible with the current platform. If the build fails, build errors can be found in the `build.log` file created in the current directory.


## Building PMCTrack from source for the Intel Xeon Phi
Expand Down Expand Up @@ -428,7 +437,7 @@ The `pmc-events` command can be used to list the virtual counters exported by th

## Using PMCTrack from the OS scheduler

PMCTrack allows any scheduling algorithm in the Linux kernel (i.e., scheduling class) to collect per-thread monitoring data, thus making it possible to drive scheduling decisions based on tasks' memory behavior or other microarchitectural properties. Turning on this mode for a particular thread from the scheduler's code boils down to activating the `prof_enabled` flag in the thread's descriptor. This flag is added to Linux's task structure when applying PMCTrack's kernel patch.
PMCTrack allows any scheduling algorithm in the Linux kernel (i.e., scheduling class) to collect per-thread monitoring data, thus making it possible to drive scheduling decisions based on tasks' memory behavior or other microarchitectural properties. Turning on this mode for a particular thread from the scheduler's code boils down to activating the `prof_enabled` flag in the thread's descriptor.

To ensure that the implementation of the scheduling algorithm that benefits from this feature remains architecture independent, the scheduler itself (implemented in the kernel) does not configure nor deals with performance counters directly. Instead, the active monitoring module in PMCTrack is in charge of feeding the scheduling policy with the necessary high-level performance monitoring metrics, such as a task's instruction per cycle ratio or its last-level-cache miss rate.

Expand Down
2 changes: 1 addition & 1 deletion etc/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
3.1
2 changes: 1 addition & 1 deletion src/modules/pmcs/cache_part_set.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static inline int suitable_place_for_insertion(cache_part_set_t* pset, unsigned
/* Check whether partitions are perfectly balanced or not */
if (nr_remaining_ways==0) {
/** Pick one randomly **/
hint_id=(get_random_int()%(nr_old_partitions-1));
hint_id=(get_random_long()%(nr_old_partitions-1));
hint_id++; /* Normalize gap */
} else {
max_val=-1;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/pmcs/group_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ sched_timer_periodic_group (void)

/* Generate random group id */
do {
target_group=get_random_int()%cpu_group_count;
target_group=get_random_long()%cpu_group_count;
} while (target_group==llc_id);


Expand Down
5 changes: 5 additions & 0 deletions src/modules/pmcs/include/pmc/mc_experiments.h
Original file line number Diff line number Diff line change
Expand Up @@ -754,5 +754,10 @@ typedef struct file_operations pmctrack_proc_ops_t;
#define PMCT_PROC_MMAP mmap
#endif

#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,17,0)
#define PMCT_PDE_DATA(inode) pde_data(inode)
#else
#define PMCT_PDE_DATA(inode) PDE_DATA(inode)
#endif

#endif
14 changes: 12 additions & 2 deletions src/modules/pmcs/include/pmc/pmcsched.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ typedef struct migration_data {
int dst_group;
int dst_cpu;
cpumask_t dst_cpumask;
unsigned long start_time;
volatile migration_state_t state;
} migration_data_t;

Expand Down Expand Up @@ -305,8 +306,9 @@ typedef struct pmcsched_thread_data {
memory_label_t memory_profile;

schedctl_t* schedctl;
/* Plugin specific fields */
unsigned long ticks_per_socket[MAX_SOCKETS_PLATFORM];

/* Plugin specific fields */
} pmcsched_thread_data_t;

extern intel_cmt_support_t pmcs_cmt_support;
Expand Down Expand Up @@ -537,13 +539,21 @@ static inline struct app_pmcsched *get_app_pmcsched(app_t *app)
void populate_clos_to_update_list(sched_thread_group_t* group, cache_part_set_t* part_set);

/*
* Static trace points for AMP systems
* Static tracepoints
*/
void trace_amp_exit(struct task_struct* p, unsigned int tid, unsigned long ticks_big, unsigned long ticks_small);

void trace_td_thread_exit(struct task_struct* p,
unsigned long noclass,
unsigned long class0,
unsigned long class1,
unsigned long class2,
unsigned long class3);

void trace_sockets_stats(struct task_struct* p,
unsigned int tid,
unsigned long ticks_socket_0,
unsigned long ticks_socket_1,
unsigned long ticks_socket_2,
unsigned long ticks_socket_3);
#endif /* SCHED_PROTO_H */
8 changes: 4 additions & 4 deletions src/modules/pmcs/intel_rdt_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ int initialize_rmid_pool(void)
INIT_LIST_HEAD(&available_rmids);

/* Generate pseudo-randomly at first */
starting_item=(get_random_int()%nr_available_rmids);
starting_item=(get_random_long()%nr_available_rmids);

/* Allocate from the beginning */
for (i=starting_item; i<nr_available_rmids; i++) {
Expand Down Expand Up @@ -151,7 +151,7 @@ uint_t get_rmid(void)
rmid_node=list_entry(available_rmids.prev,rmid_node_t,links); /* list_last_entry */
break;
case RMID_RANDOM:
random_item=(get_random_int()%nr_available_rmids);
random_item=(get_random_long()%nr_available_rmids);
list_for_each_entry_safe(rmid_node, aux, &available_rmids, links) {
if ((random_item--)==0)
break;
Expand Down Expand Up @@ -747,7 +747,7 @@ static const pmctrack_proc_ops_t res_qos_fops = {

static ssize_t res_qos_read(struct file *filp, char __user *buf, size_t len, loff_t *off)
{
unsigned long base_cpu=(unsigned long)PDE_DATA(filp->f_inode);
unsigned long base_cpu=(unsigned long)PMCT_PDE_DATA(filp->f_inode);
int bytes_read=0;
char* kbuf;
char* dst;
Expand Down Expand Up @@ -795,7 +795,7 @@ static ssize_t res_qos_write(struct file *filp, const char __user *buf, size_t l
char *kbuf;
int ret=len;
unsigned int mask=0;
unsigned long base_cpu=(unsigned long)PDE_DATA(filp->f_inode);
unsigned long base_cpu=(unsigned long)PMCT_PDE_DATA(filp->f_inode);

if (*off>0)
return 0;
Expand Down
15 changes: 14 additions & 1 deletion src/modules/pmcs/pmcsched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1533,6 +1533,7 @@ static int schedctl_proc_open(struct inode *inode, struct file *filp)
}

pdata->schedctl=handler->schedctl;

#ifdef SCHEDCTL_DEBUG
trace_printk("Schedctl kernel pointer=0x%p\n",pdata->schedctl);
#endif
Expand Down Expand Up @@ -1678,7 +1679,7 @@ noinline void trace_mt_path(pmon_prof_t* par_prof,pmcsched_thread_data_t* par_da

static int pmcsched_on_fork(unsigned long clone_flags, pmon_prof_t* prof) {
pmcsched_thread_data_t* data;
int j=0,k=0;
int i=0,j=0,k=0;
unsigned int nr_coretypes=active_scheduler->flags&PMCSCHED_AMP_SCHED?get_nr_coretypes():1;
int error=0;
pmon_prof_t *pprof = get_prof(current);
Expand Down Expand Up @@ -1741,6 +1742,9 @@ static int pmcsched_on_fork(unsigned long clone_flags, pmon_prof_t* prof) {

data->force_per_thread = 0;

for (i=0;i<MAX_SOCKETS_PLATFORM;i++)
data->ticks_per_socket[i]=0;

#ifdef TASKLET_SIGNALS_PMCSCHED
/* Init tasklet, pass data = signal_tasklet */
tasklet_init(&data->signal_tasklet,
Expand Down Expand Up @@ -2814,3 +2818,12 @@ noinline void trace_td_thread_exit(struct task_struct* p,
unsigned long class3) {
asm(" ");
}

noinline void trace_sockets_stats(struct task_struct* p,
unsigned int tid,
unsigned long ticks_socket_0,
unsigned long ticks_socket_1,
unsigned long ticks_socket_2,
unsigned long ticks_socket_3){
asm(" ");
}

0 comments on commit 881e7b8

Please sign in to comment.