| /* |
| ************************************************************************** |
| * Copyright (c) 2014, The Linux Foundation. All rights reserved. |
| * Permission to use, copy, modify, and/or distribute this software for |
| * any purpose with or without fee is hereby granted, provided that the |
| * above copyright notice and this permission notice appear in all copies. |
| * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
| * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| ************************************************************************** |
| */ |
| |
| /* |
| * profilesample.h |
| * Sample format for profiling |
| */ |
| |
| #ifndef _PROFILE_SAMPLE_H_ |
| #define _PROFILE_SAMPLE_H_ |
| |
| #define PROFILE_STACK_WORDS 4 |
| |
| /* |
| * Each sample is for an enabled thread, not including the profiling thread. |
| * HRT thread sampling is optional. |
| * Sampled threads may be active or inactive. Samples are included in thread number |
| * order, so each sample interval has a set of samples starting with one from thread 0 |
| * |
| * Samples include bits indicating if this thread is blocked |
| */ |
| #define PROFILE_I_BLOCKED_BIT 5 |
| #define PROFILE_I_BLOCKED (1 << PROFILE_I_BLOCKED_BIT) |
| #define PROFILE_D_BLOCKED_BIT 4 |
| #define PROFILE_D_BLOCKED (1 << PROFILE_D_BLOCKED_BIT) |
| #define PROFILE_BTB_SHIFT 6 |
| |
| #if !defined __unix__ && !defined __ELF__ && !defined __GNUC_ |
| typedef unsigned char uint8_t; |
| typedef unsigned short uint16_t; |
| typedef unsigned int uint32_t; |
| #endif |
| |
| struct profile_sample { |
| uint32_t pc; // PC value |
| uint32_t pid; // pid for the current process, or 0 if NOMMU or unmapped space |
| uint16_t active; // threads are active - for accurate counting |
| uint16_t d_blocked; // threads are blocked due to D cache misses : may be removed |
| uint16_t i_blocked; // threads are blocked due to I cache misses |
| uint8_t cond_codes; // for branch prediction |
| uint8_t thread; // 4-bit thread number |
| uint32_t a_reg; // source An if PC points to a calli. Otherwise a5 contents for parent of leaf function |
| uint32_t parent[PROFILE_STACK_WORDS]; |
| // return addresses from stack, to find the caller |
| }; |
| |
| |
| /* |
| * variables for all components/modules |
| */ |
| #ifdef ARCH_NUM_THREADS |
| #define PROFILE_MAX_THREADS ARCH_NUM_THREADS |
| #else |
| #define PROFILE_MAX_THREADS 12 |
| #endif |
| |
| /* |
| * common variables cross profile components/modules |
| */ |
| #define PROFILE_MAX_PACKET_SIZE 1440 // MSS - tcp/ip headers |
| |
| /* |
| * values chosen so all counter values fit in a single 1400 byte UDP packet |
| */ |
| #define PROFILE_COUNTERS 8 |
| #define PROFILE_COUNTER_NAME_LENGTH 20 |
| #define PROFILE_MAX_APP_COUNTERS 24 |
| |
| #define PROFILE_MAX_COUNTERS ((PROFILE_MAX_PACKET_SIZE - sizeof(struct profile_header_counters)) / (PROFILE_COUNTER_NAME_LENGTH + 4)) |
| |
| struct profile_counter { |
| char name[PROFILE_COUNTER_NAME_LENGTH]; |
| uint32_t value; |
| }; |
| |
| /* |
| * sampling period info cross all modules -- use extended struct to avoid copy |
| */ |
| struct profile_ext_header { |
| uint16_t d_blocked; // threads are blocked due to D cache misses |
| uint16_t i_blocked; // threads are blocked due to I cache misses |
| uint16_t high; // threads were enabled high priority -- unused |
| uint16_t enabled_threads; // threads were enabled at the last sample time |
| uint16_t hrt; // HRT threads |
| uint8_t profiler_tid; // thread running the profile sampler |
| uint8_t sample_sets; // typical 5-8 sets, and may be 9 - see design doc for details |
| uint32_t sets_map; // a set map uses a nibble, 8 maps and 9th is derived |
| uint32_t clocks; // system clock timer at last sample |
| uint32_t inst_count[PROFILE_MAX_THREADS]; // sampled instruction counts at most recent sample |
| uint32_t stats[PROFILE_COUNTERS]; // contents of the cache statistics counters |
| }; |
| |
| #endif // _PROFILE_SAMPLE_H_ |