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

Spin lock deadlock detection #1670

Merged
merged 2 commits into from
Jul 15, 2017

Conversation

jenswi-linaro
Copy link
Contributor

No description provided.

{
unsigned int retries = 0;
unsigned int reminder = 0;
assert(thread_foreign_intr_disabled());
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: empty line before the assert.

unsigned int retries = 0;
unsigned int reminder = 0;

while (!cpu_spin_trylock(&pager_spinlock)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

! or not ! ?

Copy link
Contributor

@igoropaniuk igoropaniuk Jul 7, 2017

Choose a reason for hiding this comment

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

@etienne-lms

/* returns 0 on locking success, non zero on failure */
unsigned int __cpu_spin_trylock(unsigned int *lock);
....
static inline bool cpu_spin_trylock(unsigned int *lock)
{
	unsigned int rc;

	assert(thread_foreign_intr_disabled());
	rc = __cpu_spin_trylock(lock);
	if (!rc)
		spinlock_count_incr();
	return !rc;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't actually understand why cpu_spin_trylock() == !__cpu_spin_trylock(), which can throw into confusion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, it is confusing. It stems from strex returning 1 in <Rd> on failure and 0 on success and that __cpu_spin_trylock() tries to do the bare minimum.

The code here is correct though.

@jenswi-linaro
Copy link
Contributor Author

Review comment addressed

Copy link
Contributor

@igoropaniuk igoropaniuk left a comment

Choose a reason for hiding this comment

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

Reviewed-by: Igor Opaniuk <[email protected]>

Attempts to detect and report deadlock on spin locks..

Reviewed-by: Igor Opaniuk <[email protected]>
Signed-off-by: Jens Wiklander <[email protected]>
Adds more details to deadlock report inside pager.

Reviewed-by: Igor Opaniuk <[email protected]>
Tested-by: Jens Wiklander <[email protected]>
Signed-off-by: Jens Wiklander <[email protected]>
@jenswi-linaro
Copy link
Contributor Author

Tag applied

@jforissier jforissier merged commit 3078da8 into OP-TEE:master Jul 15, 2017
@jenswi-linaro jenswi-linaro deleted the spin_lock_deadlock branch July 17, 2017 06:45
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.

4 participants