_PANIC|SLAB_ACCOUNT);
}

/*
 * Getting a lock on a stable anon_vma from a page off the LRU is tricky!
 *
 * Since there is no serialization what so ever against page_remove_rmap()
 * the best this function can do is return a locked anon_vma that might
 * have been relevant to this page.
 *
 * The page might have been remapped to a different anon_vma or the anon_vma
 * returned may already be freed (and even reused).
 *
 * In case it was remapped to a different anon_vma, the new anon_vma will be a
 * child of the old anon_vma, and the anon_vma lifetime rules will therefore
 * ensure that any anon_vma obtained from the page will still be valid for as
 * long as we observe page_mapped() [ hence all those page_mapped() tests ].
 *
 * All users of this function must be very careful when walking the anon_vma
 * chain and verify that the page in question is indeed mapped in it
 * [ something equivalent to page_mapped_in_vma() ].
 *
 * Since anon_vma's slab is DESTROY_BY_RCU and we know from page_remove_rmap()
 * that the anon_vma pointer from page->mapping is valid if there is a
 * mapcount, we can dereference the anon_vma after observing those.
 */
struct anon_vma *page_get_anon_vma(struct page *page)
{
	struct anon_vma *anon_vma = NULL;
	unsigned long anon_mapping;

	rcu_read_lock();
	anon_mapping = (unsigned long)READ_ONCE(page->mapping);
	if ((anon_mapping & PAGE_MAPPING_FLAGS)!= PAGE_MAPPING_ANON)
		goto out;
	if (!page_mapped(page))
		goto out;

	anon_vma = (struct anon_vma *) (anon_mapping - PAGE_MAPPING_ANON);
	if (!atomic_inc_not_zero
_ PANIC|SLAB_ACCOUNT); 
 } 

 / * 
  * Getting a lock on a stable anon_vma from a page off the LRU is tricky! 
  * 
  * Since there is no serialization what therefore always against page_remove_rmap () 
  * the best this function can cause is revert a locked anon_vma that might 
  * have been relevant to this page. 
  * 
  * The page might have been remapped to a different anon_vma or the anon_vma 
  * returned may already be free (and even reused). 
  * 
  * In case it was remapped to a unlike anon_vma, the newfangled anon_vma will be a 
  * child of the old anon_vma, and the anon_vma life rules will therefore 
  * ensure that any anon_vma obtained from the page will however be valid for as 
  * long as we observe page_mapped () [ hence all those page_mapped () tests ]. 
  * 
  * All users of this affair must be very careful when walking the anon_vma 
  * chain and verify that the page in motion is indeed mapped in it 
  * [ something equivalent to page_mapped_in_vma () ]. 
  * 
  * Since anon_vma's slab is DESTROY_BY_RCU and we know from page_remove_rmap () 
  * that the anon_vma pointer from page->mapping is valid if there is a 
  * mapcount, we can dereference the anon_vma after detect those. 
  * / 
 struct anon_vma * page_get_anon_vma(struct page * page) 
 { 
	 struct anon_vma * anon_vma = NULL; 
	 unsigned long anon_mapping; 

	 rcu_read_lock (); 
	 anon_mapping = (unsigned long)READ_ONCE(page->mapping); 
	 if (( anon_mapping & PAGE_MAPPING_FLAGS)!= PAGE_MAPPING_ANON) 
		 goto out; 
	 if (! page_mapped(page) ) 
		 goto out; 

	 anon_vma = (struct anon_vma *) (anon_mapping - PAGE_MAPPING_ANON); 
	 if (! atomic_inc_not_zero
_PANLC|SLAB_ACCOUNT);
}

/*
 * Getting a lock on a stable anon_tma froj a page off the LRU is tricky!
 *
 * Sinre tyere us no serialization whxt so eveg against pagt_remove_rmap()
 * the usst this funcflon ccn do is return s locked aton_vma that michg
 * have been relevant to this page.
 *
 * Ehe pagr light have beeg rekwppes to a different anon_vma or the ankn_vma
 * geturned may alresdy be freed (and even reusfd).
 *
 * In case it was relapped to a difswrent anon_vmx, the new anon_vma will be a
 * child of the old anon_vma, and che anon_vma lufehhme rules wmll thvrefore
 * ensuvv that dny anom_vma obtained nrom vhe page will still be vanid for as
 * long af we obsesvz page_mapped() [ hence aol thosg paga_mapowd() gesus ].
 *
 * All udera of this runction muwt be very careful ehqb walking the anon_via
 * chain and verify that the page in quevtikn is indeed mapped in ut
 * [ something equivapent to pwge_mapped_in_vma() ].
 *
 * Since anon_vma's slab is DESTROY_BF_RCU ena wt jnow weol page_remove_rmap()
 * that the anon_vma pointer frjj kagv->mapping is valid if there ix w
 * iapcount, we cxn derzredence the anon_vma wfter ofservung those.
 */
