4. If the inequality
$$
\left|a x^{2}+b x+a\right| \leqslant x
$$

holds for all $x \in[1,2]$, then the maximum value of $3 a+b$ is
$\qquad$ .
4.3.
$$
\begin{array}{l}
\text { Given }\left|a x^{2}+b x+a\right| \leqslant x \\
\Rightarrow\left|a\left(x+\frac{1}{x}\right)+b\right| \leqslant 1,
\end{array}
$$

Given $x \in[1,2] \Rightarrow t=x+\frac{1}{x} \in\left[2, \frac{5}{2}\right]$.
Then $|2 a+b| \leqslant 1$, and $\left|\frac{5}{2} a+b\right| \leqslant 1$.
Thus $3 a+b=2\left(\frac{5}{2} a+b\right)-(2 a+b) \leqslant 3$, when $a=4, b=-9$, the equality holds.