Proof.

log⁡x⁢∑n≤xf⁢(n)=∑n≤xf⁢(n)⁢(log⁡x-log⁡n+log⁡n)=∑n≤xf⁢(n)⁢log⁡(xn)+∑n≤xf⁢(n)⁢log⁡n≤∑n≤xf⁢(n)⁢(xn)+∑n≤xf⁢(n)⁢∑pk∥nlog⁡(pk)≤x⁢∑n≤xf⁢(n)n+∑pk≤xlog⁡(pk)⁢∑n≤x and pk∥nf⁢(n)≤x⁢∑n≤xf⁢(n)n+∑pk≤xlog⁡(pk)⁢∑n≤x and pk∥nf⁢(pk)⁢f⁢(npk)≤x⁢∑n≤xf⁢(n)n+∑pk≤xlog⁡(pk)⁢∑m≤xpkf⁢(pk)⁢f⁢(m)≤x⁢∑n≤xf⁢(n)n+∑p≤xf⁢(p)⁢log⁡p⁢∑m≤xpf⁢(m)+∑p≤x∑k≥2f⁢(pk)⁢log⁡(pk)⁢xpk⁢∑m≤xpkf⁢(m)m≤x⁢∑n≤xf⁢(n)n+∑m≤xf⁢(m)⁢∑p≤xmf⁢(p)⁢log⁡p+x⁢∑m≤xf⁢(m)m⁢∑p≤x∑k≥2f⁢(pk)⁢log⁡(pk)pk≤x⁢∑n≤xf⁢(n)n+∑m≤xf⁢(m)⁢(A⁢xm)+x⁢∑m≤xf⁢(m)m⁢B≤x⁢∑n≤xf⁢(n)n+A⁢x⁢∑n≤xf⁢(n)n+B⁢x⁢∑n≤xf⁢(n)n≤(A+B+1)⁢x⁢∑n≤xf⁢(n)n

Dividing the inequalitylog⁡x⁢∑n≤xf⁢(n)≤(A+B+1)⁢x⁢∑n≤xf⁢(n)n by log⁡x yields the desired result.
∎

The theorem has an obvious corollary:

Corollary.

If f the conditions of the theorem, then for all x>1, ∑n≤xf⁢(n)=O⁢(xlog⁡x⁢∑n≤xf⁢(n)n).