Run a bead of white caulking around the top of the wall where it meets the ceiling if the wall or ceiling, or both, are textured or rough. Smooth it with your finger or a damp rag and allow it to dry for at least four hours. This will smooth out some of the bumps and make it easier to paint a straight line.
Apply painter's tape to the ceiling where it meets the wall. Press it down firmly to prevent the paint bleeding through.
Score a line around the top of the wall with the edge of a sharp putty knife if the ceiling has popcorn or acoustic texture. This will remove stray lumps of texture from the top of the wall and makes it easier to paint a straight line.
Thin down the paint a little bit with water for the first coat. It's easier to paint a clean, straight line with slightly thinner paint. Apply the second coat of paint undiluted.