qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: "Ted Ts'o" <tytso@mit.edu>,
	"Pekka Enberg" <penberg@cs.helsinki.fi>,
	"Frank Ch. Eigler" <fche@redhat.com>,
	"Vince Weaver" <vince@deater.net>,
	"Pekka Enberg" <penberg@kernel.org>,
	"Anthony Liguori" <anthony@codemonkey.ws>,
	"Avi Kivity" <avi@redhat.com>,
	"kvm@vger.kernel.org list" <kvm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org List"
	<linux-kernel@vger.kernel.org>,
	"qemu-devel Developers" <qemu-devel@nongnu.org>,
	"Alexander Graf" <agraf@suse.de>,
	"Blue Swirl" <blauwirbel@gmail.com>,
	"Américo Wang" <xiyou.wangcong@gmail.com>,
	"Linus Torvalds" <torvalds@linux-foundation.org>,
	"Peter Zijlstra" <a.p.zijlstra@chello.nl>,
	"Arnaldo Carvalho de Melo" <acme@redhat.com>
Subject: [Qemu-devel] [F.A.Q.] perf ABI backwards and forwards compatibility
Date: Tue, 8 Nov 2011 11:22:35 +0100	[thread overview]
Message-ID: <20111108102235.GA1241@elte.hu> (raw)
In-Reply-To: <20111107203514.GG24234@thunk.org>


* Ted Ts'o <tytso@mit.edu> wrote:

> I don't believe there's ever been any guarantee that "perf test" 
> from version N of the kernel will always work on a version N+M of 
> the kernel.  Perhaps I am wrong, though. If that is a guarantee 
> that the perf developers are willing to stand behind, or have 
> already made, I would love to be corrected and would be delighted 
> to hear that in fact there is a stable, backwards compatible perf 
> ABI.

We do even more than that, the perf ABI is fully backwards *and* 
forwards compatible: you can run older perf on newer ABIs and newer 
perf on older ABIs.

To show you how it works in practice, here's a random 
cross-compatibility experiment: going back to the perf ABI of 2 years 
ago. I used v2.6.32 which was just the second upstream kernel with 
perf released in it.

So i took a fresh perf tool version and booted a vanilla v2.6.32 
(x86, defconfig, PERF_COUNTERS=y) kernel:

  $ uname -a
  Linux mercury 2.6.32 #162137 SMP Tue Nov 8 10:55:37 CET 2011 x86_64 x86_64 x86_64 GNU/Linux

  $ perf --version
  perf version 3.1.1927.gceec2

  $ perf top

  Events: 2K cycles
 61.68%  [kernel]             [k] sha_transform
 16.09%  [kernel]             [k] mix_pool_bytes_extract
  4.70%  [kernel]             [k] extract_buf
  4.17%  [kernel]             [k] _spin_lock_irqsave
  1.44%  [kernel]             [k] copy_user_generic_string
  0.75%  [kernel]             [k] extract_entropy_user
  0.37%  [kernel]             [k] acpi_pm_read

[the box is running a /dev/urandom stress-test as you can see.]

 $ perf stat sleep 1

 Performance counter stats for 'sleep 1':

          0.766698 task-clock                #    0.001 CPUs utilized          
                 1 context-switches          #    0.001 M/sec                  
                 0 CPU-migrations            #    0.000 M/sec                  
               177 page-faults               #    0.231 M/sec                  
         1,513,332 cycles                    #    1.974 GHz                    
   <not supported> stalled-cycles-frontend 
   <not supported> stalled-cycles-backend  
           522,609 instructions              #    0.35  insns per cycle        
            65,812 branches                  #   85.838 M/sec                  
             7,762 branch-misses             #   11.79% of all branches        

       1.076211168 seconds time elapsed

The two <not supported> events are not supported by the old kernel - 
but the other events were and the tool picked them up without bailing 
out.

