Skip to content

[Deepin-Kernel-SIG] [linux 6.6-y] [Upstream] LoongArch: Relax memory ordering for atomic operations#682

Merged
opsiff merged 1 commit into
deepin-community:linux-6.6.yfrom
opsiff:linux-6.6.y-2025-03-24-loongarch
Apr 7, 2025
Merged

[Deepin-Kernel-SIG] [linux 6.6-y] [Upstream] LoongArch: Relax memory ordering for atomic operations#682
opsiff merged 1 commit into
deepin-community:linux-6.6.yfrom
opsiff:linux-6.6.y-2025-03-24-loongarch

Conversation

@opsiff
Copy link
Copy Markdown
Member

@opsiff opsiff commented Mar 24, 2025

mainline inclusion
from mainline-v6.7-rc1
category: performance

This patch relaxes the implementation while satisfying the memory ordering requirements for atomic operations, which will help improve performance on LA664+.

Unixbench with full threads (8)
before after
Dhrystone 2 using register variables 203910714.2 203909539.8 0.00%
Double-Precision Whetstone 37930.9 37931 0.00%
Execl Throughput 29431.5 29545.8 0.39%
File Copy 1024 bufsize 2000 maxblocks 6645759.5 6676320 0.46%
File Copy 256 bufsize 500 maxblocks 2138772.4 2144182.4 0.25%
File Copy 4096 bufsize 8000 maxblocks 11640698.4 11602703 -0.33%
Pipe Throughput 8849077.7 8917009.4 0.77%
Pipe-based Context Switching 1255108.5 1287277.3 2.56%
Process Creation 50825.9 50442.1 -0.76%
Shell Scripts (1 concurrent) 25795.8 25942.3 0.57%
Shell Scripts (8 concurrent) 3812.6 3835.2 0.59%
System Call Overhead 9248212.6 9353348.6 1.14%
=======
System Benchmarks Index Score 8076.6 8114.4 0.47%

(cherry picked from commit affef66)

Summary by Sourcery

Enhancements:

  • Relax memory ordering for atomic operations to improve performance.

mainline inclusion
from mainline-v6.7-rc1
category: performance

This patch relaxes the implementation while satisfying the memory ordering
requirements for atomic operations, which will help improve performance on
LA664+.

Unixbench with full threads (8)
                                           before       after
  Dhrystone 2 using register variables   203910714.2  203909539.8   0.00%
  Double-Precision Whetstone                 37930.9        37931   0.00%
  Execl Throughput                           29431.5      29545.8   0.39%
  File Copy 1024 bufsize 2000 maxblocks    6645759.5      6676320   0.46%
  File Copy 256 bufsize 500 maxblocks      2138772.4    2144182.4   0.25%
  File Copy 4096 bufsize 8000 maxblocks   11640698.4     11602703  -0.33%
  Pipe Throughput                          8849077.7    8917009.4   0.77%
  Pipe-based Context Switching             1255108.5    1287277.3   2.56%
  Process Creation                           50825.9      50442.1  -0.76%
  Shell Scripts (1 concurrent)               25795.8      25942.3   0.57%
  Shell Scripts (8 concurrent)                3812.6       3835.2   0.59%
  System Call Overhead                     9248212.6    9353348.6   1.14%
                                                                  =======
  System Benchmarks Index Score               8076.6       8114.4   0.47%

Signed-off-by: WANG Rui <wangrui@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
(cherry picked from commit affef66)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Mar 24, 2025

Reviewer's Guide by Sourcery

This pull request relaxes memory ordering constraints for atomic operations on LoongArch architecture, specifically targeting LA664+ processors. It introduces new variants of atomic operations with relaxed memory ordering, potentially improving performance. The changes involve modifying macros to generate both default and relaxed versions of atomic functions and updating assembly instructions to remove the unnecessary _db suffix for relaxed operations.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Relaxed memory ordering for atomic operations by introducing variants with and without the _db suffix in assembly instructions.
  • Modified the ATOMIC_OP_RETURN macro to include mb and suffix parameters for memory ordering and relaxed versions.
  • Modified the ATOMIC_FETCH_OP macro to include mb and suffix parameters for memory ordering and relaxed versions.
  • Updated ATOMIC_OPS macro to define both default and relaxed versions of atomic operations using the new ATOMIC_OP_RETURN and ATOMIC_FETCH_OP macros.
  • Added macro definitions to alias the default atomic operations (e.g., arch_atomic_add_return) to their non-suffixed counterparts, and define relaxed versions with the _relaxed suffix.
  • Updated ATOMIC64_OP_RETURN and ATOMIC64_FETCH_OP macros similarly to their 32-bit counterparts.
  • Updated ATOMIC64_OPS macro to define both default and relaxed versions of atomic operations using the new ATOMIC64_OP_RETURN and ATOMIC64_FETCH_OP macros.
  • Added macro definitions to alias the default atomic64 operations (e.g., arch_atomic64_add_return) to their non-suffixed counterparts and define relaxed versions with the _relaxed suffix.
