Comments (6)
Interesting find.
I am not familiar enough with this code to be certain, but I would not be surprised if this set_source_info() call here: https://github.com/p4lang/behavioral-model/blob/main/src/bm_sim/actions.cpp#L371
would be best done once at P4 program load time, rather than once every time an action is invoked while processing a packet. That would be somewhat more efficient, as well as hopefully avoiding this data race.
from behavioral-model.
would be best done once at P4 program load time, rather than once every time an action is invoked while processing a packet. That would be somewhat more efficient, as well as hopefully avoiding this data race.
This was my first thought, but it is not an option here. There is a single ActionPrimitive
object instantiated for each primitive action, and it is shared by all pipelines whenever the primitive is executed, no matter which action it is executed from.
The source info we store here is related to the primitive action "call", and so it depends on the location of the actual call site. On primitive can be used many times in a given program.
Fortunately, there is a simple fix here. The field needs to be switched to a static thread_local
one. It is no different from how the pkt
and phv
fields are handled.
behavioral-model/include/bm/bm_sim/actions.h
Lines 641 to 648 in 8e183a3
I can take care of it a bit later, unless someone wants to beat me to it.
from behavioral-model.
Sorry, I got a bit confused regarding which field you are referring to that needs to be switched to a static thread_local
from behavioral-model.
I included a code snippet in my post. It's the only field shown there that is not static thread_local
.
from behavioral-model.
I tried to change the field to a static thread_local SourceInfo *call_source_info
. I had issues with building and running my tests. Not entirely clear what's wrong.
error: undefined symbol: bm::ActionPrimitive_::call_source_info
>>> referenced by primitives.cpp
>>> blaze-out/k8-fastbuild/bin/third_party/p4lang_behavioral_model/_objs/bm_sim/primitives.pic.o:(bm::core::assert_::operator()(bm::Data const&))
>>> referenced by primitives.cpp
>>> blaze-out/k8-fastbuild/bin/third_party/p4lang_behavioral_model/_objs/bm_sim/primitives.pic.o:(bm::core::assume_::operator()(bm::Data const&))
>>> referenced by primitives.cpp
>>> blaze-out/k8-fastbuild/bin/third_party/p4lang_behavioral_model/_objs/bm_sim/primitives.pic.o:(bm::core::log_msg::operator()(std::__u::basic_string<char, std::__u::char_traits<char>, std::__u::allocator<char>> const&, std::__u::vector<bm::Data, std::__u::allocator<bm::Data>>))
>>> referenced 2 more times
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I see that there are references to call_source_info
inside other files like primitives.cpp from a quick search, not particularly sure if these get affected or not.
from behavioral-model.
Did you define the static field in actions.cpp as well?
behavioral-model/src/bm_sim/actions.cpp
Lines 481 to 482 in 8e183a3
from behavioral-model.
Related Issues (20)
- TCP packets seem not to be processed correctly by bmv2 HOT 2
- Problem using multicast in runtime HOT 2
- Empty action-parameter vector is always accessed in ActionFnEntry::execute HOT 7
- How to build behavioral-model on the MacOS(Apple M1 Pro(13.5)) HOT 2
- How to track fileds of metadata with p4dbg? HOT 2
- Approximate conversion of bmv2 p4 performance to hardware performance HOT 3
- Applying the same table twice HOT 2
- Required to set forwarding pipeline before using the dataplane for streaming packets HOT 10
- Update project to require C++17 HOT 9
- Race conditions when passing in a BMv2 JSON config HOT 12
- To Add PNA support into BMv2. HOT 5
- How to build simple_switch / simple_switch_grpc on Ubuntu 24.04 ? HOT 4
- Why bmi_port.c is a C code? HOT 2
- Heap Buffer Overflow when installing many table entries HOT 1
- CMake support HOT 4
- Queue metadata with multiqueue HOT 2
- Where is the original p4 source code for recirc.json HOT 8
- Consider implementing something like Tuple Space Search for ternary table lookups
- set queue rate/depth commands with priority queues HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from behavioral-model.