Perf Error: The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (msr/tsc/)












1















I am using perf to monitor the system for certain events. However, I get the following error and I have no idea where it comes from,as the event is listed in perf list



sudo perf record -e msr/tsc/ -a



Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (msr/tsc/).
/bin/dmesg may provide additional information.
No CONFIG_PERF_EVENTS=y kernel support configured?


How can I check No CONFIG_PERF_EVENTS=y kernel support configured?



**Some test results:



sudo dmesg | grep "perf|pmu"**
[ 0.029179] ENERGY_PERF_BIAS: Set to 'normal', was 'performance'
[ 0.029179] ENERGY_PERF_BIAS: View and update with x86_energy_perf_policy(8)
[ 9475.406967] perf: interrupt took too long (2509 > 2500), lowering kernel.perf_event_max_sample_rate to 79500
[ 9475.990901] perf: interrupt took too long (3146 > 3136), lowering kernel.perf_event_max_sample_rate to 63500
[ 9476.886941] perf: interrupt took too long (3942 > 3932), lowering kernel.perf_event_max_sample_rate to 50500
[76057.268195] perf: interrupt took too long (4934 > 4927), lowering kernel.perf_event_max_sample_rate to 40500
[167368.007839] perf: interrupt took too long (6171 > 6167), lowering kernel.perf_event_max_sample_rate to 32250
[168338.165608] perf: interrupt took too long (7804 > 7713), lowering kernel.perf_event_max_sample_rate to 25500


perf list |grep msr



  msr/aperf/                                         [Kernel PMU event]
msr/mperf/ [Kernel PMU event]
msr/pperf/ [Kernel PMU event]
msr/smi/ [Kernel PMU event]
msr/tsc/


sudo uname -a
Linux bla 4.9.0-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 GNU/Linux



sudo /proc/config.gz returns command not found
Any help/ideas are appreciated.










share|improve this question

























  • What system are you using? Ubuntu? Arch Linux? uname -a output? Depending on how your kernel was compiled, it might have a /proc/config.gz containing the config options it was built with.

    – Peter Cordes
    Nov 19 '18 at 18:21











  • I edited the question and added the requested data. I use Debian

    – assembly_question
    Nov 20 '18 at 7:56
















1















I am using perf to monitor the system for certain events. However, I get the following error and I have no idea where it comes from,as the event is listed in perf list



sudo perf record -e msr/tsc/ -a



Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (msr/tsc/).
/bin/dmesg may provide additional information.
No CONFIG_PERF_EVENTS=y kernel support configured?


How can I check No CONFIG_PERF_EVENTS=y kernel support configured?



**Some test results:



sudo dmesg | grep "perf|pmu"**
[ 0.029179] ENERGY_PERF_BIAS: Set to 'normal', was 'performance'
[ 0.029179] ENERGY_PERF_BIAS: View and update with x86_energy_perf_policy(8)
[ 9475.406967] perf: interrupt took too long (2509 > 2500), lowering kernel.perf_event_max_sample_rate to 79500
[ 9475.990901] perf: interrupt took too long (3146 > 3136), lowering kernel.perf_event_max_sample_rate to 63500
[ 9476.886941] perf: interrupt took too long (3942 > 3932), lowering kernel.perf_event_max_sample_rate to 50500
[76057.268195] perf: interrupt took too long (4934 > 4927), lowering kernel.perf_event_max_sample_rate to 40500
[167368.007839] perf: interrupt took too long (6171 > 6167), lowering kernel.perf_event_max_sample_rate to 32250
[168338.165608] perf: interrupt took too long (7804 > 7713), lowering kernel.perf_event_max_sample_rate to 25500


perf list |grep msr



  msr/aperf/                                         [Kernel PMU event]
msr/mperf/ [Kernel PMU event]
msr/pperf/ [Kernel PMU event]
msr/smi/ [Kernel PMU event]
msr/tsc/


sudo uname -a
Linux bla 4.9.0-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 GNU/Linux



sudo /proc/config.gz returns command not found
Any help/ideas are appreciated.










share|improve this question

























  • What system are you using? Ubuntu? Arch Linux? uname -a output? Depending on how your kernel was compiled, it might have a /proc/config.gz containing the config options it was built with.

    – Peter Cordes
    Nov 19 '18 at 18:21











  • I edited the question and added the requested data. I use Debian

    – assembly_question
    Nov 20 '18 at 7:56














1












1








1


1






I am using perf to monitor the system for certain events. However, I get the following error and I have no idea where it comes from,as the event is listed in perf list



sudo perf record -e msr/tsc/ -a



Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (msr/tsc/).
/bin/dmesg may provide additional information.
No CONFIG_PERF_EVENTS=y kernel support configured?


How can I check No CONFIG_PERF_EVENTS=y kernel support configured?



**Some test results:



