B-4工具使用

前言

一、安装python3.8

b4最新版本需要python3.8的支持
1,wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
或者https://git.kernel.org/pub/scm/utils/b4/b4.git
2,./configure --prefix=~/LinuxKernel/python3.8_install/Python-3.8.0
make && make install
3,export PATH=~/LinuxKernel/python3.8_install/Python-3.8.0/bin:$PATH
——则再次执行python3 -V则是执行的是python3.8了
——非root用户临时使用指定python版本,故而需要每次都这样使用

二、安装b4

See https://b4.docs.kernel.org/ for online documentation.
1,python3 -m pip install --user b4
2,alias b4="$HOME/b4/b4.sh"将这一行写入~/.bash_profile(centos),~/.bashrc(ubuntu)
3,source ~/.bash_profile 或者source ~/.bashrc

三、打patch

1,可以在https://lore.kernel.org搜索需要的patch,
找到目标pathc的Message-ID
$ b4 am Message-ID
例如打如下Linux-6.2 zsmalloc patch:
在这里插入图片描述https://lore.kernel.org/all/CAKEwX=MPxEsCJ8V8vNvMgXJ66Pq7qxnOX6S1sf97dc-oqaJfWQ@mail.gmail.com/

2,执行patch解析

localhost@:~/LinuxKernel/linux$ b4.sh am 
CAKEwX=MPxEsCJ8V8vNvMgXJ66Pq7qxnOX6S1sf97dc-oqaJfWQ@mail.gmail.com
Grabbing thread from lore.kernel.org/all/CAKEwX%3DMPxEsCJ8V8vNvMgXJ66Pq7qxnOX6S1sf97dc-oqaJfWQ@mail.gmail.com/t.mbox.gz
Analyzing 21 messages in the thread
Checking attestation on all messages, may take a moment...
---
  ✓ [PATCH v7 1/6] zswap: fix writeback lock ordering for zsmalloc
    + Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org> (✓ DKIM/chromium.org)
  ✓ [PATCH v7 2/6] zpool: clean out dead code
  ✓ [PATCH v7 3/6] zsmalloc: Consolidate zs_pool's migrate_lock and size_class's locks
    + Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org> (✓ DKIM/chromium.org)
  ✓ [PATCH v7 4/6] zsmalloc: Add a LRU to zs_pool to keep track of zspages in LRU order
    + Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org> (✓ DKIM/chromium.org)
    + Acked-by: Johannes Weiner <hannes@cmpxchg.org> (✓ DKIM/cmpxchg-org.20210112.gappssmtp.com)
  ✓ [PATCH v7 5/6] zsmalloc: Add zpool_ops field to zs_pool to store evict handlers
    + Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org> (✓ DKIM/chromium.org)
    + Acked-by: Johannes Weiner <hannes@cmpxchg.org> (✓ DKIM/cmpxchg-org.20210112.gappssmtp.com)
  ✓ [PATCH v7 6/6] zsmalloc: Implement writeback mechanism for zsmalloc
    + Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org> (✓ DKIM/chromium.org)
    + Acked-by: Johannes Weiner <hannes@cmpxchg.org> (✓ DKIM/cmpxchg-org.20210112.gappssmtp.com)
  ---
  ✓ Signed: DKIM/gmail.com
---
Total patches: 6
---
Cover: ./v7_20221128_nphamcs_implement_writeback_for_zsmalloc.cover
 Link: https://lore.kernel.org/r/20221128191616.1261026-1-nphamcs@gmail.com
 Base: not specified
       git am ./v7_20221128_nphamcs_implement_writeback_for_zsmalloc.mbx

3,打入patch
git apply --check v7_20221128_nphamcs_implement_writeback_for_zsmalloc.mbx
git am ./v7_20221128_nphamcs_implement_writeback_for_zsmalloc.mbx

4,之后回退patch
git am --abort

B4的用法:

localhost@:~/LinuxKernel/b4$ b4.sh -h
usage: b4 [-h] [--version] [-d] [-q] [-n] [--offline-mode] [--no-stdin] {mbox,am,shazam,pr,ty,diff,kr,prep,trailers,send} ...

A tool to work with patches in public-inbox archives

positional arguments:
  {mbox,am,shazam,pr,ty,diff,kr,prep,trailers,send}
                        sub-command help
    mbox                Download a thread as an mbox file
    am                  Create an mbox file that is ready to git-am
    shazam              Like b4 am, but applies the series to your tree
    pr                  Fetch a pull request found in a message ID
    ty                  Generate thanks email when something gets merged/applied
    diff                Show a range-diff to previous series revision
    kr                  Keyring operations
    prep                Work on patch series to submit for mailing list review
    trailers            Operate on trailers received for mailing list reviews
send                Submit your work for review on the mailing lists

如果B4不好使,例如如下无法解析出来:
在这里插入图片描述
那么可以直接lore.kernel.org将mbox直接下载下来,之后用

gunzip xxx.mbox.gz
git apply --check xxx.mbox
git am xxx.mbox

在这里插入图片描述

引用:
1,https://people.kernel.org/monsieuricon/introducing-b4-and-patch-attestation
2,https://adam.younglogic.com/2022/10/apply-linux-kernel-patches-from-lkml/
3,https://www.cnblogs.com/dakewei/p/13959732.html
4,https://blog.youkuaiyun.com/Rong_Toa/article/details/109693210

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值