arch/loongarch/include/asm/atomic.h

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot
Copy link
Copy Markdown

deepin pr auto review

代码审查意见:

  1. 代码格式和风格

    • ATOMIC_OPSATOMIC64_OPS宏定义中,新增的mbsuffix参数使得宏定义的参数列表变得冗长,建议检查是否所有新增的宏调用都正确使用了这些参数,并且保持代码风格的一致性。
  2. 宏定义的扩展性

    • 新增的mbsuffix参数增加了宏定义的灵活性,但同时也增加了复杂性。建议评估是否所有这些参数都是必要的,或者是否有更简洁的方式来处理这些情况。
  3. 代码可读性

    • ATOMIC_OP_RETURNATOMIC_FETCH_OP宏定义中,asm_op的拼接方式可能会影响生成的汇编代码的可读性。建议确认这种拼接方式是否正确,并且不会引入任何错误。
  4. 性能考虑

    • 新增的mb参数可能用于控制内存屏障的使用,但需要确认这些内存屏障是否真的必要,以及它们对性能的影响。
  5. 代码安全性

    • 检查是否有必要对传入的参数进行验证,以防止潜在的未定义行为或安全漏洞。
  6. 注释和文档

    • 新增的宏定义和参数可能需要相应的注释和文档,以便其他开发者理解这些更改的目的和用法。
  7. 测试

    • 对于任何修改,都应该有相应的单元测试来验证更改的正确性和性能影响。
  8. 向后兼容性

    • 如果这些更改会影响现有的代码库,需要确保这些更改不会破坏现有的功能,并且有适当的迁移路径。

总体来说,这些更改提高了代码的灵活性和可维护性,但同时也增加了复杂性。建议在实施这些更改之前进行充分的测试和评估,以确保它们不会引入新的问题。

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from opsiff. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @opsiff - I've reviewed your changes - here's some feedback:

Overall Comments:

  • The proliferation of macros makes this code quite difficult to read - consider refactoring to use inline functions instead.
  • It looks like the acquire and release memory ordering semantics are being dropped, is that intended?
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@opsiff
Copy link
Copy Markdown
Member Author

opsiff commented Apr 7, 2025

