Comments (6)
I don't completely agree. ToUserDevice::cleanup() is trying to spin until no one is waiting for it (see the _exit boolean and the loop). That might be insufficient/incorrect, but I think something simpler is missing. cleanup() should walk over elem_map[] and set all entries that equal this
to null instead. Then when a user program calls back into the device they'll exit immediately.
from click.
What if we're in the middle of ToUserDevice::dev_read when /dev/config is written?
I guess it doesn't matter why the Element
is being destroyed (so /dev/config is incidental to the problem) but _lock
is not held around all places where elem
should be valid and since it is a member we get into trouble if elem
is destroyed in the meantime.
Since _proc_queue
and _lock
are members, using them is problematic to begin with. Perhaps all that is needed here is a global lock that controls access to elem_map
and an atomic ref count on TUDs that indicates whether cleanup
can go forward.
SMP version of the issue:
CPU0
ToUserDevice::dev_read
ToUserDevice *elem = GETELEM(filp); // valid here
// _lock is not held and we are not in _proc_queue
CPU1
ToUserDevice::cleanup
elem_map[_dev_minor] = 0;
...
~ToUserDevice
CPU0
elem->_read_count++; // crash!
from click.
If we;'re in the middle of dev_read then we should have the lock. That's
why the destructor for ToUD should acquire the lock...
On Wed, Apr 30, 2014 at 12:19 PM, pallas [email protected] wrote:
What if we're in the middle of ToUserDevice::dev_read when /dev/config is
written?I guess it doesn't matter why the Element is being destroyed (so
/dev/config is incidental to the problem) but _lock is not held around
all places where elem should be valid and since it is a member we get
into trouble if elem is destroyed in the meantime.Since _proc_queue and _lock are members, using them is problematic to
begin with. Perhaps all that is needed here is a global lock that controls
access to elem_map and an atomic ref count on TUDs that indicates whether
cleanup can go forward.SMP version of the issue:
CPU0
ToUserDevice::dev_read
ToUserDevice *elem = GETELEM(filp); // valid here
// _lock is not held and we are not in _proc_queueCPU1
ToUserDevice::cleanup
elem_map[_dev_minor] = 0;
...
~ToUserDeviceCPU0
elem->_read_count++; // crash!—
Reply to this email directly or view it on GitHubhttps://github.com//issues/123#issuecomment-41816870
.
from click.
Sorry, I ahve a deadline so take my effluvia as weak. But there is
definitely a way to solve this problem with locks, perhaps involving
rw-locks around the device map (GETELEM).
On Wed, Apr 30, 2014 at 12:20 PM, Eddie Kohler [email protected] wrote:
If we;'re in the middle of dev_read then we should have the lock. That's
why the destructor for ToUD should acquire the lock...On Wed, Apr 30, 2014 at 12:19 PM, pallas [email protected] wrote:
What if we're in the middle of ToUserDevice::dev_read when /dev/config is
written?I guess it doesn't matter why the Element is being destroyed (so
/dev/config is incidental to the problem) but _lock is not held around
all places where elem should be valid and since it is a member we get
into trouble if elem is destroyed in the meantime.Since _proc_queue and _lock are members, using them is problematic to
begin with. Perhaps all that is needed here is a global lock that controls
access to elem_map and an atomic ref count on TUDs that indicates
whether cleanup can go forward.SMP version of the issue:
CPU0
ToUserDevice::dev_read
ToUserDevice *elem = GETELEM(filp); // valid here
// _lock is not held and we are not in _proc_queueCPU1
ToUserDevice::cleanup
elem_map[_dev_minor] = 0;
...
~ToUserDeviceCPU0
elem->_read_count++; // crash!—
Reply to this email directly or view it on GitHubhttps://github.com//issues/123#issuecomment-41816870
.
from click.
So I have good newses and bad news. The bad news is that I verified that this is actually a problem. The good news is that it is very rare and I have a patch, which I'll prepare for pull soon. The other good news is that the more frequent problem was a local change to replace register_chrdev
& friends with cdev_init
& friends, since the former is deprecated, and I can turn that into a mainline pull as well if you're interested.
from click.
I would love to see cdev_init as a patch, fwiw.
from click.
Related Issues (20)
- multiple queue for one device HOT 3
- Unit test for Elements HOT 2
- How to build a dependencies files HOT 2
- Add library to click HOT 2
- issue with adding library HOT 3
- chaning .click file dynamicly HOT 4
- Run multiple instanse of click with same DPDK HOT 3
- Sync with meson in DPDK HOT 2
- compilation error on Ubuntu 21.04 (g++ 11.1) HOT 9
- firewall implementation and traffic forwarding HOT 4
- Flow based Load Balancer HOT 7
- create handler HOT 2
- Benchmarking a click NF showing weird behavior
- Multi threading in click HOT 2
- Make minios fails on Ubuntu 20.04 error: no include path in which to search for stdint.h
- linux_true was not declared HOT 1
- Hash collisions in IPRewriter? HOT 2
- Click program with DPDK cause high CPU utilization on other cores even if using taskset and lcore option HOT 1
- VXLAN elements
- element "IPReassembled" how to use?
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 click.