-
Notifications
You must be signed in to change notification settings - Fork 623
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
base: criu-dev
Are you sure you want to change the base?
Conversation
criu/mount.c
Outdated
void mntinfo_add_list_before(struct mount_info **head, struct mount_info *new) | ||
{ | ||
new->next = *head; | ||
if(!*head) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls use tab indents.
@@ -90,6 +90,7 @@ struct mount_info { | |||
int deleted_level; | |||
struct list_head deleted_list; | |||
struct mount_info *next; | |||
struct mount_info *tail; |
There was a problem hiding this comment.
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.
criu/mount.c
Outdated
@@ -1959,7 +1959,7 @@ static int dump_mnt_ns(struct ns_id *ns, struct mount_info *pms) | |||
_mi = list_entry(_mi->children._el, struct mount_info, siblings); \ | |||
continue; \ | |||
} \ | |||
up: \ | |||
up: \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should not change unrelated code...
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).