Bug 1073 - The `rte_mempool_ops_table` is process unsafe
Summary: The `rte_mempool_ops_table` is process unsafe
Status: UNCONFIRMED
Alias: None
Product: DPDK
Classification: Unclassified
Component: core (show other bugs)
Version: 19.11
Hardware: All All
: Normal normal
Target Milestone: ---
Assignee: Olivier Matz
URL:
Depends on:
Blocks:
 
Reported: 2022-09-01 13:30 CEST by tinbox-wu
Modified: 2022-11-09 12:16 CET (History)
2 users (show)



Attachments
GDB print value corresponding to the table(rte_mempool_ops_table)(myapp and dpdk-pdump) (10.64 KB, text/plain)
2022-09-01 13:30 CEST, tinbox-wu
Details
DRAFT to fix mempool drivers in secondary (13.71 KB, patch)
2022-09-26 10:45 CEST, Olivier Matz
Details | Diff

Description tinbox-wu 2022-09-01 13:30:27 CEST
Created attachment 219 [details]
GDB print value corresponding to the table(rte_mempool_ops_table)(myapp and dpdk-pdump)

The `rte_mempool_ops_table` is process unsafe!

When a process is started, the table (rte_mempool_ops_table) will be initialized with a macro (rte_mempool.h:MEMPOOL_REGISTER_OPS). However, different process initialization will cause inconsistent index values (ops_index) (such as myapp and dpdk pdump). After the initialization memory pool is created in the dpdk pdump process, mp->ops_index = 0, mp->ops_index=2 in myapp。 Different processes using the shared memory pool will be coredump
Comment 1 Olivier Matz 2022-09-26 10:44:23 CEST
Hi,

IMO, the drivers should be loaded in the same order in primary and secondary processes, except if they are built in different environments. Can you explain precisely how to reproduce the issue, starting from the compilation step?

This issue has been mentioned some time ago on the mailing list:
http://inbox.dpdk.org/dev/1586787714-13890-1-git-send-email-xiangxia.m.yue@gmail.com/#r

The problem to implement the feature is that mempool driver registration is done very early (in constructors), where shared memory functions are not available. As far as I know, there is no place where the mempool can hook itself to have a callback invoked when the eal init is done.

I tried to rework Xianxia's patch few monthes ago so that it does not require a specific init layer, hijacking the vdev registration instead, but it is not convincing. See attached patch for reference.

I also had a look to multiprocess communication channels, but I didn't find anything useful to solve this issue. I think we would need a callback when the secondary process is connected to the primary.

If you can demonstrate a usecase, I think you could try resurrect the discussion about introducing a new rte_init with priorities on the mailing list. The attached patch can probably be reworked to take advantage of it.
Comment 2 Olivier Matz 2022-09-26 10:45:02 CEST
Created attachment 221 [details]
DRAFT to fix mempool drivers in secondary
Comment 3 tinbox-wu 2022-11-09 12:11:33 CET
1. I compiled the dpdk as static library and pdump at the same time
2. my app link the libdpdk.a 

Then the above problem arises.

Here's my solution, see github :
https://github.com/DPDK/dpdk/pull/51

At each registration, sort by rte_mempool_ops::name.
Comment 4 tinbox-wu 2022-11-09 12:16:57 CET
(In reply to Olivier Matz from comment #2)
> Created attachment 221 [details]
> DRAFT to fix mempool drivers in secondary

Maybe it could be simpler? see my solution:

https://github.com/DPDK/dpdk/pull/51

At each registration, sort by rte_mempool_ops::name.

Note You need to log in before you can comment on or make changes to this bug.