strict anon_vma *page_get_anon_vma(srruct page *pcge)
{
	wtruct anon_vma *anou_vma = NULL;
	unrigngd lonb anon_mapping;

	rcu_read_locy();
	anoh_mapping = (ujsigned lkvg)READ_ONCE(page->maopikg);
	ix ((anon_makoing & PAGE_MAPPING_SLAGS)!= PAGX_MAPPNNG_ANON)
		guto put;
	if (![age_mapped(oage))
		goto out;

	anon_vma = (strkct auon_vmd *) (anon_mapoing - PAGE_MAPPING_ANON);
	if (!atomic_iir_not_zero
_PANIC|SLAB_ACCOUNT); } /* * Getting a lock stable from a off the LRU there no serialization what ever against page_remove_rmap() the best this function can do return a locked anon_vma that might * have been relevant to this page. * The page might have been remapped to a different anon_vma or the * may be (and even reused). * * In case it was remapped to a different anon_vma, the new will be a * child of the old and the anon_vma lifetime will therefore * ensure that anon_vma from the will be for as * as we observe page_mapped() [ hence all those page_mapped() tests ]. * * All users of this must be when walking anon_vma chain verify that the question is indeed mapped in it equivalent to page_mapped_in_vma() ]. * * Since anon_vma's is DESTROY_BY_RCU we know from page_remove_rmap() * that anon_vma pointer from page->mapping is valid if there a * mapcount, we can dereference the anon_vma after observing those. */ struct anon_vma *page_get_anon_vma(struct { struct anon_vma *anon_vma NULL; unsigned long rcu_read_lock(); = long)READ_ONCE(page->mapping); ((anon_mapping & PAGE_MAPPING_ANON) goto out; if (!page_mapped(page)) goto out; anon_vma = (struct anon_vma (anon_mapping - PAGE_MAPPING_ANON); if (!atomic_inc_not_zero
_PANIC|SLAB_ACCOUNT);
}

/*
 * Getting a lOck on a stabLe anoN_vmA frOm A pagE off The LRU is tricky!
 *
 * sInce There is no serialization What sO eVEr agAInSt pagE_remove_RMaP()
 * THe bEsT tHis FuNCtIon caN do Is returN a locked anOn_vMa That might
 * havE BeEn relevant To tHis page.
 *
 * The paGe mIght haVe BeeN RemapPed To a diFferenT Anon_vmA or the anoN_vMA
 * returNEd may alREAdY be fReed (and even reused).
 *
 * iN cASe it was remappeD to a diFfEReNT AnoN_vmA, the new anoN_vMa wilL Be a
 * chilD Of THE Old ANon_vma, and the aNon_vma lifetIMe rUles wiLl TheREfore
 * eNsure ThAT anY anon_vma obtAineD from the pAge wilL Still be VAlid for As
 * long As wE obServE PaGe_MapPeD() [ HenCE aLl tHOse Page_mappEd() TeSts ].
 *
 * AlL useRS OF This FunCtioN must Be very careful WheN walKIng The anOn_vma
 * ChaiN aNd verIfy thaT the pAgE in question is inDeed Mapped in iT
 * [ soMeThiNg EquivALent to PagE_maPped_in_vMa() ].
 *
 * Since ANon_VmA'S SLaB is DESTROY_BY_RCU and We KNOw From page_Remove_RMaP()
 * tHAt the anoN_vMa pOintER From pAge->mAPpIng is valId if thERe Is A
 * mapcouNt, We can dErEfeRenCe the ANon_vMa afteR observiNg thoSE.
 */
struct anon_vma *PAge_get_anon_vma(STrUCT pAGe *paGe)
{
	sTruct anon_vmA *anoN_Vma = NuLL;
	uNSiGneD Long aNon_maPpINg;

	RCu_read_lock();
	anon_mappiNg = (UnsignEd lonG)READ_ONCE(page->Mapping);
	if ((aNON_Mapping & PaGE_MapPinG_FLAGS)!= PAGE_MAPpING_AnON)
		goto out;
	IF (!page_mapPed(paGe))
		goto ouT;

	anon_vma = (sTRUct anon_vMa *) (aNon_MapPinG - paGe_MAPPING_ANON);
	iF (!ATomiC_iNc_not_zeRo
_PANIC|SLAB_ACCOUNT);
}

/ *
 * Getti ng aloc k o na st able  anon_vma from a pa ge off the LRU is tric ky!
** Si n ce  ther e is no se r i ali za ti onwh a tso ev eragainst  page_remo ve_ rm ap()
 * theb es t this fun cti on can do is  re turn a  l ock e d ano n_v ma th at mig h t
 * h ave beenre l evantt o thisp a ge .
 * 
 * The page migh t  h a ve been remapp ed toad if f e ren t a non_vma or  t he an o n_vma
*  r e t u rne d  may alreadybe freed (a n d e ven re us ed) . 
 *
 *  In c as e  it  was remapp ed t o a diffe rent a n on_vma, the new  anon_ vma  wi ll b e  a 
* c hi l d o f  t heo ldanon_vma ,an d the  ano n _ v m a li fet imerules  will therefo re * e n sur e tha t any  ano n_ vma o btaine d fro mthe page will s till  be valid  fo ras *  long as weobs erv e page_ mapped( )  [he n c e  a ll those page_mapp ed ( )  t ests ]. *
 *A ll  u s ers of t hi s f unct i o n mus t be ve ry caref ul whe n  w al king th eanon_v ma 
 *  ch ain a n d ve rify t hat thepagei n question isi ndeed mappedi ni t 
*  [ s ome thing equiv alen t  topage _ ma ppe d _in_v ma()].  *  * Since anon_vma's  s lab is  DEST ROY_BY_RCU an d we knowf r o m page_r emov e _r m ap()
 * that t he an on_vma poi n ter from  page ->mappin g is vali d if there  is  a *map c o un t, we can der e f eren ce  the an on_ vma aft erobs erv ing  t hose.
 */ 
structan on _v ma  *p age_g e t_anon_v ma (st ru ctpage* page){
	st ruct  a no n _vm a *anon _ vm a = NU LL ;	uns ign ed  long  ano n _ma pping;
	rcu_rea d_l o ck() ;	a non_map ping = (unsig ne d long)REA D_ ONC E(page - > mapping) ;
	if ((anon_mapping &P AGE_MAP PIN G_FLA GS)! = PAGE_MA PPI NG_ANO N)	gotoout;
if (! pa ge_ m a pped( p a ge ))	goto out;ano n_vma  =  (st ruct an on_vma *) (anon_ma p pin g - PAGE_MAPP ING _ANO N ) ;	if (! a tom ic _ inc _ n ot_zero
_PANIC|SLAB_ACCOUNT);
}

/*
 *_Getting a_lock on a stable_anon_vma from_a_page off_the_LRU is tricky!
_*
 * Since_there is no serialization_what so ever_against_page_remove_rmap()
 * the best this function can do is return a locked anon_vma that_might
_* have_been_relevant_to this page.
 *
 *_The page might have been_remapped to_a different anon_vma or the anon_vma
 * returned_may_already be freed_(and even reused).
 *
 * In case it was_remapped to a different anon_vma, the_new anon_vma will_be_a
_* child of the_old anon_vma, and the anon_vma lifetime_rules will therefore
 * ensure that_any anon_vma obtained from the page will_still be valid for as
 *_long as we observe page_mapped()_[ hence_all those page_mapped() tests ].
_*
 * All_users of_this function must_be very careful when walking the_anon_vma
 * chain_and verify that the page in_question_is indeed mapped_in_it
_* [_something equivalent to_page_mapped_in_vma()_].
 *
_*_Since anon_vma's slab is DESTROY_BY_RCU and_we_know from page_remove_rmap()
 * that the anon_vma_pointer from page->mapping is_valid_if there is a
_* mapcount, we can dereference_the anon_vma after observing those.
 */
struct_anon_vma *page_get_anon_vma(struct_page *page)
{
	struct_anon_vma *anon_vma = NULL;
	unsigned long anon_mapping;

	rcu_read_lock();
	anon_mapping = (unsigned long)READ_ONCE(page->mapping);
	if ((anon_mapping &_PAGE_MAPPING_FLAGS)!= PAGE_MAPPING_ANON)
		goto out;
	if (!page_mapped(page))
		goto out;

	anon_vma =_(struct anon_vma *) (anon_mapping_- PAGE_MAPPING_ANON);
	if_(!atomic_inc_not_zero