aboutsummaryrefslogtreecommitdiffstats
path: root/mm/vmpressure.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/vmpressure.c')
-rw-r--r--mm/vmpressure.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/mm/vmpressure.c b/mm/vmpressure.c
index 736a6011c2c8..0c1e37d829fa 100644
--- a/mm/vmpressure.c
+++ b/mm/vmpressure.c
@@ -180,12 +180,12 @@ static void vmpressure_work_fn(struct work_struct *work)
180 if (!vmpr->scanned) 180 if (!vmpr->scanned)
181 return; 181 return;
182 182
183 mutex_lock(&vmpr->sr_lock); 183 spin_lock(&vmpr->sr_lock);
184 scanned = vmpr->scanned; 184 scanned = vmpr->scanned;
185 reclaimed = vmpr->reclaimed; 185 reclaimed = vmpr->reclaimed;
186 vmpr->scanned = 0; 186 vmpr->scanned = 0;
187 vmpr->reclaimed = 0; 187 vmpr->reclaimed = 0;
188 mutex_unlock(&vmpr->sr_lock); 188 spin_unlock(&vmpr->sr_lock);
189 189
190 do { 190 do {
191 if (vmpressure_event(vmpr, scanned, reclaimed)) 191 if (vmpressure_event(vmpr, scanned, reclaimed))
@@ -240,13 +240,13 @@ void vmpressure(gfp_t gfp, struct mem_cgroup *memcg,
240 if (!scanned) 240 if (!scanned)
241 return; 241 return;
242 242
243 mutex_lock(&vmpr->sr_lock); 243 spin_lock(&vmpr->sr_lock);
244 vmpr->scanned += scanned; 244 vmpr->scanned += scanned;
245 vmpr->reclaimed += reclaimed; 245 vmpr->reclaimed += reclaimed;
246 scanned = vmpr->scanned; 246 scanned = vmpr->scanned;
247 mutex_unlock(&vmpr->sr_lock); 247 spin_unlock(&vmpr->sr_lock);
248 248
249 if (scanned < vmpressure_win || work_pending(&vmpr->work)) 249 if (scanned < vmpressure_win)
250 return; 250 return;
251 schedule_work(&vmpr->work); 251 schedule_work(&vmpr->work);
252} 252}
@@ -367,8 +367,24 @@ void vmpressure_unregister_event(struct cgroup *cg, struct cftype *cft,
367 */ 367 */
368void vmpressure_init(struct vmpressure *vmpr) 368void vmpressure_init(struct vmpressure *vmpr)
369{ 369{
370 mutex_init(&vmpr->sr_lock); 370 spin_lock_init(&vmpr->sr_lock);
371 mutex_init(&vmpr->events_lock); 371 mutex_init(&vmpr->events_lock);
372 INIT_LIST_HEAD(&vmpr->events); 372 INIT_LIST_HEAD(&vmpr->events);
373 INIT_WORK(&vmpr->work, vmpressure_work_fn); 373 INIT_WORK(&vmpr->work, vmpressure_work_fn);
374} 374}
375
376/**
377 * vmpressure_cleanup() - shuts down vmpressure control structure
378 * @vmpr: Structure to be cleaned up
379 *
380 * This function should be called before the structure in which it is
381 * embedded is cleaned up.
382 */
383void vmpressure_cleanup(struct vmpressure *vmpr)
384{
385 /*
386 * Make sure there is no pending work before eventfd infrastructure
387 * goes away.
388 */
389 flush_work(&vmpr->work);
390}