--data-page-size::
        Record the sampled data address data page size.
 
+--code-page-size::
+       Record the sampled code address (ip) page size
+
 -T::
 --timestamp::
        Record the sample timestamps. Use it with 'perf report -D' to see the
 
                    "Record the sample physical addresses"),
        OPT_BOOLEAN(0, "data-page-size", &record.opts.sample_data_page_size,
                    "Record the sampled data address data page size"),
+       OPT_BOOLEAN(0, "code-page-size", &record.opts.sample_code_page_size,
+                   "Record the sampled code address (ip) page size"),
        OPT_BOOLEAN(0, "sample-cpu", &record.opts.sample_cpu, "Record the sample cpu"),
        OPT_BOOLEAN_SET('T', "timestamp", &record.opts.sample_time,
                        &record.opts.sample_time_set,
 
        u64 data_src;
        u64 phys_addr;
        u64 data_page_size;
+       u64 code_page_size;
        u64 cgroup;
        u32 flags;
        u16 insn_len;
 
        if (opts->sample_data_page_size)
                evsel__set_sample_bit(evsel, DATA_PAGE_SIZE);
 
+       if (opts->sample_code_page_size)
+               evsel__set_sample_bit(evsel, CODE_PAGE_SIZE);
+
        if (opts->record_switch_events)
                attr->context_switch = track;
 
         * Must probe features in the order they were added to the
         * perf_event_attr interface.
         */
-        if (!perf_missing_features.data_page_size &&
+       if (!perf_missing_features.code_page_size &&
+           (evsel->core.attr.sample_type & PERF_SAMPLE_CODE_PAGE_SIZE)) {
+               perf_missing_features.code_page_size = true;
+               pr_debug2_peo("Kernel has no PERF_SAMPLE_CODE_PAGE_SIZE support, bailing out\n");
+               goto out_close;
+       } else if (!perf_missing_features.data_page_size &&
            (evsel->core.attr.sample_type & PERF_SAMPLE_DATA_PAGE_SIZE)) {
                perf_missing_features.data_page_size = true;
                pr_debug2_peo("Kernel has no PERF_SAMPLE_DATA_PAGE_SIZE support, bailing out\n");
                array++;
        }
 
+       data->code_page_size = 0;
+       if (type & PERF_SAMPLE_CODE_PAGE_SIZE) {
+               data->code_page_size = *array;
+               array++;
+       }
+
        if (type & PERF_SAMPLE_AUX) {
                OVERFLOW_CHECK_u64(array);
                sz = *array++;
        "We found oprofile daemon running, please stop it and try again.");
                break;
        case EINVAL:
+               if (evsel->core.attr.sample_type & PERF_SAMPLE_CODE_PAGE_SIZE && perf_missing_features.code_page_size)
+                       return scnprintf(msg, size, "Asking for the code page size isn't supported by this kernel.");
                if (evsel->core.attr.sample_type & PERF_SAMPLE_DATA_PAGE_SIZE && perf_missing_features.data_page_size)
                        return scnprintf(msg, size, "Asking for the data page size isn't supported by this kernel.");
                if (evsel->core.attr.write_backward && perf_missing_features.write_backward)
 
        bool branch_hw_idx;
        bool cgroup;
        bool data_page_size;
+       bool code_page_size;
 };
 
 extern struct perf_missing_features perf_missing_features;
 
                bit_name(BRANCH_STACK), bit_name(REGS_USER), bit_name(STACK_USER),
                bit_name(IDENTIFIER), bit_name(REGS_INTR), bit_name(DATA_SRC),
                bit_name(WEIGHT), bit_name(PHYS_ADDR), bit_name(AUX),
-               bit_name(CGROUP), bit_name(DATA_PAGE_SIZE),
+               bit_name(CGROUP), bit_name(DATA_PAGE_SIZE), bit_name(CODE_PAGE_SIZE),
                { .name = NULL, }
        };
 #undef bit_name
 
        bool          sample_address;
        bool          sample_phys_addr;
        bool          sample_data_page_size;
+       bool          sample_code_page_size;
        bool          sample_weight;
        bool          sample_time;
        bool          sample_time_set;
 
        if (type & PERF_SAMPLE_DATA_PAGE_SIZE)
                result += sizeof(u64);
 
+       if (type & PERF_SAMPLE_CODE_PAGE_SIZE)
+               result += sizeof(u64);
+
        if (type & PERF_SAMPLE_AUX) {
                result += sizeof(u64);
                result += sample->aux_sample.size;
                array++;
        }
 
+       if (type & PERF_SAMPLE_CODE_PAGE_SIZE) {
+               *array = sample->code_page_size;
+               array++;
+       }
+
        if (type & PERF_SAMPLE_AUX) {
                sz = sample->aux_sample.size;
                *array++ = sz;