How to put something at the top of the \longrightarrow?

In this instance, I think \xrightarrow would suit you better. Here's an example using the former, and the traditional \overset from amsmath:

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}    
\[
  \mathcal{X}\overset{k\rightarrow\infty}{\longrightarrow}\mathcal{Y} \qquad 
  \mathcal{X}\xrightarrow{k\rightarrow\infty}\mathcal{Y}
\]
\end{document}

\xrightarrow{<stuff>} is an extensible arrow, which conforms in length to the overset argument <stuff>.


Use

\stackrel{k\rightarrow\infty}{\longrightarrow}

enter image description here

Alternatively, if you want the long arrow to stretch you may prefer

\xrightarrow{k\rightarrow\infty}

enter image description here