* recorded as part of interrupt regs. Thus we need to use rip from
         * interrupt regs while unwinding call stack.
         */
-       if (event->attr.sample_type & PERF_SAMPLE_CALLCHAIN)
+       if (event->attr.sample_type & PERF_SAMPLE_CALLCHAIN) {
                data.callchain = perf_callchain(event, iregs);
+               data.sample_flags |= PERF_SAMPLE_CALLCHAIN;
+       }
 
        throttle = perf_event_overflow(event, &data, ®s);
 out:
 
         * previous PMI context or an (I)RET happened between the record and
         * PMI.
         */
-       if (sample_type & PERF_SAMPLE_CALLCHAIN)
+       if (sample_type & PERF_SAMPLE_CALLCHAIN) {
                data->callchain = perf_callchain(event, iregs);
+               data->sample_flags |= PERF_SAMPLE_CALLCHAIN;
+       }
 
        /*
         * We use the interrupt regs as a base because the PEBS record does not
         * previous PMI context or an (I)RET happened between the record and
         * PMI.
         */
-       if (sample_type & PERF_SAMPLE_CALLCHAIN)
+       if (sample_type & PERF_SAMPLE_CALLCHAIN) {
                data->callchain = perf_callchain(event, iregs);
+               data->sample_flags |= PERF_SAMPLE_CALLCHAIN;
+       }
 
        *regs = *iregs;
        /* The ip in basic is EventingIP */
 
        if (sample_type & PERF_SAMPLE_CALLCHAIN) {
                int size = 1;
 
-               if (!(sample_type & __PERF_SAMPLE_CALLCHAIN_EARLY))
+               if (filtered_sample_type & PERF_SAMPLE_CALLCHAIN)
                        data->callchain = perf_callchain(event, regs);
 
                size += data->callchain->nr;