beat one's head against the wall
Also, bang or run one's head against or into a brick wall. Waste one's time in a hopeless enterprise, as in I have tried many times to convince him to stop smoking, but I'm beating my head against a brick wall. The metaphoric phrase alludes to a physical expression of frustration. [Late 1500s] Also see beat the air.