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

Improve "sysnums" test (signal_pre_syscall.c). #7163

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

egrimley-arm
Copy link
Contributor

The test is rewritten to repeatedly adjust the timer so that it hits the critical section more often. On AArch64 without DEBUG the new test ran in about 0.5 s instead of about 15 s and hit the critical section about 400 times instead of about 1 time.

The test is rewritten to repeatedly adjust the timer so that it hits
the critical section more often. On AArch64 without DEBUG the new test
ran in about 0.5 s instead of about 15 s and hit the critical section
about 400 times instead of about 1 time.

Change-Id: I96b51e817b57dddaabf9ece193d333d78085f84c
@egrimley-arm egrimley-arm self-assigned this Dec 20, 2024
@abhinav92003 abhinav92003 requested review from abhinav92003 and removed request for derekbruening December 22, 2024 02:59
{
long seconds = 30;

/* Parse optional "seconds" argument. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it help to use a droption_t instead?

Edit: this seems to be unused actually.

syscall_wrapper();
syscall_wrapper(volatile int *);

static volatile int flag1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe call them flag_handler_src, flag_handler_dst, or something similar.

* signal will never appear to have happened during the critical block.
*/
int
try(timer_t timer, unsigned long long ns)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/ns/timer_duration_ns/

if (unchanged_results < 5)
step = step / 2 > 0 ? step / 2 : step;
else
step = step * 2 > 0 ? step * 2 : step;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this just be step *= 2? Though I see we strive to ensure step is never zero, but: if step*2 is zero, step must be zero too, so same outcome.

{
uint64_t time = 10000000;
/* Stop trying if the signal arrived during the critical block.
* This never happens (or seems never to happen) under DynamoRIO.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add an assert result !=0 || !dr_app_running_under_dynamorio()?

for (int i = 0; i < 1000; ++i)
syscall_wrapper();
}
unsigned long long ns = 1024; /* arbitrary initial value */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/ns/timer_duration_ns/

time -= i * 100000;
/* Adjust ns for next try. */
if (result < 0)
ns = ns + step > ns ? ns + step : (unsigned long long)-1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would ns + step > ns be false? I thought we try that step always stays positive?

fdiv v10.2d, v11.2d, v12.2d
fdiv v10.2d, v11.2d, v12.2d
fdiv v10.2d, v11.2d, v12.2d
fdiv v0.2d, v0.2d, v1.2d
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why this sequence of fdiv needed to be changed. Does it matter to the test what regs are used with the fdiv?

/* Return -1 if the signal happened before the critical block, 0 if it
* happened during the critical block, or 1 if it happened after the
* critical block or the timer was cancelled. Under DynamoRIO the
* signal will never appear to have happened during the critical block.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add to the comment that this is because we delay async signals to the end of the block

@@ -1,6 +1,6 @@
/* **********************************************************
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and hit the critical section about 400 times instead of about 1 time.

Optional: Curious if we tested this on x86?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants