\(\Delta=\left(m+1\right)^2-4\left(m^2-2m+2\right)=-3m^2+10m-7\ge0\)
\(\Rightarrow1\le m\le\dfrac{7}{3}\)
\(\left\{{}\begin{matrix}x_1+x_2=m+1\\x_1x_2=m^2-2m+2\end{matrix}\right.\)
\(P=\left(x_1+x_2\right)^2-2x_1x_2\)
\(=\left(m+1\right)^2-2\left(m^2-2m+2\right)\)
\(=-m^2+6m-3\)
\(=\left(-m^2+6m-\dfrac{77}{9}\right)+\dfrac{50}{9}\)
\(=\left(\dfrac{11}{3}-m\right)\left(m-\dfrac{7}{3}\right)+\dfrac{50}{9}\le\dfrac{50}{9}\)
\(P_{max}=\dfrac{50}{9}\) khi \(m=\dfrac{7}{3}\)