sudo dmesg | grep "perf|pmu"**
[ 0.029179] ENERGY_PERF_BIAS: Set to 'normal', was 'performance'
[ 0.029179] ENERGY_PERF_BIAS: View and update with x86_energy_perf_policy(8)
[ 9475.406967] perf: interrupt took too long (2509 > 2500), lowering kernel.perf_event_max_sample_rate to 79500
[ 9475.990901] perf: interrupt took too long (3146 > 3136), lowering kernel.perf_event_max_sample_rate to 63500
[ 9476.886941] perf: interrupt took too long (3942 > 3932), lowering kernel.perf_event_max_sample_rate to 50500
[76057.268195] perf: interrupt took too long (4934 > 4927), lowering kernel.perf_event_max_sample_rate to 40500
[167368.007839] perf: interrupt took too long (6171 > 6167), lowering kernel.perf_event_max_sample_rate to 32250
[168338.165608] perf: interrupt took too long (7804 > 7713), lowering kernel.perf_event_max_sample_rate to 25500


perf list |grep msr



  msr/aperf/                                         [Kernel PMU event]
msr/mperf/ [Kernel PMU event]
msr/pperf/ [Kernel PMU event]
msr/smi/ [Kernel PMU event]
msr/tsc/


sudo uname -a
Linux bla 4.9.0-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 GNU/Linux



sudo /proc/config.gz returns command not found
Any help/ideas are appreciated.










share|improve this question
















I am using perf to monitor the system for certain events. However, I get the following error and I have no idea where it comes from,as the event is listed in perf list



sudo perf record -e msr/tsc/ -a



Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (msr/tsc/).
/bin/dmesg may provide additional information.
No CONFIG_PERF_EVENTS=y kernel support configured?


How can I check No CONFIG_PERF_EVENTS=y kernel support configured?



**Some test results:



sudo dmesg | grep "perf|pmu"**
[ 0.029179] ENERGY_PERF_BIAS: Set to 'normal', was 'performance'
[ 0.029179] ENERGY_PERF_BIAS: View and update with x86_energy_perf_policy(8)
[ 9475.406967] perf: interrupt took too long (2509 > 2500), lowering kernel.perf_event_max_sample_rate to 79500
[ 9475.990901] perf: interrupt took too long (3146 > 3136), lowering kernel.perf_event_max_sample_rate to 63500
[ 9476.886941] perf: interrupt took too long (3942 > 3932), lowering kernel.perf_event_max_sample_rate to 50500
[76057.268195] perf: interrupt took too long (4934 > 4927), lowering kernel.perf_event_max_sample_rate to 40500
[167368.007839] perf: interrupt took too long (6171 > 6167), lowering kernel.perf_event_max_sample_rate to 32250
[168338.165608] perf: interrupt took too long (7804 > 7713), lowering kernel.perf_event_max_sample_rate to 25500


perf list |grep msr



  msr/aperf/                                         [Kernel PMU event]
msr/mperf/ [Kernel PMU event]
msr/pperf/ [Kernel PMU event]
msr/smi/ [Kernel PMU event]
msr/tsc/


sudo uname -a
Linux bla 4.9.0-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 GNU/Linux



sudo /proc/config.gz returns command not found
Any help/ideas are appreciated.







profiling perf tsc msr






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 '18 at 7:54







assembly_question

















asked Nov 19 '18 at 12:41









assembly_questionassembly_question

92




92













  • What system are you using? Ubuntu? Arch Linux? uname -a output? Depending on how your kernel was compiled, it might have a /proc/config.gz containing the config options it was built with.

    – Peter Cordes
    Nov 19 '18 at 18:21











  • I edited the question and added the requested data. I use Debian

    – assembly_question
    Nov 20 '18 at 7:56



















  • What system are you using? Ubuntu? Arch Linux? uname -a output? Depending on how your kernel was compiled, it might have a /proc/config.gz containing the config options it was built with.

    – Peter Cordes
    Nov 19 '18 at 18:21











  • I edited the question and added the requested data. I use Debian

    – assembly_question
    Nov 20 '18 at 7:56

















What system are you using? Ubuntu? Arch Linux? uname -a output? Depending on how your kernel was compiled, it might have a /proc/config.gz containing the config options it was built with.

– Peter Cordes
Nov 19 '18 at 18:21





What system are you using? Ubuntu? Arch Linux? uname -a output? Depending on how your kernel was compiled, it might have a /proc/config.gz containing the config options it was built with.

– Peter Cordes
Nov 19 '18 at 18:21













I edited the question and added the requested data. I use Debian

– assembly_question
Nov 20 '18 at 7:56





I edited the question and added the requested data. I use Debian

– assembly_question
Nov 20 '18 at 7:56












1 Answer
1






active

oldest

votes


















2














There was a patch introduced in perf to support MSR Performance Monitoring Units. These MSR PMUs support free-running MSR counters. These counters include time and frequency-based counters like TSC, IA32_APERF, IA32_MPERF and IA32_PPERF.



These MSR events do not support sampling modes. As visible by this line of code in the linux kernel(v4.9) source code.



Snippet:



if event->attr.sample_period) /* no sampling */
return -EINVAL;



