Skip to content
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

encoding, core: Add find_watchpoint() and encoding #6

Merged
merged 1 commit into from
Jun 13, 2022

Conversation

linD026
Copy link
Owner

@linD026 linD026 commented Jun 6, 2022

Add the implementation of find_watchpoint().

Since the 64-bit architecture, the virtual address only uses the least
57 bit. So we can let the watchpoint store the information, like
operation type and object size, on the 64 to 57 bit.

Signed-off-by: Chih-En Lin shiyn.lin@gmail.com

@linD026 linD026 requested a review from ziyuan1135 June 6, 2022 17:32
@linD026
Copy link
Owner Author

linD026 commented Jun 6, 2022

@ziyuan1135
Please check if the patch does not conflict with your thought.

@linD026 linD026 changed the title encoding, core: Add findwatchpoint() and encoding encoding, core: Add find_watchpoint() and encoding Jun 6, 2022
@linD026 linD026 mentioned this pull request Jun 6, 2022
@linD026 linD026 force-pushed the dev-findwatchpoint branch 2 times, most recently from 8c30ed8 to 427f9fb Compare June 7, 2022 01:38
@linD026
Copy link
Owner Author

linD026 commented Jun 8, 2022

@ziyuan1135
Could you please help me check this PR?

Add the implementation of find_watchpoint().

Since the 64-bit architecture, the virtual address only uses the least
57 bit. So we can let the watchpoint store the information, like
operation type and object size, on the 64 to 57 bit.

Signed-off-by: Chih-En Lin <shiyn.lin@gmail.com>
@linD026
Copy link
Owner Author

linD026 commented Jun 12, 2022

watchpoints(array)裡面存的應該是mem. address,element type為atomic long(64bits) 所以應該是watchpoint = watchpoints[slot + i]就好了?

If we want to get the value at this line, we need to use the atomic read.
like:

v = atomic_read(&watchpoints[slot + i]);

Then, determine whether the value is registered or not by direct access.

if (v & SOME_FLAGS)
    do_something();

But, we cannot promise that the value we read is synchronous with the corresponding value in the watchpoints array.

For example, thread B register after thread A get the value but doesn't check yet.

// thread A
v = atomic_read(&watchpoints[slot + i]);

// thread B
atomic_set((&watchpoints[slot + i], 1);

// thread A
// non-synchronous here
if (v & SOME_FLAGS)
    do_something();

It needs to handle more corner cases when we use this method.

不應該是拿watchpoints(array)這個mem. address嗎? 即watchpoint = &watchpoints[slot + i] 如果有理解錯,再跟我說一下,感謝

So, at this point, we will first get the address of the index of watchpoints array, and use the
atomic RMW operation to access it.
And that is why we first get the address here.

@linD026
Copy link
Owner Author

linD026 commented Jun 12, 2022

我剛剛的問題是在[bd693d1]這邊。程式碼的部分:core.c第78行 這邊想問,這個find_watchpoint func.是可以直接用的嗎? 還是我需要在加東西

You can directly use it.
It doesn't need to add anything if you only want to find the watchpoint that is registered or not.

@linD026
Copy link
Owner Author

linD026 commented Jun 13, 2022

It seems like the PR doesn't conflict with your mind.

@linD026 linD026 merged commit d7b056f into main Jun 13, 2022
@linD026 linD026 deleted the dev-findwatchpoint branch June 13, 2022 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants