提交 a5f32c14 编写于 作者: X xuanzhuo

alinux: Revert "net: get rid of an signed integer overflow in ip_idents_reserve()"

fix #24463023

This reverts commit adb03115.

Related Links:
    https://lkml.org/lkml/2019/7/24/243
    https://lore.kernel.org/lkml/b0160f4b-b996-b0ee-405a-3d5f1866272e@gmail.com/
    https://lore.kernel.org/lkml/20181101172739.GA3196@hirez.programming.kicks-ass.net/

test methods:
   1. add dummy net dev. "ip link add pps_dummy0 type dummy"
   2. set the dummy dev with addr 10.10.10.1
   3. send numerous udp packets to 10.10.10.2(fake addr) by dummy dev

test command: sockperf tp -m 14 -t 20 --mps=max -i 10.10.10.2 -p 11111

By default, the ip_idents_reserve function will be called to distribute the
identities of the identities in the ip layer without the DF flag. Use this
method to stress test this function.

After testing under vm, after the concurrent CPU exceeds 12, the old patch pps
will no longer rise. The data for concurrent CPU 32 is as follows:

test without atomic_add_return:
    11:32:10 AM pps_dummy0      0.00 8008897.00      0.00 437986.55      0.00      0.00      0.00
    11:32:11 AM pps_dummy0      0.00 7992910.00      0.00 437112.27      0.00      0.00      0.00
    11:32:12 AM pps_dummy0      0.00 7982553.00      0.00 436545.87      0.00      0.00      0.00
    11:32:13 AM pps_dummy0      0.00 7977757.00      0.00 436283.59      0.00      0.00      0.00
    11:32:14 AM pps_dummy0      0.00 7968355.00      0.00 435769.41      0.00      0.00      0.00

test with atomic_add_return:
    11:33:20 AM pps_dummy0      0.00 16024069.00      0.00 876316.27      0.00      0.00      0.00
    11:33:21 AM pps_dummy0      0.00 16024252.00      0.00 876326.28      0.00      0.00      0.00
    11:33:22 AM pps_dummy0      0.00 16021639.00      0.00 876183.38      0.00      0.00      0.00
    11:33:23 AM pps_dummy0      0.00 16018738.00      0.00 876024.73      0.00      0.00      0.00
    11:33:24 AM pps_dummy0      0.00 16022333.00      0.00 876221.34      0.00      0.00      0.00
    11:33:25 AM pps_dummy0      0.00 16028147.00      0.00 876539.29      0.00      0.00      0.00
Signed-off-by: Nxuanzhuo <xuanzhuo@linux.alibaba.com>
Acked-by: NDust Li <dust.li@linux.alibaba.com>
上级 8dcc27c2
......@@ -483,18 +483,12 @@ u32 ip_idents_reserve(u32 hash, int segs)
atomic_t *p_id = ip_idents + hash % IP_IDENTS_SZ;
u32 old = READ_ONCE(*p_tstamp);
u32 now = (u32)jiffies;
u32 new, delta = 0;
u32 delta = 0;
if (old != now && cmpxchg(p_tstamp, old, now) == old)
delta = prandom_u32_max(now - old);
/* Do not use atomic_add_return() as it makes UBSAN unhappy */
do {
old = (u32)atomic_read(p_id);
new = old + delta + segs;
} while (atomic_cmpxchg(p_id, old, new) != old);
return new - segs;
return atomic_add_return(segs + delta, p_id) - segs;
}
EXPORT_SYMBOL(ip_idents_reserve);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册