Isn't this the kind of problem that ECN is supposed to solve? Unless the buffers are very small compared to the port throughput, the upper layers should be able to handle it.
ECN purely allows the sending CCA to modulate sending rate before packet loss. Buffers filling up does not change, what changes is how early the sender reduces their window sizes and whether packet loss occurs before then.
The ECN bit can be flipped by routers but not switches. Layer 2 performance pathologies can’t be solved at layer 3.