perf_events can instrument in three ways (counting events, sampling events and bpf events). Remember that when you run perf record, you are now invoking the sampling mode. Even though you do not explicitly specify the sampling period, internally sampling is happening at a default sampling frequency.



To count msr events, you need to run perf_events in counting/aggregation mode. You run perf stat for this --



perf stat -e msr/tsc/ -a

^C

Performance counter stats for 'system wide':

34,83,07,96,035 msr/tsc/

2.419151644 seconds time elapsed


Read this to understand more about counting and sampling events/modes.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374880%2fperf-error-the-sys-perf-event-open-syscall-returned-with-22-invalid-argument%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    There was a patch introduced in perf to support MSR Performance Monitoring Units. These MSR PMUs support free-running MSR counters. These counters include time and frequency-based counters like TSC, IA32_APERF, IA32_MPERF and IA32_PPERF.



    These MSR events do not support sampling modes. As visible by this line of code in the linux kernel(v4.9) source code.



    Snippet:



    if event->attr.sample_period) /* no sampling */
    return -EINVAL;



    perf_events can instrument in three ways (counting events, sampling events and bpf events). Remember that when you run perf record, you are now invoking the sampling mode. Even though you do not explicitly specify the sampling period, internally sampling is happening at a default sampling frequency.



    To count msr events, you need to run perf_events in counting/aggregation mode. You run perf stat for this --



    perf stat -e msr/tsc/ -a

    ^C

    Performance counter stats for 'system wide':

    34,83,07,96,035 msr/tsc/

    2.419151644 seconds time elapsed


    Read this to understand more about counting and sampling events/modes.






    share|improve this answer




























      2














      There was a patch introduced in perf to support MSR Performance Monitoring Units. These MSR PMUs support free-running MSR counters. These counters include time and frequency-based counters like TSC, IA32_APERF, IA32_MPERF and IA32_PPERF.



      These MSR events do not support sampling modes. As visible by this line of code in the linux kernel(v4.9) source code.



      Snippet:



      if event->attr.sample_period) /* no sampling */
      return -EINVAL;



      perf_events can instrument in three ways (counting events, sampling events and bpf events). Remember that when you run perf record, you are now invoking the sampling mode. Even though you do not explicitly specify the sampling period, internally sampling is happening at a default sampling frequency.



      To count msr events, you need to run perf_events in counting/aggregation mode. You run perf stat for this --



      perf stat -e msr/tsc/ -a

      ^C

      Performance counter stats for 'system wide':

      34,83,07,96,035 msr/tsc/

      2.419151644 seconds time elapsed


      Read this to understand more about counting and sampling events/modes.






      share|improve this answer


























        2












        2








        2







        There was a patch introduced in perf to support MSR Performance Monitoring Units. These MSR PMUs support free-running MSR counters. These counters include time and frequency-based counters like TSC, IA32_APERF, IA32_MPERF and IA32_PPERF.



        These MSR events do not support sampling modes. As visible by this line of code in the linux kernel(v4.9) source code.



        Snippet:



        if event->attr.sample_period) /* no sampling */
        return -EINVAL;



        perf_events can instrument in three ways (counting events, sampling events and bpf events). Remember that when you run perf record, you are now invoking the sampling mode. Even though you do not explicitly specify the sampling period, internally sampling is happening at a default sampling frequency.



        To count msr events, you need to run perf_events in counting/aggregation mode. You run perf stat for this --



        perf stat -e msr/tsc/ -a

        ^C

        Performance counter stats for 'system wide':

        34,83,07,96,035 msr/tsc/

        2.419151644 seconds time elapsed


        Read this to understand more about counting and sampling events/modes.






        share|improve this answer













        There was a patch introduced in perf to support MSR Performance Monitoring Units. These MSR PMUs support free-running MSR counters. These counters include time and frequency-based counters like TSC, IA32_APERF, IA32_MPERF and IA32_PPERF.



        These MSR events do not support sampling modes. As visible by this line of code in the linux kernel(v4.9) source code.



        Snippet:



        if event->attr.sample_period) /* no sampling */
        return -EINVAL;



        perf_events can instrument in three ways (counting events, sampling events and bpf events). Remember that when you run perf record, you are now invoking the sampling mode. Even though you do not explicitly specify the sampling period, internally sampling is happening at a default sampling frequency.



        To count msr events, you need to run perf_events in counting/aggregation mode. You run perf stat for this --



        perf stat -e msr/tsc/ -a

        ^C

        Performance counter stats for 'system wide':

        34,83,07,96,035 msr/tsc/

        2.419151644 seconds time elapsed


        Read this to understand more about counting and sampling events/modes.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 20 '18 at 17:42









        Arnabjyoti KalitaArnabjyoti Kalita

        7631618




        7631618






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374880%2fperf-error-the-sys-perf-event-open-syscall-returned-with-22-invalid-argument%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to change which sound is reproduced for terminal bell?

            Can I use Tabulator js library in my java Spring + Thymeleaf project?

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents