-
Notifications
You must be signed in to change notification settings - Fork 13
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
[Sub-issue of #378] Add PinnedKernel
, and use Pin
in locks, MruArena
, and MruEntry
#394
Conversation
Lines 118 to 124 in 6fd7edc
추가로, @Medowhill 님께서 여기에 TODO를 남기셨는데, " ptr is a valid pointer to MruEntry<T> " 정도로만 추가해도 될까요? 아니면 ArrayPtr 처럼 lifetime을 추가하실 계획이시거나 다른 PR에서 작업하실 계획이신가요?
|
|
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.
pin_project
가 사용된 부분에서는 rust analyzer가 타입을 못 알아내서 다소 불편하네요... 다른 분들도 같은 문제가 있나요?
문제가 잘 해결이 안 되는것 같네요...
조금 더 실험을 해보겠습니다만, 계속 안되면 편의를 위해 차라리 getter 함수들을 일일이 다 만드는게 나을지 고민해봐야 할 것 같습니다. (다만, 이러면 쓸데없는 unsafe가 많이 생깁니다.) |
|
Pin
in Spinlock
, MruArena
, and MruEntry
Pin
in locks, MruArena
, and MruEntry
@@ -453,6 +453,7 @@ impl Deref for ProcGuard { | |||
} | |||
} | |||
|
|||
// TODO(travis1829): Change &mut Target -> Pin<&mut Target> |
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.
이 PR에서 되어야하지 않을까 생각합니다.
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.
현재 손서윤님께서 하고계신 PR이랑 겹치는 내용이 많을것 같아 보류하였습니다. 특히, PR #385 가 끝나고 나면 Proc
의 내부를 접근하는 방법이 조금 바뀔 것 같아서 일단은 TODO로만 표시했습니다.
|
/// If `T: !Unpin`, `Spinlock` or `SpinlockGuard` will only provide pinned mutable references | ||
/// of the inner data to the outside. However, it is still the caller's responsibility to | ||
/// make sure that the `Spinlock` itself never gets moved. | ||
pub const unsafe fn new_unchecked(name: &'static str, data: T) -> Self { |
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.
Sleeplock
과 Sleepablelock
도 동일한 설명이 들어가야 하지 않나요?
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.
#394 (comment)
맞습니다! 위 comment에 제 생각을 적어놨습니다. (두번째 부분)
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.
아 그렇네요. 죄송합니다. 저는 Lock
trait을 추가하는 것도 좋아 보입니다.
|
최종적으로는 |
이 부분은 TODO로 표시해두면 될 것 같습니다. |
실험적으로, 이걸 지금 미리 해봤습니다. (다만, *lock들의 API들은 아직은 그대로 놔뒀습니다.)
@Medowhill 혹시 어떻게 생각하시는지 말씀해주실 수 있으신가요? EDIT: 다만, |
정리해 보면 2가지 방법이 있는 것이 맞나요?
2가 좀 더 좋지 않을까 하는데, 2를 해보고 나면 그 쪽이 더 복잡해서 1이 나아 보일 수도 있을 것 같습니다. 둘 다 해 보고 결정하는 것이 좋아 보이지만, 지금 PR에서는 1로 해 두고 이후에 2를 시도해 본 뒤 괜찮으면 merge하고 별로면 그대로 두는 식으로 하는 것이 어떨까요? |
#394 (comment)
|
조금 첨언을 하자면, 어차피 |
|
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.
수고하셨습니다~
감사합니다!
|
Pin
in locks, MruArena
, and MruEntry
PinnedKernel
, and use Pin
in locks, MruArena
, and MruEntry
bors r+ |
Build succeeded: |
Partially resolves # 378.
T: Unpin
인 경우에만 (즉,T
가 move되어도 상관없는 경우에만)Spinlock
,SpinlockGuard
와 같은 lock 및 guard들이get_mut()
,get_mut_unchecked()
,DerefMut
을 impl하도록 바꿨습니다. 그 대신,get_pin()
을 추가했습니다.ListEntry
API가Pin
을 사용하게끔 바꿨습니다.MruArena
,MruEntry
에서 mutable reference가 필요할 때는 항상Pin<&mut ...>
을 사용하게끔 바꿨습니다.Pin
으로만 접근하도록 제한했습니다. 다만 pin_project가 procedural macro를 사용해서인지 dependency를 약 10개나 늘려버립니다. 참고로, procedural macro를 쓰지 않는 pin_project_lite도 있기는 한데 이건 기능이 제한적입니다.EDIT:
Pin
의 안전성을 깔끔하게 보장하기 위해서PinnedKernel
이라는 struct 및 static 변수를 추가했습니다. 지금은BcacheInner
만 들어있지만 추후Pin
이 필요한 struct들을Kernel
에서 여기로 옮길 계획입니다.PinnedKernel
, and usePin
in locks,MruArena
, andMruEntry
#394 (comment)