In glycolysis, 4 ATP are produced via substrate-level phosphorylation, but 2 ATP are consumed in the preparatory phase, resulting in a net gain of 2 ATP. The total of 8 ATP often refers to the total yield including NADH oxidation in aerobic conditions, but the question phrasing is slightly ambiguous regarding the 'total' vs 'net' distinction.