Which Goyim surrounded him?
Rashi: This discusses the war of Gog and Magog. All the Goyim will be there - "v'Asafti Es Kol ha'Goyim El Yerushalayim la'Milchamah" (Zecharyah 14:2).
Radak: If the Mizmor discusses David, it is when Pelishtim and Yisrael wanted to harm him when he came to Achish (Shmuel I, 27:28), and the Goyim who burned Tziklag and took the women captive (ibid., 30:1-5).
Malbim: It is Melech Ashur and the Goyim with him.
What is the meaning of "Amilam"?
Rashi: I will cut them 1 . This is like "Yemolel v'Yavesh" (90:6). Radak (11) - this is like Amilem (the same grammatical form as "Asimem b'Rosheichem" - Devarim 1:13), just there is a Patach in place of the Tzeirei.
Malbim: I see that it was Hashem's command that all these Goyim besiege Yerushalayim, in order that they will fall there - "Ka'asher Dimisi; Lishbor Ashur b'Artzi v'Al Harai Avusenu" (Yeshayah 14:24-25).