Tworzymy patch ze źródeł przechowywanych na platformie git – część 2

Jak już wspominałem w innym wpisie, stworzenie patcha za pomocą oprogramowania Git jest niezwykle proste. W poprzednim wpisie omawiałem narzędzie git format-patch, dzisiaj skupimy się na git diff. Tak jak poprzednim razem, na początku musimy sklonować interesujące nas repozytorium na dysk twardy. W niniejszym poradniku zaprezentuję ponownie jak stworzyć patch na jądro Linuksa zawierający schedulery bfq-sq oraz bfq-mq. Tym razem plik wynikowy przybierze nieco inną formę.

Jak wspominałem, aby stworzyć patch musimy sklonować interesujące nas repozytorium. Jest to czynność niezwykle prosta:

git clone https://github.com/Algodev-github/bfq-mq

Następnie wchodzimy do sklonowanego katalogu bfq-mq poleceniem cd:

cd bfq-mq

Teraz musimy przejrzeć historię zmian w repozytorium, by wybrać tylko te, które potrzebujemy. Do tego posłużymy się komendą:

git log --oneline

Parametr –oneline wyświetli tylko i wyłącznie ID rewizji i krótki opis.

W naszym przypadku otrzymujemy następujący wynik:

[lucjan@archlinux bfq-mq]$ git log --oneline
698937edfe79 (HEAD -> bfq-mq, origin/bfq-mq, origin/HEAD) block, bfq-sq, bfq-mq: prevent soft_rt_next_start from being stuck at infinity
20b4413e4f55 block, bfq-sq, bfq-mq: increase weight-raising duration for interactive apps
122cc34196ed block, bfq-sq, bfq-mq: remove slow-system class
d1d2eeb0494e block, bfq-sq, bfq-mq: add description of weight-raising heuristics
fc76355e222d block, bfq-mq: remove the removal of 'next' rq in bfq_requests_merged
8949a14a3a2d block, bfq-mq: remove wrong check in bfq_requests_merged
0b8d53eb8fb2 block, bfq-mq: remove wrong lock in bfq_requests_merged
a2c79780040a block, bfq-mq: postpone rq preparation to insert or merge
ae5d5407f10c block, bfq-sq, bfq-mq: lower-bound the estimated peak rate to 1
cd25a0910cff bfq-sq, bfq-mq: port of "block, bfq: fix error handle in bfq_init"
c4dfc7130ab1 bfq-sq, bfq-mq: port of "bfq: Use icq_to_bic() consistently"
8f0c0fa24f4b bfq-mq: port of "block, bfq: remove batches of confusing ifdefs"
8adf7f0190e0 block, bfq-mq, bfq-sq: make bfq_bfqq_expire print expiration reason
3901dc6473cf block, bfq-mq, bfq-sq: make log functions print names of calling functions
c01b40cbaf23 block, bfq-mq: add requeue-request hook
c7771900b2a3 block, bfq-sq, bfq-mq: remove trace_printks
ebdf45df6cb9 bfq-sq, bfq-mq: compile group put for oom queue only if BFQ_GROUP_IOSCHED is set
a565f65575a5 block, bfq-sq, bfq-mq: trace get and put of bfq groups
2764e0cccaff bfq-sq, bfq-mq: release oom-queue ref to root group on exit
be841a21d087 bfq-sq, bfq-mq: put async queues for root bfq groups too
2f11415f375d bfq-sq, bfq-mq: limit sectors served with interactive weight raising
444f41c7f8d2 block, bfq-mq: limit tags for writes and async I/O
56906113a3c4 block, bfq-sq, bfq-mq: specify usage condition of delta_us in bfq_log_bfqq call
568aac23d008 block, bfq-sq, bfq-mq: increase threshold to deem I/O as random
787d5f35d8b3 block, bfq-sq, bfq-mq: remove superfluous check in queue-merging setup
a16206fb271e block, bfq-sq, bfq-mq: let a queue be merged only shortly after starting I/O
87d2a44a5da0 block, bfq-sq, bfq-mq: check low_latency flag in bfq_bfqq_save_state()
54c860c71cde block, bfq-sq, bfq-mq: add missing rq_pos_tree update on rq removal
93cc45699852 block, bfq-mq: fix occurrences of request prepare/finish methods' old names
70788692d917 block, bfq-sq, bfq-mq: consider also past I/O in soft real-time detection
bfeb203ca91f block, bfq-mq: turn BUG_ON on request-size into WARN_ON
91b1cf2358c9 block, bfq-sq, bfq-mq: move debug blkio stats behind CONFIG_DEBUG_BLK_CGROUP
2b0c02780455 block, bfq-mq: update blkio stats outside the scheduler lock
296c71887349 block, bfq-mq: add missing invocations of bfqg_stats_update_io_add/remove
0bb4549310d9 doc, block, bfq-mq: update max IOPS sustainable with BFQ
f08c2f36fea5 bfq-sq, bfq-mq: fix unbalanced decrements of burst size
06a36328530b bfq-sq, bfq-mq: decrease burst size when queues in burst exit
644c4716ef13 bfq-sq, bfq-mq: let early-merged queues be weight-raised on split too
913601c15b45 bfq-sq, bfq-mq: check and switch back to interactive wr also on queue split
1ce6cb969142 Fix commit "Unnest request-queue and ioc locks from scheduler locks"
5e852e4fa7e9 bfq-mq, bfq-sq: fix wrong init of saved start time for weight raising
f885f241b1d7 bfq-mq, bfq-sq: Disable writeback throttling
583a448b5240 doc, block, bfq: fix some typos and stale sentences
a2b7e5035368 bfq-sq-mq: guarantee update_next_in_service always returns an eligible entity
ac4d58cfa8ce bfq-sq-mq: remove direct switch to an entity in higher class
1921edfd1e83 bfq-sq-mq: make lookup_next_entity push up vtime on expirations
e2205ba08d20 bfq-sq: fix commit "Remove all get and put of I/O contexts" in branch bfq-mq
76fbfbd11cda Improve most frequently used no-logging path
f97149eae035 Add to documentation that bfq-mq and bfq-sq contain last fixes too
ce9783b42b5f bfq-sq: fix prefix of names of cgroups parameters
93035532c30f Add list of bfq instances to documentation
7bbcb9297f2f Port of "blk-mq-sched: unify request prepare methods"
1bfbdb7b4779 Port of "bfq-iosched: fix NULL ioc check in bfq_get_rq_private"
956de26fbdd0 Port of "blk-mq-sched: unify request finished methods"
c7cb528f3f57 bfq-mq: fix macro name in conditional invocation of policy_unregister
c1739175056d block, bfq-mq: access and cache blkg data only when safe
3730ec5248b0 Add tentative extra tests on groups, reqs and queues
78759df457a3 Change cgroup params prefix to bfq-mq for bfq-mq
8b80c1ef8e03 Fix wrong unlikely
f6dd28416a57 BUGFIX: Remove unneeded and deadlock-causing lock in request_merged
51357e3dba67 Remove all get and put of I/O contexts
1e223d642ed9 Complete support for cgroups
38b0917ea82b TESTING: Check wrong invocation of merge and put_rq_priv functions
39757dad8609 Add checks and extra log messages - Part III
8edaa45620d0 Fix unbalanced increment of rq_in_driver
705832a00428 Add checks and extra log messages - Part II
d1f673a53f43 Unnest request-queue and ioc locks from scheduler locks
09b953542ea0 bfq-mq: execute exit_icq operations immediately
be2606e95597 Add lock check in bfq_allow_bio_merge
aab9148f11e1 Add checks and extra log messages - Part I
70223aa8697a Modify interface and operation to comply with blk-mq-sched
997a7f4d0cd6 Embed bfq-ioc.c and add locking on request queue
56a24dd138ad Move thinktime from bic to bfqq
b24a71116946 Copy header file bfq.h as bfq-mq.h
9640fca96ccd Increase max policies for io controller
6e59de381059 Add config and build bits for bfq-mq-iosched
b9775bca0031 FIRST BFQ-MQ COMMIT: Copy bfq-sq-iosched.c as bfq-mq-iosched.c
8de0c6886b2f block, bfq: improve and refactor throughput-boosting logic
1b1da074fdb4 block, bfq: consider also in_service_entity to state whether an entity is active
b14e9d8c982c block, bfq: reset in_service_entity if it becomes idle
b3b47ecca489 Add extra checks related to entity scheduling
30c9b350615d Add BFQ-v8r12
0adb32858b0b Linux 4.16

