Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\swapfile.c Create Date:2022-07-28 15:19:09
Last Modify:2020-03-17 22:19:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:SYSCALL_DEFINE1

Proto:SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)

Type:

Parameter:Nothing

2517  struct swap_info_struct * p = NULL
2525  found = 0
2528  If Not Check operation authority Then Return -EPERM
2531  BUG_ON(!mm)
2533  pathname = getname(specialfile)
2534  If IS_ERR(pathname) Then Return PTR_ERR(pathname)
2537  victim = file_open_name(pathname, O_RDWR | O_LARGEFILE, 0)
2538  err = PTR_ERR(victim)
2539  If IS_ERR(victim) Then Go to out
2542  mapping = f_mapping
2543  spin_lock( & swap_lock)
2544  plist_for_each_entry - iterate over list of given type*@pos: the type * to use as a loop counter*@head: the head for your list*@mem: the name of the list_head within the struct(p, & all active swap_info_structs* protected with swap_lock, and ordered by priority., list)
2546  If f_mapping == mapping Then
2547  found = 1
2548  Break
2552  If Not found Then
2553  err = -EINVAL
2554  spin_unlock( & swap_lock)
2555  Go to out_dput
2557  If Not security_vm_enough_memory_mm(mm, al of usable pages of swap ) Then vm_unacct_memory(al of usable pages of swap )
2559  Else
2560  err = -ENOMEM
2561  spin_unlock( & swap_lock)
2562  Go to out_dput
2564  del_from_avail_list(p)
2565  spin_lock( & protect map scan related fields like* swap_map, lowest_bit, highest_bit,* inuse_pages, cluster_next,* cluster_nr, lowest_alloc,* highest_alloc, free/discard cluster* list. other fields are only changed* at swapon/swapoff, so are protected* by swap_lock)
2566  If swap priority of this type < 0 Then
2567  si = p
2572  prio--
2573  for_each_node(nid)
2574  If prio != 1 Then prio--
2578  least_priority++
2580  plist_del - Remove a @node from plist.*@node: &struct plist_node pointer - entry to be removed*@head: &struct plist_head pointer - list head
2581  atomic_long_sub(al of usable pages of swap , & nr_swap_pages)
2582  protected with swap_lock. reading in vm_swap_full() doesn't need lock -= al of usable pages of swap
2583  SWP_USED etc: see above &= ~SWP_WRITEOK
2584  spin_unlock( & protect map scan related fields like* swap_map, lowest_bit, highest_bit,* inuse_pages, cluster_next,* cluster_nr, lowest_alloc,* highest_alloc, free/discard cluster* list. other fields are only changed* at swapon/swapoff, so are protected* by swap_lock)
2585  spin_unlock( & swap_lock)
2587  disable_swap_slots_cache_lock()
2589  set_current_oom_origin()
2590  err = If the boolean frontswap is true, only unuse pages_to_unuse pages;* pages_to_unuse==0 means all pages; ignored if frontswap is false
2591  clear_current_oom_origin()
2593  If err Then
2595  reinsert_swap_info(p)
2596  reenable_swap_slots_cache_unlock()
2597  Go to out_dput
2600  reenable_swap_slots_cache_unlock()
2602  spin_lock( & swap_lock)
2603  spin_lock( & protect map scan related fields like* swap_map, lowest_bit, highest_bit,* inuse_pages, cluster_next,* cluster_nr, lowest_alloc,* highest_alloc, free/discard cluster* list. other fields are only changed* at swapon/swapoff, so are protected* by swap_lock)
2604  SWP_USED etc: see above &= ~SWP_VALID
2605  spin_unlock( & protect map scan related fields like* swap_map, lowest_bit, highest_bit,* inuse_pages, cluster_next,* cluster_nr, lowest_alloc,* highest_alloc, free/discard cluster* list. other fields are only changed* at swapon/swapoff, so are protected* by swap_lock)
2606  spin_unlock( & swap_lock)
2611  Wait for a grace period to elapse. But it is illegal to invoke* synchronize_rcu() from within an RCU read-side critical section.* Therefore, any legal call to synchronize_rcu() is a quiescent
2613  lush_work - wait for a work to finish executing the last queueing instance*@work: the work to flush* Wait until @work has finished execution
2615  Free all of a swapdev's extent information
2616  If SWP_USED etc: see above & SWP_CONTINUED Then _swap_count_continuations - swapoff free all the continuation pages* appended to the swap_map, after swap_map is quiesced, before vfree'ing it.
2619  If Not swap device or bdev of swap file || Not blk_queue_nonrot(bdev_get_queue(swap device or bdev of swap file )) Then atomic_dec( & nr_rotate_swap)
2622  mutex_lock( & swapon_mutex)
2623  spin_lock( & swap_lock)
2624  spin_lock( & protect map scan related fields like* swap_map, lowest_bit, highest_bit,* inuse_pages, cluster_next,* cluster_nr, lowest_alloc,* highest_alloc, free/discard cluster* list. other fields are only changed* at swapon/swapoff, so are protected* by swap_lock)
2625  After a successful try_to_unuse, if no swap is now in use, we know* we can empty the mmlist. swap_lock must be held on entry and exit.* Note that mmlist_lock nests inside swap_lock, and an mm must be
2628  dex of last free in swap_map = 0
2629  When SWP_USED etc: see above >= SWP_SCANNING cycle
2630  spin_unlock( & protect map scan related fields like* swap_map, lowest_bit, highest_bit,* inuse_pages, cluster_next,* cluster_nr, lowest_alloc,* highest_alloc, free/discard cluster* list. other fields are only changed* at swapon/swapoff, so are protected* by swap_lock)
2631  spin_unlock( & swap_lock)
2632  schedule_timeout_uninterruptible(1)
2633  spin_lock( & swap_lock)
2634  spin_lock( & protect map scan related fields like* swap_map, lowest_bit, highest_bit,* inuse_pages, cluster_next,* cluster_nr, lowest_alloc,* highest_alloc, free/discard cluster* list. other fields are only changed* at swapon/swapoff, so are protected* by swap_lock)
2637  swap_file = seldom referenced
2638  old_block_size = seldom referenced
2639  seldom referenced = NULL
2640  xtent of the swap_map = 0
2641  swap_map = vmalloc'ed array of usage counts
2642  vmalloc'ed array of usage counts = NULL
2643  cluster_info = cluster info. Only for SSD
2644  cluster info. Only for SSD = NULL
2645  frontswap_map = frontswap_map_get(p)
2646  spin_unlock( & protect map scan related fields like* swap_map, lowest_bit, highest_bit,* inuse_pages, cluster_next,* cluster_nr, lowest_alloc,* highest_alloc, free/discard cluster* list. other fields are only changed* at swapon/swapoff, so are protected* by swap_lock)
2647  spin_unlock( & swap_lock)
2648  frontswap_invalidate_area(strange name for an index )
2649  frontswap_map_set(p, NULL)
2650  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
2651  free previously allocated percpu memory
2652  per cpu's swap location = NULL
2653  vfree - release memory allocated by vmalloc()*@addr: memory base address* Free the virtually continuous memory area starting at @addr, as* obtained from vmalloc(), vmalloc_32() or __vmalloc()
2654  kvfree() - Free memory.*@addr: Pointer to allocated memory.* kvfree frees memory allocated by any of vmalloc(), kmalloc() or kvmalloc().* It is slightly more efficient to use kfree() or vfree() if you are certain* that you know which one to use.
2655  kvfree() - Free memory.*@addr: Pointer to allocated memory.* kvfree frees memory allocated by any of vmalloc(), kmalloc() or kvmalloc().* It is slightly more efficient to use kfree() or vfree() if you are certain* that you know which one to use.
2657  swap_cgroup_swapoff(strange name for an index )
2658  exit_swap_address_space(strange name for an index )
2660  inode = host
2661  If S_ISBLK(i_mode) Then
2662  bdev = I_BDEV(inode)
2664  set_blocksize(bdev, old_block_size)
2665  blkdev_put(bdev, le is open for reading | le is open for writing | File is opened with O_EXCL (only set for block devices) )
2668  inode_lock(inode)
2669  i_flags &= ~Do not truncate: swapon got its bmaps
2670  inode_unlock(inode)
2671  filp_close(swap_file, NULL)
2678  spin_lock( & swap_lock)
2679  SWP_USED etc: see above = 0
2680  spin_unlock( & swap_lock)
2682  err = 0
2683  atomic_inc( & Activity counter to indicate that a swapon or swapoff has occurred )
2684  wake_up_interruptible( & proc_poll_wait)
2686  out_dput :
2687  filp_close(victim, NULL)
2688  out :
2689  putname(pathname)
2690  Return err