Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\z3fold.c Create Date:2022-07-28 16:29:36
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:compact_single_buddy

Proto:static struct z3fold_header *compact_single_buddy(struct z3fold_header *zhdr)

Type:struct z3fold_header

Parameter:

TypeParameterName
struct z3fold_header *zhdr
672  pool = zhdr_to_pool(zhdr)
673  p = zhdr
674  old_handle = 0
675  sz = 0
676  struct z3fold_header * new_zhdr = NULL
677  first_idx = Helper function to build the index
678  middle_idx = Helper function to build the index
679  last_idx = Helper function to build the index
680  unsigned short * moved_chunks = NULL
686  If first_chunks && * we are using BUDDY_MASK in handle_to_buddy etc. so there should * be enough slots to hold all possible variants[first_idx] Then
687  p += ZHDR_SIZE_ALIGNED
688  sz = first_chunks << CHUNK_SHIFT
689  old_handle = (unsigned long) & * we are using BUDDY_MASK in handle_to_buddy etc. so there should * be enough slots to hold all possible variants[first_idx]
690  moved_chunks = first_chunks
691  Else if middle_chunks && * we are using BUDDY_MASK in handle_to_buddy etc. so there should * be enough slots to hold all possible variants[middle_idx] Then
692  p += start_middle << CHUNK_SHIFT
693  sz = middle_chunks << CHUNK_SHIFT
694  old_handle = (unsigned long) & * we are using BUDDY_MASK in handle_to_buddy etc. so there should * be enough slots to hold all possible variants[middle_idx]
695  moved_chunks = middle_chunks
696  Else if last_chunks && * we are using BUDDY_MASK in handle_to_buddy etc. so there should * be enough slots to hold all possible variants[last_idx] Then
697  p += PAGE_SIZE - (last_chunks << CHUNK_SHIFT)
698  sz = last_chunks << CHUNK_SHIFT
699  old_handle = (unsigned long) & * we are using BUDDY_MASK in handle_to_buddy etc. so there should * be enough slots to hold all possible variants[last_idx]
700  moved_chunks = last_chunks
703  If sz > 0 Then
704  new_bud = HEADLESS
705  chunks = Converts an allocation size in bytes to size in z3fold chunks
708  new_zhdr = rns _locked_ z3fold page header or NULL
709  If Not new_zhdr Then Return NULL
712  If WARN_ON(new_zhdr == zhdr) Then Go to out_fail
715  If first_chunks == 0 Then
716  If middle_chunks != 0 && chunks >= start_middle Then
718  new_bud = LAST
719  Else
720  new_bud = FIRST
722  Else if last_chunks == 0 Then
723  new_bud = LAST
724  Else if middle_chunks == 0 Then
725  new_bud = MIDDLE
727  q = new_zhdr
729  Case new_bud == FIRST
731  q += ZHDR_SIZE_ALIGNED
732  Break
733  Case new_bud == MIDDLE
737  q += start_middle << CHUNK_SHIFT
738  Break
739  Case new_bud == LAST
742  Break
743  Default
744  Go to out_fail
746  foreign_handles++
747  memcpy(q, p, sz)
748  write_lock( & lock)
749  old_handle = new_zhdr + Helper function to build the index
751  If new_bud == LAST Then old_handle |= last_chunks << BUDDY_SHIFT
754  write_unlock( & lock)
755  Add to the appropriate unbuddied list
756  Unlock a z3fold page
758  moved_chunks = 0
761  Return new_zhdr
763  out_fail :
764  If new_zhdr Then
765  If kref_put - decrement refcount for object.*@kref: object.*@release: pointer to the function that will clean up the object when the* last reference to the object is released.* This pointer is required, and it is not acceptable to pass kfree Then atomic64_dec( & pages_nr)
767  Else
772  Return NULL
Caller
NameDescribe
do_compact_page