@@ -341,89 +341,6 @@ static unsigned long __frontswap_curr_pages(void)
341
341
return totalpages ;
342
342
}
343
343
344
- static int __frontswap_unuse_pages (unsigned long total , unsigned long * unused ,
345
- int * swapid )
346
- {
347
- int ret = - EINVAL ;
348
- struct swap_info_struct * si = NULL ;
349
- int si_frontswap_pages ;
350
- unsigned long total_pages_to_unuse = total ;
351
- unsigned long pages = 0 , pages_to_unuse = 0 ;
352
-
353
- assert_spin_locked (& swap_lock );
354
- plist_for_each_entry (si , & swap_active_head , list ) {
355
- si_frontswap_pages = atomic_read (& si -> frontswap_pages );
356
- if (total_pages_to_unuse < si_frontswap_pages ) {
357
- pages = pages_to_unuse = total_pages_to_unuse ;
358
- } else {
359
- pages = si_frontswap_pages ;
360
- pages_to_unuse = 0 ; /* unuse all */
361
- }
362
- /* ensure there is enough RAM to fetch pages from frontswap */
363
- if (security_vm_enough_memory_mm (current -> mm , pages )) {
364
- ret = - ENOMEM ;
365
- continue ;
366
- }
367
- vm_unacct_memory (pages );
368
- * unused = pages_to_unuse ;
369
- * swapid = si -> type ;
370
- ret = 0 ;
371
- break ;
372
- }
373
-
374
- return ret ;
375
- }
376
-
377
- /*
378
- * Used to check if it's necessary and feasible to unuse pages.
379
- * Return 1 when nothing to do, 0 when need to shrink pages,
380
- * error code when there is an error.
381
- */
382
- static int __frontswap_shrink (unsigned long target_pages ,
383
- unsigned long * pages_to_unuse ,
384
- int * type )
385
- {
386
- unsigned long total_pages = 0 , total_pages_to_unuse ;
387
-
388
- assert_spin_locked (& swap_lock );
389
-
390
- total_pages = __frontswap_curr_pages ();
391
- if (total_pages <= target_pages ) {
392
- /* Nothing to do */
393
- * pages_to_unuse = 0 ;
394
- return 1 ;
395
- }
396
- total_pages_to_unuse = total_pages - target_pages ;
397
- return __frontswap_unuse_pages (total_pages_to_unuse , pages_to_unuse , type );
398
- }
399
-
400
- /*
401
- * Frontswap, like a true swap device, may unnecessarily retain pages
402
- * under certain circumstances; "shrink" frontswap is essentially a
403
- * "partial swapoff" and works by calling try_to_unuse to attempt to
404
- * unuse enough frontswap pages to attempt to -- subject to memory
405
- * constraints -- reduce the number of pages in frontswap to the
406
- * number given in the parameter target_pages.
407
- */
408
- void frontswap_shrink (unsigned long target_pages )
409
- {
410
- unsigned long pages_to_unuse = 0 ;
411
- int type , ret ;
412
-
413
- /*
414
- * we don't want to hold swap_lock while doing a very
415
- * lengthy try_to_unuse, but swap_list may change
416
- * so restart scan from swap_active_head each time
417
- */
418
- spin_lock (& swap_lock );
419
- ret = __frontswap_shrink (target_pages , & pages_to_unuse , & type );
420
- spin_unlock (& swap_lock );
421
- if (ret == 0 )
422
- try_to_unuse (type , true, pages_to_unuse );
423
- return ;
424
- }
425
- EXPORT_SYMBOL (frontswap_shrink );
426
-
427
344
/*
428
345
* Count and return the number of frontswap pages across all
429
346
* swap devices. This is exported so that backend drivers can
0 commit comments