Regular profiling:

 $ perf record -a sleep 1
 [ perf record: Woken up 1 times to write data ]
 [ perf record: Captured and wrote 0.075 MB perf.data (~3279 samples) ]

perf report output:

 $ perf report

 Events: 1K cycles
  64.45%          dd  [kernel.kallsyms]    [k] sha_transform
  19.39%          dd  [kernel.kallsyms]    [k] mix_pool_bytes_extract
   4.11%          dd  [kernel.kallsyms]    [k] _spin_lock_irqsave
   2.98%          dd  [kernel.kallsyms]    [k] extract_buf
   0.84%          dd  [kernel.kallsyms]    [k] copy_user_generic_string
   0.38%         ssh  libcrypto.so.0.9.8b  [.] lh_insert
   0.28%   flush-8:0  [kernel.kallsyms]    [k] block_write_full_page_endio
   0.28%   flush-8:0  [kernel.kallsyms]    [k] generic_make_request

These examples show *PICTURE PERFECT* backwards ABI compatibility, 
when using the bleeding perf tool on an ancient perf kernel (when it 
wasnt even called 'perf events' but 'perf counters').

[ Note, i didnt go back to v2.6.31, the oldest upstream perf kernel, 
  because it's such a pain to build with recent binutils and recent 
  GCC ... v2.6.32 already needed a workaround and a couple of .config 
  tweaks to build and boot at all. ]

Then i built the ancient v2.6.32 perf tool from 2 years ago:

 $ perf --version
 perf version 0.0.2.PERF

and booted a fresh v3.1+ kernel:

 $ uname -a
 Linux mercury 3.1.0-tip+ #162138 SMP Tue Nov 8 11:14:26 CET 2011 x86_64 x86_64 x86_64 GNU/Linux

 $ perf stat ls

 Performance counter stats for 'ls':

       1.739193  task-clock-msecs         #      0.069 CPUs 
              0  context-switches         #      0.000 M/sec
              0  CPU-migrations           #      0.000 M/sec
            250  page-faults              #      0.144 M/sec
        3477562  cycles                   #   1999.526 M/sec
        1661460  instructions             #      0.478 IPC  
         839826  cache-references         #    482.883 M/sec
          15742  cache-misses             #      9.051 M/sec

    0.025231139  seconds time elapsed

 $ perf top

 ------------------------------------------------------------------------------
   PerfTop:   38916 irqs/sec  kernel:99.6% [100000 cycles],  (all, 2 CPUs)
 ------------------------------------------------------------------------------

             samples    pcnt   kernel function
             _______   _____   _______________

            41191.00 - 53.1% : sha_transform
            20818.00 - 26.8% : mix_pool_bytes_extract
             5481.00 -  7.1% : _raw_spin_lock_irqsave
             2132.00 -  2.7% : extract_buf
             1788.00 -  2.3% : copy_user_generic_string
              801.00 -  1.0% : acpi_pm_read
              446.00 -  0.6% : _raw_spin_unlock_irqrestore
              284.00 -  0.4% : __memset
              259.00 -  0.3% : extract_entropy_user

 $ perf record -a -f sleep 1
 [ perf record: Woken up 1 times to write data ]
 [ perf record: Captured and wrote 0.034 MB perf.data (~1467 samples) ]

 $ perf report

 # Samples: 1023
 #
 # Overhead        Command                     Shared Object  Symbol
 # ........  .............  ................................  ......
 #
     4.50%        swapper  [kernel]                          [k] acpi_pm_read
     4.01%        swapper  [kernel]                          [k] delay_tsc
     2.05%           sudo  /lib64/libcrypto.so.0.9.8b        [.] 0x000000000a0549
     1.96%           perf  [kernel]                          [k] vsnprintf
     1.86%        swapper  [kernel]                          [k] test_clear_page_writeback
     1.66%           perf  [kernel]                          [k] format_decode
     1.56%           sudo  /lib64/ld-2.7.so                  [.] do_lookup_x

