On Wed, Jun 05, 2024 at 02:54:54PM +0530, Kundan Kumar wrote: > + /* > + * Check if pages are contiguous and belong to the > + * same folio. > + */ Oh, a useful comment here would be *why* we do this, not *what* we do. /* * We might COW a single page in the middle of * a large folio, so we have to check that all * pages belong to the same folio. */ for example. > + for (j = i + 1; j < i + num_pages; j++) { > + size_t next = min_t(size_t, PAGE_SIZE, bytes); > + > + if (page_folio(pages[j]) != folio || > + pages[j] != pages[j - 1] + 1) { > + break; > + } > + contig_sz += next; > + bytes -= next; > + } > + num_pages = j - i; > + len = contig_sz; > + }