It looks like two things occurring, one is a lack of magnesium in the diet and the other is an increased demand with high carb diets.
There was a rather cranky woman who posted on a lot of blogs about mineral shortages, magnesium was one and manganese was another. She made some good points but was otherwise rather monomaniac and for some reason championed high grain diets.
Elsewhere I read a compelling concept that increasing yield of especially wheat in plants that only had the same size rootstock meant they would uptake the same amount of minerals but dilute them into an increased quantity of grains, so I don't really think that part of her argument holds up.
Magnesium is fairly easy to dose. Too much gives you the squits so when that happens back off on the dose until it stops happening. I used it to counter leg cramps but haven't actually taken any for a while now, presumably my requirements are being met through diet.