Why is KMP preprocessing O(N)?
Each len_ = lps[len - 1] decreases $lps$ by at least 1, thus, it can only happen for lps[i - 1] + 1 - lps[i] times, since you initialize lps[i] as lps[i - 1] + 1. Therefore, the maximum number of times len_ = lps[len - 1] can happen is $\displaystyle \sum_{i=1}^n (lps[i - 1] + 1) - lps[i]$. As you know, $lps$ can increase by at most $n$ in total, therefore, it can decrease by at most $n$ in total, since $lps$ can never be negative, or equivalently, for each $+1$ $lps$ gets, it can get at most one $-1$. thus $\displaystyle \sum_{i=1}^n (lps[i - 1] + 1) - lps[i]$ will be $O(n)$.
I hope my answer was helpful.