[PWCI] "dpdk: Update dpdk-lcore-mask handling."#11
Conversation
Add some more details about dpdk-lcore-mask and remove the recommendation to use it. Signed-off-by: Kevin Traynor <ktraynor@redhat.com> Signed-off-by: 0-day Robot <robot@bytheb.org>
Default values are not used here, so remove the option for them. Suggested-by: David Marchand <david.marchand@redhat.com> Signed-off-by: Kevin Traynor <ktraynor@redhat.com> Signed-off-by: 0-day Robot <robot@bytheb.org>
OVS currently uses other_config:dpdk-lcore-mask <coremask> directly in DPDK rte_eal_init() with '-c <coremask>' argument. '-c' argument is now deprecated from DPDK and will be removed in DPDK 25.11, so OVS will no longer be able to use the '-c <coremask>' argument. Convert dpdk-lcore-mask core mask to a core list that can be used with '--lcores' and add some tests. The core list is validated to prevent invalid cores being passed to DPDK rte_eal_init(). Using the '--lcores' argument also adds compability for using a core in the core mask that is greater than the max lcore, similar to commit fe53b47 ("dpdk: Fix main lcore on systems with many cores.") Signed-off-by: Kevin Traynor <ktraynor@redhat.com> Signed-off-by: 0-day Robot <robot@bytheb.org>
|
Caution Review failedAn error occurred during the review process. Please try again later. ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Reviewer's GuideThis PR enhances dpdk-lcore-mask support by introducing a conversion helper that translates a hex core mask into a sorted DPDK lcore list, refactors the options mapping to use a generic conversion callback for parameters, and updates documentation and tests to reflect the new behavior. Class diagram for updated DPDK options mapping and core mask conversionclassDiagram
class dpdk_options_map {
+const char *ovs_configuration
+const char *dpdk_option
+char *(*param_conversion)(const char *)
}
class cmask_to_lcore_list {
+char *cmask_to_lcore_list(const char *cmask)
}
dpdk_options_map --> cmask_to_lcore_list : uses param_conversion
class construct_dpdk_options {
+void construct_dpdk_options(const struct smap *, struct svec *)
}
construct_dpdk_options --> dpdk_options_map : iterates opts[]
construct_dpdk_options --> cmask_to_lcore_list : calls for conversion
class compare_core_ids {
+int compare_core_ids(const void *, const void *)
}
cmask_to_lcore_list --> compare_core_ids : uses for sorting
class ovs_numa_dump_cores_with_cmask {
+struct ovs_numa_dump *ovs_numa_dump_cores_with_cmask(const char *)
}
cmask_to_lcore_list --> ovs_numa_dump_cores_with_cmask : gets core dump
class ovs_numa_dump_count {
+unsigned int ovs_numa_dump_count(struct ovs_numa_dump *)
}
cmask_to_lcore_list --> ovs_numa_dump_count : gets core count
class ovs_numa_dump_destroy {
+void ovs_numa_dump_destroy(struct ovs_numa_dump *)
}
cmask_to_lcore_list --> ovs_numa_dump_destroy : cleans up
class svec {
+void svec_add(struct svec *, const char *)
}
construct_dpdk_options --> svec : adds options
Flow diagram for hex core mask to DPDK lcore list conversionflowchart TD
A["Input: Hexadecimal core mask"] --> B["ovs_numa_dump_cores_with_cmask(cmask)"]
B --> C["ovs_numa_dump_count(lcore_dump)"]
C --> D["Extract core IDs from dump"]
D --> E["Sort core IDs (compare_core_ids)"]
E --> F["Limit to RTE_MAX_LCORE if needed"]
F --> G["Format as DPDK lcore list string"]
G --> H["Output: lcore list string"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `lib/dpdk.c:90` </location>
<code_context>
+ lcore_dump = ovs_numa_dump_cores_with_cmask(cmask);
+
+ num_cores = ovs_numa_dump_count(lcore_dump);
+ core_ids = xmalloc(num_cores * sizeof *core_ids);
+
+ FOR_EACH_CORE_ON_DUMP(core, lcore_dump) {
</code_context>
<issue_to_address>
Potential allocation of zero bytes if num_cores is zero.
Check if num_cores is zero before allocating memory, and return NULL early to prevent unsafe zero-byte allocation.
</issue_to_address>
### Comment 2
<location> `lib/dpdk.c:113` </location>
<code_context>
+ free(lcores);
+ lcores = new_lcores;
+ }
+ if (lcores) {
+ lcores[strlen(lcores) - 1] = '\0';
+ }
+
</code_context>
<issue_to_address>
Manual removal of trailing comma may be error-prone.
Setting the last character to '\0' without verifying the string length can cause undefined behavior if lcores is empty. Please add a length check before modifying the string.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| lcore_dump = ovs_numa_dump_cores_with_cmask(cmask); | ||
|
|
||
| num_cores = ovs_numa_dump_count(lcore_dump); | ||
| core_ids = xmalloc(num_cores * sizeof *core_ids); |
There was a problem hiding this comment.
issue (bug_risk): Potential allocation of zero bytes if num_cores is zero.
Check if num_cores is zero before allocating memory, and return NULL early to prevent unsafe zero-byte allocation.
| if (lcores) { | ||
| lcores[strlen(lcores) - 1] = '\0'; |
There was a problem hiding this comment.
issue (bug_risk): Manual removal of trailing comma may be error-prone.
Setting the last character to '\0' without verifying the string length can cause undefined behavior if lcores is empty. Please add a length check before modifying the string.
When vport_add_channel() is called duplicate, the resources for previously
specified sock was not freed. This patch fixes this issue.
Reported by Address Sanitizer.
Direct leak of 60 byte(s) in 3 object(s) allocated from:
#0 0xffffb3658080 in malloc (/usr/lib64/libasan.so.6+0xa9080)
#1 0x922630 in xmalloc__ lib/util.c:141
#2 0x922718 in xmalloc lib/util.c:176
#3 0x9c67e4 in nl_sock_create lib/netlink-socket.c:147
#4 0x94cb6c in create_nl_sock lib/dpif-netlink.c:283
#5 0x950bec in dpif_netlink_port_add__ lib/dpif-netlink.c:978
#6 0x951a20 in dpif_netlink_port_add_compat lib/dpif-netlink.c:1101
#7 0x951cd0 in dpif_netlink_port_add lib/dpif-netlink.c:1147
#8 0x616354 in dpif_port_add lib/dpif.c:602
#9 0x49f424 in port_add ofproto/ofproto-dpif.c:4144
#10 0x44d51c in ofproto_port_add ofproto/ofproto.c:2204
#11 0x416914 in iface_do_create vswitchd/bridge.c:2203
#12 0x416dbc in iface_create vswitchd/bridge.c:2246
#13 0x40e1d0 in bridge_add_ports__ vswitchd/bridge.c:1225
#14 0x40e290 in bridge_add_ports vswitchd/bridge.c:1241
#15 0x40cc6c in bridge_reconfigure vswitchd/bridge.c:952
#16 0x420884 in bridge_run vswitchd/bridge.c:3440
#17 0x42f3d0 in main vswitchd/ovs-vswitchd.c:137
Fixes: 69c5158 ("dpif-netlink: don't allocate per thread netlink sockets")
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
When vport_add_channel() is called duplicate, the resources for previously
specified sock was not freed. This patch fixes this issue.
Reported by Address Sanitizer.
Direct leak of 60 byte(s) in 3 object(s) allocated from:
#0 0xffffb3658080 in malloc (/usr/lib64/libasan.so.6+0xa9080)
#1 0x922630 in xmalloc__ lib/util.c:141
#2 0x922718 in xmalloc lib/util.c:176
#3 0x9c67e4 in nl_sock_create lib/netlink-socket.c:147
#4 0x94cb6c in create_nl_sock lib/dpif-netlink.c:283
#5 0x950bec in dpif_netlink_port_add__ lib/dpif-netlink.c:978
#6 0x951a20 in dpif_netlink_port_add_compat lib/dpif-netlink.c:1101
#7 0x951cd0 in dpif_netlink_port_add lib/dpif-netlink.c:1147
#8 0x616354 in dpif_port_add lib/dpif.c:602
#9 0x49f424 in port_add ofproto/ofproto-dpif.c:4144
#10 0x44d51c in ofproto_port_add ofproto/ofproto.c:2204
#11 0x416914 in iface_do_create vswitchd/bridge.c:2203
#12 0x416dbc in iface_create vswitchd/bridge.c:2246
#13 0x40e1d0 in bridge_add_ports__ vswitchd/bridge.c:1225
#14 0x40e290 in bridge_add_ports vswitchd/bridge.c:1241
#15 0x40cc6c in bridge_reconfigure vswitchd/bridge.c:952
#16 0x420884 in bridge_run vswitchd/bridge.c:3440
#17 0x42f3d0 in main vswitchd/ovs-vswitchd.c:137
Reproduce steps:
ovs-vsctl add-br br-ovs
ovs-vsctl add-port br-ovs test -- set interface test type=internal
ip netns add ns_test
ip link set test netns ns_test
ip netns del ns_test
ifconfig br-ovs up
sleep 1
ifconfig br-ovs down
sleep 1
ovs-vsctl del-br br-ovs
Fixes: 69c5158 ("dpif-netlink: don't allocate per thread netlink sockets")
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
Auto-submission for "http://patchwork.ozlabs.org/project/openvswitch/list/?series=472733"
Summary by Sourcery
Introduce a core-mask conversion utility and integrate it into DPDK startup options, replacing the old dpdk-lcore-mask handling and improving parameter conversion and validation.
Enhancements:
Documentation: