During some brain surgeries you are asleep and some brain surgeries you are awake.
But even when you're awake during the brain surgery you cannot feel any pain because the brain surgeon will use an anesthetic to stop you from feeling any pain while they cut into your head to work on your brain.
During brain surgery the brain surgeon makes an incision and folds back a flap of scalp and muscle and sometimes that's done while asleep while other times you're awake.
My Grandpa went through brain surgery and he was awake during it and said he never felt any pain but he was nervous when he went into the surgery room.
But he said it was not all that bad after all.
Brain surgery is major surgery but with advancements in medicine and surgeon knowledge the brain surgery is pretty safe.