perf tool versioning fixes
v2 cover perf tool versioning fixes
This series includes a couple of fixes I made from working on a clone of acme.git
It is based on perf/urgent @ commit b3d971ec2534.
Differences to v1:
- Add patch to fix kernel version tag
- Fix perf out-of-tree build
John Garry (2):
perf: Fix dependency for version file creation
perf: Fix version kernel tag
tools/perf/Makefile.perf | 4 ++-- tools/perf/util/PERF-VERSION-GEN | 13 ++++--------- 2 files changed, 6 insertions(+), 11 deletions(-)
Signature · 1 line
2.26.2
PATCH v2 1/2 perf: Fix dependency for version file creation
The version generated by perf may not be correct by just changing the head commit, like this:
$git log --pretty=format:"%H" -n 1b5d9d4708a24ac1889a30e9aedf8af8d73102139
$perf -v
perf version 5.16.gb5d9d4708a24
$git reset --hard HEAD^
HEAD is now at 629f520b265f
$make
...
$./perf -v
perf version 5.16.gb5d9d4708a24
The dependency to building PERF-VERSION-FILE should also include ORIG_HEAD, as this changes when changing the head commit (while HEAD does not).
--- tools/perf/Makefile.perf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/Makefile.perf +2 -2
@@ -691,7 +691,7 @@ $(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt) $(SCRIPTS) : % : %.sh $(QUIET_GEN)$(INSTALL) '[email protected]' '$(OUTPUT)$@' -$(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD +$(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD ../../.git/ORIG_HEAD $(Q)$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT) $(Q)touch $(OUTPUT)PERF-VERSION-FILE
@@ -1144,7 +1144,7 @@ endif # then force version regeneration: # ifeq ($(wildcard ../../.git/HEAD),) - GIT-HEAD-PHONY = ../../.git/HEAD + GIT-HEAD-PHONY = ../../.git/HEAD ../../.git/ORIG_HEAD else GIT-HEAD-PHONY = endif
Signature · 1 line
2.26.2
PATCH v2 2/2 perf: Fix version kernel tag
In reply to John GarryGenerating the version kernel tag relies on "git describe" command to get the latest Linus kernel tag.
However, when working from clones of Linus' git we may not have the latest tag. For example, when working on Arnaldo's acme.git, we can have this:
$git branch
perf/core
$head -n 5 ../../Makefile
head -n 5 ../../Makefile | tail -n 4
VERSION = 5
PATCHLEVEL = 17
SUBLEVEL = 0
EXTRAVERSION = -rc3
$ git describe --abbrev=0 --match "v[0-9].[0-9]*" v4.13-rc5
Indeed using tags is a problem as it relies on tags being pulled from Linus' git (and pushed to the clone).
In commit a4147f0f9138 ("perf tools: Fix perf version generation"), Robert introduced a change to use the kernelversion rule to generate the kernel tag when no git tags are available. However, as mentioned above, the tag we generate may be incorrect, so just always use kernelversion to get the tag (apart from building perf out of tree).
--- tools/perf/util/PERF-VERSION-GEN | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
tools/perf/util/PERF-VERSION-GEN +4 -9
@@ -11,23 +11,18 @@ LF=' ' # -# First check if there is a .git to get the version from git describe -# otherwise try to get the version from the kernel Makefile +# Always try first to get the version from the kernel Makefile # CID= TAG= if test -d ../../.git -o -f ../../.git then - TAG=$(git describe --abbrev=0 --match "v[0-9].[0-9]*" 2>/dev/null ) + TAG=$(MAKEFLAGS= make -sC ../.. kernelversion) CID=$(git log -1 --abbrev=12 --pretty=format:"%h" 2>/dev/null) && CID="-g$CID" -elif test -f ../../PERF-VERSION-FILE -then +else TAG=$(cut -d' ' -f3 ../../PERF-VERSION-FILE | sed -e 's/\"//g') fi -if test -z "$TAG" -then - TAG=$(MAKEFLAGS= make -sC ../.. kernelversion) -fi + VN="$TAG$CID" if test -n "$CID" then
Signature · 1 line
2.26.2
A message that is not in the archive (sent off-list or not yet received): CAP-5=fXT3VYB2uBXmihuruq==FENLFcFSHMLY0Fk29pRvU-wag@mail.gmail.com
Re: [PATCH v2 2/2] perf: Fix version kernel tag
Quoted 4 lines · Ian Rogers
Generating the version kernel tag relies on "git describe" command to get
the latest Linus kernel tag.
Quoted 14 lines
However, when working from clones of Linus' git we may not have the latest
tag. For example, when working on Arnaldo's acme.git, we can have this:
$git branch
perf/core
$head -n 5 ../../Makefile
head -n 5 ../../Makefile | tail -n 4
VERSION = 5
PATCHLEVEL = 17
SUBLEVEL = 0
EXTRAVERSION = -rc3
$ git describe --abbrev=0 --match "v[0-9].[0-9]*"
v4.13-rc5
Hi Ian,
Thanks for having a look.
Quoted 17 lines
I'm a little confused by this, isn't the "git branch" showing your local branch? For me:
$git branch
acme
$git status
On branch acme
Your branch is up to date with 'acme/perf/core'.
$git describe --abbrev=0 --match "v[0-9].[0-9]*"
v5.17-rc4
$git remote show acme
* remote acme
Fetch URL:git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git<http://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git>
Push URL:git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git<http://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git>
...
Quoted 4 lines
$ /tmp/perf/perf --version perf version 5.17.rc4.g56dce868198cIs your branch tracking acme/master ?
I was following acme/perf/core but I don't think that it is so important.
The difference is that I am working from a clone of acme/linux.git and so torvalds/linux.git is a remote for me. I assume that you have a clone of torvalds/linux.git
That means that if my clone of acme git does not pull in the tags from torvalds git then "git describe" gives a wrong result.
Please check this experiment:
john@localhost:~> git clone git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git acme_test Cloning into 'acme_test'...
remote: Enumerating objects: 59, done.
remote: Counting objects: 100% (59/59), done.
remote: Compressing objects: 100% (3/3), done.
...
john@localhost:~> cd acme_test/
john@localhost:~/acme_test> git checkout remotes/origin/perf/core -B perf/core Updating files: 100% (58299/58299), done.
Branch 'perf/core' set up to track remote branch 'perf/core' from 'origin'. Switched to a new branch 'perf/core'
john@localhost:~/acme_test> git describe --abbrev=0 --match "v[0-9].[0-9]*" v4.13-rc5
john@localhost:~/acme_test> head -n 5 Makefile | tail -n 4 VERSION = 5
PATCHLEVEL = 17
SUBLEVEL = 0
EXTRAVERSION = -rc4
john@localhost:~/acme_test> git remote add torvalds git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
john@localhost:~/acme_test> git fetch torvalds
remote: Enumerating objects: 1516, done.
remote: Counting objects: 100% (1516/1516), done.
remote: Compressing objects: 100% (413/413), done.
remote: Total 1944 (delta 1202), reused 1314 (delta 1098), pack-reused 428 Receiving objects: 100% (1944/1944), 1.68 MiB | 5.12 MiB/s, done. Resolving deltas: 100% (1270/1270), completed with 400 local objects. From git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux
* [new branch] master -> torvalds/master
...
* [new tag] v5.17-rc2 -> v5.17-rc2 * [new tag] v5.17-rc3 -> v5.17-rc3 * [new tag] v5.17-rc4 -> v5.17-rc4 * [new tag] v5.17-rc5 -> v5.17-rc5 * [new tag] v5.17-rc6 -> v5.17-rc6
...
john@localhost:~/acme_test> git describe --abbrev=0 --match "v[0-9].[0-9]*" v5.17-rc4
So you can see that "git describe" gives the wrong result (v4.13-rc5) before we pull in torvalds git.
My point is that git tags are unreliable and we should avoid them.
Thanks,
John
Re: [PATCH v2 2/2] perf: Fix version kernel tag
Quoted 110 lines · John Garry
Quoted 4 lines · Ian Rogers
Generating the version kernel tag relies on "git describe" command to get
the latest Linus kernel tag.Quoted 14 lines
However, when working from clones of Linus' git we may not have the latest
tag. For example, when working on Arnaldo's acme.git, we can have this:
$git branch
perf/core
$head -n 5 ../../Makefile
head -n 5 ../../Makefile | tail -n 4
VERSION = 5
PATCHLEVEL = 17
SUBLEVEL = 0
EXTRAVERSION = -rc3
$ git describe --abbrev=0 --match "v[0-9].[0-9]*"
v4.13-rc5Hi Ian,
Thanks for having a look.
Quoted 20 lines
I'm a little confused by this, isn't the "git branch" showing your local branch? For me:
$git branch
acme
$git status
On branch acme
Your branch is up to date with 'acme/perf/core'.
$git describe --abbrev=0 --match "v[0-9].[0-9]*"
v5.17-rc4
$git remote show acme
* remote acme
Fetch URL:git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git
<http://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git>
Push URL:git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git
<http://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git>
...Quoted 4 lines
$ /tmp/perf/perf --version perf version 5.17.rc4.g56dce868198cIs your branch tracking acme/master ?
I was following acme/perf/core but I don't think that it is so important.
The difference is that I am working from a clone of acme/linux.git and so torvalds/linux.git is a remote for me. I assume that you have a clone of torvalds/linux.git
That means that if my clone of acme git does not pull in the tags from torvalds git then "git describe" gives a wrong result.
Please check this experiment:
john@localhost:~> git clone
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.gitacme_testCloning into 'acme_test'...
remote: Enumerating objects: 59, done.
remote: Counting objects: 100% (59/59), done.
remote: Compressing objects: 100% (3/3), done....
john@localhost:~> cd acme_test/
john@localhost:~/acme_test> git checkout remotes/origin/perf/core -B perf/core
Updating files: 100% (58299/58299), done.
Branch 'perf/core' set up to track remote branch 'perf/core' from 'origin'. Switched to a new branch 'perf/core'john@localhost:~/acme_test> git describe --abbrev=0 --match "v[0-9].[0-9]*" v4.13-rc5
john@localhost:~/acme_test> head -n 5
Makefile| tail -n 4 VERSION = 5
PATCHLEVEL = 17
SUBLEVEL = 0
EXTRAVERSION = -rc4john@localhost:~/acme_test> git remote add torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.gitjohn@localhost:~/acme_test> git fetch torvalds
remote: Enumerating objects: 1516, done.
remote: Counting objects: 100% (1516/1516), done.
remote: Compressing objects: 100% (413/413), done.
remote: Total 1944 (delta 1202), reused 1314 (delta 1098), pack-reused 428 Receiving objects: 100% (1944/1944), 1.68 MiB | 5.12 MiB/s, done. Resolving deltas: 100% (1270/1270), completed with 400 local objects.
Fromgit://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux
* [new branch] master -> torvalds/master...
* [new tag] v5.17-rc2 -> v5.17-rc2 * [new tag] v5.17-rc3 -> v5.17-rc3 * [new tag] v5.17-rc4 -> v5.17-rc4 * [new tag] v5.17-rc5 -> v5.17-rc5 * [new tag] v5.17-rc6 -> v5.17-rc6...
Quoted 7 lines
john@localhost:~/acme_test> git describe --abbrev=0 --match "v[0-9].[0-9]*" v5.17-rc4
So you can see that "git describe" gives the wrong result (v4.13-rc5) before we pull in torvalds git.
My point is that git tags are unreliable and we should avoid them.
(Plain text resend)
Got it, thanks for the detailed explanation!
Thanks,
Ian
Quoted 3 lines
Thanks,
John
Re: [PATCH v2 2/2] perf: Fix version kernel tag
Quoted 6 lines · Ian Rogers
Quoted 6 lines
john@localhost:~/acme_test> git describe --abbrev=0 --match "v[0-9].[0-9]*" v5.17-rc4
So you can see that "git describe" gives the wrong result (v4.13-rc5) before we pull in torvalds git.
Quoted 7 lines
Quoted 1 line
My point is that git tags are unreliable and we should avoid them.
(Plain text resend)
Got it, thanks for the detailed explanation!
Acked-by Ian Rogers<[email protected]>
Great, thanks
Arnaldo, Can you kindly consider picking up this series?
Cheers,
John
Quoted 3 lines · John Garry
This series includes a couple of fixes I made from working on a clone of acme.git
Hi Arnaldo,
Can you kindly check this series if you get a chance? If you try from a clone of your own git you may see the issue reported in 2/2.
Thanks!!
Quoted 14 lines
It is based on perf/urgent @ commit
b3d971ec2534.Differences to v1:
- Add patch to fix kernel version tag
- Fix perf out-of-tree buildJohn Garry (2):
perf: Fix dependency for version file creation
perf: Fix version kernel tagtools/perf/Makefile.perf | 4 ++-- tools/perf/util/PERF-VERSION-GEN | 13 ++++--------- 2 files changed, 6 insertions(+), 11 deletions(-)