In selective laser melting (SLM) process, the build part quality is determined by process parameters such as laser scanning speed and power. The presence of porosity, a major printing defect that significantly affects part performance, may arise in laser melting process due to insufficient or excess energy input. The improvement of build quality heavily depends on fundamental understanding of porosity formation in the SLM process. In this study, the discrete element method (DEM) has been utilized to simulate the creation of a newly deposited powder layer. A computational fluid dynamics (CFD) model was developed to simulate the melting and solidification process of Ti-6Al-4V powders in the SLM process. The thermo-fluid model includes effect of surface tension and recoil pressure as well as laser ray multi-reflection in keyhole. The predictability of the developed CFD model has been validated against literature experimental data. It is found that the collapse of an unstable deep keyhole was responsible for the formation of pores. In addition, higher laser scanning speeds tend to form unstable melt pools, e.g., melt pool break-up.