Let $\pi(x;q,a)$ count the number of primes $\leq x$ congruent to $a$ mod $q$. The Brun-Titchmarsh Theorem states that for all $q< x$, $(a,q)=1$, we have $$ \tag{1} \pi(x;q,a) \leq \frac{2x}{\varphi(q)\log(x/q)}. $$ Let $f(n) = 1$ if $n$ is prime and $0$ otherwise. Then we can rephrase $(1)$ as (almost) saying that $$ \tag{2} \sum_{\substack{n\leq x\\ n\equiv a (q)}} f(n) \leq \frac{2}{\varphi(q)} \sum_{\substack{n\leq x\\ (n,q)=1}} f(n). $$ I'm curious if inequalities like these have been studied for other arithmetic functions $f$. There is a vast literature proving asymptotic formulas, i.e. things like $$ \tag{3} \sum_{\substack{n\leq x\\ n\equiv a (q)}} f(n) \sim \frac{1}{\varphi(q)} \sum_{\substack{n\leq x\\ (n,q)=1}} f(n), $$ for various specific arithmetic functions (e.g. the divisor function or the indicator function of squarefree numbers or smooth numbers). However, I have not found much literature on inequalities like $(2)$. Thus my question:

**Are there any results that prove inequalities like $(2)$ for arithmetic functions other than the prime-indicator function?**

Any references and comments are most appreciated. Some thoughts and remarks about this general kind of problem:

- The fact that $(1)$ has $x/q$ instead of $x$ inside the $\log$ is not a mere technicality; it represents a deep barrier to improving the inequality. By analogy, inequalities like $(2)$ might only be provable in a slightly weaker form.
- Typically, one is more concerned with the range of validity and amount of uniformity of formulas of the type $(3)$, rather than the quality of the error terms (though these are certainly important as well). Given that the full conjectured range of validity and uniformity for formulas like $(3)$ are seldom known, inequalities like $(2)$ seem like an interesting avenue of research, as such inequalities (by analogy with $(1)$) may hold in wider ranges.
- My original motivation for this was thinking about smooth numbers in arithmetic progressions. In that case, the constant $2$ arises from thinking about what might happen if Vinogradov's conjecture on the least quadratic non-residue modulo a prime was false (basically, if $y$ is small enough, every $y$-smooth number is a quadratic residue, and these would (conjecturally) equidistribute in the $\varphi(p)/2$ available residue classes).
- Equidistribution results like $(3)$ often require complex/harmonic-analytic tools, such as the distribution of zeros of $L$-functions or estimates for Kloosterman sums (e.g. in the case of the divisor function). However, the Brun-Titchmarsh theorem (in its original form) uses only elementary sieve theory. If inequalities like $(2)$ can be proved without the use of such "heavy machinery," this would be another reason why they are interesting to study.