Re: [PATCH v2 4/8] mm/lru: only change the lru_lock iff page's lruvec is different

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




在 2019/11/13 下午9:45, Matthew Wilcox 写道:
>>> Why not simply:
>>>
>>> 	rcu_read_lock();
>>> 	lruvec = mem_cgroup_page_lruvec(page, pgdat);
>>> 	rcu_read_unlock();
>>>
>>> 	if (locked_lruvec == lruvec)
>> The rcu_read_unlock here is for guarding the locked_lruvec/lruvec comparsion.
>> Otherwise memcg/lruvec maybe changed, like, from memcg migration etc. I guess.
> How does holding the RCU lock guard the comparison?  You're comparing two
> pointers for equality.  Nothing any other CPU can do at this point will
> change the results of that comparison.
> 

Hi Matthew, Thanks for reply!

The reason of guarding lruvec compasion here is a bit undistinct, in fact, it guards the page's memcg from free/migrate etc, since the lruvec is kind of binding to each of memcg. The detailed explanation could be found in lock_page_memcg().

Thanks
Alex





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux