tracing/user_events: Use bits vs bytes for enabled status page data
User processes may require many events and when they do the cache performance of a byte index status check is less ideal than a bit index. The previous event limit per-page was 4096, the new limit is 32,768. This change adds a bitwise index to the user_reg struct. Programs check that the bit at status_bit has a bit set within the status page(s). Link: https://lkml.kernel.org/r/20220728233309.1896-6-beaub@linux.microsoft.com Link: https://lore.kernel.org/all/2059213643.196683.1648499088753.JavaMail.zimbra@efficios.com/ Suggested-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
This commit is contained in:
committed by
Steven Rostedt (Google)
parent
d401b72458
commit
39d6d08b2e
@@ -12,13 +12,21 @@
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <asm/bitsperlong.h>
|
||||
#include <endian.h>
|
||||
#include <linux/user_events.h>
|
||||
|
||||
#if __BITS_PER_LONG == 64
|
||||
#define endian_swap(x) htole64(x)
|
||||
#else
|
||||
#define endian_swap(x) htole32(x)
|
||||
#endif
|
||||
|
||||
/* Assumes debugfs is mounted */
|
||||
const char *data_file = "/sys/kernel/debug/tracing/user_events_data";
|
||||
const char *status_file = "/sys/kernel/debug/tracing/user_events_status";
|
||||
|
||||
static int event_status(char **status)
|
||||
static int event_status(long **status)
|
||||
{
|
||||
int fd = open(status_file, O_RDONLY);
|
||||
|
||||
@@ -33,7 +41,8 @@ static int event_status(char **status)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_reg(int fd, const char *command, int *status, int *write)
|
||||
static int event_reg(int fd, const char *command, long *index, long *mask,
|
||||
int *write)
|
||||
{
|
||||
struct user_reg reg = {0};
|
||||
|
||||
@@ -43,7 +52,8 @@ static int event_reg(int fd, const char *command, int *status, int *write)
|
||||
if (ioctl(fd, DIAG_IOCSREG, ®) == -1)
|
||||
return -1;
|
||||
|
||||
*status = reg.status_index;
|
||||
*index = reg.status_bit / __BITS_PER_LONG;
|
||||
*mask = endian_swap(1L << (reg.status_bit % __BITS_PER_LONG));
|
||||
*write = reg.write_index;
|
||||
|
||||
return 0;
|
||||
@@ -51,8 +61,9 @@ static int event_reg(int fd, const char *command, int *status, int *write)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int data_fd, status, write;
|
||||
char *status_page;
|
||||
int data_fd, write;
|
||||
long index, mask;
|
||||
long *status_page;
|
||||
struct iovec io[2];
|
||||
__u32 count = 0;
|
||||
|
||||
@@ -61,7 +72,7 @@ int main(int argc, char **argv)
|
||||
|
||||
data_fd = open(data_file, O_RDWR);
|
||||
|
||||
if (event_reg(data_fd, "test u32 count", &status, &write) == -1)
|
||||
if (event_reg(data_fd, "test u32 count", &index, &mask, &write) == -1)
|
||||
return errno;
|
||||
|
||||
/* Setup iovec */
|
||||
@@ -75,7 +86,7 @@ ask:
|
||||
getchar();
|
||||
|
||||
/* Check if anyone is listening */
|
||||
if (status_page[status]) {
|
||||
if (status_page[index] & mask) {
|
||||
/* Yep, trace out our data */
|
||||
writev(data_fd, (const struct iovec *)io, 2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user