Before:
8 CPUs in system; running 1 parallel copy of tests
Dhrystone 2 using register variables 41193038.5 lps (10.0 s, 7 samples)
Double-Precision Whetstone 5035.1 MWIPS (10.0 s, 7 samples)
Execl Throughput 4248.3 lps (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks 621670.0 KBps (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks 164863.5 KBps (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks 1896980.0 KBps (30.0 s, 2 samples)
Pipe Throughput 1187258.1 lps (10.0 s, 7 samples)
Pipe-based Context Switching 109270.7 lps (10.0 s, 7 samples)
Process Creation 8702.0 lps (30.0 s, 2 samples)
Shell Scripts (1 concurrent) 11797.6 lpm (60.0 s, 2 samples)
Shell Scripts (8 concurrent) 4773.6 lpm (60.0 s, 2 samples)
System Call Overhead 1284812.1 lps (10.0 s, 7 samples)
System Benchmarks Index Values BASELINE RESULT INDEX
Dhrystone 2 using register variables 116700.0 41193038.5 3529.8
Double-Precision Whetstone 55.0 5035.1 915.5
Execl Throughput 43.0 4248.3 988.0
File Copy 1024 bufsize 2000 maxblocks 3960.0 621670.0 1569.9
File Copy 256 bufsize 500 maxblocks 1655.0 164863.5 996.2
File Copy 4096 bufsize 8000 maxblocks 5800.0 1896980.0 3270.7
Pipe Throughput 12440.0 1187258.1 954.4
Pipe-based Context Switching 4000.0 109270.7 273.2
Process Creation 126.0 8702.0 690.6
Shell Scripts (1 concurrent) 42.4 11797.6 2782.5
Shell Scripts (8 concurrent) 6.0 4773.6 7956.1
System Call Overhead 15000.0 1284812.1 856.5
System Benchmarks Index Score 1398.0
Dhrystone 2 using register variables 221318057.8 lps (10.0 s, 7 samples)
Double-Precision Whetstone 37174.1 MWIPS (10.0 s, 7 samples)
Execl Throughput 23089.8 lps (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks 3426413.9 KBps (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks 936160.4 KBps (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks 7895970.5 KBps (30.0 s, 2 samples)
Pipe Throughput 6994333.2 lps (10.0 s, 7 samples)
Pipe-based Context Switching 967203.7 lps (10.0 s, 7 samples)
Process Creation 48383.1 lps (30.0 s, 2 samples)
Shell Scripts (1 concurrent) 41782.5 lpm (60.0 s, 2 samples)
Shell Scripts (8 concurrent) 5426.0 lpm (60.0 s, 2 samples)
System Call Overhead 7489205.5 lps (10.0 s, 7 samples)
System Benchmarks Index Values BASELINE RESULT INDEX
Dhrystone 2 using register variables 116700.0 221318057.8 18964.7
Double-Precision Whetstone 55.0 37174.1 6758.9
Execl Throughput 43.0 23089.8 5369.7
File Copy 1024 bufsize 2000 maxblocks 3960.0 3426413.9 8652.6
File Copy 256 bufsize 500 maxblocks 1655.0 936160.4 5656.6
File Copy 4096 bufsize 8000 maxblocks 5800.0 7895970.5 13613.7
Pipe Throughput 12440.0 6994333.2 5622.5
Pipe-based Context Switching 4000.0 967203.7 2418.0
Process Creation 126.0 48383.1 3839.9
Shell Scripts (1 concurrent) 42.4 41782.5 9854.4
Shell Scripts (8 concurrent) 6.0 5426.0 9043.3
System Call Overhead 15000.0 7489205.5 4992.8
System Benchmarks Index Score 6848.9
After:
8 CPUs in system; running 1 parallel copy of tests
Dhrystone 2 using register variables 41338050.2 lps (10.0 s, 7 samples)
Double-Precision Whetstone 5035.5 MWIPS (10.0 s, 7 samples)
Execl Throughput 4290.3 lps (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks 625513.1 KBps (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks 166766.0 KBps (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks 1892782.1 KBps (30.0 s, 2 samples)
Pipe Throughput 1188553.2 lps (10.0 s, 7 samples)
Pipe-based Context Switching 110585.7 lps (10.0 s, 7 samples)
Process Creation 8580.5 lps (30.0 s, 2 samples)
Shell Scripts (1 concurrent) 11865.7 lpm (60.0 s, 2 samples)
Shell Scripts (8 concurrent) 4810.9 lpm (60.0 s, 2 samples)
System Call Overhead 1285163.6 lps (10.0 s, 7 samples)
System Benchmarks Index Values BASELINE RESULT INDEX
Dhrystone 2 using register variables 116700.0 41338050.2 3542.2
Double-Precision Whetstone 55.0 5035.5 915.5
Execl Throughput 43.0 4290.3 997.7
File Copy 1024 bufsize 2000 maxblocks 3960.0 625513.1 1579.6
File Copy 256 bufsize 500 maxblocks 1655.0 166766.0 1007.6
File Copy 4096 bufsize 8000 maxblocks 5800.0 1892782.1 3263.4
Pipe Throughput 12440.0 1188553.2 955.4
Pipe-based Context Switching 4000.0 110585.7 276.5
Process Creation 126.0 8580.5 681.0
Shell Scripts (1 concurrent) 42.4 11865.7 2798.5
Shell Scripts (8 concurrent) 6.0 4810.9 8018.1
System Call Overhead 15000.0 1285163.6 856.8
System Benchmarks Index Score 1402.9
Dhrystone 2 using register variables 221329300.0 lps (10.0 s, 7 samples)
Double-Precision Whetstone 37173.5 MWIPS (10.0 s, 7 samples)
Execl Throughput 23274.5 lps (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks 3462085.0 KBps (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks 954300.1 KBps (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks 7714182.9 KBps (30.0 s, 2 samples)
Pipe Throughput 7003171.4 lps (10.0 s, 7 samples)
Pipe-based Context Switching 994933.1 lps (10.0 s, 7 samples)
Process Creation 48563.7 lps (30.0 s, 2 samples)
Shell Scripts (1 concurrent) 41691.9 lpm (60.0 s, 2 samples)
Shell Scripts (8 concurrent) 5477.6 lpm (60.0 s, 2 samples)
System Call Overhead 7492018.1 lps (10.0 s, 7 samples)

System Benchmarks Index Values BASELINE RESULT INDEX
Dhrystone 2 using register variables 116700.0 221329300.0 18965.7
Double-Precision Whetstone 55.0 37173.5 6758.8
Execl Throughput 43.0 23274.5 5412.7
File Copy 1024 bufsize 2000 maxblocks 3960.0 3462085.0 8742.6
File Copy 256 bufsize 500 maxblocks 1655.0 954300.1 5766.2
File Copy 4096 bufsize 8000 maxblocks 5800.0 7714182.9 13300.3
Pipe Throughput 12440.0 7003171.4 5629.6
Pipe-based Context Switching 4000.0 994933.1 2487.3
Process Creation 126.0 48563.7 3854.3
Shell Scripts (1 concurrent) 42.4 41691.9 9833.0
Shell Scripts (8 concurrent) 6.0 5477.6 9129.4
System Call Overhead 15000.0 7492018.1 4994.7
System Benchmarks Index Score 6880.5

@opsiff opsiff merged commit 9027ae0 into deepin-community:linux-6.6.y Apr 7, 2025
opsiff pushed a commit to opsiff/UOS-kernel that referenced this pull request Jul 14, 2025
mainline inclusion
from mainline-v6.7-rc1
category: bugfix

Getting the following splat [1] with CONFIG_DEBUG_NET=y and this
reproducer [2]. Problem seems to be that classifiers clear 'struct
tcf_result::drop_reason', thereby triggering the warning in
__kfree_skb_reason() due to reason being 'SKB_NOT_DROPPED_YET' (0).

Fixed by disambiguating a legit error from a verdict with a bogus drop_reason

[1]
WARNING: CPU: 0 PID: 181 at net/core/skbuff.c:1082 kfree_skb_reason+0x38/0x130
Modules linked in:
CPU: 0 PID: 181 Comm: mausezahn Not tainted 6.6.0-rc6-custom-ge43e6d9582e0 deepin-community#682
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-1.fc37 04/01/2014
RIP: 0010:kfree_skb_reason+0x38/0x130
[...]
Call Trace:
 <IRQ>
 __netif_receive_skb_core.constprop.0+0x837/0xdb0
 __netif_receive_skb_one_core+0x3c/0x70
 process_backlog+0x95/0x130
 __napi_poll+0x25/0x1b0
 net_rx_action+0x29b/0x310
 __do_softirq+0xc0/0x29b
 do_softirq+0x43/0x60
 </IRQ>

[2]

ip link add name veth0 type veth peer name veth1
ip link set dev veth0 up
ip link set dev veth1 up
tc qdisc add dev veth1 clsact
tc filter add dev veth1 ingress pref 1 proto all flower dst_mac 00:11:22:33:44:55 action drop
mausezahn veth0 -a own -b 00:11:22:33:44:55 -q -c 1

Ido reported:

  [...] getting the following splat [1] with CONFIG_DEBUG_NET=y and this
  reproducer [2]. Problem seems to be that classifiers clear 'struct
  tcf_result::drop_reason', thereby triggering the warning in
  __kfree_skb_reason() due to reason being 'SKB_NOT_DROPPED_YET' (0). [...]

  [1]
  WARNING: CPU: 0 PID: 181 at net/core/skbuff.c:1082 kfree_skb_reason+0x38/0x130
  Modules linked in:
  CPU: 0 PID: 181 Comm: mausezahn Not tainted 6.6.0-rc6-custom-ge43e6d9582e0 deepin-community#682
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-1.fc37 04/01/2014
  RIP: 0010:kfree_skb_reason+0x38/0x130
  [...]
  Call Trace:
   <IRQ>
   __netif_receive_skb_core.constprop.0+0x837/0xdb0
   __netif_receive_skb_one_core+0x3c/0x70
   process_backlog+0x95/0x130
   __napi_poll+0x25/0x1b0
   net_rx_action+0x29b/0x310
   __do_softirq+0xc0/0x29b
   do_softirq+0x43/0x60
   </IRQ>

  [2]
  #!/bin/bash

  ip link add name veth0 type veth peer name veth1
  ip link set dev veth0 up
  ip link set dev veth1 up
  tc qdisc add dev veth1 clsact
  tc filter add dev veth1 ingress pref 1 proto all flower dst_mac 00:11:22:33:44:55 action drop
  mausezahn veth0 -a own -b 00:11:22:33:44:55 -q -c 1

What happens is that inside most classifiers the tcf_result is copied over
from a filter template e.g. *res = f->res which then implicitly overrides
the prior SKB_DROP_REASON_TC_{INGRESS,EGRESS} default drop code which was
set via sch_handle_{ingress,egress}() for kfree_skb_reason().

Commit text above copied verbatim from Daniel. The general idea of the patch
is not very different from what Ido originally posted but instead done at the
cls_api codepath.

Fixes: 54a59ae ("net, sched: Make tc-related drop reason more flexible")
Reported-by: Ido Schimmel <idosch@idosch.org>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Link: https://lore.kernel.org/netdev/ZTjY959R+AFXf3Xy@shredder
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 40cb2fd)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Avenger-285714 pushed a commit that referenced this pull request Jul 16, 2025
mainline inclusion
from mainline-v6.7-rc1
category: bugfix

Getting the following splat [1] with CONFIG_DEBUG_NET=y and this
reproducer [2]. Problem seems to be that classifiers clear 'struct
tcf_result::drop_reason', thereby triggering the warning in
__kfree_skb_reason() due to reason being 'SKB_NOT_DROPPED_YET' (0).

Fixed by disambiguating a legit error from a verdict with a bogus drop_reason

[1]
WARNING: CPU: 0 PID: 181 at net/core/skbuff.c:1082 kfree_skb_reason+0x38/0x130
Modules linked in:
CPU: 0 PID: 181 Comm: mausezahn Not tainted 6.6.0-rc6-custom-ge43e6d9582e0 #682
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-1.fc37 04/01/2014
RIP: 0010:kfree_skb_reason+0x38/0x130
[...]
Call Trace:
 <IRQ>
 __netif_receive_skb_core.constprop.0+0x837/0xdb0
 __netif_receive_skb_one_core+0x3c/0x70
 process_backlog+0x95/0x130
 __napi_poll+0x25/0x1b0
 net_rx_action+0x29b/0x310
 __do_softirq+0xc0/0x29b
 do_softirq+0x43/0x60
 </IRQ>

[2]

ip link add name veth0 type veth peer name veth1
ip link set dev veth0 up
ip link set dev veth1 up
tc qdisc add dev veth1 clsact
tc filter add dev veth1 ingress pref 1 proto all flower dst_mac 00:11:22:33:44:55 action drop
mausezahn veth0 -a own -b 00:11:22:33:44:55 -q -c 1

Ido reported:

  [...] getting the following splat [1] with CONFIG_DEBUG_NET=y and this
  reproducer [2]. Problem seems to be that classifiers clear 'struct
  tcf_result::drop_reason', thereby triggering the warning in
  __kfree_skb_reason() due to reason being 'SKB_NOT_DROPPED_YET' (0). [...]

  [1]
  WARNING: CPU: 0 PID: 181 at net/core/skbuff.c:1082 kfree_skb_reason+0x38/0x130
  Modules linked in:
  CPU: 0 PID: 181 Comm: mausezahn Not tainted 6.6.0-rc6-custom-ge43e6d9582e0 #682
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-1.fc37 04/01/2014
  RIP: 0010:kfree_skb_reason+0x38/0x130
  [...]
  Call Trace:
   <IRQ>
   __netif_receive_skb_core.constprop.0+0x837/0xdb0
   __netif_receive_skb_one_core+0x3c/0x70
   process_backlog+0x95/0x130
   __napi_poll+0x25/0x1b0
   net_rx_action+0x29b/0x310
   __do_softirq+0xc0/0x29b
   do_softirq+0x43/0x60
   </IRQ>

  [2]
  #!/bin/bash

  ip link add name veth0 type veth peer name veth1
  ip link set dev veth0 up
  ip link set dev veth1 up
  tc qdisc add dev veth1 clsact
  tc filter add dev veth1 ingress pref 1 proto all flower dst_mac 00:11:22:33:44:55 action drop
  mausezahn veth0 -a own -b 00:11:22:33:44:55 -q -c 1

What happens is that inside most classifiers the tcf_result is copied over
from a filter template e.g. *res = f->res which then implicitly overrides
the prior SKB_DROP_REASON_TC_{INGRESS,EGRESS} default drop code which was
set via sch_handle_{ingress,egress}() for kfree_skb_reason().

Commit text above copied verbatim from Daniel. The general idea of the patch
is not very different from what Ido originally posted but instead done at the
cls_api codepath.

Fixes: 54a59ae ("net, sched: Make tc-related drop reason more flexible")
Reported-by: Ido Schimmel <idosch@idosch.org>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Link: https://lore.kernel.org/netdev/ZTjY959R+AFXf3Xy@shredder
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 40cb2fd)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants