Rory Kramer / TMZ

JUSTIN BIEBER PERFORMED “LONELY” FOR INMATES

JB performed for inmates at the California State Prison in L.A. last month and chose to sing “Lonely” . . . a song that doesn’t sound much like a pick-me-up for people who spend their lives behind bars.

Justin was there to support the prison’s faith-based programs. He also sat down with inmates in the prison yard listening to speakers who were spreading the gospel.

And Justin did sing three other songs during his performance, but there’s no word what they were. Guess no one told him to read the room.