← Documents Documentation/admin-guide/bug-bisect.rst GitHub 원문 ↗

Linux 6.18.37 · Administration / Bug diagnosis

Bisecting a regression

Kernel regression의 git bisect 준비·반복 판정·revert 검증, linux-next endpoint와 재배포 조건을 설명합니다.

Source pathDocumentation/admin-guide/bug-bisect.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

Main bisection

bug-bisect.rst:1-110

Known-good/bad 사이를 build·test하고 log·config를 보존해 culprit를 검증합니다.

linux-next and references

bug-bisect.rst:111-143

next/stable과 next/master endpoint, 추가 bisect 자료를 정리합니다.

Maintenance and license

bug-bisect.rst:144-165

Maintainer contact, contribution sign-off와 GPL/CC-BY 재배포 조건을 기록합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: (GPL-2.0+ OR CC-BY-4.0)
2 .. [see the bottom of this file for redistribution information]
3
4 ======================
5 Bisecting a regression
6 ======================
7
8 This document describes how to use a ``git bisect`` to find the source code
9 change that broke something -- for example when some functionality stopped
10 working after upgrading from Linux 6.0 to 6.1.
11
12 The text focuses on the gist of the process. If you are new to bisecting the
13 kernel, better follow Documentation/admin-guide/verify-bugs-and-bisect-regressions.rst
14 instead: it depicts everything from start to finish while covering multiple
15 aspects even kernel developers occasionally forget. This includes detecting
16 situations early where a bisection would be a waste of time, as nobody would
17 care about the result -- for example, because the problem happens after the
18 kernel marked itself as 'tainted', occurs in an abandoned version, was already
19 fixed, or is caused by a .config change you or your Linux distributor performed.
20
21 Finding the change causing a kernel issue using a bisection
22 ===========================================================
23
24 *Note: the following process assumes you prepared everything for a bisection.
25 This includes having a Git clone with the appropriate sources, installing the
26 software required to build and install kernels, as well as a .config file stored
27 in a safe place (the following example assumes '~/prepared_kernel_.config') to
28 use as pristine base at each bisection step; ideally, you have also worked out
29 a fully reliable and straight-forward way to reproduce the regression, too.*
30
31 * Preparation: start the bisection and tell Git about the points in the history
32 you consider to be working and broken, which Git calls 'good' and 'bad'::
33
34 git bisect start
35 git bisect good v6.0
36 git bisect bad v6.1
37
38 Instead of Git tags like 'v6.0' and 'v6.1' you can specify commit-ids, too.
39
40 1. Copy your prepared .config into the build directory and adjust it to the
41 needs of the codebase Git checked out for testing::
42
43 cp ~/prepared_kernel_.config .config
44 make olddefconfig
45
46 2. Now build, install, and boot a kernel. This might fail for unrelated reasons,
47 for example, when a compile error happens at the current stage of the
48 bisection a later change resolves. In such cases run ``git bisect skip`` and
49 go back to step 1.
50
51 3. Check if the functionality that regressed works in the kernel you just built.
52
53 If it works, execute::
54
55 git bisect good
56
57 If it is broken, run::
58
59 git bisect bad
60
61 Note, getting this wrong just once will send the rest of the bisection
62 totally off course. To prevent having to start anew later you thus want to
63 ensure what you tell Git is correct; it is thus often wise to spend a few
64 minutes more on testing in case your reproducer is unreliable.
65
66 After issuing one of these two commands, Git will usually check out another
67 bisection point and print something like 'Bisecting: 675 revisions left to
68 test after this (roughly 10 steps)'. In that case go back to step 1.
69
70 If Git instead prints something like 'cafecaca0c0dacafecaca0c0dacafecaca0c0da
71 is the first bad commit', then you have finished the bisection. In that case
72 move to the next point below. Note, right after displaying that line Git will
73 show some details about the culprit including its patch description; this can
74 easily fill your terminal, so you might need to scroll up to see the message
75 mentioning the culprit's commit-id.
76
77 In case you missed Git's output, you can always run ``git bisect log`` to
78 print the status: it will show how many steps remain or mention the result of
79 the bisection.
80
81 * Recommended complementary task: put the bisection log and the current .config
82 file aside for the bug report; furthermore tell Git to reset the sources to
83 the state before the bisection::
84
85 git bisect log > ~/bisection-log
86 cp .config ~/bisection-config-culprit
87 git bisect reset
88
89 * Recommended optional task: try reverting the culprit on top of the latest
90 codebase and check if that fixes your bug; if that is the case, it validates
91 the bisection and enables developers to resolve the regression through a
92 revert.
93
94 To try this, update your clone and check out latest mainline. Then tell Git
95 to revert the change by specifying its commit-id::
96
97 git revert --no-edit cafec0cacaca0
98
99 Git might reject this, for example when the bisection landed on a merge
100 commit. In that case, abandon the attempt. Do the same, if Git fails to revert
101 the culprit on its own because later changes depend on it -- at least unless
102 you bisected a stable or longterm kernel series, in which case you want to
103 check out its latest codebase and try a revert there.
104
105 If a revert succeeds, build and test another kernel to check if reverting
106 resolved your regression.
107
108 With that the process is complete. Now report the regression as described by
109 Documentation/admin-guide/reporting-issues.rst.
110
111 Bisecting linux-next
112 --------------------
113
114 If you face a problem only happening in linux-next, bisect between the
115 linux-next branches 'stable' and 'master'. The following commands will start
116 the process for a linux-next tree you added as a remote called 'next'::
117
118 git bisect start
119 git bisect good next/stable
120 git bisect bad next/master
121
122 The 'stable' branch refers to the state of linux-mainline that the current
123 linux-next release (found in the 'master' branch) is based on -- the former
124 thus should be free of any problems that show up in -next, but not in Linus'
125 tree.
126
127 This will bisect across a wide range of changes, some of which you might have
128 used in earlier linux-next releases without problems. Sadly there is no simple
129 way to avoid checking them: bisecting from one linux-next release to a later
130 one (say between 'next-20241020' and 'next-20241021') is impossible, as they
131 share no common history.
132
133 Additional reading material
134 ---------------------------
135
136 * The `man page for 'git bisect' <https://git-scm.com/docs/git-bisect>`_ and
137 `fighting regressions with 'git bisect' <https://git-scm.com/docs/git-bisect-lk2009.html>`_
138 in the Git documentation.
139 * `Working with git bisect <https://nathanchance.dev/posts/working-with-git-bisect/>`_
140 from kernel developer Nathan Chancellor.
141 * `Using Git bisect to figure out when brokenness was introduced <http://webchick.net/node/99>`_.
142 * `Fully automated bisecting with 'git bisect run' <https://lwn.net/Articles/317154>`_.
143
144 ..
145 end-of-content
146 ..
147 This document is maintained by Thorsten Leemhuis <[email protected]>. If
148 you spot a typo or small mistake, feel free to let him know directly and
149 he'll fix it. You are free to do the same in a mostly informal way if you
150 want to contribute changes to the text -- but for copyright reasons please CC
151 [email protected] and 'sign-off' your contribution as
152 Documentation/process/submitting-patches.rst explains in the section 'Sign
153 your work - the Developer's Certificate of Origin'.
154 ..
155 This text is available under GPL-2.0+ or CC-BY-4.0, as stated at the top
156 of the file. If you want to distribute this text under CC-BY-4.0 only,
157 please use 'The Linux kernel development community' for author attribution
158 and link this as source:
159 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/Documentation/admin-guide/bug-bisect.rst
160
161 ..
162 Note: Only the content of this RST file as found in the Linux kernel sources
163 is available under CC-BY-4.0, as versions of this text that were processed
164 (for example by the kernel's build system) might contain content taken from
165 files which use a more restrictive license.
166

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

Regression bisect 목적과 준비

1-39

이 문서는 GPL-2.0+ 또는 CC-BY-4.0으로 제공되며 `git bisect`로 Linux 6.0에서 6.1로 올린 뒤 기능이 멈춘 경우처럼 문제를 만든 source-code change를 찾는 방법을 설명합니다.

여기서는 핵심 절차에 집중합니다. Kernel bisect가 처음이면 `Documentation/admin-guide/verify-bugs-and-bisect-regressions.rst`를 따라 start-to-finish 지침을 보는 편이 낫습니다. 그 문서는 tainted kernel, 버려진 version, 이미 수정된 문제, user 또는 distribution의 `.config` 변경처럼 결과를 활용할 사람이 없어 bisect가 낭비가 되는 상황을 일찍 찾는 방법도 다룹니다.

Bisect 전에 적절한 source Git clone, kernel build·install software, 매 step의 pristine base로 쓸 안전하게 보관한 `.config`(예제는 `~/prepared_kernel_.config`), 신뢰할 수 있고 단순한 regression reproducer를 준비합니다.

Git history에서 정상 지점을 `good`, 고장 지점을 `bad`로 알려 bisect를 시작합니다. Tag 대신 commit ID도 사용할 수 있습니다.

* Preparation: start the bisection and tell Git about the points in the history
  you consider to be working and broken, which Git calls 'good' and 'bad'::

     git bisect start
     git bisect good v6.0
     git bisect bad v6.1

  Instead of Git tags like 'v6.0' and 'v6.1' you can specify commit-ids, too.
Prepare a kernel regression bisection
Confirm supported, untainted regressionPrepare source, build tools, pristine .configCreate reliable reproducerMark known-good and known-bad revisions

결과가 의미 있는지 확인한 뒤 reproducible good/bad endpoints를 고릅니다.

Build·test·good/bad/skip 반복

40-80

각 step에서 준비한 `.config`를 build directory에 복사하고 Git이 checkout한 codebase에 맞게 `make olddefconfig`로 조정합니다.

1. Copy your prepared .config into the build directory and adjust it to the
   needs of the codebase Git checked out for testing::

     cp ~/prepared_kernel_.config .config
     make olddefconfig

Kernel을 build·install·boot합니다. 현재 revision의 compile error가 나중 change에서 해결되는 등 regression과 무관한 이유로 실패하면 `git bisect skip`을 실행하고 step 1로 돌아갑니다.

새 kernel에서 regression 기능을 검사합니다. 정상 작동하면 `git bisect good`, 고장이면 `git bisect bad`를 실행합니다.

3. Check if the functionality that regressed works in the kernel you just built.

   If it works, execute::

     git bisect good

   If it is broken, run::

     git bisect bad

판정을 한 번만 잘못해도 나머지 bisect가 완전히 틀어집니다. Reproducer가 불안정하면 처음부터 다시 시작하지 않도록 몇 분 더 테스트해 Git에 주는 답이 정확한지 확인합니다.

명령 뒤 Git이 `675 revisions left ... roughly 10 steps`처럼 다음 point를 checkout하면 step 1로 돌아갑니다. `... is the first bad commit`을 출력하면 완료입니다. 이어지는 patch description이 terminal을 채울 수 있으므로 culprit commit ID message를 보려면 위로 scroll해야 할 수 있습니다.

출력을 놓쳤다면 언제든 `git bisect log`로 남은 step 또는 결과를 확인할 수 있습니다.

Kernel bisect loop
Copy pristine .config + olddefconfigBuild, install, bootRegression unrelated build failuregit bisect skipNext revision
Build succeedsRegression worksgit bisect goodNext revision
Build succeedsRegression reproducedgit bisect badNext revision or first bad commit

Build 결과와 regression test 결과에 따라 다음 revision을 선택합니다.

Log 보존·reset·revert 검증·report

81-110

권장 보완 작업으로 bug report에 쓸 bisect log와 현재 `.config`를 따로 저장하고 source를 bisect 전 상태로 reset합니다.

* Recommended complementary task: put the bisection log and the current .config
  file aside for the bug report; furthermore tell Git to reset the sources to
  the state before the bisection::

     git bisect log > ~/bisection-log
     cp .config ~/bisection-config-culprit
     git bisect reset

Optional 권장 작업은 최신 codebase 위에서 culprit를 revert하고 bug가 사라지는지 확인하는 것입니다. 성공하면 bisect를 검증하고 developer가 revert로 regression을 해결할 수 있게 합니다. Clone을 update하고 최신 mainline을 checkout한 뒤 culprit commit ID를 지정합니다.

* Recommended optional task: try reverting the culprit on top of the latest
  codebase and check if that fixes your bug; if that is the case, it validates
  the bisection and enables developers to resolve the regression through a
  revert.

  To try this, update your clone and check out latest mainline. Then tell Git
  to revert the change by specifying its commit-id::

     git revert --no-edit cafec0cacaca0

Bisect 결과가 merge commit이거나 뒤 change가 culprit에 의존해 Git이 자동 revert하지 못하면 시도를 포기합니다. 단 stable 또는 longterm series를 bisect했다면 해당 series의 최신 codebase에서 revert를 시도합니다. Revert가 성공하면 kernel을 다시 build·test해 regression 해결 여부를 확인합니다.

절차가 끝나면 `Documentation/admin-guide/reporting-issues.rst`에 따라 regression을 보고합니다.

Validate and report the culprit
Save git bisect log and culprit .configgit bisect resetTry revert on latest suitable branchBuild and retestReport regression with evidence

Bisect 산출물을 보존하고 가능한 경우 revert로 인과를 재검증합니다.

linux-next bisect

111-132

문제가 linux-next에서만 발생하면 linux-next의 `stable`과 `master` branch 사이를 bisect합니다. Remote 이름이 `next`인 tree에서는 다음 명령을 사용합니다.

If you face a problem only happening in linux-next, bisect between the
linux-next branches 'stable' and 'master'. The following commands will start
the process for a linux-next tree you added as a remote called 'next'::

  git bisect start
  git bisect good next/stable
  git bisect bad next/master

`stable`은 현재 `master` linux-next release가 기반으로 삼은 linux-mainline 상태입니다. 따라서 `stable`에는 -next에서만 나타나고 Linus tree에는 없는 문제가 없어야 합니다.

이 방식은 넓은 change 범위를 bisect하므로 과거 linux-next release에서 문제없이 사용한 change도 다시 검사할 수 있습니다. `next-20241020`과 `next-20241021`처럼 두 linux-next release 사이에는 공통 history가 없으므로 그 둘을 직접 bisect하는 간단한 방법은 없습니다.

linux-next bisect endpoints
EndpointRevisionMeaning
Goodnext/stableCurrent -next base from linux-mainline
Badnext/masterCurrent linux-next release

Current linux-next가 기반으로 한 mainline과 -next head를 비교합니다.

추가 자료

133-143

추가 자료로 Git의 `git bisect` man page, `fighting regressions with git bisect`, kernel developer Nathan Chancellor의 `Working with git bisect`, `Using Git bisect to figure out when brokenness was introduced`, LWN의 `Fully automated bisecting with git bisect run`을 제시합니다.

Bisect reading list
ResourceURL
git bisect manualhttps://git-scm.com/docs/git-bisect
Fighting regressionshttps://git-scm.com/docs/git-bisect-lk2009.html
Working with git bisecthttps://nathanchance.dev/posts/working-with-git-bisect/
When brokenness was introducedhttp://webchick.net/node/99
Automated git bisect runhttps://lwn.net/Articles/317154

원문이 제시한 URL과 주제입니다.

문서 유지관리와 재배포 조건

144-165

이 문서는 Thorsten Leemhuis `<[email protected]>`가 유지합니다. Typo나 작은 오류는 직접 알려도 되며, 비공식적으로 text change를 기여할 수도 있습니다. 다만 copyright를 위해 `[email protected]`를 CC하고 `Documentation/process/submitting-patches.rst`의 Developer's Certificate of Origin 절차에 따라 sign-off해야 합니다.

원문은 file 상단에 명시한 대로 GPL-2.0+ 또는 CC-BY-4.0으로 제공됩니다. CC-BY-4.0만으로 배포하려면 author attribution을 `The Linux kernel development community`로 하고 원문 source URL을 link해야 합니다.

   This text is available under GPL-2.0+ or CC-BY-4.0, as stated at the top
   of the file. If you want to distribute this text under CC-BY-4.0 only,
   please use 'The Linux kernel development community' for author attribution
   and link this as source:
   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/Documentation/admin-guide/bug-bisect.rst

CC-BY-4.0은 Linux kernel source에 있는 이 RST file 내용에만 적용됩니다. Kernel build system 등으로 처리된 version은 더 제한적인 license의 다른 file 내용을 포함할 수 있습니다.

bug-bisect redistribution
ChoiceRequirement
GPL-2.0+Source file의 dual-license 선택지
CC-BY-4.0 onlyThe Linux kernel development community attribution과 source link
Processed output다른 license content가 포함될 수 있어 CC-BY-4.0 범위를 별도 확인

선택한 license와 attribution·범위 조건입니다.