I had an issue with the shifting on my KDX400, occasionally if I shifted up into the next gear in a fast motion, the bike would immediately jump back to the gear I was in. Like, I shift into 4th and it would jump back to 3rd, then back to 4th again.
The feeling of the gear selection action with the engine not running did not feel definite, after internal inspection I find the shift-drum detent roller is quite large and doesn't drop into the gap between pins in the end of the shift drum very far.
I pulled a similar styled mechanism (KX250A5) from my boxes of spares to compare, it runs a much smaller detent roller, giving a more definite click when going into gear, plus more resistance to bouncing out of its detent.
So I got a spare detent roller and ground it down from 18mm diameter to 17mm, this has made it shift with much more definition and hasn't jumped between gears yet.
The pics below show the difference between the 250A5 and the 400/420/450 version for both the shift drum and the detent rollers.
The difference between detent/pin spacing is 1mm less on the 250, the pins in the 250 drum are radially fitted closer to the centre of the drum, keeping correct alignment for the shift fork grooves.
Because the gap between the pins was less on the 250 drum, I figured I'd not grind down to the 14.80mm of the 250 roller, but I may consider grinding another mill after further testing :-)
Not sure if this mod is applicable to other brands/models but something to think about :-)