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

optimize: added a tail pointer in mntinfo_add_list #2593

Open
wants to merge 3 commits into
base: criu-dev
Choose a base branch
from

Conversation

ankushT369
Copy link

The mntinfo_add_list function previously traversed the entire linked list to find the tail node, resulting in a time complexity of O(n). This commit introduces a mntinfo_tail pointer to track the last node of the list, reducing the time complexity of insertion to O(1).

criu/mount.c Outdated Show resolved Hide resolved
@@ -90,6 +90,7 @@ struct mount_info {
int deleted_level;
struct list_head deleted_list;
struct mount_info *next;
struct mount_info *tail;
Copy link
Member

Choose a reason for hiding this comment

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

I think it is better to user the list_head structure here.

Copy link
Author

@ankushT369 ankushT369 Feb 8, 2025

Choose a reason for hiding this comment

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

You mean instead of mount_info *tail should I make it list_head tail

criu/mount.c Outdated Show resolved Hide resolved
@ankushT369
Copy link
Author

ankushT369 commented Feb 8, 2025

@avagin What changes should I make to the code overall?

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.

2 participants