Under RAW, your intelligence ability score, and your proficiency with intelligence skills, measure your ability to recall. That is explicit. It is not a question of whether you use immersive role playing or not - it is spelled out in the rules.
Regardless of whether you've been exposed to trolls or not, through lore, experience, etc... it is your INTELLIGENCE and PROFICIENCIES that determine if your PC knows things about them when he wants to recall it. A player's knowledge, under RAW, has nothing to do with what the character knows. That is the core mechanics.
So, let's say your 6 Intelligence barbarian, who grew up amongst a clan that fought trolls often, and has seen countless trolls beaten in combat, faces a troll. Does he remember that fire and acid are necessary to stop the troll's regeneration? Under RAW, that is a question of intelligence. as the core mechanic.
The DM may set a DC and allow the player to beat it was a passive roll. The DM may require a roll, or set a DC higher than a passive roll would best, which would mean they'd ask for an intelligence roll. The DM might give advantage or a bonus based upon past experience or other circumstances. These are all things the DM might due, but they all relate back to the intelligence of the PC, not the knowledge of the player.
A failed roll might mean the barbarian never learned the lesson in the first place, or just forgot in the moment. However, in the end, it is the intelligence and skill proficiencies of the PCs, under RAW, that determine whether a PC knows something about a monster or not.