The best method I know is to apply kraft paper between subfloor layers, to prevent squeeks, and then shoot or pound 2 5/8" ringshank nails on 6" or less centers. I usually put them in every 4". These nails will not pop and will hold things for a very long time. You could use subfloor adhesive and the same nailing method, but without using the kraft paper, but since you only are putting carpeting above I think that would be overkill. If this were a tile project I'd consider using liquid floor leveler, since tile adheres very nicely to the leveler, Hope this helps.