On Tue, Dec 20, 2022 at 09:26:05PM +0500, Muhammad Usama Anjum wrote: ... > > +static inline int nsdr_adjust_new_first(struct vm_area_struct *new, struct vm_area_struct *vma) > +{ > + struct non_sd_reg *r, *r_tmp, *reg; > + unsigned long mid = vma->vm_start; > + > + list_for_each_entry_safe(r, r_tmp, &vma->non_sd_reg, nsdr_head) { > + if (r->start < mid && r->end > mid) { > + reg = kmalloc(sizeof(struct non_sd_reg), GFP_KERNEL); > + if (!reg) > + return -ENOMEM; > + reg->start = r->start; > + reg->end = mid; > + list_add_tail(®->nsdr_head, &new->non_sd_reg); > + > + r->start = mid; > + } else if (r->end <= mid) { > + list_move_tail(&r->nsdr_head, &new->non_sd_reg); > + } > + } > + return 0; > +} Hi Muhhamad, really sorry for delay. Please enlighten me here if I get your idea right -- every new VMA merge might create a new non_sd_seg entry, right? And this operation will be applied again and again until vma get freed. IOW we gonna have a chain of non_sd_reg which will be hanging around until VMA get freed, right?