-
Notifications
You must be signed in to change notification settings - Fork 49
rust : Add RROS_SPINLOCK flag and adjust spinlock initialization for new constructor #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v6.6.y-rros-rebase
Are you sure you want to change the base?
Changes from 11 commits
d897f9a
aa2df1d
3c18d74
27d9d77
78397e2
ce619a1
9e1871f
b9728a4
220446e
d6369f7
37a4295
aaff261
e68dfdb
384acdf
47abfa2
8e2e824
fcfe82e
4884575
d6005dd
b2921b7
63377a2
8154918
85bac65
b27d418
ec59aa3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
config RROS_SPINLOCK | ||
bool "Enable RROS Spinlock" | ||
depends on RROS | ||
help | ||
Enable spinlock functionality for RROS. This option provides a | ||
specialized spinlock mechanism designed for the Rust Real-time Core. | ||
|
||
Note: This option is experimental and should only be enabled if | ||
you understand the implications on system performance. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,7 @@ use kernel::{ | |
ktime::{self, timespec64_to_ktime, Timespec64}, | ||
linked_list::{GetLinks, Links, List}, | ||
prelude::*, | ||
rbtree, spinlock_init, | ||
rbtree, new_spinlock, | ||
str::CStr, | ||
sync::Lock, | ||
sync::SpinLock, | ||
|
@@ -67,7 +67,7 @@ pub const RROS_POLIOC_WAIT: u32 = kernel::ioctl::_IOWR::<(i64, i64, i64)>(RROS_P | |
pub struct RrosPollGroup { | ||
pub item_index: rbtree::RBTree<u32, Arc<RrosPollItem>>, | ||
pub item_list: List<Arc<RrosPollItem>>, | ||
pub waiter_list: SpinLock<List<Arc<RrosPollWaiter>>>, | ||
pub waiter_list: Pin<Box<SpinLock<List<Arc<RrosPollWaiter>>>>>, | ||
pub rfile: RrosFile, | ||
// pub item_lock: mutex::RrosKMutex, | ||
pub nr_items: i32, | ||
|
@@ -79,7 +79,7 @@ impl RrosPollGroup { | |
Self { | ||
item_index: rbtree::RBTree::new(), | ||
item_list: List::new(), | ||
waiter_list: unsafe { SpinLock::new(List::new()) }, | ||
waiter_list: Box::pin_init(new_spinlock!(List::new(),"RrosPollGroup::waiter_list")), | ||
rfile: RrosFile::new(), | ||
// item_lock: mutex::RrosKMutex::new(), | ||
nr_items: 0, | ||
|
@@ -88,8 +88,8 @@ impl RrosPollGroup { | |
} | ||
|
||
pub fn init(&mut self) { | ||
let pinned = unsafe { Pin::new_unchecked(&mut self.waiter_list) }; | ||
spinlock_init!(pinned, "RrosPollGroup::waiter_list"); | ||
// let pinned = unsafe { Pin::new_unchecked(&mut self.waiter_list) }; | ||
// spinlock_init!(pinned, "RrosPollGroup::waiter_list"); | ||
//FIXME: init kmutex fail | ||
// rros_init_kmutex(&mut item_lock as *mut RrosKMutex); | ||
} | ||
|
@@ -155,22 +155,22 @@ impl RrosPollWaiter { | |
} | ||
|
||
pub struct RrosPollHead { | ||
pub watchpoints: SpinLock<list_head>, | ||
pub watchpoints: Pin<Box<SpinLock<list_head>>>, | ||
} | ||
|
||
impl RrosPollHead { | ||
pub fn new() -> Self { | ||
Self { | ||
watchpoints: unsafe { SpinLock::new(list_head::default()) }, | ||
watchpoints: Box::pin_init(new_spinlock!(list_head::default(),"RrosPollHead")).unwrap() , | ||
} | ||
} | ||
|
||
pub fn init(&mut self) { | ||
init_list_head!(self.watchpoints.locked_data().get()); | ||
spinlock_init!( | ||
unsafe { Pin::new_unchecked(&mut self.watchpoints) }, | ||
"RrosPollHead" | ||
); | ||
// spinlock_init!( | ||
// unsafe { Pin::new_unchecked(&mut self.watchpoints) }, | ||
// "RrosPollHead" | ||
// ); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @shannmu There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good for me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
pub struct RrosPollConnector { | ||
|
@@ -1123,28 +1123,30 @@ impl FileOperations for PollOps { | |
} | ||
} | ||
|
||
pub static mut RROS_POLL_FACTORY: SpinLock<factory::RrosFactory> = unsafe { | ||
SpinLock::new(factory::RrosFactory { | ||
name: CStr::from_bytes_with_nul_unchecked("poll\0".as_bytes()), | ||
// fops: Some(&Pollops), | ||
nrdev: 0, | ||
build: None, | ||
dispose: None, | ||
attrs: None, | ||
flags: factory::RrosFactoryType::SINGLE, | ||
inside: Some(factory::RrosFactoryInside { | ||
type_: DeviceType::new(), | ||
class: None, | ||
cdev: None, | ||
device: None, | ||
sub_rdev: None, | ||
kuid: None, | ||
kgid: None, | ||
minor_map: None, | ||
index: None, | ||
name_hash: None, | ||
hash_lock: None, | ||
register: None, | ||
}), | ||
}) | ||
pub static mut RROS_POLL_FACTORY: Pin<Box<SpinLock<factory::RrosFactory>>> = unsafe { | ||
Box::pin_init( | ||
new_spinlock!(factory::RrosFactory { | ||
name: CStr::from_bytes_with_nul_unchecked("poll\0".as_bytes()), | ||
// fops: Some(&Pollops), | ||
nrdev: 0, | ||
build: None, | ||
dispose: None, | ||
attrs: None, | ||
flags: factory::RrosFactoryType::SINGLE, | ||
inside: Some(factory::RrosFactoryInside { | ||
type_: DeviceType::new(), | ||
class: None, | ||
cdev: None, | ||
device: None, | ||
sub_rdev: None, | ||
kuid: None, | ||
kgid: None, | ||
minor_map: None, | ||
index: None, | ||
name_hash: None, | ||
hash_lock: None, | ||
register: None, | ||
}), | ||
}) | ||
).unwrap() | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @shannmu
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is good for me for now.
Box::pin_init
returns aResult
and usingunwrap
here is a temporary solution. I believe we need to address this problem later.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok