Apple has posted documentation on how to use the 27 inch iMac as an external display.
To use a 27-inch iMac in Target Display mode with another computer as the source:
Step One Make sure both computers are turned on and awake.
Step Two Connect a male-to-male Mini DisplayPort cable to the Mini DisplayPort on each computer. The 27-inch iMac will enter Target Display Mode and display content from the source computer.
Note: If you are connecting two 27-inch iMacs, connect a Mini DisplayPort cable to each computer and press Command + F2 on the 27-inch iMac keyboard that you will use as an external display.
Step Three To leave Target Display mode, press Command + F2 on the keyboard of the 27-inch iMac that is in Target Display mode. To return to Target Display mode, press Command + F2 again.
Useless curiosity:
If I were to press command F2 on both computers would I essentially have them with their displays swapped, or is there something to prevent both from entering target mode
Don't think so, DisplayPort probably is a "one way only" video cable. If you press Command + F2 in the master mac, may be it will change to target display mode, and the old slave mac change to master.