add NOSHARE flag#336
Conversation
3fff47b to
46a783a
Compare
| if (!object->shared) | ||
| luaL_error(L, "%s objects cannot be shared across runtimes", object->class->name); |
There was a problem hiding this comment.
it's not enough, right? we probably need to add single flag to the API for creating new objects..
There was a problem hiding this comment.
also, avoiding creating mutex/spinlock and refcount unnecessarily..
| union { | ||
| struct mutex mutex; | ||
| spinlock_t spin; | ||
| }; |
There was a problem hiding this comment.
maybe we should have a substruct allocated dynamically for kref and lock.. but let's worry about this after having the first version settled..
| #define lunatik_class_issleepable(cls) ((cls)->sleep) | ||
|
|
||
| #define lunatik_locker(o, mutex_op, spin_op) \ | ||
| do { \ |
There was a problem hiding this comment.
it should check if it's single, right? it should lock in that case.. also, refcount shouldn't be applied if single
|
This version lunatik driver is working properly... |
| static inline int lunatik_trylock(lunatik_object_t *object) | ||
| { | ||
| return object->sleep ? mutex_trylock(&object->mutex) : spin_trylock_bh(&object->spin); | ||
| return object->single ? 1 : lunatik_object_issleepable(object) ? mutex_trylock(&object->mutex) : spin_trylock_bh(&object->spin); |
There was a problem hiding this comment.
why should we return 1 if single? what's the use case?
| object->gfp = sleep ? GFP_KERNEL : GFP_ATOMIC; | ||
| lunatik_newlock(object); | ||
| if(!single) | ||
| lunatik_newlock(object); |
There was a problem hiding this comment.
we don't need refcount as well, right?
| lunatik_object_t *object = lunatik_newobject(L, &luadata_class, sizeof(luadata_t)); | ||
| luadata_t *data = (luadata_t *)object->private; | ||
|
|
||
| object->single = single; |
There was a problem hiding this comment.
doing this after the object creation won't avoid the lock init
There was a problem hiding this comment.
Wanted to know if im going in correct direction for creating objects:here
I didnt update the function here yet... Will do update this.. (the line is just redundancy as of now, will remove)
|
Hi |
Agreed; also, this will be useful for other objects as well, I think |
|
hi @Physic69, I'm thinking that it would be better for me to tackle this issue if it's cool for you. I think I will need diff exec modes for bottom halves and irqs, I could bundle single mode on this change or at least create the flag (for implementing the decision later). Is it alright for you? Then, you could tackle another issue ;-). Thanks. |
Sure, that’s totally fine 👍... |
No description provided.