My first SLR was a Pentax Program Plus with the Pentax-A 50mm f1.7, and that camera was with me for more than a decade. It captured some of my life's most memorable moments and will always occupy a small niche in my heart, though I don't shoot Pentax any more. Still, I hold on to a few Pentax lenses, and the 40mm f2.8 pancake is one of them.
The lens is about the same size as the Canon 40mm f2.8 STM and I am sure they share a similar optical formula of the Tessar variant. Mounting it on the 5D Mark II looks kind of funny, but it looks perfect on smaller cameras like the Pentax MV, MX, etc. I really have no complains about its optical performance. Stopped down a bit, the lens is sharp from corner to corner, on full frame. Even the bokeh is quite nice. It's a little hard to focus with the very thin focusing ring, but it's a pancake lens, after all. One thing bothers me, is that like so many manual focus lenses, this one hits the 5D II's mirror, even at minimum focus distance. I was forced to use the live-view, in very strong sunlight, but it was nearly useless.
If you are a Canon shooter, I would recommend the EF 40mm f2.8 STM. It's sharper than the Pentax, for not much more, for a new one, and it auto focuses, and does not hit the mirror.
All pictures below taken with the Pentax-M 40mm f2.8 Pancake, and the Canon 5D Mark II.