How to find a gap in knowledge, for my PhD?
Ask the advisor.
If he/she is helpful, follow their advice.
If he/she is not helpful, either
change the advisor (which is preferred) or else
find an interesting and open problem in your field (in some areas such as mathematics, searching for "open problem" or similar in recent publications, including literature reviews, might help). The problem should be such that that you should be able to solve it within the time allocated for your PhD studies, including writing your dissertation. Then, ask the advisor again whether the problem is suitable for your thesis. How to proceed from there would be a different question.
I would not suggest starting by looking for gaps at all for a few reasons.
Some gaps are left gaps for a reason. Some are not relevant enough to be bothered with, some have not enough data to work with, some lack technology to work with. In any case, even if you find a gap, the follow up question will be why do you want to spend time and resources trying to fill in that gap? That is a pretty hard question to answer.
Instead, try to start by finding a problem. Look for a problem that is relevant, that is worth solving, that is even conceptually solvable. And the most important thing, look for a problem that you are passionate about because you are about to spend a good chunk of your life trying to solve it and will probably fail for the most part. So every bit of success you have should be meaningful for you and for others who are affected by this problem.
Once you found the problem you want to help solve, then you can look for gaps within that narrow area. That should be a piece of cake because chances are you will bump right into them and later find yourself surrounded by them.
As someone coming out the other side, I'm not going to give you two answers. The easy answer is to just ask your advisor and have them give you a project. I've seen plenty of people try this and the problem is that if it doesn't really grab your interest then grad school will be a grueling frustrating boring experience.
The alternative is the far better solution, at least in my opinion. That is simply, don't look for it. As counter-intuitive as that sounds. Most programs don't expect you to have your project figured out the first semester or even the first year in many cases. Take that time to really dig into the parts of your field that interest you. Really dig deep and learn all you can learn. As you learn you'll have questions. If you're doing it right, they'll be the kind of questions that keep you up at night. You really need those answers to satisfy your mind. Go look for those answers. When you come to the question that is vexing you and you can't find the answer and nobody around knows where it is, then you've found your gap in the knowledge. Only this time it will consume your mind and you will be able to think of nothing else. And grad school will feel like this beautiful opportunity to have all of these resources behind you while you try to answer your question. It will almost be fun. It will be rewarding. And it will keep your interest. And when you get done, you won't just have the degree, but you'll also have all the other stuff that can come with it when you really do it right.