linux社区工作经验总结

今天刚往社区里放了一个patchset,

https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/commit/?id=f379fdf10b12e19080ee4e2ce27ed54d9e8806d8


共包含三个patch,具体内容如下:

https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/commit/?id=388f79fda74fd3d8700ed5d899573ec58c2e0253

https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/commit/?id=c15ab236d69dd6dad24541400f460c47853803f8

https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/commit/?id=65a206c01e8e7ffe971477a36419422099216eff


 加上其他的两个bugfix,也算是贡献了上千行代码了。

$ git  log --oneline --author="[email protected]"

65a206c net/sched: Change act_api and act_xxx modules to use IDR
c15ab23 net/sched: Change cls_flower to use IDR
388f79f idr: Add new APIs to support unsigned long
7f3b39d net/sched: Fix the logic error to decide the ingress qdisc
5f195c2 net/mlx5e: Fix min inline value for VF rep SQs


首先请仔细阅读下面的文章,review代码要用到git send-email

https://burzalodowa.wordpress.com/2013/10/05/how-to-send-patches-with-git-send-email/

如果你有三个commits,用下面的命令生成如下四个文件:

$  git format-patch --cover-letter --subject-prefix="patch net-next" -o $patch_dir -3

$ cd $patch_dir

$ ll

total 80K
-rw-r--r-- 1 chrism mtl 2.0K Aug 30 02:26 0000-cover-letter.patch
-rw-r--r-- 1 chrism mtl 9.5K Aug 30 02:22 0001-idr-Add-new-APIs-to-support-unsigned-long.patch
-rw-r--r-- 1 chrism mtl 4.8K Aug 30 02:22 0002-net-sched-Change-cls_flower-to-use-IDR.patch
-rw-r--r-- 1 chrism mtl  52K Aug 30 02:22 0003-net-sched-Change-act_api-and-act_xxx-modules-to-use-.patch

修改文件0000-cover-letter.patch,说明这个patchset是干什么的。

如果只有一个commit,就不要cover-letter了。feature要往branch net-next里面放,重要的bugfix一般放到branch net里面。

我们主要工作在networking上,所以基本只用这两个branch。


在发出去review前,要用脚本scripts/checkpatch.pl检查有没有格式上的错误,脚本在linux代码里面。

信发给谁呢,可以用scripts/get_maintainer.pl这个脚本得到一些邮件列表,如果列表太大,不要全发,会被challenge的

捡些重要的发就行了。

下面是个例子:

git send-email /labhome/chrism/net-next/review3/* [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    --suppress-cc=all

send-email有个--dry-run选项,发前可以先检查一下。


如果根据别人的comment修改过代码后,再发时,要加上v2,v3等等,并且cover-letter上要有changlog。

$  git format-patch --cover-letter --subject-prefix="patch net-next v2" -o $patch_dir -3


send-email需要在~/.gitconfig里加上如下内容:

[sendemail]
        smtpserver = labmailer.lab.your.com
        smtpserverport = 25
        aliasesfile = ~/.gitaliases
        aliasfiletype = mutt
        confirm = always


comment的格式也有要求,举个例子:

一定要有标题,标题前要标明改的是哪个模块,标题第一个字母要大写


    net/sched: Change cls_flower to use IDR

    Currently, all filters with the same priority are linked in a doubly
    linked list. Every filter should have a unique handle. To make the
    handle unique, we need to iterate the list every time to see if the
    handle exists or not when inserting a new filter. It is time-consuming.
    For example, it takes about 5m3.169s to insert 64K rules.

    This patch changes cls_flower to use IDR. With this patch, it
    takes about 0m1.127s to insert 64K rules. The improvement is huge.

    But please note that in this testing, all filters share the same action.
    If every filter has a unique action, that is another bottleneck.
    Follow-up patch in this patchset addresses that.

    Signed-off-by: Chris Mi


如果是bugfix的话,一定要找出是哪个commit引起的问题,举个例子:


    net/sched: Fix the logic error to decide the ingress qdisc

    The offending commit used a newly added helper function.
    But the logic is wrong. Without this fix, the affected NICs
    can't do HW offload. Error -EOPNOTSUPP will be returned directly.

    Fixes: a2e8da9378cc ("net/sched: use newly added classid identity helpers")

    Signed-off-by: Chris Mi

并且offending commit的obj ID(a2e8da9378cc)一定是前12位

Signed-off-by一般是作者的邮件,别人review过你的代码后,会说

Acked-by: name

别忘记在comment上加了。


好了,大概就这么多了,有什么补充的以后再修改了。

你可能感兴趣的:(linux)