• Andrew Morton's avatar
    [PATCH] rmap 10 add anonmm rmap · 6bccf794
    Andrew Morton authored
    From: Hugh Dickins <hugh@veritas.com>
    
    Hugh's anonmm object-based reverse mapping scheme for anonymous pages.  We
    have not yet decided whether to adopt this scheme, or Andrea's more advanced
    anon_vma scheme.  anonmm is easier for me to merge quickly, to replace the
    pte_chain rmap taken out in the previous patch; a patch to install Andrea's
    anon_vma will follow in due course.
    
    Why build up and tear down chains of pte pointers for anonymous pages, when a
    page can only appear at one particular address, in a restricted group of mms
    that might share it?  (Except: see next patch on mremap.)
    
    Introduce struct anonmm per mm to track anonymous pages, all forks from one
    exec sharing the same bundle of linked anonmms.  Anonymous pages originate in
    one mm, but may be forked into another mm of the bundle later on.  Callouts
    from fork.c to allocate, dup and exit the anonmm structure private to rmap.c.
    
    From: Hugh Dickins <hugh@veritas.com>
    
      Two concurrent exits (of the last two mms sharing the anonhd).  First
      exit_rmap brings anonhd->count down to 2, gets preempted (at the
      spin_unlock) by second, which brings anonhd->count down to 1, sees it's 1
      and frees the anonhd (without making any change to anonhd->count itself),
      cpu goes on to do something new which reallocates the old anonhd as a new
      struct anonmm (probably not a head, in which case count will start at 1),
      first resumes after the spin_unlock and sees anonhd->count 1, frees "anonhd"
      again, it's used for something else, a later exit_rmap list_del finds list
      corrupt.
    6bccf794
rmap.c 21.5 KB