# My first Linux kernel pull request
###### tags: `2022/06` `linux kernel` `pull request` `pr`
> (2022/6/20) [Jim Huang](https://github.com/sysprog21)'s student, [steven1lung](https://github.com/steven1lung), post an article '[提交第一份 Patch 到 Linux Kernel](https://hackmd.io/@steven1lung/submitting-patches) about his experience of first Linux kernel pull request.
>
> Later, found another article [第一次給Linux Kernel發patch](https://hackmd.io/@rhythm/BkjJeugOv), also helpful.
>
> Linux kernel does not adopt github PR (Pull Request) process, though its source code is mirrored and published on github. Let's give it a try to see if can contribute to Open Source Linux kernel.
---
**Table of Contents**
[TOC]
---
## :memo: Introducing Linux Kernel
Assume you are familiar with Linux, and maybe Linux kernel. In this article, we will focus on the Linux kernel patch. Linux community requests contributors to do the compilation at 4 different machines before sending the patch. We will touch upon the basic of building Linux kernel in this section.
There is official [HOWTO do Linux kernel development¶](https://www.kernel.org/doc/html/latest/process/howto.html). However, it is not easy to follow as newbies. [This article](https://phoenixnap.com/kb/build-linux-kernel) provides a clear picture about how to build Linux kernel.
Below is a very brief go-through of preparing and building Linux kernel.
#### <font color="#337FFF">1. Install packages to build Linux kernel</font>
```
$ sudo apt-get install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc flex libelf-dev bison
$ sudo apt install dwarves
# install dwarves is to avoid below error encountered
BTF: .tmp_vmlinux.btf: pahole (pahole) is not available
Failed to generate BTF for vmlinux
Try to disable CONFIG_DEBUG_INFO_BTF
make: *** [Makefile:1106: vmlinux] Error 1
```
#### <font color="#337FFF">2. Download the Linux kernel source code</font>
```
$ git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
```
#### <font color="#337FFF">3. Configurate - `make menuconfig`</font>
#### <font color="#337FFF">4. Correct the `linux/.config` content</font>
```
make[1] **No rule to nake target ‘debian/canonical-certs.pew’, needed by ‘certs/x509_certificate_list’.Stop.
```
Search CONFIG_SYSTEM_TRUSTED_KEYS, and remove debian/canonical-certs.pew, and leave it blank.Same for CONFIG_SYSTEM_REVOCATION_KEYS.
#### <font color="#337FFF">5. Make</font>
```
# I use a server of 32 cores (16 cores per socket x 2 sockets).
That gives me maximum of 64 threads for `make`
$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 64
On-line CPU(s) list: 0-63
Thread(s) per core: 2
Core(s) per socket: 16
Socket(s): 2
NUMA node(s): 2
Vendor ID: GenuineIntel
CPU family: 6
Model: 85
Model name: Intel(R) Xeon(R) Gold 6130 CPU @ 2.10GHz
$ time make
10582.07user 1772.13system 3:17:38elapsed 104%CPU
$ time make -j 2
10694.89user 1850.39system 1:40:38elapsed 207%CPU
$ time make -j 4
10929.35user 1907.20system 52:17.20elapsed 409%CPU
$ time make -j 8
11146.45user 1884.67system 27:24.38elapsed 792%CPU
$ time make -j 16
12379.05user 1863.47system 16:00.89elapsed 1482%CPU
$ time make -j 32
13215.08user 2016.08system 10:14.39elapsed 2479%CPU
$ time make -j 64
17429.77user 2417.85system 8:32.16elapsed 3875%CPU
$ time make -j 128
18884.64user 2540.17system 8:02.04elapsed 4444%CPU
$ time make -j 256
19332.70user 2570.70system 8:05.18elapsed 4514%CPU
```
---
## :memo: Set up `git` and `git send-email` (Using Gmail or Yahoo mail account)
This is the article mentioned '[提交第一份 Patch 到 Linux Kernel](https://hackmd.io/@steven1lung/submitting-patches)'.
---
## :memo: Email the patch with right format
---
## :memo: References
Further study
1. [Getting started with Linux kernel development](https://gist.github.com/vegard/22200a9f91af138a99ae22a9b814a9a4#getting-started-with-linux-kernel-development)
[:arrow_left:Previous article - Install Jupyter:arrow_left:](https://hackmd.io/@MarconiJiang/install_jupyter) [:arrow_up:back to marconi's blog:arrow_up:](https://marconi1964.github.io/) [:arrow_right:Next article:arrow_right:](https://marconi1964.github.io/)