mirror of
https://github.com/torvalds/linux.git
synced 2024-12-27 21:33:00 +00:00
vmpressure: change vmpressure::sr_lock to spinlock
There is nothing that can sleep inside critical sections protected by this lock and those sections are really small so there doesn't make much sense to use mutex for them. Change the log to a spinlock Signed-off-by: Michal Hocko <mhocko@suse.cz> Reported-by: Tejun Heo <tj@kernel.org> Cc: Anton Vorontsov <anton.vorontsov@linaro.org> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Li Zefan <lizefan@huawei.com> Reviewed-by: Tejun Heo <tj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
62e32ac350
commit
22f2020f84
@ -12,7 +12,7 @@ struct vmpressure {
|
||||
unsigned long scanned;
|
||||
unsigned long reclaimed;
|
||||
/* The lock is used to keep the scanned/reclaimed above in sync. */
|
||||
struct mutex sr_lock;
|
||||
struct spinlock sr_lock;
|
||||
|
||||
/* The list of vmpressure_event structs. */
|
||||
struct list_head events;
|
||||
|
@ -180,12 +180,12 @@ static void vmpressure_work_fn(struct work_struct *work)
|
||||
if (!vmpr->scanned)
|
||||
return;
|
||||
|
||||
mutex_lock(&vmpr->sr_lock);
|
||||
spin_lock(&vmpr->sr_lock);
|
||||
scanned = vmpr->scanned;
|
||||
reclaimed = vmpr->reclaimed;
|
||||
vmpr->scanned = 0;
|
||||
vmpr->reclaimed = 0;
|
||||
mutex_unlock(&vmpr->sr_lock);
|
||||
spin_unlock(&vmpr->sr_lock);
|
||||
|
||||
do {
|
||||
if (vmpressure_event(vmpr, scanned, reclaimed))
|
||||
@ -240,11 +240,11 @@ void vmpressure(gfp_t gfp, struct mem_cgroup *memcg,
|
||||
if (!scanned)
|
||||
return;
|
||||
|
||||
mutex_lock(&vmpr->sr_lock);
|
||||
spin_lock(&vmpr->sr_lock);
|
||||
vmpr->scanned += scanned;
|
||||
vmpr->reclaimed += reclaimed;
|
||||
scanned = vmpr->scanned;
|
||||
mutex_unlock(&vmpr->sr_lock);
|
||||
spin_unlock(&vmpr->sr_lock);
|
||||
|
||||
if (scanned < vmpressure_win || work_pending(&vmpr->work))
|
||||
return;
|
||||
@ -367,7 +367,7 @@ void vmpressure_unregister_event(struct cgroup *cg, struct cftype *cft,
|
||||
*/
|
||||
void vmpressure_init(struct vmpressure *vmpr)
|
||||
{
|
||||
mutex_init(&vmpr->sr_lock);
|
||||
spin_lock_init(&vmpr->sr_lock);
|
||||
mutex_init(&vmpr->events_lock);
|
||||
INIT_LIST_HEAD(&vmpr->events);
|
||||
INIT_WORK(&vmpr->work, vmpressure_work_fn);
|
||||
|
Loading…
Reference in New Issue
Block a user