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

perf optimization on filestat in file.c #308

Open
mallicksm opened this issue Jan 30, 2025 · 0 comments
Open

perf optimization on filestat in file.c #308

mallicksm opened this issue Jan 30, 2025 · 0 comments

Comments

@mallicksm
Copy link

Summary:
Optimize stati() by replacing sleeplock (ilock()) with a spinlock for fast metadata access, avoiding unnecessary context switches.

Description:
Currently, stati() uses ilock(), which is a sleeplock, to prevent concurrent modifications when copying inode metadata. However, stati() is a quick read-only operation that only copies a few fields from struct inode to struct stat. Using a sleeplock is overkill and causes unnecessary thread rescheduling if the lock is already held.

Proposed Fix:
• Add a spinlock (inode_lock) to struct inode.
• Use this spinlock in stati() instead of ilock(), ensuring atomicity without costly context switches.
• Keep ilock() for long-duration operations like readi() and writei() that require sleeping.

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

No branches or pull requests

1 participant