In the book of Prigogine, Modern Thermodynamics, at page 113, it is given the example of an irreversible expansion of a gas.
In a reversible expansion of a gas, the pressure of the gas and that on the piston are assumed to be the same. If we consider an isothermal expansion of a gas that has a constant temperature $T$ by virtue of its contact with a heat reservoir, the change in entropy of the gas de $S=\mathrm{d} Q / T,$ in which dQ is the heat flow from the reservoir to the gas that is necessary to maintain the temperature constant. This is an ideal situation. In any real expansion of a gas that takes place in a finite time, the pressure of the gas is greater than that on the piston. If $p_{gas }$ is the pressure of the gas and that $p_{piston}$ the pressure on the piston, the difference $(p_{gas} - p_{piston})dV$ is the force per unit area that moves the piston. The irreversible increase in entropy in this case is given by $$ \mathrm{d}_{\mathrm{i}} S=\frac{p_{\mathrm{gas}}-p_{\mathrm{piston}}}{T} \mathrm{d} V>0 $$ In this case, the term ( $p_{\text {gas }}-p_{\text {piston }}$ ) /T corresponds to the 'thermodynamic force' and dV/dt the corresponding 'flow'. The term ( $p_{\text {pas }}-P_{\text {piston }}$ ) dV may be identified as the "uncompensated heat' of Clausius. since the change in the volume and $\left(p_{\text {gas }}-p_{\text {piton }}\right)$ have the same sign, di $S$ is always positive. In this case, $\mathrm{d} S=\mathrm{d}_{\mathrm{e}} S+$ $\mathrm{d}_{\mathrm{i}} S=\mathrm{d} Q / T+\left(p_{\mathrm{gas}}-\mathrm{p}_{\mathrm{piston}}\right) \mathrm{d} V / T .$ In the case of an ideal gas, since the energy is only a function of $T,$ the initial and final energies of the gas remain the same; the heat absorbed is equal to the work done in moving the piston $p_{piston}dV$.
However, the author does not give any explanation for how he figured out that the difference between $p_{gas}$ and $p_{piston}$ results in a irreversible process. In other words, I was given this question without the solution, how should I suppose to identify that there is a nonzero contribution to the entropy production coming from the work done by the pressure difference?