andikleen / pmu-tools

Intel PMU profiling tools
GNU General Public License v2.0
2.04k stars 341 forks source link

The # of tracked addresses are too small #364

Closed mesunyyam closed 4 years ago

mesunyyam commented 4 years ago

Hello, I am a rookie of perf tool for gathering statistics.

I want to gather addresses of load instructions. I used jevent/addr for this purpose and slightly modify it to track process of given pid until it exits.

However, when I track memcached using jevent/addr, only small numbers of load instructions (about 400s) are tracked even if memcached acquired 14GB memory footprint.

This is script for running test - tracked process is memcached.

sync; echo 3 > /proc/sys/vm/drop_caches; sync
/home/mhan/memcached-1.6.6/memcached -p 11211 -u root -m 32768 -l 127.0.0.1 -t 4 &
PID=$!
./addr $PID 1 > sample1_logs &

/home/mhan/ycsb-0.17.0/bin/ycsb load memcached -s -P /home/mhan/ycsb-0.17.0/workloads/workload_template -p memcached.hosts=127.0.0.1 -threads 24
/home/mhan/ycsb-0.17.0/bin/ycsb run memcached -s -P /home/mhan/ycsb-0.17.0/workloads/workload_template -p memcached.hosts=127.0.0.1 -threads 24
pkill memcached

This is code of addr that I modified.

int main(int ac, char **av)
{

        if (ac < 3)
        {
                printf("./addr pid sample_period\n");
                exit(1);
        }

        char path[20] = "/proc/";
        struct stat stats;
        strcat(path, av[1]);

        /* Set up perf for loads */
        struct perf_event_attr attr = {
                .type = PERF_TYPE_RAW,
                .size = PERF_ATTR_SIZE_VER0,
                .sample_type = PERF_SAMPLE_ADDR,
                .sample_period = atoi(av[2]),           /* Period */
                .precise_ip = 3,                /* Enable PEBS */
                .mmap = 1, .comm = 1, .task = 1, .mmap_data = 1, .mmap2 = 1, .context_switch = 1,
                .config1 = 0,                   /* Load Latency threshold */
                .config = mem_loads_event(),    /* Event */
                .disabled = 1,
        };

        if (attr.config == -1) {
                printf("Unknown CPU model\n");
                exit(1);
        }

        struct perf_fd loads, stores;
        if (perf_fd_open_other(&loads, &attr, BUF_SIZE_SHIFT, atoi(av[1]), -1) < 0)
                err("perf event init loads");

        if (perf_enable(&loads) < 0)
                err("PERF_EVENT_IOC_ENABLE");

        while (stat(path, &stats) == 0)
        {

        }

        if (perf_disable(&loads) < 0)
                err("PERF_EVENT_IOC_DISABLE");

        gen_hist("loads", &loads);

        perf_fd_close(&loads);

        return 0;
}

Could you help me to find the reason of this issue?

Regards, Miseon Han