linux/mm/mlock.c
<<
opti.14/spa> .14/form .14a opti.1 href="../linux+v3.7.4/mm/mlock.c">opti.14img src="../.static/gfx/right.png" alt=">>">op4/spa> op4spa> class="lxr_search">opti="+search" method="post" onsubmit="return do_search(this);">opti.14input typ> hidden" nam> navtarget" tion> ">opti.14input typ> text" nam> search" id search">opti.14butt/optyp> submit">Search op4spa> class="lxr_prefs" .14a href="+prefs?return=mm/mlock.c"opti.1 onclick="return ajax_prefs();">opti.1Prefs .14/a>op4/spa> ti.1 14/div ti.1 14form ac >="ajax+*" method="post" onsubmit="return false;">op4input typ> hidden" nam> ajax_lookup" id ajax_lookup" tion> ">oti.1 14/form oti.1 14div class="headingbott/m">
4div id file_contents"
 L1">1 114/a>4spa> class="comment">/*4/spa>
 
 L2">1 124/a>4spa> class="comment"> *ti.1 1linux/mm/mlock.c4/spa>
 
 L3">1 134/a>4spa> class="comment"> *4/spa>
 
 L4">1 144/a>4spa> class="comment"> *ti(C) Copyright 1995 Linus Tortiods4/spa>
 
 L5">1 154/a>4spa> class="comment"> *ti(C) Copyright 2002 Christoph Hellwig4/spa>
 
 L6">1 164/a>4spa> class="comment"> */4/spa>
 
 L7">1 174/a>o
 L8">1 184/a>#include <linux/capability.h4/a>>o
 L9">1 194/a>#include <linux/mman.h4/a>>o
 L10">1 tiona>#include <linux/mm.h4/a>>o
 L11">1 11ona>#include <linux/swap.h4/a>>o
 L12">1 12ona>#include <linux/swapops.h4/a>>o
 L13">1 13ona>#include <linux/pagemap.h4/a>>o
 L14">1 14ona>#include <linux/mempolicy.h4/a>>o
 L15">1 15ona>#include <linux/syscalls.h4/a>>o
 L16">1 16ona>#include <linux/sched.h4/a>>o
 L17">1 17ona>#include <linux/export.h4/a>>o
 L18">1 184/a>#include <linux/rmap.h4/a>>o
 L19">1 194/a>#include <linux/mmzone.h4/a>>o
 L20">1 2iona>#include <linux/hugetlb.h4/a>>o
 L21">1 214/a>o
 L22">1 22ona>#include "internal.h4/a>"o
 L23">1 234/a>o
 L24">1 24ona>int14a href="+code=can_do_mlock" class="sref">can_do_mlockona>(void)o
 L25">1 25ona>{o
 L26">1 26ona>        if (4a href="+code=capable" class="sref">capableona>(4a href="+code=CAP_IPC_LOCK" class="sref">CAP_IPC_LOCKona>))o
 L27">1 27ona>                return 1;o
 L28">1 28ona>        if (4a href="+code=rlimit" class="sref">rlimitona>(4a href="+code=RLIMIT_MEMLOCK" class="sref">RLIMIT_MEMLOCKona>) != 0)o
 L29">1 29ona>                return 1;o
 L30">1 30ona>        return 0;o
 L31">1 314/a>}o
 L32">1 324/a>4a href="+code=EXPORT_SYMBOL" class="sref">EXPORT_SYMBOLona>(4a href="+code=can_do_mlock" class="sref">can_do_mlockona>);o
 L33">1 334/a>o
 L34">1 344/a>4spa> class="comment">/*4/spa>
 
 L35">1 354/a>4spa> class="comment"> *tMlocked pages are marked with PageMlocked() flag for efficient testing4/spa>
 
 L36">1 364/a>4spa> class="comment"> * in vmscan and, possibly, the fault path; and to support semi-accurate4/spa>
 
 L37">1 374/a>4spa> class="comment"> * statistics.4/spa>
 
 L38">1 384/a>4spa> class="comment"> *4/spa>
 
 L39">1 394/a>4spa> class="comment"> * An mlocked page [PageMlocked(page)] is unevictable.  As such, it will4/spa>
 
 L40">1 404/a>4spa> class="comment"> * be placed /opthe LRU "unevictable" list, ratherpthaopthe [in]ac	 ve lists.4/spa>
 
 L41">1 414/a>4spa> class="comment"> * The unevictable list is a> LRU sibling list to the [in]ac	 ve lists.4/spa>
 
 L42">1 424/a>4spa> class="comment"> *tPageUnevictable is set to indicate the unevictable state.4/spa>
 
 L43">1 434/a>4spa> class="comment"> *4/spa>
 
 L44">1 444/a>4spa> class="comment"> *tWhen lazy mlocking via vmscan, it is important to ensure that the4/spa>
 
 L45">1 454/a>4spa> class="comment"> *tvma's VM_LOCKED status is not concurrently being modified, otherwise we4/spa>
 
 L46">1 464/a>4spa> class="comment"> * may have mlocked a page that is being munlocked. So lazy mlock must take4/spa>
 
 L47">1 474/a>4spa> class="comment"> * the mmap_sem for read, and verify that thetvma really is locked4/spa>
 
 L48">1 484/a>4spa> class="comment"> * (see mm/rmap.c).4/spa>
 
 L49">1 494/a>4spa> class="comment"> */4/spa>
 
 L50">1 504/a>o
 L51">1 514/a>4spa> class="comment">/*4/spa>
 
 L52">1 524/a>4spa> class="comment"> *tiLRU accounting for clear_page_mlock()4/spa>
 
 L53">1 534/a>4spa> class="comment"> */4/spa>
 
 L54">1 544/a>void14a href="+code=clear_page_mlock" class="sref">clear_page_mlockona>(struct14a href="+code=page" class="sref">pageona> *4a href="+code=page" class="sref">pageona>)o
 L55">1 55ona>{o
 L56">1 56ona>        if (!4a href="+code=TestClearPageMlocked" class="sref">TestClearPageMlockedona>(4a href="+code=page" class="sref">pageona>))o
 L57">1 57ona>                return;o
 L58">1 584/a>o
 L59">1 59ona>        4a href="+code=mod_zone_page_state" class="sref">mod_zone_page_stateona>(4a href="+code=page_zone" class="sref">page_zoneona>(4a href="+code=page" class="sref">pageona>), 4a href="+code=NR_MLOCK" class="sref">NR_MLOCKona>, 
 L60">1 60ona>                            -4a href="+code=hpage_nr_pages" class="sref">hpage_nr_pagesona>(4a href="+code=page" class="sref">pageona>));o
 L61">1 61ona>        4a href="+code=count_vm_event" class="sref">count_vm_eventona>(4a href="+code=UNEVICTABLE_PGCLEARED" class="sref">UNEVICTABLE_PGCLEAREDona>);o
 L62">1 62ona>        if (!4a href="+code=isolate_lru_page" class="sref">isolate_lru_pageona>(4a href="+code=page" class="sref">pageona>)) {o
 L63">1 63ona>                4a href="+code=putback_lru_page" class="sref">putback_lru_pageona>(4a href="+code=page" class="sref">pageona>);o
 L64">1 64ona>        } else {o
 L65">1 65ona>                4spa> class="comment">/*4/spa>
 
 L66">1 664/a>4spa> class="comment">                 *tWe lost thetrace. thetpage already moved to evictable list.4/spa>
 
 L67">1 674/a>4spa> class="comment">                 */4/spa>
 
 L68">1 68ona>                if (4a href="+code=PageUnevictable" class="sref">PageUnevictableona>(4a href="+code=page" class="sref">pageona>))o
 L69">1 69ona>                        4a href="+code=count_vm_event" class="sref">count_vm_eventona>(4a href="+code=UNEVICTABLE_PGSTRANDED" class="sref">UNEVICTABLE_PGSTRANDEDona>);o
 L70">1 70ona>        }o
 L71">1 714/a>}o
 L72">1 724/a>o
 L73">1 734/a>4spa> class="comment">/*4/spa>
 
 L74">1 744/a>4spa> class="comment"> *tMarktpage as mlocked if not already.4/spa>
 
 L75">1 754/a>4spa> class="comment"> *tIftpage o> LRU, isolate and putback to move to unevictable list.4/spa>
 
 L76">1 764/a>4spa> class="comment"> */4/spa>
 
 L77">1 774/a>void14a href="+code=mlock_vma_page" class="sref">mlock_vma_pageona>(struct14a href="+code=page" class="sref">pageona> *4a href="+code=page" class="sref">pageona>)o
 L78">1 78ona>{o
 L79">1 79ona>        4a href="+code=BUG_ON" class="sref">BUG_ONona>(!4a href="+code=PageLocked" class="sref">PageLockedona>(4a href="+code=page" class="sref">pageona>));o
 L80">1 804/a>o
 L81">1 81ona>        if (!4a href="+code=TestSetPageMlocked" class="sref">TestSetPageMlockedona>(4a href="+code=page" class="sref">pageona>)) {o
 L82">1 82ona>                4a href="+code=mod_zone_page_state" class="sref">mod_zone_page_stateona>(4a href="+code=page_zone" class="sref">page_zoneona>(4a href="+code=page" class="sref">pageona>), 4a href="+code=NR_MLOCK" class="sref">NR_MLOCKona>, 
 L83">1 83ona>                                    4a href="+code=hpage_nr_pages" class="sref">hpage_nr_pagesona>(4a href="+code=page" class="sref">pageona>));o
 L84">1 84ona>                4a href="+code=count_vm_event" class="sref">count_vm_eventona>(4a href="+code=UNEVICTABLE_PGMLOCKED" class="sref">UNEVICTABLE_PGMLOCKEDona>);o
 L85">1 85ona>                if (!4a href="+code=isolate_lru_page" class="sref">isolate_lru_pageona>(4a href="+code=page" class="sref">pageona>))o
 L86">1 86ona>                        4a href="+code=putback_lru_page" class="sref">putback_lru_pageona>(4a href="+code=page" class="sref">pageona>);o
 L87">1 87ona>        }o
 L88">1 884/a>}o
 L89">1 894/a>o
 L90">1 904/a>4spa> class="comment">/**4/spa>
 
 L91">1 914/a>4spa> class="comment"> * munlock_vma_page - munlock atvma pageonspa>
 
 L92">1 924/a>4spa> class="comment"> *t@page - page to be unlockedonspa>
 
 L93">1 934/a>4spa> class="comment"> *4/spa>
 
 L94">1 944/a>4spa> class="comment"> *tcalled from munlock()/munmap() path with page supposedly /opthe LRU.4/spa>
 
 L95">1 954/a>4spa> class="comment"> *tWhen we munlock atpage, because thetvma where we found thetpage is being4/spa>
 
 L96">1 964/a>4spa> class="comment"> * munlock()ed /r munmap()ed, we want to check whetherpothertvmas hold the4/spa>
 
 L97">1 974/a>4spa> class="comment"> * page locked so that we can leave it /opthe unevictable lru list and not4/spa>
 
 L98">1 984/a>4spa> class="comment"> * bothertvmscan with it.  However, to walk thetpage's rmap list in4/spa>
 
 L99">1 994/a>4spa> class="comment"> * try_to_munlock() we must isolate thetpage from the LRU. tIftsomepother4/spa>
 
 L100">11004/a>4spa> class="comment"> * task has removed thetpage from the LRU, we won't be able to do that.4/spa>
 
 L101">11014/a>4spa> class="comment"> * So we clear the PageMlocked as we might not get anothertchance. tIftwe4/spa>
 
 L102">11024/a>4spa> class="comment"> *tcan't isolate thetpage, we leave it for putback_lru_page() and vmscan4/spa>
 
 L103">11034/a>4spa> class="comment"> * [page_referenced()/try_to_unmap()] to deal with.4/spa>
 
 L104">11044/a>4spa> class="comment"> */4/spa>
 
 L105">11054/a>void14a href="+code=munlock_vma_page" class="sref">munlock_vma_pageona>(struct14a href="+code=page" class="sref">pageona> *4a href="+code=page" class="sref">pageona>)o
 L106">1106ona>{o
 L107">1107ona>        4a href="+code=BUG_ON" class="sref">BUG_ONona>(!4a href="+code=PageLocked" class="sref">PageLockedona>(4a href="+code=page" class="sref">pageona>));o
 L108">11084/a>o
 L109">1109ona>        if (4a href="+code=TestClearPageMlocked" class="sref">TestClearPageMlockedona>(4a href="+code=page" class="sref">pageona>)) {o
 L110">1110ona>                4a href="+code=mod_zone_page_state" class="sref">mod_zone_page_stateona>(4a href="+code=page_zone" class="sref">page_zoneona>(4a href="+code=page" class="sref">pageona>), 4a href="+code=NR_MLOCK" class="sref">NR_MLOCKona>, 
 L111">1111ona>                                    -4a href="+code=hpage_nr_pages" class="sref">hpage_nr_pagesona>(4a href="+code=page" class="sref">pageona>));o
 L112">1112ona>                if (!4a href="+code=isolate_lru_page" class="sref">isolate_lru_pageona>(4a href="+code=page" class="sref">pageona>)) {o
 L113">1113ona>                        int14a href="+code=ret" class="sref">retona> =14a href="+code=SWAP_AGAIN" class="sref">SWAP_AGAINona>;o
 L114">1114ona>o
 L115">1115ona>                        4spa> class="comment">/*4/spa>
 
 L116">11164/a>4spa> class="comment">                         * Optimiza	  >: if thetpage was mapped just once,4/spa>
 
 L117">11174/a>4spa> class="comment">                         * that's our mapping and we don't need to check all the4/spa>
 
 L118">11184/a>4spa> class="comment">                         * othertvmas.4/spa>
 
 L119">11194/a>4spa> class="comment">                         */4/spa>
 
 L120">1120ona>                        if (4a href="+code=page_mapcount" class="sref">page_mapcountona>(4a href="+code=page" class="sref">pageona>) > 1)o
 L121">1121ona>                                4a href="+code=ret" class="sref">retona> =14a href="+code=try_to_munlock" class="sref">try_to_munlockona>(4a href="+code=page" class="sref">pageona>);o
 L122">1122ona>                        4spa> class="comment">/*4/spa>
 
 L123">11234/a>4spa> class="comment">                         * did1try_to_unlock() succeed /r punt?4/spa>
 
 L124">11244/a>4spa> class="comment">                         */4/spa>
 
 L125">1125ona>                        if (4a href="+code=ret" class="sref">retona> !=14a href="+code=SWAP_MLOCK" class="sref">SWAP_MLOCKona>)o
 L126">1126ona>                                4a href="+code=count_vm_event" class="sref">count_vm_eventona>(4a href="+code=UNEVICTABLE_PGMUNLOCKED" class="sref">UNEVICTABLE_PGMUNLOCKEDona>);o
 L127">11274/a>o
 L128">1128ona>                        4a href="+code=putback_lru_page" class="sref">putback_lru_pageona>(4a href="+code=page" class="sref">pageona>);o
 L129">1129ona>                } else {o
 L130">1130ona>                        4spa> class="comment">/*4/spa>
 
 L131">11314/a>4spa> class="comment">                         * Somepother task has removed thetpage from the LRU.4/spa>
 
 L132">11324/a>4spa> class="comment">                         * putback_lru_page() will take care of removing the4/spa>
 
 L133">11334/a>4spa> class="comment">                         * page from the unevictable list, if necessary.4/spa>
 
 L134">11344/a>4spa> class="comment">                         * vmscan [page_referenced()] will move thetpage back4/spa>
 
 L135">11354/a>4spa> class="comment">                         * to the unevictable list iftsomepothertvma has it4/spa>
 
 L136">11364/a>4spa> class="comment">                         * mlocked.4/spa>
 
 L137">11374/a>4spa> class="comment">                         */4/spa>
 
 L138">1138ona>                        if (4a href="+code=PageUnevictable" class="sref">PageUnevictableona>(4a href="+code=page" class="sref">pageona>))o
 L139">1139ona>                                4a href="+code=count_vm_event" class="sref">count_vm_eventona>(4a href="+code=UNEVICTABLE_PGSTRANDED" class="sref">UNEVICTABLE_PGSTRANDEDona>);o
 L140">1140ona>                        elseo
 L141">1141ona>                                4a href="+code=count_vm_event" class="sref">count_vm_eventona>(4a href="+code=UNEVICTABLE_PGMUNLOCKED" class="sref">UNEVICTABLE_PGMUNLOCKEDona>);o
 L142">1142ona>                }o
 L143">1143ona>        }o
 L144">11444/a>}o
 L145">11454/a>o
 L146">11464/a>4spa> class="comment">/**4/spa>
 
 L147">11474/a>4spa> class="comment"> * __mlock_vma_pages_range() -  mlock a range of pages in thetvma.4/spa>
 
 L148">11484/a>4spa> class="comment"> * @vma:   targettvma4/spa>
 
 L149">11494/a>4spa> class="comment"> * @start: start address4/spa>
 
 L150">11504/a>4spa> class="comment"> * @end:   end address4/spa>
 
 L151">11514/a>4spa> class="comment"> *4/spa>
 
 L152">11524/a>4spa> class="comment"> *tThis takes care of making the pages present too.4/spa>
 
 L153">11534/a>4spa> class="comment"> *4/spa>
 
 L154">11544/a>4spa> class="comment"> *treturn 0 /opsuccess, nega	 ve error code /operror.4/spa>
 
 L155">11554/a>4spa> class="comment"> *4/spa>
 
 L156">11564/a>4spa> class="comment"> * vma->vm_mm->mmap_sem must be held for at least read.4/spa>
 
 L157">11574/a>4spa> class="comment"> */4/spa>
 
 L158">11584/a>static long 4a href="+code=__mlock_vma_pages_range" class="sref">__mlock_vma_pages_rangeona>(struct14a href="+code=vm_area_struct" class="sref">vm_area_structona> *4a href="+code=vma" class="sref">vmaona>, 
 L159">1159ona>                                    unsigned long 4a href="+code=start" class="sref">startona>, unsigned long 4a href="+code=end" class="sref">endona>, 
 L160">1160ona>                                    int1*4a href="+code=nonblocking" class="sref">nonblockingona>)o
 L161">1161ona>{o
 L162">1162ona>        struct14a href="+code=mm_struct" class="sref">mm_structona> *4a href="+code=mm" class="sref">mmona> =14a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_mm" class="sref">vm_mmona>;o
 L163">1163ona>        unsigned long 4a href="+code=addr" class="sref">addrona> =14a href="+code=start" class="sref">startona>;o
 L164">1164ona>        int14a href="+code=nr_pages" class="sref">nr_pagesona> =1(4a href="+code=end" class="sref">endona> - 4a href="+code=start" class="sref">startona>) / 4a href="+code=PAGE_SIZE" class="sref">PAGE_SIZEona>;o
 L165">1165ona>        int14a href="+code=gup_flags" class="sref">gup_flagsona>;o
 L166">11664/a>o
 L167">1167ona>        4a href="+code=VM_BUG_ON" class="sref">VM_BUG_ONona>(4a href="+code=start" class="sref">startona> & ~4a href="+code=PAGE_MASK" class="sref">PAGE_MASKona>);o
 L168">1168ona>        4a href="+code=VM_BUG_ON" class="sref">VM_BUG_ONona>(4a href="+code=end" class="sref">endona>   & ~4a href="+code=PAGE_MASK" class="sref">PAGE_MASKona>);o
 L169">1169ona>        4a href="+code=VM_BUG_ON" class="sref">VM_BUG_ONona>(4a href="+code=start" class="sref">startona> <14a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_start" class="sref">vm_startona>);o
 L170">1170ona>        4a href="+code=VM_BUG_ON" class="sref">VM_BUG_ONona>(4a href="+code=end" class="sref">endona>   >14a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_end" class="sref">vm_endona>);o
 L171">1171ona>        4a href="+code=VM_BUG_ON" class="sref">VM_BUG_ONona>(!4a href="+code=rwsem_is_locked" class="sref">rwsem_is_lockedona>(&4a href="+code=mm" class="sref">mmona>->4a href="+code=mmap_sem" class="sref">mmap_semona>));o
 L172">11724/a>o
 L173">1173ona>        4a href="+code=gup_flags" class="sref">gup_flagsona> =14a href="+code=FOLL_TOUCH" class="sref">FOLL_TOUCHona> |14a href="+code=FOLL_MLOCK" class="sref">FOLL_MLOCKona>;o
 L174">1174ona>        4spa> class="comment">/*4/spa>
 
 L175">11754/a>4spa> class="comment">         *tWe want to touch writable mappings with a write fault in order4/spa>
 
 L176">11764/a>4spa> class="comment">         *tto break COW, except for shared mappings because these don't COW4/spa>
 
 L177">11774/a>4spa> class="comment">         * and we would not want to dirty them for nothing.4/spa>
 
 L178">11784/a>4spa> class="comment">         */4/spa>
 
 L179">1179ona>        if ((4a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_flags" class="sref">vm_flagsona> & (4a href="+code=VM_WRITE" class="sref">VM_WRITEona> |14a href="+code=VM_SHARED" class="sref">VM_SHAREDona>)) ==14a href="+code=VM_WRITE" class="sref">VM_WRITEona>)o
 L180">1180ona>                4a href="+code=gup_flags" class="sref">gup_flagsona> |=14a href="+code=FOLL_WRITE" class="sref">FOLL_WRITEona>;o
 L181">11814/a>o
 L182">1182ona>        4spa> class="comment">/*4/spa>
 
 L183">11834/a>4spa> class="comment">         *tWe want mlock to succeed for regions that have any permissions4/spa>
 
 L184">11844/a>4spa> class="comment">         * othertthaopPROT_NONE.4/spa>
 
 L185">11854/a>4spa> class="comment">         */4/spa>
 
 L186">1186ona>        if (4a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_flags" class="sref">vm_flagsona> & (4a href="+code=VM_READ" class="sref">VM_READona> |14a href="+code=VM_WRITE" class="sref">VM_WRITEona> |14a href="+code=VM_EXEC" class="sref">VM_EXECona>))o
 L187">1187ona>                4a href="+code=gup_flags" class="sref">gup_flagsona> |=14a href="+code=FOLL_FORCE" class="sref">FOLL_FORCEona>;o
 L188">11884/a>o
 L189">1189ona>        return 4a href="+code=__get_user_pages" class="sref">__get_user_pagesona>(4a href="+code=current" class="sref">currentona>, 4a href="+code=mm" class="sref">mmona>, 4a href="+code=addr" class="sref">addrona>, 4a href="+code=nr_pages" class="sref">nr_pagesona>, 4a href="+code=gup_flags" class="sref">gup_flagsona>, 
 L190">1190ona>                                4a href="+code=NULL" class="sref">NULLona>, 4a href="+code=NULL" class="sref">NULLona>, 4a href="+code=nonblocking" class="sref">nonblockingona>);o
 L191">11914/a>}o
 L192">11924/a>o
 L193">11934/a>4spa> class="comment">/*4/spa>
 
 L194">11944/a>4spa> class="comment"> *tconvert get_user_pages() return tion> to posix mlock() error4/spa>
 
 L195">11954/a>4spa> class="comment"> */4/spa>
 
 L196">11964/a>static int14a href="+code=__mlock_posix_error_return" class="sref">__mlock_posix_error_returnona>(long 4a href="+code=rettio" class="sref">rettioona>)o
 L197">11974/a>{o
 L198">1198ona>        if (4a href="+code=rettio" class="sref">rettioona> ==1-4a href="+code=EFAULT" class="sref">EFAULTona>)o
 L199">1199ona>                4a href="+code=rettio" class="sref">rettioona> =1-4a href="+code=ENOMEM" class="sref">ENOMEMona>;o
 L200">1200ona>        else if (4a href="+code=rettio" class="sref">rettioona> ==1-4a href="+code=ENOMEM" class="sref">ENOMEMona>)o
 L201">1201ona>                4a href="+code=rettio" class="sref">rettioona> =1-4a href="+code=EAGAIN" class="sref">EAGAINona>;o
 L202">1202ona>        return 4a href="+code=rettio" class="sref">rettioona>;o
 L203">12034/a>}o
 L204">1204ona>o
 L205">12054/a>4spa> class="comment">/**4/spa>
 
 L206">12064/a>4spa> class="comment"> * mlock_vma_pages_range() - mlock pages in specifiedtvma range.4/spa>
 
 L207">12074/a>4spa> class="comment"> * @vma - thetvma containing the specfiedtaddress rangeonspa>
 
 L208">12084/a>4spa> class="comment"> * @start - starting address in @vma to mlockonspa>
 
 L209">12094/a>4spa> class="comment"> * @end   - end address [+1] in @vma to mlockonspa>
 
 L210">12104/a>4spa> class="comment"> *onspa>
 
 L211">12114/a>4spa> class="comment"> * F/r mmap()/mremap()/expa>sion of mlockedtvma.4/spa>
 
 L212">12124/a>4spa> class="comment"> *4/spa>
 
 L213">12134/a>4spa> class="comment"> * return 0 /opsuccess for "normal" vmas.4/spa>
 
 L214">12144/a>4spa> class="comment"> *4/spa>
 
 L215">12154/a>4spa> class="comment"> *treturn numberpof pages [>10] to be removed from locked_vm /opsuccess4/spa>
 
 L216">12164/a>4spa> class="comment"> *pof "special" vmas.4/spa>
 
 L217">12174/a>4spa> class="comment"> */4/spa>
 
 L218">12184/a>long 4a href="+code=mlock_vma_pages_range" class="sref">mlock_vma_pages_rangeona>(struct14a href="+code=vm_area_struct" class="sref">vm_area_structona> *4a href="+code=vma" class="sref">vmaona>, 
 L219">1219ona>                        unsigned long 4a href="+code=start" class="sref">startona>, unsigned long 4a href="+code=end" class="sref">endona>)o
 L220">1220ona>{o
 L221">1221ona>        int14a href="+code=nr_pages" class="sref">nr_pagesona> =1(4a href="+code=end" class="sref">endona> - 4a href="+code=start" class="sref">startona>) / 4a href="+code=PAGE_SIZE" class="sref">PAGE_SIZEona>;o
 L222">1222ona>        4a href="+code=BUG_ON" class="sref">BUG_ONona>(!(4a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_flags" class="sref">vm_flagsona> & 4a href="+code=VM_LOCKED" class="sref">VM_LOCKEDona>));o
 L223">12234/a>o
 L224">1224ona>        4spa> class="comment">/*4/spa>
 
 L225">12254/a>4spa> class="comment">         *tfilterpunlockable vmas4/spa>
 
 L226">12264/a>4spa> class="comment">         */4/spa>
 
 L227">1227ona>        if (4a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_flags" class="sref">vm_flagsona> & (4a href="+code=VM_IO" class="sref">VM_IOona> |14a href="+code=VM_PFNMAP" class="sref">VM_PFNMAPona>))o
 L228">1228ona>                goto 4a href="+code=no_mlock" class="sref">no_mlockona>;o
 L229">12294/a>o
 L230">1230ona>        if (!((4a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_flags" class="sref">vm_flagsona> & 4a href="+code=VM_DONTEXPAND" class="sref">VM_DONTEXPANDona>) ||o
 L231">1231ona>                        4a href="+code=is_vm_hugetlb_page" class="sref">is_vm_hugetlb_pageona>(4a href="+code=vma" class="sref">vmaona>) ||o
 L232">1232ona>                        4a href="+code=vma" class="sref">vmaona> ==14a href="+code=get_gate_vma" class="sref">get_gate_vmaona>(4a href="+code=current" class="sref">currentona>->4a href="+code=mm" class="sref">mmona>))) {o
 L233">12334/a>o
 L234">1234ona>                4a href="+code=__mlock_vma_pages_range" class="sref">__mlock_vma_pages_rangeona>(4a href="+code=vma" class="sref">vmaona>, 4a href="+code=start" class="sref">startona>, 4a href="+code=end" class="sref">endona>, 4a href="+code=NULL" class="sref">NULLona>);o
 L235">12354/a>o
 L236">1236ona>                4spa> class="comment">/* Hide errors from mmap() and othertcallers */4/spa>
 
 L237">1237ona>                return 0;o
 L238">1238ona>        }o
 L239">12394/a>o
 L240">1240ona>        4spa> class="comment">/*4/spa>
 
 L241">12414/a>4spa> class="comment">         * User mapped kernel pages or huge pages:4/spa>
 
 L242">12424/a>4spa> class="comment">         * make these pages present to populate thetptes, but4/spa>
 
 L243">12434/a>4spa> class="comment">         * fall thru' to reset VM_LOCKED--no need to unlock, and4/spa>
 
 L244">12444/a>4spa> class="comment">         * return nr_pages so these don't gettcountedtagainst task's4/spa>
 
 L245">12454/a>4spa> class="comment">         * lockedtlimit.  huge pages are already countedtagainst4/spa>
 
 L246">12464/a>4spa> class="comment">         * lockedtvmtlimit.4/spa>
 
 L247">12474/a>4spa> class="comment">         */4/spa>
 
 L248">1248ona>        4a href="+code=make_pages_present" class="sref">make_pages_presentona>(4a href="+code=start" class="sref">startona>, 4a href="+code=end" class="sref">endona>);o
 L249">12494/a>o
 L250">12504/a>4a href="+code=no_mlock" class="sref">no_mlockona>:o
 L251">1251ona>        4a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_flags" class="sref">vm_flagsona> &= ~4a href="+code=VM_LOCKED" class="sref">VM_LOCKEDona>;    4spa> class="comment">/* and don't comepback! */4/spa>
 
 L252">1252ona>        return 4a href="+code=nr_pages" class="sref">nr_pagesona>;                4spa> class="comment">/* error /r pages NOT mlockedt*/4/spa>
 
 L253">12534/a>}o
 L254">1254ona>o
 L255">12554/a>4spa> class="comment">/*4/spa>
 
 L256">12564/a>4spa> class="comment"> * munlock_vma_pages_range() - munlock all pages in thetvma range.'4/spa>
 
 L257">12574/a>4spa> class="comment"> * @vma - vma containing range to be munlock()ed.4/spa>
 
 L258">12584/a>4spa> class="comment"> * @start - start address in @vma of thetrangeonspa>
 
 L259">12594/a>4spa> class="comment"> * @end - end of range in @vma.4/spa>
 
 L260">12604/a>4spa> class="comment"> *onspa>
 
 L261">12614/a>4spa> class="comment"> *  F/r mremap(), munmap() and exit().4/spa>
 
 L262">12624/a>4spa> class="comment"> *4/spa>
 
 L263">12634/a>4spa> class="comment"> * Called with @vma VM_LOCKED.4/spa>
 
 L264">12644/a>4spa> class="comment"> *4/spa>
 
 L265">12654/a>4spa> class="comment"> *tReturns with VM_LOCKED cleared.  Callers must be prepared to4/spa>
 
 L266">12664/a>4spa> class="comment"> * deal with this.4/spa>
 
 L267">12674/a>4spa> class="comment"> *4/spa>
 
 L268">12684/a>4spa> class="comment"> * We don't save and restore VM_LOCKED here because pages are4/spa>
 
 L269">12694/a>4spa> class="comment"> * still on lru. tIn unmap path, pages might be scanned by reclaim4/spa>
 
 L270">12704/a>4spa> class="comment"> * and re-mlockedtby try_to_{munlock|unmap} before we unmap and4/spa>
 
 L271">12714/a>4spa> class="comment"> * free them. tThis will result in freeing mlockedtpages.4/spa>
 
 L272">12724/a>4spa> class="comment"> */4/spa>
 
 L273">1273ona>void14a href="+code=munlock_vma_pages_range" class="sref">munlock_vma_pages_rangeona>(struct14a href="+code=vm_area_struct" class="sref">vm_area_structona> *4a href="+code=vma" class="sref">vmaona>, 
 L274">1274ona>                             unsigned long 4a href="+code=start" class="sref">startona>, unsigned long 4a href="+code=end" class="sref">endona>)o
 L275">12754/a>{o
 L276">1276ona>        unsigned long 4a href="+code=addr" class="sref">addrona>;o
 L277">12774/a>o
 L278">1278ona>        4a href="+code=lru_add_drain" class="sref">lru_add_drainona>();o
 L279">1279ona>        4a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_flags" class="sref">vm_flagsona> &= ~4a href="+code=VM_LOCKED" class="sref">VM_LOCKEDona>;o
 L280">12804/a>o
 L281">1281ona>        for (4a href="+code=addr" class="sref">addrona> =14a href="+code=start" class="sref">startona>; 4a href="+code=addr" class="sref">addrona> <14a href="+code=end" class="sref">endona>; 4a href="+code=addr" class="sref">addrona> +=14a href="+code=PAGE_SIZE" class="sref">PAGE_SIZEona>) {o
 L282">1282ona>                struct14a href="+code=page" class="sref">pageona> *4a href="+code=page" class="sref">pageona>;o
 L283">1283ona>                4spa> class="comment">/*4/spa>
 
 L284">12844/a>4spa> class="comment">                 * Although FOLL_DUMP is intended for get_dump_page(),4/spa>
 
 L285">12854/a>4spa> class="comment">                 * it just so happens that its special treatment of the4/spa>
 
 L286">12864/a>4spa> class="comment">                 * ZERO_PAGE (returning an error instead of doing get_page)4/spa>
 
 L287">12874/a>4spa> class="comment">                 * suits munlock very well (and iftsomehow an abnormal pageonspa>
 
 L288">12884/a>4spa> class="comment">                 * has sneakedtinto thetrange, we won't oops here: great).4/spa>
 
 L289">12894/a>4spa> class="comment">                 */4/spa>
 
 L290">1290ona>                4a href="+code=page" class="sref">pageona> =14a href="+code=follow_page" class="sref">follow_pageona>(4a href="+code=vma" class="sref">vmaona>, 4a href="+code=addr" class="sref">addrona>, 4a href="+code=FOLL_GET" class="sref">FOLL_GETona> |14a href="+code=FOLL_DUMP" class="sref">FOLL_DUMPona>);o
 L291">1291ona>                if (4a href="+code=page" class="sref">pageona> && !4a href="+code=IS_ERR" class="sref">IS_ERRona>(4a href="+code=page" class="sref">pageona>)) {o
 L292">1292ona>                        4a href="+code=lock_page" class="sref">lock_pageona>(4a href="+code=page" class="sref">pageona>);o
 L293">1293ona>                        4a href="+code=munlock_vma_page" class="sref">munlock_vma_pageona>(4a href="+code=page" class="sref">pageona>);o
 L294">1294ona>                        4a href="+code=unlock_page" class="sref">unlock_pageona>(4a href="+code=page" class="sref">pageona>);o
 L295">1295ona>                        4a href="+code=put_page" class="sref">put_pageona>(4a href="+code=page" class="sref">pageona>);o
 L296">1296ona>                }o
 L297">1297ona>                4a href="+code=cond_resched" class="sref">cond_reschedona>();o
 L298">1298ona>        }o
 L299">1299ona>}o
 L300">13004/a>o
 L301">13014/a>4spa> class="comment">/*4/spa>
 
 L302">13024/a>4spa> class="comment"> *tmlock_fixup  - handle mlock[all]/munlock[all] requests.4/spa>
 
 L303">13034/a>4spa> class="comment"> *4/spa>
 
 L304">13044/a>4spa> class="comment"> * Filters out "special" vmas -- VM_LOCKED never gets set for these, and4/spa>
 
 L305">13054/a>4spa> class="comment"> * munlock is a no-op.  However, for somepspecial vmas, we go ahead and4/spa>
 
 L306">13064/a>4spa> class="comment"> * populate thetptes via make_pages_present().4/spa>
 
 L307">13074/a>4spa> class="comment"> *4/spa>
 
 L308">13084/a>4spa> class="comment"> * F/r vmas that pass thetfilters, merge/split as appropriate.4/spa>
 
 L309">13094/a>4spa> class="comment"> */4/spa>
 
 L310">13104/a>static int14a href="+code=mlock_fixup" class="sref">mlock_fixupona>(struct14a href="+code=vm_area_struct" class="sref">vm_area_structona> *4a href="+code=vma" class="sref">vmaona>, struct14a href="+code=vm_area_struct" class="sref">vm_area_structona> **4a href="+code=prev" class="sref">prevona>, 
 L311">1311ona>        unsigned long 4a href="+code=start" class="sref">startona>, unsigned long 4a href="+code=end" class="sref">endona>,14a href="+code=vm_flags_t" class="sref">vm_flags_tona> 4a href="+code=newflags" class="sref">newflagsona>)o
 L312">13124/a>{o
 L313">1313ona>        struct14a href="+code=mm_struct" class="sref">mm_structona> *4a href="+code=mm" class="sref">mmona> =14a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_mm" class="sref">vm_mmona>;o
 L314">1314ona>        4a href="+code=pgoff_t" class="sref">pgoff_tona> 4a href="+code=pgoff" class="sref">pgoffona>;o
 L315">1315ona>        int14a href="+code=nr_pages" class="sref">nr_pagesona>;o
 L316">1316ona>        int14a href="+code=ret" class="sref">retona> =10;o
 L317">1317ona>        int14a href="+code=lock" class="sref">lockona> =1!!(4a href="+code=newflags" class="sref">newflagsona> & 4a href="+code=VM_LOCKED" class="sref">VM_LOCKEDona>);o
 L318">13184/a>o
 L319">1319ona>        if (4a href="+code=newflags" class="sref">newflagsona> ==14a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_flags" class="sref">vm_flagsona> || (4a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_flags" class="sref">vm_flagsona> & 4a href="+code=VM_SPECIAL" class="sref">VM_SPECIALona>) ||o
 L320">1320ona>            4a href="+code=is_vm_hugetlb_page" class="sref">is_vm_hugetlb_pageona>(4a href="+code=vma" class="sref">vmaona>) || 4a href="+code=vma" class="sref">vmaona> ==14a href="+code=get_gate_vma" class="sref">get_gate_vmaona>(4a href="+code=current" class="sref">currentona>->4a href="+code=mm" class="sref">mmona>))o
 L321">1321ona>                goto 4a href="+code=out" class="sref">outona>;       4spa> class="comment">/* don't set VM_LOCKED,  don't count1*/4/spa>
 
 L322">13224/a>o
 L323">1323ona>        4a href="+code=pgoff" class="sref">pgoffona> =14a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_pgoff" class="sref">vm_pgoffona> + ((4a href="+code=start" class="sref">startona> - 4a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_start" class="sref">vm_startona>) >>14a href="+code=PAGE_SHIFT" class="sref">PAGE_SHIFTona>);o
 L324">1324ona>        *4a href="+code=prev" class="sref">prevona> =14a href="+code=vma_merge" class="sref">vma_mergeona>(4a href="+code=mm" class="sref">mmona>, *4a href="+code=prev" class="sref">prevona>, 4a href="+code=start" class="sref">startona>, 4a href="+code=end" class="sref">endona>, 4a href="+code=newflags" class="sref">newflagsona>,14a href="+code=vma" class="sref">vmaona>->4a href="+code=anon_vma" class="sref">anon_vmaona>, 
 L325">1325ona>                          4a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_file" class="sref">vm_fileona>,14a href="+code=pgoff" class="sref">pgoffona>,14a href="+code=vma_policy" class="sref">vma_policyona>(4a href="+code=vma" class="sref">vmaona>));o
 L326">1326ona>        if (*4a href="+code=prev" class="sref">prevona>) {o
 L327">1327ona>                4a href="+code=vma" class="sref">vmaona> = *4a href="+code=prev" class="sref">prevona>;o
 L328">1328ona>                goto 4a href="+code=success" class="sref">success4/a>;o
 L329">1329ona>        }o
 L330">13304/a>o
 L331">1331ona>        if (4a href="+code=start" class="sref">startona> !=14a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_start" class="sref">vm_startona>) {o
 L332">1332ona>                4a href="+code=ret" class="sref">retona> =14a href="+code=split_vma" class="sref">split_vmaona>(4a href="+code=mm" class="sref">mmona>, 4a href="+code=vma" class="sref">vmaona>, 4a href="+code=start" class="sref">startona>, 1);o
 L333">1333ona>                if (4a href="+code=ret" class="sref">retona>)o
 L334">1334ona>                        goto 4a href="+code=out" class="sref">outona>;o
 L335">1335ona>        }o
 L336">13364/a>o
 L337">1337ona>        if (4a href="+code=end" class="sref">endona> !=14a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_end" class="sref">vm_endona>) {o
 L338">1338ona>                4a href="+code=ret" class="sref">retona> =14a href="+code=split_vma" class="sref">split_vmaona>(4a href="+code=mm" class="sref">mmona>, 4a href="+code=vma" class="sref">vmaona>, 4a href="+code=end" class="sref">endona>, 0);o
 L339">1339ona>                if (4a href="+code=ret" class="sref">retona>)o
 L340">1340ona>                        goto 4a href="+code=out" class="sref">outona>;o
 L341">1341ona>        }o
 L342">13424/a>o
 L343">13434/a>4a href="+code=success" class="sref">success4/a>:o
 L344">1344ona>        4spa> class="comment">/*4/spa>
 
 L345">13454/a>4spa> class="comment">         * Keep track of amount1of lockedtVM.4/spa>
 
 L346">13464/a>4spa> class="comment">         */4/spa>
 
 L347">1347ona>        4a href="+code=nr_pages" class="sref">nr_pagesona> =1(4a href="+code=end" class="sref">endona> - 4a href="+code=start" class="sref">startona>) >>14a href="+code=PAGE_SHIFT" class="sref">PAGE_SHIFTona>;o
 L348">1348ona>        if (!4a href="+code=lock" class="sref">lockona>)o
 L349">1349ona>                4a href="+code=nr_pages" class="sref">nr_pagesona> =1-4a href="+code=nr_pages" class="sref">nr_pagesona>;o
 L350">1350ona>        4a href="+code=mm" class="sref">mmona>->4a href="+code=locked_vm" class="sref">locked_vmona> +=14a href="+code=nr_pages" class="sref">nr_pagesona>;o
 L351">13514/a>o
 L352">1352ona>        4spa> class="comment">/*4/spa>
 
 L353">13534/a>4spa> class="comment">         * vm_flags is protectedtby the mmap_sem held in write mode.4/spa>
 
 L354">13544/a>4spa> class="comment">         * It's okay if try_to_unmap_one unmaps a page just afterpweonspa>
 
 L355">13554/a>4spa> class="comment">         * set VM_LOCKED, __mlock_vma_pages_range will bring itpback.4/spa>
 
 L356">13564/a>4spa> class="comment">         */4/spa>
 
 L357">13574/a>o
 L358">1358ona>        if (4a href="+code=lock" class="sref">lockona>)o
 L359">1359ona>                4a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_flags" class="sref">vm_flagsona> =14a href="+code=newflags" class="sref">newflagsona>;o
 L360">1360ona>        elseo
 L361">1361ona>                4a href="+code=munlock_vma_pages_range" class="sref">munlock_vma_pages_rangeona>(4a href="+code=vma" class="sref">vmaona>, 4a href="+code=start" class="sref">startona>, 4a href="+code=end" class="sref">endona>);o
 L362">13624/a>o
 L363">13634/a>4a href="+code=out" class="sref">outona>:o
 L364">1364ona>        *4a href="+code=prev" class="sref">prevona> =14a href="+code=vma" class="sref">vmaona>;o
 L365">1365ona>        return 4a href="+code=ret" class="sref">retona>;o
 L366">13664/a>}o
 L367">13674/a>o
 L368">13684/a>static int14a href="+code=do_mlock" class="sref">do_mlockona>(unsigned long 4a href="+code=start" class="sref">startona>, 4a href="+code=size_t" class="sref">size_tona> 4a href="+code=len" class="sref">lenona>, int14a href="+code=on" class="sref">onona>)o
 L369">13694/a>{o
 L370">1370ona>        unsigned long 4a href="+code=nstart" class="sref">nstartona>, 4a href="+code=end" class="sref">endona>, 4a href="+code=tmp" class="sref">tmpona>;o
 L371">1371ona>        struct14a href="+code=vm_area_struct" class="sref">vm_area_structona> * 4a href="+code=vma" class="sref">vmaona>, * 4a href="+code=prev" class="sref">prevona>;o
 L372">1372ona>        int14a href="+code=error" class="sref">error4/a>;o
 L373">13734/a>o
 L374">1374ona>        4a href="+code=VM_BUG_ON" class="sref">VM_BUG_ONona>(4a href="+code=start" class="sref">startona> & ~4a href="+code=PAGE_MASK" class="sref">PAGE_MASKona>);o
 L375">1375ona>        4a href="+code=VM_BUG_ON" class="sref">VM_BUG_ONona>(4a href="+code=len" class="sref">lenona> !=14a href="+code=PAGE_ALIGN" class="sref">PAGE_ALIGNona>(4a href="+code=len" class="sref">lenona>));o
 L376">1376ona>        4a href="+code=end" class="sref">endona> =14a href="+code=start" class="sref">startona> + 4a href="+code=len" class="sref">lenona>;o
 L377">1377ona>        if (4a href="+code=end" class="sref">endona> <14a href="+code=start" class="sref">startona>)o
 L378">1378ona>                return -4a href="+code=EINVAL" class="sref">EINVALona>;o
 L379">1379ona>        if (4a href="+code=end" class="sref">endona> ==14a href="+code=start" class="sref">startona>)o
 L380">1380ona>                return 0;o
 L381">1381ona>        4a href="+code=vma" class="sref">vmaona> = 4a href="+code=find_vma" class="sref">find_vmaona>(4a href="+code=current" class="sref">currentona>->4a href="+code=mm" class="sref">mmona>, 4a href="+code=start" class="sref">startona>);o
 L382">1382ona>        if (!4a href="+code=vma" class="sref">vmaona> || 4a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_start" class="sref">vm_startona> >14a href="+code=start" class="sref">startona>)o
 L383">1383ona>                return -4a href="+code=ENOMEM" class="sref">ENOMEMona>;o
 L384">1384ona>o
 L385">1385ona>        4a href="+code=prev" class="sref">prevona> =14a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_prev" class="sref">vm_prevona>;o
 L386">1386ona>        if (4a href="+code=start" class="sref">startona> >14a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_start" class="sref">vm_startona>)o
 L387">1387ona>                4a href="+code=prev" class="sref">prevona> =14a href="+code=vma" class="sref">vmaona>;o
 L388">13884/a>o
 L389">1389ona>        for (4a href="+code=nstart" class="sref">nstartona> =14a href="+code=start" class="sref">startona> ; ; ) {o
 L390">1390ona>                4a href="+code=vm_flags_t" class="sref">vm_flags_tona> 4a href="+code=newflags" class="sref">newflagsona>;o
 L391">13914/a>o
 L392">1392ona>                4spa> class="comment">/* Here we know that  vma->vm_start <= nstart < vma->vm_end. */4/spa>
 
 L393">13934/a>o
 L394">1394ona>                4a href="+code=newflags" class="sref">newflagsona> =14a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_flags" class="sref">vm_flagsona> | 4a href="+code=VM_LOCKED" class="sref">VM_LOCKEDona>;o
 L395">1395ona>                if (!4a href="+code=on" class="sref">onona>)o
 L396">1396ona>                        4a href="+code=newflags" class="sref">newflagsona> &= ~4a href="+code=VM_LOCKED" class="sref">VM_LOCKEDona>;o
 L397">13974/a>o
 L398">1398ona>                4a href="+code=tmp" class="sref">tmpona> =14a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_end" class="sref">vm_endona>;o
 L399">1399ona>                if (4a href="+code=tmp" class="sref">tmpona> >14a href="+code=end" class="sref">endona>)o
 L400">1400ona>                        4a href="+code=tmp" class="sref">tmpona> =14a href="+code=end" class="sref">endona>;o
 L401">1401ona>                4a href="+code=error" class="sref">error4/a> =14a href="+code=mlock_fixup" class="sref">mlock_fixupona>(4a href="+code=vma" class="sref">vmaona>, &4a href="+code=prev" class="sref">prevona>, 4a href="+code=nstart" class="sref">nstartona>, 4a href="+code=tmp" class="sref">tmpona>, 4a href="+code=newflags" class="sref">newflagsona>);o
 L402">1402ona>                if (4a href="+code=error" class="sref">error4/a>)o
 L403">1403ona>                        break;o
 L404">1404ona>                4a href="+code=nstart" class="sref">nstartona> =14a href="+code=tmp" class="sref">tmpona>;o
 L405">1405ona>                if (4a href="+code=nstart" class="sref">nstartona> <14a href="+code=prev" class="sref">prevona>->4a href="+code=vm_end" class="sref">vm_endona>)o
 L406">1406ona>                        4a href="+code=nstart" class="sref">nstartona> =14a href="+code=prev" class="sref">prevona>->4a href="+code=vm_end" class="sref">vm_endona>;o
 L407">1407ona>                if (4a href="+code=nstart" class="sref">nstartona> >= 4a href="+code=end" class="sref">endona>)o
 L408">1408ona>                        break;o
 L409">14094/a>o
 L410">1410ona>                4a href="+code=vma" class="sref">vmaona> = 4a href="+code=prev" class="sref">prevona>->4a href="+code=vm_next" class="sref">vm_nextona>;o
 L411">1411ona>                if (!4a href="+code=vma" class="sref">vmaona> || 4a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_start" class="sref">vm_startona> !=14a href="+code=nstart" class="sref">nstartona>) {o
 L412">1412ona>                        4a href="+code=error" class="sref">error4/a> =1-4a href="+code=ENOMEM" class="sref">ENOMEMona>;o
 L413">1413ona>                        break;o
 L414">1414ona>                }o
 L415">1415ona>        }o
 L416">1416ona>        return 4a href="+code=error" class="sref">error4/a>;o
 L417">1417ona>}o
 L418">14184/a>o
 L419">1419ona>static int14a href="+code=do_mlock_pages" class="sref">do_mlock_pagesona>(unsigned long 4a href="+code=start" class="sref">startona>, 4a href="+code=size_t" class="sref">size_tona> 4a href="+code=len" class="sref">lenona>, int14a href="+code=ignore_errors" class="sref">ignore_errorsona>)o
 L420">1420ona>{o
 L421">1421ona>        struct14a href="+code=mm_struct" class="sref">mm_structona> *4a href="+code=mm" class="sref">mmona> =14a href="+code=current" class="sref">currentona>->4a href="+code=mm" class="sref">mmona>;o
 L422">1422ona>        unsigned long 4a href="+code=end" class="sref">endona>,14a href="+code=nstart" class="sref">nstartona>, 4a href="+code=nend" class="sref">nendona>;o
 L423">1423ona>        struct14a href="+code=vm_area_struct" class="sref">vm_area_structona> *4a href="+code=vma" class="sref">vmaona> =14a href="+code=NULL" class="sref">NULLona>;o
 L424">1424ona>        int14a href="+code=locked" class="sref">lockedona> =10;o
 L425">1425ona>        int14a href="+code=ret" class="sref">retona> =10;o
 L426">14264/a>o
 L427">1427ona>        4a href="+code=VM_BUG_ON" class="sref">VM_BUG_ONona>(4a href="+code=start" class="sref">startona> & ~4a href="+code=PAGE_MASK" class="sref">PAGE_MASKona>);o
 L428">1428ona>        4a href="+code=VM_BUG_ON" class="sref">VM_BUG_ONona>(4a href="+code=len" class="sref">lenona> !=14a href="+code=PAGE_ALIGN" class="sref">PAGE_ALIGNona>(4a href="+code=len" class="sref">lenona>));o
 L429">1429ona>        4a href="+code=end" class="sref">endona> =14a href="+code=start" class="sref">startona> + 4a href="+code=len" class="sref">lenona>;o
 L430">14304/a>o
 L431">1431ona>        for (4a href="+code=nstart" class="sref">nstartona> =14a href="+code=start" class="sref">startona>;14a href="+code=nstart" class="sref">nstartona> <14a href="+code=end" class="sref">endona>; 4a href="+code=nstart" class="sref">nstartona> =14a href="+code=nend" class="sref">nendona>) {o
 L432">1432ona>                4spa> class="comment">/*4/spa>
 
 L433">14334/a>4spa> class="comment">                 * We want to fault in pages for [nstart; end) address range.4/spa>
 
 L434">14344/a>4spa> class="comment">                 * Find first corresponding VMA.4/spa>
 
 L435">14354/a>4spa> class="comment">                 */4/spa>
 
 L436">1436ona>                if (!4a href="+code=locked" class="sref">lockedona>) {o
 L437">1437ona>                        4a href="+code=locked" class="sref">lockedona> =11;o
 L438">1438ona>                        4a href="+code=down_read" class="sref">down_readona>(&4a href="+code=mm" class="sref">mmona>->4a href="+code=mmap_sem" class="sref">mmap_semona>);o
 L439">1439ona>                        4a href="+code=vma" class="sref">vmaona> = 4a href="+code=find_vma" class="sref">find_vmaona>(4a href="+code=mm" class="sref">mmona>, 4a href="+code=nstart" class="sref">nstartona>);o
 L440">1440ona>                } else if (4a href="+code=nstart" class="sref">nstartona> >= 4a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_end" class="sref">vm_endona>)o
 L441">1441ona>                        4a href="+code=vma" class="sref">vmaona> = 4a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_next" class="sref">vm_nextona>;o
 L442">1442ona>                if (!4a href="+code=vma" class="sref">vmaona> || 4a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_start" class="sref">vm_startona> >= 4a href="+code=end" class="sref">endona>)o
 L443">1443ona>                        break;o
 L444">1444ona>                4spa> class="comment">/*4/spa>
 
 L445">14454/a>4spa> class="comment">                 * Set [nstart; nend) to intersection of desired address4/spa>
 
 L446">14464/a>4spa> class="comment">                 * range with the first VMA. Also, skip undesirable VMA types.4/spa>
 
 L447">14474/a>4spa> class="comment">                 */4/spa>
 
 L448">1448ona>                4a href="+code=nend" class="sref">nendona> =14a href="+code=min" class="sref">minona>(4a href="+code=end" class="sref">endona>,14a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_end" class="sref">vm_endona>);o
 L449">1449ona>                if (4a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_flags" class="sref">vm_flagsona> & (4a href="+code=VM_IO" class="sref">VM_IOona> | 4a href="+code=VM_PFNMAP" class="sref">VM_PFNMAPona>))o
 L450">1450ona>                        continue;o
 L451">1451ona>                if (4a href="+code=nstart" class="sref">nstartona> <14a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_start" class="sref">vm_startona>)o
 L452">1452ona>                        4a href="+code=nstart" class="sref">nstartona> =14a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_start" class="sref">vm_startona>;o
 L453">1453ona>                4spa> class="comment">/*4/spa>
 
 L454">14544/a>4spa> class="comment">                 * Now fault in a range of pages. __mlock_vma_pages_range()4/spa>
 
 L455">14554/a>4spa> class="comment">                 * double checks thetvma flags, so that it won't mlock pagesonspa>
 
 L456">14564/a>4spa> class="comment">                 * if thetvma was already munlocked.4/spa>
 
 L457">14574/a>4spa> class="comment">                 */4/spa>
 
 L458">1458ona>                4a href="+code=ret" class="sref">retona> =14a href="+code=__mlock_vma_pages_range" class="sref">__mlock_vma_pages_rangeona>(4a href="+code=vma" class="sref">vmaona>, 4a href="+code=nstart" class="sref">nstartona>, 4a href="+code=nend" class="sref">nendona>, &4a href="+code=locked" class="sref">lockedona>);o
 L459">1459ona>                if (4a href="+code=ret" class="sref">retona> <10) {o
 L460">1460ona>                        if (4a href="+code=ignore_errors" class="sref">ignore_errorsona>) {o
 L461">1461ona>                                4a href="+code=ret" class="sref">retona> =10;o
 L462">1462ona>                                continue;       4spa> class="comment">/* continue at next VMA */4/spa>
 
 L463">1463ona>                        }o
 L464">1464ona>                        4a href="+code=ret" class="sref">retona> =14a href="+code=__mlock_posix_error_return" class="sref">__mlock_posix_error_returnona>(4a href="+code=ret" class="sref">retona>);o
 L465">1465ona>                        break;o
 L466">1466ona>                }o
 L467">1467ona>                4a href="+code=nend" class="sref">nendona> =14a href="+code=nstart" class="sref">nstartona> + 4a href="+code=ret" class="sref">retona> * 4a href="+code=PAGE_SIZE" class="sref">PAGE_SIZEona>;o
 L468">1468ona>                4a href="+code=ret" class="sref">retona> =10;o
 L469">1469ona>        }o
 L470">1470ona>        if (4a href="+code=locked" class="sref">lockedona>)o
 L471">1471ona>                4a href="+code=up_read" class="sref">up_readona>(&4a href="+code=mm" class="sref">mmona>->4a href="+code=mmap_sem" class="sref">mmap_semona>);o
 L472">1472ona>        return 4a href="+code=ret" class="sref">retona>;     4spa> class="comment">/* 0 or negative error code */4/spa>
 
 L473">14734/a>}o
 L474">1474ona>o
 L475">1475ona>4a href="+code=SYSCALL_DEFINE2" class="sref">SYSCALL_DEFINE2ona>(4a href="+code=mlock" class="sref">mlockona>, unsigned long, 4a href="+code=start" class="sref">startona>, 4a href="+code=size_t" class="sref">size_tona>, 4a href="+code=len" class="sref">lenona>)o
 L476">1476ona>{o
 L477">1477ona>        unsigned long 4a href="+code=locked" class="sref">lockedona>;o
 L478">1478ona>        unsigned long 4a href="+code=lock_limit" class="sref">lock_limitona>;o
 L479">1479ona>        int14a href="+code=error" class="sref">error4/a> =1-4a href="+code=ENOMEM" class="sref">ENOMEMona>;o
 L480">14804/a>o
 L481">1481ona>        if (!4a href="+code=can_do_mlock" class="sref">can_do_mlockona>())o
 L482">1482ona>                return -4a href="+code=EPERM" class="sref">EPERMona>;o
 L483">14834/a>o
 L484">1484ona>        4a href="+code=lru_add_drain_all" class="sref">lru_add_drain_allona>();    4spa> class="comment">/* flush pagevec */4/spa>
 
 L485">1485ona> 
 L486">1486ona>        4a href="+code=down_write" class="sref">down_writeona>(&4a href="+code=current" class="sref">currentona>->4a href="+code=mm" class="sref">mmona>->4a href="+code=mmap_sem" class="sref">mmap_semona>);o
 L487">1487ona>        4a href="+code=len" class="sref">lenona> =14a href="+code=PAGE_ALIGN" class="sref">PAGE_ALIGNona>(4a href="+code=len" class="sref">lenona> + (4a href="+code=start" class="sref">startona> & ~4a href="+code=PAGE_MASK" class="sref">PAGE_MASKona>));o
 L488">1488ona>        4a href="+code=start" class="sref">startona> &=14a href="+code=PAGE_MASK" class="sref">PAGE_MASKona>;o
 L489">14894/a>o
 L490">1490ona>        4a href="+code=locked" class="sref">lockedona> =14a href="+code=len" class="sref">lenona> >>14a href="+code=PAGE_SHIFT" class="sref">PAGE_SHIFTona>;o
 L491">1491ona>        4a href="+code=locked" class="sref">lockedona> +=14a href="+code=current" class="sref">currentona>->4a href="+code=mm" class="sref">mmona>->4a href="+code=locked_vm" class="sref">locked_vmona>;o
 L492">14924/a>o
 L493">1493ona>        4a href="+code=lock_limit" class="sref">lock_limitona> =14a href="+code=rlimit" class="sref">rlimitona>(4a href="+code=RLIMIT_MEMLOCK" class="sref">RLIMIT_MEMLOCKona>);o
 L494">1494ona>        4a href="+code=lock_limit" class="sref">lock_limitona> >>=14a href="+code=PAGE_SHIFT" class="sref">PAGE_SHIFTona>;o
 L495">1495ona> 
 L496">1496ona>        4spa> class="comment">/* check against resource limits */4/spa>
 
 L497">1497ona>        if ((4a href="+code=locked" class="sref">lockedona> <= 4a href="+code=lock_limit" class="sref">lock_limitona>) || 4a href="+code=capable" class="sref">capableona>(4a href="+code=CAP_IPC_LOCK" class="sref">CAP_IPC_LOCKona>))o
 L498">1498ona>                4a href="+code=error" class="sref">error4/a> =14a href="+code=do_mlock" class="sref">do_mlockona>(4a href="+code=start" class="sref">startona>, 4a href="+code=len" class="sref">lenona>, 1);o
 L499">1499ona>        4a href="+code=up_write" class="sref">up_writeona>(&4a href="+code=current" class="sref">currentona>->4a href="+code=mm" class="sref">mmona>->4a href="+code=mmap_sem" class="sref">mmap_semona>);o
 L500">1500ona>        if (!4a href="+code=error" class="sref">error4/a>)o
 L501">1501ona>                4a href="+code=error" class="sref">error4/a> =14a href="+code=do_mlock_pages" class="sref">do_mlock_pagesona>(4a href="+code=start" class="sref">startona>, 4a href="+code=len" class="sref">lenona>, 0);o
 L502">1502ona>        return 4a href="+code=error" class="sref">error4/a>;o
 L503">15034/a>}o
 L504">1504ona>o
 L505">1505ona>4a href="+code=SYSCALL_DEFINE2" class="sref">SYSCALL_DEFINE2ona>(4a href="+code=munlock" class="sref">munlockona>, unsigned long, 4a href="+code=start" class="sref">startona>, 4a href="+code=size_t" class="sref">size_tona>, 4a href="+code=len" class="sref">lenona>)o
 L506">1506ona>{o
 L507">1507ona>        int14a href="+code=ret" class="sref">retona>;o
 L508">15084/a>o
 L509">1509ona>        4a href="+code=down_write" class="sref">down_writeona>(&4a href="+code=current" class="sref">currentona>->4a href="+code=mm" class="sref">mmona>->4a href="+code=mmap_sem" class="sref">mmap_semona>);o
 L510">1510ona>        4a href="+code=len" class="sref">lenona> =14a href="+code=PAGE_ALIGN" class="sref">PAGE_ALIGNona>(4a href="+code=len" class="sref">lenona> + (4a href="+code=start" class="sref">startona> & ~4a href="+code=PAGE_MASK" class="sref">PAGE_MASKona>));o
 L511">1511ona>        4a href="+code=start" class="sref">startona> &=14a href="+code=PAGE_MASK" class="sref">PAGE_MASKona>;o
 L512">1512ona>        4a href="+code=ret" class="sref">retona> =14a href="+code=do_mlock" class="sref">do_mlockona>(4a href="+code=start" class="sref">startona>, 4a href="+code=len" class="sref">lenona>, 0);o
 L513">1513ona>        4a href="+code=up_write" class="sref">up_writeona>(&4a href="+code=current" class="sref">currentona>->4a href="+code=mm" class="sref">mmona>->4a href="+code=mmap_sem" class="sref">mmap_semona>);o
 L514">1514ona>        return 4a href="+code=ret" class="sref">retona>;o
 L515">1515ona>}o
 L516">15164/a>o
 L517">1517ona>static int14a href="+code=do_mlockall" class="sref">do_mlockallona>(int14a href="+code=flags" class="sref">flagsona>)o
 L518">15184/a>{o
 L519">1519ona>        struct14a href="+code=vm_area_struct" class="sref">vm_area_structona> * 4a href="+code=vma" class="sref">vmaona>, * 4a href="+code=prev" class="sref">prevona> =14a href="+code=NULL" class="sref">NULLona>;o
 L520">1520ona>        unsigned int14a href="+code=def_flags" class="sref">def_flagsona> =10;o
 L521">15214/a>o
 L522">1522ona>        if (4a href="+code=flags" class="sref">flagsona> & 4a href="+code=MCL_FUTURE" class="sref">MCL_FUTUREona>)o
 L523">1523ona>                4a href="+code=def_flags" class="sref">def_flagsona> =14a href="+code=VM_LOCKED" class="sref">VM_LOCKEDona>;o
 L524">1524ona>        4a href="+code=current" class="sref">currentona>->4a href="+code=mm" class="sref">mmona>->4a href="+code=def_flags" class="sref">def_flagsona> =14a href="+code=def_flags" class="sref">def_flagsona>;o
 L525">1525ona>        if (4a href="+code=flags" class="sref">flagsona> ==14a href="+code=MCL_FUTURE" class="sref">MCL_FUTUREona>)o
 L526">1526ona>                goto 4a href="+code=out" class="sref">outona>;o
 L527">15274/a>o
 L528">1528ona>        for (4a href="+code=vma" class="sref">vmaona> = 4a href="+code=current" class="sref">currentona>->4a href="+code=mm" class="sref">mmona>->4a href="+code=mmap" class="sref">mmapona>; 4a href="+code=vma" class="sref">vmaona> ; 4a href="+code=vma" class="sref">vmaona> = 4a href="+code=prev" class="sref">prevona>->4a href="+code=vm_next" class="sref">vm_nextona>) {o
 L529">1529ona>                4a href="+code=vm_flags_t" class="sref">vm_flags_tona> 4a href="+code=newflags" class="sref">newflagsona>;o
 L530">15304/a>o
 L531">1531ona>                4a href="+code=newflags" class="sref">newflagsona> =14a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_flags" class="sref">vm_flagsona> | 4a href="+code=VM_LOCKED" class="sref">VM_LOCKEDona>;o
 L532">1532ona>                if (!(4a href="+code=flags" class="sref">flagsona> & 4a href="+code=MCL_CURRENT" class="sref">MCL_CURRENTona>))o
 L533">1533ona>                        4a href="+code=newflags" class="sref">newflagsona> &= ~4a href="+code=VM_LOCKED" class="sref">VM_LOCKEDona>;o
 L534">1534ona>o
 L535">1535ona>                4spa> class="comment">/* Ignore errors */4/spa>
 
 L536">1536ona>                4a href="+code=mlock_fixup" class="sref">mlock_fixupona>(4a href="+code=vma" class="sref">vmaona>, &4a href="+code=prev" class="sref">prevona>, 4a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_start" class="sref">vm_startona>,14a href="+code=vma" class="sref">vmaona>->4a href="+code=vm_end" class="sref">vm_endona>, 4a href="+code=newflags" class="sref">newflagsona>);o
 L537">1537ona>        }o
 L538">1538ona>4a href="+code=out" class="sref">outona>:o
 L539">1539ona>        return 0;o
 L540">1540ona>}o
 L541">15414/a>o
 L542">1542ona>4a href="+code=SYSCALL_DEFINE1" class="sref">SYSCALL_DEFINE1ona>(4a href="+code=mlockall" class="sref">mlockallona>, int, 4a href="+code=flags" class="sref">flagsona>)o
 L543">1543ona>{o
 L544">1544ona>        unsigned long 4a href="+code=lock_limit" class="sref">lock_limitona>;o
 L545">1545ona>        int14a href="+code=ret" class="sref">retona> =1-4a href="+code=EINVAL" class="sref">EINVALona>;o
 L546">15464/a>o
 L547">1547ona>        if (!4a href="+code=flags" class="sref">flagsona> || (4a href="+code=flags" class="sref">flagsona> & ~(4a href="+code=MCL_CURRENT" class="sref">MCL_CURRENTona> | 4a href="+code=MCL_FUTURE" class="sref">MCL_FUTUREona>)))o
 L548">1548ona>                goto 4a href="+code=out" class="sref">outona>;o
 L549">15494/a>o
 L550">1550ona>        4a href="+code=ret" class="sref">retona> =1-4a href="+code=EPERM" class="sref">EPERMona>;o
 L551">1551ona>        if (!4a href="+code=can_do_mlock" class="sref">can_do_mlockona>())o
 L552">1552ona>                goto 4a href="+code=out" class="sref">outona>;o
 L553">15534/a>o
 L554">1554ona>        if (4a href="+code=flags" class="sref">flagsona> & 4a href="+code=MCL_CURRENT" class="sref">MCL_CURRENTona>)o
 L555">1555ona>                4a href="+code=lru_add_drain_all" class="sref">lru_add_drain_allona>();    4spa> class="comment">/* flush pagevec */4/spa>
 
 L556">15564/a>o
 L557">1557ona>        4a href="+code=down_write" class="sref">down_writeona>(&4a href="+code=current" class="sref">currentona>->4a href="+code=mm" class="sref">mmona>->4a href="+code=mmap_sem" class="sref">mmap_semona>);o
 L558">15584/a>o
 L559">1559ona>        4a href="+code=lock_limit" class="sref">lock_limitona> =14a href="+code=rlimit" class="sref">rlimitona>(4a href="+code=RLIMIT_MEMLOCK" class="sref">RLIMIT_MEMLOCKona>);o
 L560">1560ona>        4a href="+code=lock_limit" class="sref">lock_limitona> >>=14a href="+code=PAGE_SHIFT" class="sref">PAGE_SHIFTona>;o
 L561">15614/a>o
 L562">1562ona>        4a href="+code=ret" class="sref">retona> =1-4a href="+code=ENOMEM" class="sref">ENOMEMona>;o
 L563">1563ona>        if (!(4a href="+code=flags" class="sref">flagsona> & 4a href="+code=MCL_CURRENT" class="sref">MCL_CURRENTona>) || (4a href="+code=current" class="sref">currentona>->4a href="+code=mm" class="sref">mmona>->4a href="+code=total_vm" class="sref">total_vmona> <= 4a href="+code=lock_limit" class="sref">lock_limitona>) ||o
 L564">1564ona>            4a href="+code=capable" class="sref">capableona>(4a href="+code=CAP_IPC_LOCK" class="sref">CAP_IPC_LOCKona>))o
 L565">1565ona>                4a href="+code=ret" class="sref">retona> =14a href="+code=do_mlockall" class="sref">do_mlockallona>(4a href="+code=flags" class="sref">flagsona>);o
 L566">1566ona>        4a href="+code=up_write" class="sref">up_writeona>(&4a href="+code=current" class="sref">currentona>->4a href="+code=mm" class="sref">mmona>->4a href="+code=mmap_sem" class="sref">mmap_semona>);o
 L567">1567ona>        if (!4a href="+code=ret" class="sref">retona> && (4a href="+code=flags" class="sref">flagsona> & 4a href="+code=MCL_CURRENT" class="sref">MCL_CURRENTona>)) {o
 L568">1568ona>                4spa> class="comment">/* Ignore errors */4/spa>
 
 L569">1569ona>                4a href="+code=do_mlock_pages" class="sref">do_mlock_pagesona>(0, 4a href="+code=TASK_SIZE" class="sref">TASK_SIZEona>, 1);o
 L570">1570ona>        }o
 L571">1571ona>4a href="+code=out" class="sref">outona>:o
 L572">1572ona>        return 4a href="+code=ret" class="sref">retona>;o
 L573">15734/a>}o
 L574">1574ona>o
 L575">1575ona>4a href="+code=SYSCALL_DEFINE0" class="sref">SYSCALL_DEFINE0ona>(4a href="+code=munlockall" class="sref">munlockallona>)o
 L576">1576ona>{o
 L577">1577ona>        int14a href="+code=ret" class="sref">retona>;o
 L578">15784/a>o
 L579">1579ona>        4a href="+code=down_write" class="sref">down_writeona>(&4a href="+code=current" class="sref">currentona>->4a href="+code=mm" class="sref">mmona>->4a href="+code=mmap_sem" class="sref">mmap_semona>);o
 L580">1580ona>        4a href="+code=ret" class="sref">retona> =14a href="+code=do_mlockall" class="sref">do_mlockallona>(0);o
 L581">1581ona>        4a href="+code=up_write" class="sref">up_writeona>(&4a href="+code=current" class="sref">currentona>->4a href="+code=mm" class="sref">mmona>->4a href="+code=mmap_sem" class="sref">mmap_semona>);o
 L582">1582ona>        return 4a href="+code=ret" class="sref">retona>;o
 L583">15834/a>}o
 L584">1584ona>o
 L585">15854/a>4spa> class="comment">/*4/spa>
 
 L586">15864/a>4spa> class="comment"> * Objects with different lifetime than processes (SHM_LOCK and SHM_HUGETLB4/spa>
 
 L587">15874/a>4spa> class="comment"> * shm segments) get accounted against thetuser_struct instead.4/spa>
 
 L588">1588ona>4spa> class="comment"> */4/spa>
 
 L589">1589ona>static 4a href="+code=DEFINE_SPINLOCK" class="sref">DEFINE_SPINLOCKona>(4a href="+code=shmlock_user_lock" class="sref">shmlock_user_lockona>);o
 L590">15904/a>o
 L591">1591ona>int14a href="+code=user_shm_lock" class="sref">user_shm_lockona>(4a href="+code=size_t" class="sref">size_tona> 4a href="+code=size" class="sref">sizeona>, struct14a href="+code=user_struct" class="sref">user_structona> *4a href="+code=user" class="sref">userona>)o
 L592">15924/a>{o
 L593">1593ona>        unsigned long 4a href="+code=lock_limit" class="sref">lock_limitona>, 4a href="+code=locked" class="sref">lockedona>;o
 L594">1594ona>        int14a href="+code=allowed" class="sref">allowedona> =10;o
 L595">1595ona> 
 L596">1596ona>        4a href="+code=locked" class="sref">lockedona> =1(4a href="+code=size" class="sref">sizeona> + 4a href="+code=PAGE_SIZE" class="sref">PAGE_SIZEona> - 1) >>14a href="+code=PAGE_SHIFT" class="sref">PAGE_SHIFTona>;o
 L597">1597ona>        4a href="+code=lock_limit" class="sref">lock_limitona> =14a href="+code=rlimit" class="sref">rlimitona>(4a href="+code=RLIMIT_MEMLOCK" class="sref">RLIMIT_MEMLOCKona>);o
 L598">1598ona>        if (4a href="+code=lock_limit" class="sref">lock_limitona> ==14a href="+code=RLIM_INFINITY" class="sref">RLIM_INFINITYona>)o
 L599">1599ona>                4a href="+code=allowed" class="sref">allowedona> =11;o
 L600">1600ona>        4a href="+code=lock_limit" class="sref">lock_limitona> >>=14a href="+code=PAGE_SHIFT" class="sref">PAGE_SHIFTona>;o
 L601">1601ona>        4a href="+code=spin_lock" class="sref">spin_lockona>(&4a href="+code=shmlock_user_lock" class="sref">shmlock_user_lockona>);o
 L602">1602ona>        if (!4a href="+code=allowed" class="sref">allowedona> &&o
 L603">1603ona>            4a href="+code=locked" class="sref">lockedona> + 4a href="+code=user" class="sref">userona>->4a href="+code=locked_shm" class="sref">locked_shm01">1601o 4a href="+code=lock_limit" class="sref">lock_limitona> &; (4a hrefa href="+code=can_pable" class="sref">capableona>(4a href="+code=CAP_IPC_LOCK" class="sref">CAP_IPC_LOCKona>))o
 L604">1604ona>                goto 4a href="+code=out" class="sref">outona>;o
 L605">1605ona>        4a href="+code=get_uid" class="sref">get_uidona>(4a href="+code=user" class="sref">userona>);o
 L606">1606ona>        4a href="+code=user" class="sref">userona>->4a href="+code=locked_shm" class="sref">locked_shm01">1+=14a href="+code=locked" class="sref">lockedona>;o
 L607">1607ona>        4a href="+code=allowed" class="sref">allowedona> =11;o
 L608">1608ona>4a href="+code=out" class="sref">outona>:o
 L609">1609ona>        4a href="+code=spin_unlock" class="sref">spin_unlockona>(&4a href="+code=shmlock_user_lock" class="sref">shmlock_user_lockona>);o
 L610">1610ona>        return 4a href="+code=allowed" class="sref">allowedona>;o
 L611">1611ona>}o
 L612">16124/a>o
 L613">1613ona>void14a href="+code=user_shm_unlock" class="sref">user_shm_unlockona>(4a href="+code=size_t" class="sref">size_tona> 4a href="+code=size" class="sref">sizeona>, struct14a href="+code=user_struct" class="sref">user_structona> *4a href="+code=user" class="sref">userona>)o
 L614">1614ona>{o
 L615">1615ona>        4a href="+code=spin_lock" class="sref">spin_lockona>(&4a href="+code=shmlock_user_lock" class="sref">shmlock_user_lockona>);o
 L616">1616ona>        4a href="+code=user" class="sref">userona>->4a href="+code=locked_shm" class="sref">locked_shm01">1-=1(4a href="+code=size" class="sref">sizeona> + 4a href="+code=PAGE_SIZE" class="sref">PAGE_SIZEona> - 1) >>14a href="+code=PAGE_SHIFT" class="sref">PAGE_SHIFTona>;o
 L617">1617ona>        4a href="+code=spin_unlock" class="sref">spin_unlockona>(&4a href="+code=shmlock_user_lock" class="sref">shmlock_user_lockona>);o
 L618">1618ona>        4a href="+code=free_uid" class="sref">free_uidona>(4a href="+code=user" class="sref">userona>);o
 L619">1619ona>}o
 L620">1620ona>
lxr.linux.no kindly hosted by Redpill Linpro ASona>, provider of Linux consulting and operations services since 1995.