These examples show *PICTURE PERFECT* forwards ABI compatibility, 
using the ancient perf tool on a bleeding edge kernel.

During the years we migrated across various transformations of the 
subsystem and added tons of features, while maintaining the perf ABI.

I don't know where the whole ABI argument comes from - perf has 
argumably one of the best and most compatible tooling ABIs within 
Linux. I suspect back in the original perf flamewars people made up 
their mind prematurely that it 'cannot' possibly work and never 
changed their mind about it, regardless of reality proving them
wrong ;-)

And yes, the quality of the ABI and tooling cross-compatibility is 
not accidental at all, it is fully intentional and we take great care 
that it stays so. More than that we'll gladly take more 'perf test' 
testcases, for obscure corner-cases that other tools might rely on. 
I.e. we are willing to help external tooling to get their testcases 
built into the kernel repo.

Note that such level of ABI support is arguably clearly overkill for 
instrumentation: which by its very nature tends to migrate to the 
newer versions - still we maintain it because in our opinion good, 
usable tooling should have a good, extensible ABI.

Thanks,

	Ingo

  reply	other threads:[~2011-11-08 10:24 UTC|newest]

Thread overview: 158+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-06  1:35 [Qemu-devel] [PATCH] KVM: Add wrapper script around QEMU to test kernels Alexander Graf
2011-11-06  1:14 ` Andreas Färber
2011-11-06 10:04 ` Pekka Enberg
2011-11-06 10:07   ` Avi Kivity
2011-11-06 10:12     ` Pekka Enberg
2011-11-06 10:23       ` Avi Kivity
2011-11-06 11:08         ` Pekka Enberg
2011-11-06 11:50           ` Avi Kivity
2011-11-06 12:14             ` Pekka Enberg
2011-11-06 12:27               ` Avi Kivity
2011-11-06 12:32                 ` Pekka Enberg
2011-11-06 12:43                   ` Avi Kivity
2011-11-06 13:06                     ` Pekka Enberg
2011-11-06 15:56                       ` Avi Kivity
2011-11-06 16:35                         ` Pekka Enberg
2011-11-06 16:50                           ` Avi Kivity
2011-11-06 17:08                             ` Anthony Liguori
2011-11-06 18:09                               ` Pekka Enberg
2011-11-07  1:38                                 ` Anthony Liguori
2011-11-07  6:45                                   ` Pekka Enberg
2011-11-06 18:31                               ` Ted Ts'o
2011-11-06 18:54                                 ` Pekka Enberg
2011-11-06 18:58                                   ` Pekka Enberg
2011-11-06 23:19                                     ` Ted Ts'o
2011-11-07  6:42                                       ` Pekka Enberg
2011-11-07 17:03                                         ` Vince Weaver
2011-11-07 17:59                                           ` Ingo Molnar
2011-11-07 20:03                                             ` Frank Ch. Eigler
2011-11-07 20:09                                               ` Pekka Enberg
2011-11-07 20:35                                                 ` Ted Ts'o
2011-11-08 10:22                                                   ` Ingo Molnar [this message]
2011-11-08 10:32                                                     ` [Qemu-devel] [F.A.Q.] perf ABI backwards and forwards compatibility Peter Zijlstra
2011-11-08 11:34                                                       ` Ingo Molnar
2011-11-08 10:41                                                     ` Theodore Tso
2011-11-08 11:20                                                       ` Pekka Enberg
2011-11-08 11:25                                                         ` Theodore Tso
2011-11-08 11:29                                                           ` Pekka Enberg
2011-11-08 11:31                                                     ` Frank Ch. Eigler
2011-11-08 11:39                                                       ` Pekka Enberg
2011-11-08 12:15                                                         ` Ingo Molnar
2011-11-08 12:20                                                           ` Peter Zijlstra
2011-11-08 12:59                                                             ` Ingo Molnar
2011-11-09 10:05                                                               ` Peter Zijlstra
2011-11-08  5:29                                             ` [Qemu-devel] [PATCH] KVM: Add wrapper script around QEMU to test kernels Vince Weaver
2011-11-08 12:07                                               ` Ingo Molnar
2011-11-08 13:08                                                 ` Arnaldo Carvalho de Melo
2011-11-09  6:04                                                   ` Vince Weaver
2011-11-07 19:53                                           ` Pekka Enberg
2011-11-07 20:32                                             ` Ted Ts'o
2011-11-07 21:36                                               ` Pekka Enberg
2011-11-07 22:19                                                 ` Anthony Liguori
2011-11-07 23:42                                                   ` Theodore Tso
2011-11-08  9:32                                                     ` [Qemu-devel] [F.A.Q.] the advantages of a shared tool/kernel Git repository, tools/perf/ and tools/kvm/ Ingo Molnar
2011-11-08 10:21                                                       ` Theodore Tso
2011-11-08 12:55                                                         ` Ingo Molnar
2011-11-08 16:33                                                           ` Ted Ts'o
2011-11-08 17:14                                                             ` Anca Emanuel
2011-11-08 19:24                                                               ` Ted Ts'o
2011-11-09  8:28                                                                 ` Ingo Molnar
2011-11-08 21:15                                                             ` John Kacur
2011-11-09  8:38                                                               ` Ingo Molnar
2011-11-09  8:23                                                             ` Ingo Molnar
2011-11-10  1:41                                                               ` Alexander Graf
2011-11-10  8:14                                                                 ` Ingo Molnar
2011-11-08 12:56                                                         ` Arnaldo Carvalho de Melo
2011-11-08 13:40                                                           ` Gerd Hoffmann
2011-11-08 14:32                                                             ` Arnaldo Carvalho de Melo
2011-11-08 15:38                                                               ` Gerd Hoffmann
2011-11-08 16:13                                                                 ` Arnaldo Carvalho de Melo
2011-11-09  8:55                                                                   ` Ingo Molnar
2011-11-09  8:51                                                                 ` Ingo Molnar
2011-11-09 10:40                                                                   ` Gerd Hoffmann
2011-11-09 10:50                                                                     ` Hagen Paul Pfeifer
2011-11-09 11:55                                                                     ` Arnaldo Carvalho de Melo
2011-11-09 12:26                                                                       ` Gerd Hoffmann
2011-11-09 12:30                                                                         ` Arnaldo Carvalho de Melo
2011-11-09 12:33                                                                           ` Arnaldo Carvalho de Melo
2011-11-09 12:46                                                                             ` Peter Zijlstra
2011-11-09 12:51                                                                               ` Arnaldo Carvalho de Melo
2011-11-09 13:17                                                                             ` Ingo Molnar
2011-11-09 19:25                                                                       ` Jim Paris
2011-11-09 20:13                                                                         ` Arnaldo Carvalho de Melo
2011-11-09 22:32                                                                           ` Anca Emanuel
2011-11-10  8:00                                                                             ` Ingo Molnar
2011-11-10  8:12                                                                               ` Anca Emanuel
2011-11-10  8:39                                                                         ` Gerd Hoffmann
2011-11-08 15:43                                                       ` Steven Rostedt
2011-11-09  9:21                                                         ` Ingo Molnar
2011-11-09 12:03                                                           ` Arnaldo Carvalho de Melo
2011-11-09 13:40                                                       ` Américo Wang
2011-11-10  7:47                                                         ` Ingo Molnar
2011-11-07 10:31                                 ` [Qemu-devel] [PATCH] KVM: Add wrapper script around QEMU to test kernels Kevin Wolf
2011-11-07 11:38                                   ` Pekka Enberg
2011-11-07 11:59                                     ` Kevin Wolf
2011-11-06 16:19                       ` Jan Kiszka
2011-11-06 16:30                         ` Pekka Enberg
2011-11-06 16:39                           ` Jan Kiszka
2011-11-06 17:11                             ` Pekka Enberg
2011-11-06 17:23                               ` Jan Kiszka
2011-11-06 17:55                                 ` Pekka Enberg
2011-11-06 16:39                         ` Pekka Enberg
2011-11-07 10:11                         ` Gerd Hoffmann
2011-11-07 10:18                           ` Pekka Enberg
2011-11-06 17:10                       ` Anthony Liguori
2011-11-06 17:15                       ` Alexander Graf
2011-11-06 17:28                         ` Pekka Enberg
2011-11-06 17:30                           ` Alexander Graf
2011-11-06 18:05                             ` Pekka Enberg
2011-11-06 19:14                               ` Paolo Bonzini
2011-11-06 19:19                                 ` Pekka Enberg
2011-11-06 22:08                             ` Frank Ch. Eigler
2011-11-07  6:58                               ` Pekka Enberg
2011-11-06 19:11                           ` Paolo Bonzini
2011-11-06 19:17                             ` Pekka Enberg
2011-11-06 20:01                               ` Paolo Bonzini
2011-11-06 20:17                                 ` Pekka Enberg
2011-11-07  8:00                                   ` Paolo Bonzini
2011-11-07  8:09                                     ` Pekka Enberg
2011-11-07  8:20                                       ` Paolo Bonzini
2011-11-07  8:45                                         ` Pekka Enberg
2011-11-07  8:52                                           ` Paolo Bonzini
2011-11-07  8:57                                             ` Pekka Enberg
2011-11-07  8:13                                     ` Pekka Enberg
2011-11-06 20:31                                 ` Pekka Enberg
2011-11-07 10:23                           ` Gerd Hoffmann
2011-11-07 10:30                             ` Sasha Levin
2011-11-07 11:02                               ` Paolo Bonzini
2011-11-07 11:44                                 ` Pekka Enberg
2011-11-07 12:18                                   ` Gerd Hoffmann
2011-11-07 12:21                                     ` Pekka Enberg
2011-11-07 12:26                               ` Avi Kivity
2011-11-07 12:29                                 ` Pekka Enberg
2011-11-07 12:43                                   ` Ted Ts'o
2011-11-07 12:44                                   ` Avi Kivity
2011-11-07 11:34                             ` Pekka Enberg
2011-11-07 11:57                               ` Ingo Molnar
2011-11-07 13:17                                 ` Anthony Liguori
2011-11-07 12:08                               ` Gerd Hoffmann
2011-11-07 12:29                                 ` Ted Ts'o
2011-11-07 12:42                                   ` Pekka Enberg
2011-11-07 12:47                                     ` Ted Ts'o
2011-11-07 12:59                                       ` Pekka Enberg
2011-11-07 13:12                                       ` Pekka Enberg
2011-11-08 13:29                                         ` Karel Zak
2011-11-08 14:30                                           ` Pekka Enberg
2011-11-06 13:11                     ` Pekka Enberg
2011-11-06 17:09                       ` Alexander Graf
2011-11-06 12:27             ` Pekka Enberg
2011-11-08 14:41 ` Avi Kivity
2011-11-08 14:52   ` Christoph Hellwig
2011-11-08 14:55     ` Sasha Levin
2011-11-08 14:57     ` Avi Kivity
2011-11-08 14:59       ` Christoph Hellwig
2011-11-08 17:34         ` Alexander Graf
2011-11-08 17:36           ` Avi Kivity
2011-11-08 15:04     ` Jan Kiszka
2011-11-08 15:26     ` Pekka Enberg
2011-11-08 15:28       ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111108102235.GA1241@elte.hu \
    --to=mingo@elte.hu \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=agraf@suse.de \
    --cc=anthony@codemonkey.ws \
    --cc=avi@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=fche@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penberg@cs.helsinki.fi \
    --cc=penberg@kernel.org \
    --cc=qemu-devel@nongnu.org \
    --cc=torvalds@linux-foundation.org \
    --cc=tytso@mit.edu \
    --cc=vince@deater.net \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).