Przechodząc do meritum – dokładnie tak, jak w poprzednim wpisie, aby stworzyć patch musimy wybrać jako pierwszy commit POPRZEDZAJĄCY ten, który nas interesuje (więc w naszym wypadku będzie to 0adb32858b0b) oraz jako drugi ostatni interesujący nas commit (a więc będzie to 698937edfe79).

Do stworzenia patcha posłużymy się poleceniem:

git diff

Polecenie którego użyjemy powinno przyjąć taką formę, bliźniaczo podobną do tej, jaką zastosowałem w poleceniu git format-patch

git diff 0b07194bb55e...5b5e52d2a620 > 4.17-bfq-sq-mq-v8r12-2K180531-v3.patch

Jeśli wszystko wykonaliśmy poprawnie, nasz patch powinien wyglądać następująco:

4.17-bfq-sq-mq-v8r12-2K180531-v3.patch

Czym różni się taki patch od tego zaprezentowanego w pierwszym wpisie? Za pierwszym razem uzyskaliśmy patch zawierający kilkadziesiąt zmian. Nakładanie takiego patcha wygląda mniej więcej tak:

==> Patching source with BFQ-SQ-MQ patches
patching file Makefile
patching file block/Kconfig.iosched
patching file block/Makefile
patching file block/bfq-cgroup-included.c
patching file block/bfq-ioc.c
patching file block/bfq-sched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq.h
patching file include/linux/blkdev.h
Hunk #1 succeeded at 57 (offset 1 line).
patching file block/bfq-sched.c
patching file block/bfq-sched.c
patching file block/bfq-sched.c
patching file block/bfq.h
patching file block/bfq-sq-iosched.c
patching file block/bfq.h
patching file block/bfq-mq-iosched.c
patching file Makefile
patching file block/Kconfig.iosched
patching file block/Makefile
patching file block/bfq-cgroup-included.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-sched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq.h
patching file include/linux/blkdev.h
Hunk #1 succeeded at 57 (offset 1 line).
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq.h
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq.h
patching file block/bfq-mq-iosched.c
patching file block/bfq-cgroup-included.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq.h
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq.h
patching file block/bfq-cgroup-included.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq.h
patching file block/bfq-sched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-sched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq-iosched.c
patching file include/linux/blkdev.h
Hunk #1 succeeded at 130 (offset 1 line).
patching file block/Kconfig.iosched
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq.h
patching file block/bfq-cgroup-included.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq.h
patching file block/bfq-sched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-cgroup-included.c
patching file block/bfq-cgroup-included.c
patching file block/bfq-mq-iosched.c
patching file include/linux/blkdev.h
Hunk #1 succeeded at 132 (offset 1 line).
patching file block/bfq-cgroup-included.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq.h
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq-iosched.c
patching file Documentation/block/bfq-iosched.txt
patching file Documentation/block/bfq-iosched.txt
patching file block/bfq-cgroup-included.c
patching file Documentation/block/bfq-iosched.txt
patching file block/bfq-mq.h
patching file block/bfq.h
patching file block/bfq-sched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-sched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq-sched.c
patching file block/bfq-sched.c
patching file Documentation/block/bfq-iosched.txt
patching file block/bfq-mq-iosched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-sq-iosched.c
patching file Documentation/block/bfq-iosched.txt
patching file block/bfq-mq-iosched.c
patching file Documentation/block/bfq-iosched.txt
patching file block/bfq-mq-iosched.c
patching file block/bfq-sched.c
patching file Documentation/block/bfq-iosched.txt
patching file block/bfq-cgroup-included.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq.h
patching file block/bfq.h
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq.h
patching file block/bfq-sched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq.h
patching file block/bfq-mq-iosched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq.h
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq.h
patching file block/bfq-sched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq.h
patching file block/bfq-cgroup-included.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq-cgroup-included.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq-cgroup-included.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-cgroup-included.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq.h
patching file block/bfq-sched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq.h
patching file block/bfq-mq-iosched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq.h
patching file block/bfq-sq-iosched.c
patching file block/bfq.h
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-mq.h
patching file block/bfq-sq-iosched.c
patching file block/bfq.h
patching file block/bfq-mq-iosched.c
patching file block/bfq-sq-iosched.c
patching file block/bfq-mq-iosched.c
patching file block/bfq-sq-iosched.c

Jak widzimy, output jest dość długi i wygląda mało przejrzyście. Drugi patch, uzyskany za pomocą narzędzia git diff, choć na pierwszy rzut oka posiada całkowicie inną składnię, ma dokładanie taką samą zawartość – tyle, że wszystko zostało maksymalnie skompresowane i uproszczone.

==> Patching source with BFQ-SQ-MQ patches
patching file block/bfq-cgroup-included.c
patching file block/bfq.h
patching file block/bfq-ioc.c
patching file block/bfq-mq.h
patching file block/bfq-mq-iosched.c
patching file block/bfq-sched.c
patching file block/bfq-sq-iosched.c
patching file block/Kconfig.iosched
patching file block/Makefile
patching file Documentation/block/bfq-iosched.txt
patching file include/linux/blkdev.h

Dodaj komentarz