}
 
 static void process_event(union perf_event *event, struct perf_sample *sample,
-                         struct perf_evsel *evsel, struct thread *thread,
-                         struct addr_location *al)
+                         struct perf_evsel *evsel, struct addr_location *al)
 {
+       struct thread *thread = al->thread;
        struct perf_event_attr *attr = &evsel->attr;
 
        if (output[attr->type].fields == 0)
        if (cpu_list && !test_bit(sample->cpu, cpu_bitmap))
                return 0;
 
-       scripting_ops->process_event(event, sample, evsel, al.thread, &al);
+       scripting_ops->process_event(event, sample, evsel, &al);
 
        return 0;
 }
 
 static void perl_process_event(union perf_event *event,
                               struct perf_sample *sample,
                               struct perf_evsel *evsel,
-                              struct thread *thread,
-                              struct addr_location *al __maybe_unused)
+                              struct addr_location *al)
 {
-       perl_process_tracepoint(sample, evsel, thread);
+       perl_process_tracepoint(sample, evsel, al->thread);
        perl_process_event_generic(event, sample, evsel);
 }
 
 
 
 static void python_process_tracepoint(struct perf_sample *sample,
                                      struct perf_evsel *evsel,
-                                     struct thread *thread,
                                      struct addr_location *al)
 {
        struct event_format *event = evsel->tp_format;
        int cpu = sample->cpu;
        void *data = sample->raw_data;
        unsigned long long nsecs = sample->time;
-       const char *comm = thread__comm_str(thread);
+       const char *comm = thread__comm_str(al->thread);
 
        t = PyTuple_New(MAX_FIELDS);
        if (!t)
 
 static void python_process_general_event(struct perf_sample *sample,
                                         struct perf_evsel *evsel,
-                                        struct thread *thread,
                                         struct addr_location *al)
 {
        PyObject *handler, *t, *dict, *callchain, *dict_sample;
        pydict_set_item_string_decref(dict, "raw_buf", PyString_FromStringAndSize(
                        (const char *)sample->raw_data, sample->raw_size));
        pydict_set_item_string_decref(dict, "comm",
-                       PyString_FromString(thread__comm_str(thread)));
+                       PyString_FromString(thread__comm_str(al->thread)));
        if (al->map) {
                pydict_set_item_string_decref(dict, "dso",
                        PyString_FromString(al->map->dso->name));
 static void python_process_event(union perf_event *event,
                                 struct perf_sample *sample,
                                 struct perf_evsel *evsel,
-                                struct thread *thread,
                                 struct addr_location *al)
 {
        struct tables *tables = &tables_global;
 
        switch (evsel->attr.type) {
        case PERF_TYPE_TRACEPOINT:
-               python_process_tracepoint(sample, evsel, thread, al);
+               python_process_tracepoint(sample, evsel, al);
                break;
        /* Reserve for future process_hw/sw/raw APIs */
        default:
                if (tables->db_export_mode)
                        db_export__sample(&tables->dbe, event, sample, evsel,
-                                         thread, al);
+                                         al->thread, al);
                else
-                       python_process_general_event(sample, evsel, thread, al);
+                       python_process_general_event(sample, evsel, al);
        }
 }