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

CA-407313: Replace semaphore & spinlock with rwlock #26

Merged
merged 6 commits into from
Mar 5, 2025

Conversation

GeraldEV
Copy link
Collaborator

@GeraldEV GeraldEV commented Mar 4, 2025

rwlock decreases the amount of blocking for logging by separating the
locking for logging to thread safe stdio versus thread unsafe
operations such as reopening files.

Use flockfile/funlockfile to ensure contiguous log messages where
needed.

Signed-off-by: Gerald Elder-Vass gerald.elder-vass@cloud.com

Tested on a pool which previously had HA enabled; disabled HA, updated xha, re-enabled HA and monitored the pool for a while (and some operations to spark some logging)

Gerald Elder-Vass added 2 commits March 4, 2025 19:17
rwlock decreases the amount of blocking for logging by separating the
locking for logging to thread safe stdio versus thread unsafe
operations such as reopening files.

Use flockfile/funlockfile to ensure contiguous log messages where
needed.

Signed-off-by: Gerald Elder-Vass <gerald.elder-vass@cloud.com>
Signed-off-by: Gerald Elder-Vass <gerald.elder-vass@cloud.com>
don't hold the rwlock during syslogging (except for the wrlock during
reopen)
release the lock before syslogging

Signed-off-by: Gerald Elder-Vass <gerald.elder-vass@cloud.com>
@GeraldEV GeraldEV requested a review from alexbrett March 4, 2025 19:40
pthread_spin_destroy(&lock);
#endif
pthread_rwlock_unlock(&lock);
pthread_rwlock_destroy(&lock);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I haven't checked the order of cleanup/termination, but destroying the lock can be problematic if other threads try to use it afterwards. I realized that the previous code did this too...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll investigate the clean up order to determine if this can safely be destroyed here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

log_terminate is used once when the threads haven't been setup yet (e.g. if a license check fails), and again after the clean up once each of the threads have been terminated
Therefore destroying the lock during log_terminate is safe

Gerald Elder-Vass added 2 commits March 4, 2025 19:58
Signed-off-by: Gerald Elder-Vass <gerald.elder-vass@cloud.com>
Signed-off-by: Gerald Elder-Vass <gerald.elder-vass@cloud.com>
//

va_start(ap, fmt);
vfprintf(fpLogfile, fmt, ap);

Check warning

Code scanning / CodeChecker

the value returned by this function should not be disregarded; neglecting it may lead to errors Warning

the value returned by this function should not be disregarded; neglecting it may lead to errors
//

va_start(ap, fmt);
vfprintf(fpLogfile, fmt, ap);

Check warning

Code scanning / CodeChecker

format string is not a string literal Warning

format string is not a string literal

for (; col < MAX_COL; col++)
{
fprintf(fpLogfile, " ");

Check warning

Code scanning / CodeChecker

the value returned by this function should not be disregarded; neglecting it may lead to errors Warning

the value returned by this function should not be disregarded; neglecting it may lead to errors
fprintf(fpLogfile, " ");
}

fprintf(fpLogfile, ": %s\n", asc_dmp);

Check warning

Code scanning / CodeChecker

the value returned by this function should not be disregarded; neglecting it may lead to errors Warning

the value returned by this function should not be disregarded; neglecting it may lead to errors
@GeraldEV GeraldEV merged commit 05f5ea2 into xenserver:master Mar 5, 2025
4 checks passed
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.

3 participants