CONTRIBUTING.md revision 11921
1955SN/AAuthors: Jason Lowe-Power
2955SN/A         Andreas Sandberg
31762SN/A         Steve Reinhardt
4955SN/A
5955SN/AIf you've made changes to gem5 that might benefit others, we strongly encourage
6955SN/Ayou to contribute those changes to the public gem5 repository. There are
7955SN/Aseveral reasons to do this:
8955SN/A * Share your work with others, so that they can benefit from new functionality.
9955SN/A * Support the scientific principle by enabling others to evaluate your
10955SN/A   suggestions without having to guess what you did.
11955SN/A * Once your changes are part of the main repo, you no longer have to merge
12955SN/A   them back in every time you update your local repo. This can be a huge time
13955SN/A   saving!
14955SN/A * Once your code is in the main repo, other people have to make their changes
15955SN/A   work with your code, and not the other way around.
16955SN/A * Others may build on your contributions to make them even better, or extend
17955SN/A   them in ways you did not have time to do.
18955SN/A * You will have the satisfaction of contributing back to the community.
19955SN/A
20955SN/AThe main method for contributing code to gem5 is via our code review website:
21955SN/Ahttps://gem5-review.googlesource.com/. This documents describes the details of
22955SN/Ahow to create code changes, upload your changes, have your changes
23955SN/Areviewed, and finally push your changes to gem5. More information can be found
24955SN/Afrom the following sources:
25955SN/A * http://gem5.org/Submitting_Contributions
26955SN/A * https://gerrit-review.googlesource.com/Documentation/index.html
27955SN/A * https://git-scm.com/book
282665Ssaidi@eecs.umich.edu
292665Ssaidi@eecs.umich.edu
30955SN/AHigh-level flow for submitting changes
31955SN/A======================================
32955SN/A
333583Sbinkertn@umich.edu    +-------------+
34955SN/A    | Make change |
35955SN/A    +------+------+
36955SN/A           |
37955SN/A           |
38955SN/A           v
39955SN/A    +------+------+
40955SN/A    | Post review |
41955SN/A    +------+------+
42955SN/A           |
43955SN/A           v
44955SN/A    +--------+---------+
45955SN/A    | Wait for reviews | <--------+
46955SN/A    +--------+---------+          |
47955SN/A           |                      |
482023SN/A           |                      |
49955SN/A           v                      |
503089Ssaidi@eecs.umich.edu      +----+----+   No     +------+------+
51955SN/A      |Reviewers+--------->+ Update code |
52955SN/A      |happy?   |          +------+------+
53955SN/A      +----+----+                 ^
54955SN/A           |                      |
55955SN/A           | Yes                  |
56955SN/A           v                      |
57955SN/A      +----+-----+   No           |
58955SN/A      |Maintainer+----------------+
591031SN/A      |happy?    |
60955SN/A      +----+-----+
611388SN/A           |
62955SN/A           | Yes
63955SN/A           v
641296SN/A    +------+------+
65955SN/A    | Submit code |
66955SN/A    +-------------+
67955SN/A
68955SN/AAfter creating your change to gem5, you can post a review on our Gerrit
69955SN/Acode-review site: https://gem5-review.googlesource.com. Before being able to
70955SN/Asubmit your code to the mainline of gem5, the code is reviewed by others in the
71955SN/Acommunity. Additionally, the maintainer for that part of the code must sign off
72955SN/Aon it.
73955SN/A
74955SN/ACloning the gem5 repo to contribute
75955SN/A===================================
76955SN/A
773584Ssaidi@eecs.umich.eduIf you plan on contributing, it is strongly encouraged for you to clone the
78955SN/Arepository directly from our gerrit instance at
79955SN/Ahttps://gem5.googlesource.com/.
80955SN/A
81955SN/ATo clone the master gem5 repository:
82955SN/A > git clone https://gem5.googlesource.com/public/gem5
83955SN/A
84955SN/AOther gem5 repositories
852325SN/A-----------------------
861717SN/A
872652Ssaidi@eecs.umich.eduThere are a few repositories other than the main gem5 development repository.
88955SN/A
892736Sktlim@umich.edu * public/m5threads: The code for a pthreads implementation that works with
902410SN/A   gem5's syscall emulation mode.
91955SN/A
922290SN/AOther gem5 branches
93955SN/A-------------------
942683Sktlim@umich.edu
952683Sktlim@umich.eduNone right now.
962669Sktlim@umich.edu
972568SN/AMaking changes to gem5
982568SN/A======================
993012Ssaidi@eecs.umich.edu
1002462SN/AIt is strongly encouraged to use git branches when making changes to gem5.
1012568SN/AAdditionally, keeping changes small and concise and only have a single logical
1022395SN/Achange per commit.
1032405SN/A
1042914Ssaidi@eecs.umich.eduUnlike our previous flow with Mercurial and patch queues, when using git, you
105955SN/Awill be committing changes to your local branch. By using separate branches in
1062811Srdreslin@umich.edugit, you will be able to pull in and merge changes from mainline and simply
1072811Srdreslin@umich.edukeep up with upstream changes.
1082811Srdreslin@umich.edu
1092811Srdreslin@umich.eduRequirements for change descriptions
1102811Srdreslin@umich.edu------------------------------------
1112811Srdreslin@umich.eduTo help reviewers and future contributors more easily understand and track
1122811Srdreslin@umich.educhanges, we require all change descriptions be strictly formatted.
1132811Srdreslin@umich.edu
1142811Srdreslin@umich.eduA canonical commit message consists of three parts:
1152811Srdreslin@umich.edu * A short summary line describing the change. This line starts with one or
1162811Srdreslin@umich.edu   more keywords separated by commas followed by a colon and a description of
1172811Srdreslin@umich.edu   the change. This line should be no more than 65 characters long since
1182811Srdreslin@umich.edu   version control systems usually add a prefix that causes line-wrapping for
1192811Srdreslin@umich.edu   longer lines.
1202811Srdreslin@umich.edu * (Optional, but highly recommended) A detailed description. This describes
1212811Srdreslin@umich.edu   what you have done and why. If the change isn't obvious, you might want to
1222814Srdreslin@umich.edu   motivate why it is needed. Lines need to be wrapped to 75 characters or
1232811Srdreslin@umich.edu   less.
1242811Srdreslin@umich.edu * Tags describing patch metadata. You are highly recommended to use
1252811Srdreslin@umich.edu   tags to acknowledge reviewers for their work. Gerrit will automatically add
1262811Srdreslin@umich.edu   most tags.
1272811Srdreslin@umich.edu
1282811Srdreslin@umich.eduThe keyword should be one or more of the following separated by commas:
1292811Srdreslin@umich.edu * Architecture name in lower case (e.g., arm or x86): Anything that is
1302813Srdreslin@umich.edu   target-architecture specific.
1312813Srdreslin@umich.edu * base
1323645Sbinkertn@umich.edu * ext
1333624Sbinkertn@umich.edu * stats
1343624Sbinkertn@umich.edu * sim
135955SN/A * syscall_emul
136955SN/A * config:
137955SN/A * mem: Classic memory system. Ruby uses its own keyword.
1382090SN/A * ruby: Ruby memory models.
139955SN/A * cpu: CPU-model specific (except for kvm)
140955SN/A * kvm: KVM-specific. Changes to host architecture specific components should
1411696SN/A   include an architecture keyword (e.g., arm or x86) as well.
142955SN/A * gpu-compute
143955SN/A * energy
144955SN/A * dev
1451127SN/A * arch: General architecture support (src/arch/)
146955SN/A * scons: Build-system related. Trivial changes as a side effect of doing
147955SN/A   something unrelated (e.g., adding a source file to a SConscript) don't
1482379SN/A   require this.
149955SN/A * tests
150955SN/A * style: Changes to the style checkers of style fixes.
151955SN/A * misc
1522422SN/A
1532422SN/ATags are an optional mechanism to store additional metadata about a patch and
1542422SN/Aacknowledge people who reported a bug or reviewed that patch. Tags are
1552422SN/Agenerally appended to the end of the commit message in the order they happen.
1562422SN/AWe currently use the following tags:
1572422SN/A * Signed-off-by: Added by the author and the submitter (if different).
1582422SN/A   This tag is a statement saying that you believe the patch to be correct and
1592397SN/A   have the right to submit the patch according to the license in the affected
1602397SN/A   files. Similarly, if you commit someone else's patch, this tells the rest
1612422SN/A   of the world that you have have the right to forward it to the main
1622422SN/A   repository. If you need to make any changes at all to submit the change,
163955SN/A   these should be described within hard brackets just before your
164955SN/A   Signed-off-by tag. By adding this line, the contributor certifies the
165955SN/A   contribution is made under the terms of the Developer Certificate of Origin
166955SN/A   (DCO) [https://developercertificate.org/].
167955SN/A * Reviewed-by: Used to acknowledge patch reviewers. It's generally considered
168955SN/A   good form to add these. Added automatically.
169955SN/A * Reported-by: Used to acknowledge someone for finding and reporting a bug.
170955SN/A * Reviewed-on: Link to the review request corresponding to this patch. Added
1711078SN/A   automatically.
172955SN/A * Change-Id: Used by Gerrit to track changes across rebases. Added
173955SN/A   automatically with a commit hook by git.
174955SN/A * Tested-by: Used to acknowledge people who tested a patch. Sometimes added
175955SN/A   automatically by review systems that integrate with CI systems.
1761917SN/A
177955SN/AOther than the "Signed-off-by", "Reported-by", and "Tested-by" tags, you
178955SN/Agenerally don't need to add these manually as they are added automatically by
1791730SN/AGerrit.
180955SN/A
1812521SN/AIt is encouraged for the author of the patch and the submitter to add a
1822521SN/ASigned-off-by tag to the commit message. By adding this line, the contributor
1832507SN/Acertifies the contribution is made under the terms of the Developer Certificate
1842507SN/Aof Origin (DCO) [https://developercertificate.org/].
1852989Ssaidi@eecs.umich.edu
1863408Ssaidi@eecs.umich.eduIt is imperative that you use your real name and your real email address in
1872507SN/Aboth tags and in the author field of the changeset.
1882507SN/A
1892507SN/AFor significant changes, authors are encouraged to add copyright information
190955SN/Aand their names at the beginning of the file. The main purpose of the author
191955SN/Anames on the file is to track who is most knowledgeable about the file (e.g.,
192955SN/Awho has contributed a significant amount of code to the file).
193955SN/A
194955SN/ANote: If you do not follow these guidelines, the gerrit review site will
195955SN/Aautomatically reject your patch.
196955SN/AIf this happens, update your changeset descriptions to match the required style
197955SN/Aand resubmit. The following is a useful git command to update the most recent
1982520SN/Acommit (HEAD).
1992517SN/A
2002253SN/A > git commit --amend
2012253SN/A
2022253SN/APosting a review
2032253SN/A================
2042553SN/A
2052553SN/AIf you have not signed up for an account on the Gerrit review site
2062553SN/A(https://gem5-review.googlesource.com), you first have to create an account.
2072553SN/A
2082507SN/ASetting up an account
2092400SN/A---------------------
2102400SN/A 1. Go to https://gem5.googlesource.com/
211955SN/A 2. Click "Sign In" in the upper right corner. Note: You will need a Google
212955SN/A account to contribute.
2132667Sstever@eecs.umich.edu 3. After signing in, click "Generate Password" and follow the instructions.
2142667Sstever@eecs.umich.edu
2152667Sstever@eecs.umich.eduSubmitting a change
2162667Sstever@eecs.umich.edu-------------------
2172667Sstever@eecs.umich.edu
2182667Sstever@eecs.umich.eduIn gerrit, to submit a review request, you can simply push your git commits to
2192037SN/Aa special named branch. For more information on git push see
2202037SN/Ahttps://git-scm.com/docs/git-push.
2212037SN/A
2223534Sgblack@eecs.umich.eduThere are three ways to push your changes to gerrit.
2232139SN/A
2243534Sgblack@eecs.umich.eduPush change to gerrit review
2253534Sgblack@eecs.umich.edu----------------------------
2263542Sgblack@eecs.umich.edu
2273583Sbinkertn@umich.edu > git push origin HEAD:refs/for/master
2283583Sbinkertn@umich.edu
2293542Sgblack@eecs.umich.eduAssuming origin is https://gem5.googlesource.com/public/gem5 and you want to
2303499Ssaidi@eecs.umich.edupush the changeset at HEAD, this will create a new review request on top of the
2313583Sbinkertn@umich.edumaster branch. More generally,
2323583Sbinkertn@umich.edu
2333547Sgblack@eecs.umich.edu > git push <gem5 gerrit instance> <changeset>:refs/for/<branch>
2342155SN/A
235955SN/ASee https://gerrit-review.googlesource.com/Documentation/user-upload.html for
2362155SN/Amore information.
237955SN/A
2383583Sbinkertn@umich.eduPushing your first change
2393583Sbinkertn@umich.edu--------------------------
2403583Sbinkertn@umich.eduThe first time you push a change you may get the following error:
2413583Sbinkertn@umich.edu
2423583Sbinkertn@umich.edu > remote: ERROR: [fb1366b] missing Change-Id in commit message footer
243955SN/A > ...
244955SN/A
245955SN/AWithin the error message, there is a command line you should run. For every new
246955SN/Aclone of the git repo, you need to run the following command to automatically
247955SN/Ainsert the change id in the the commit (all on one line).
2481858SN/A
249955SN/A > curl -Lo `git rev-parse --git-dir`/hooks/commit-msg
2501858SN/A   https://gerrit-review.googlesource.com/tools/hooks/commit-msg ; chmod +x
2511858SN/A   `git rev-parse --git-dir`/hooks/commit-msg
2521858SN/A
2531085SN/AIf you receive the above error, simply run this command and then amend your
254955SN/Achangeset.
255955SN/A
256955SN/A > git commit --amend
257955SN/A
258955SN/APush change to gerrit as a draft
259955SN/A--------------------------------
260955SN/A
261955SN/A > git push origin HEAD:refs/drafts/master
262955SN/A
263955SN/APush change bypassing gerrit
264955SN/A-----------------------------
265955SN/A
2662667Sstever@eecs.umich.eduOnly maintainers can bypass gerrit review. This should very rarely be used.
2671045SN/A
268955SN/A > git push origin HEAD:refs/heads/master
269955SN/A
270955SN/AOther gerrit push options
271955SN/A-------------------------
2721108SN/A
273955SN/AThere are a number of options you can specify when uploading your changes to
274955SN/Agerrit (e.g., reviewers, labels). The gerrit documentation has more
275955SN/Ainformation.
276955SN/Ahttps://gerrit-review.googlesource.com/Documentation/user-upload.html
277955SN/A
278955SN/A
279955SN/AReviewing patches
280955SN/A=================
281955SN/A
282955SN/AReviewing patches is done on our gerrit instance at
283955SN/Ahttps://gem5-review.googlesource.com/.
284955SN/A
285955SN/AAfter logging in with your Google account, you will be able to comment, review,
286955SN/Aand push your own patches as well as review others' patches. All gem5 users are
287955SN/Aencouraged to review patches. The only requirement to review patches is to be
288955SN/Apolite and respectful of others.
2892655Sstever@eecs.umich.edu
2902655Sstever@eecs.umich.eduThere are multiple labels in Gerrit that can be applied to each review detailed
2912655Sstever@eecs.umich.edubelow.
2922655Sstever@eecs.umich.edu * Code-review: This is used by any gem5 user to review patches. When reviewing
2932655Sstever@eecs.umich.edu   a patch you can give it a score of -2 to +2 with the following semantics.
2942655Sstever@eecs.umich.edu   * -2: This blocks the patch. You believe that this patch should never be
2952655Sstever@eecs.umich.edu     committed. This label should be very rarely used.
2962655Sstever@eecs.umich.edu   * -1: You would prefer this is not merged as is
2972655Sstever@eecs.umich.edu   * 0: No score
2982655Sstever@eecs.umich.edu   * +1: This patch seems good, but you aren't 100% confident that it should be
2992655Sstever@eecs.umich.edu     pushed.
3002655Sstever@eecs.umich.edu   * +2: This is a good patch and should be pushed as is.
3012655Sstever@eecs.umich.edu * Maintainer: Currently only PMC members are maintainers. At least one
3022655Sstever@eecs.umich.edu   maintainer must review your patch and give it a +1 before it can be merged.
3032655Sstever@eecs.umich.edu * Verified: This is automatically generated from the continuous integrated
3042655Sstever@eecs.umich.edu   (CI) tests. Each patch must receive at least a +1 from the CI tests before
3052655Sstever@eecs.umich.edu   the patch can be merged. The patch will receive a +1 if gem5 builds and
3062655Sstever@eecs.umich.edu   runs, and it will receive a +2 if the stats match.
3072655Sstever@eecs.umich.edu * Style-Check: This is automatically generated and tests the patch against the
3082655Sstever@eecs.umich.edu   gem5 code style (http://www.gem5.org/Coding_Style). The patch must receive a
3092655Sstever@eecs.umich.edu   +1 from the style checker to be pushed.
3102655Sstever@eecs.umich.edu
311955SN/ANote: Whenever the patch creator updates the patch all reviewers must re-review
3123515Ssaidi@eecs.umich.eduthe patch. There is no longer a "Fix it, then Ship It" option.
3133515Ssaidi@eecs.umich.edu
3143515Ssaidi@eecs.umich.eduOnce you have received reviews for your patch, you will likely need to make
3153515Ssaidi@eecs.umich.educhanges. To do this, you should update the original git changeset. Then, you
3163515Ssaidi@eecs.umich.educan simply push the changeset again to the same Gerrit branch to update the
3173515Ssaidi@eecs.umich.edureview request.
3183515Ssaidi@eecs.umich.edu
3192655Sstever@eecs.umich.edu > git push origin HEAD:refs/for/master
3203515Ssaidi@eecs.umich.edu
3213619Sbinkertn@umich.eduNote: If you have posted a patch and don't receive any reviews, you may need to
322955SN/Aprod the reviewers. You can do this by adding a reply to your changeset review
323955SN/Aon gerrit. It is expected that at least the maintainer will supply a review for
3242655Sstever@eecs.umich.eduyour patch.
3253619Sbinkertn@umich.edu
3263619Sbinkertn@umich.eduCommitting changes
327955SN/A==================
328955SN/A
3292655Sstever@eecs.umich.eduEach patch must meet the following criteria to be merged:
3302655Sstever@eecs.umich.edu * At least one review with +2
3313619Sbinkertn@umich.edu * At least one maintainer with +1
332955SN/A * At least +1 from the CI tests (gem5 must build and run)
333955SN/A * At least +1 from the style checker
3342655Sstever@eecs.umich.edu
3352655Sstever@eecs.umich.eduOnce a patch meets the above criteria, the submitter of the patch will be able
3363683Sstever@eecs.umich.eduto merge the patch by pressing the "Submit" button on Gerrit. When the patch is
3372655Sstever@eecs.umich.edusubmitted, it is merged into the public gem5 branch.
3381869SN/A