Is it safe to take ibuprofen everyday for cavity tooth pain?

Me

i been taking ibuprofen every night for my tooth cavity pain. i go back to the dentist next Wednesday to finish my teeth cleaning since they are letting my gums heal since they were puffy and swollen. my dentist prescribed me some medicated mouthwash which i use twice a day. I have brush my teeth woth two types of sensitive toothpaste to help with the pain that comes and goes but it lingers too. i am wondering if its okay to take ibuprofen every day for pain? my cavity pain makes me not sleep well at night but the cavity isnt in where the nerve is just yet, just the chamber part they said. dentist also said gums can cause this too!! i just wish i could get some sleep soon!!