1. A method of controlling a downhole operation, comprising: controlling a tool to perform the downhole operation at a selected downhole location using a first value of an operation parameter of the tool, wherein a magnetostrictive probe extends along a section of the tool for determining a temperature profile along the section of the tool related to the operation being performed using the first value of the operation parameter; and using a processor to: activate a transducer at a first location of the magnetostrictive probe to generate an ultrasonic pulse at the first location, receive a signal from the transducer related to a reflection of the generated ultrasonic pulse from a first notch at a second location of the magnetostrictive probe, determine a travel time of the ultrasonic pulse between the first location and the second location, determine a temperature at the second location from the determined travel time and a reference travel time for an ultrasonic pulse between the first location and the second location at a known reference temperature, determine, from the temperature at the second location, a temperature profile along the section of the tool; compare the temperature profile to a selected threshold, and alter the operation parameter to a second value based on the comparison of the temperature profile to the selected threshold.