Use of PID to get the required RPM.

It doesn't matter that the relationship between PWM and RPM is not linear.

You will first need to download the PID library or otherwise incorporate PID code into your program.

Study on line tutorials to learn how to choose the constants Kp, Ki and Kd (google "PID tuning").

Then choose setpoint = desired RPM, process value = current RPM, and start tuning.