linux/lib/lru_cache.c
<<
on v14./spa 14./form 14.a on v14 href="../linux+v3.7.5/lib/lru_cache.c">on v14.img src="../.static/gfx/right.png" alt=">>">on./spa on.spa class="lxr_search">on v ="+search" method="post" onsubmit="return do_search(this);">on v14.input typ hidden" nam navtarget" ion> ">on v14.input typ text" nam search" id search">on v14.buttopttyp submit">Searchon v14Prefs 14./a>on./spa v14 4./div v14 4.form ac > ="ajax+*" method="post" onsubmit="return false;">on.input typ hidden" nam ajax_lookup" id ajax_lookup" ion> ">o v14 4./form o v14 4.div class="headingbottom">
.div id file_contents"
4 41./a>.spa
 class="comment">/*./spa
  4 42./a>.spa
 class="comment">4 4lru_cache.c./spa
  4 43./a>o4 44./a>.spa
 class="comment">4 4This file is part of DRBD by Philipp Reisner and Lars Ellenberg../spa
  4 45./a>o4 46./a>.spa
 class="comment">4 4Copyright (C) 2003-2008, LINBIT Informa4 47./a>.spa
 class="comment">4 4Copyright (C) 2003-2008, Philipp Reisner <philipp.reisner@linbit.com>../spa
  4 48./a>.spa
 class="comment">4 4Copyright (C) 2003-2008, Lars Ellenberg <lars.ellenberg@linbit.com>../spa
  4 49./a>o4 .10"a>.spa
 class="comment">4 4drbd is free software; you ca
 redistribute it and/or modify./spa
  4 11./a>.spa
 class="comment">4 4it under the terms of the GNU General Public License as published by./spa
  4 12./a>.spa
 class="comment">4 4the Free Software Founda
)./spa
  4 13./a>.spa
 class="comment">4 4any later vers/op../spa
  4 14./a>o4 150"a>.spa
 class="comment">4 4drbd is distributed in4the hope that it will be useful,./spa
  4 16./a>.spa
 class="comment">4 4but WITHOUT ANY WARRANTY; without even4the implied warranty of./spa
  4 17./a>.spa
 class="comment">4 4MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the./spa
  4 18./a>.spa
 class="comment">4 4GNU General Public License for more details../spa
  4 19./a>o4 210"a>.spa
 class="comment">4 4You should have received a copy of the GNU General Public License./spa
  4 21./a>.spa
 class="comment">4 4along with4drbd; see the file COPYING.  If not, write to./spa
  4 22./a>.spa
 class="comment">4 4the Free Software Founda4 23./a>o4 24./a>.spa
 class="comment">4*/./spa
  4 25./a>o4 26./a>#include <linux/module.h./a>>o4 27./a>#include <linux/bitops.h./a>>o4 28./a>#include <linux/slab.h./a>>o4 29./a>#include <linux/string.h./a>> .spa
 class="comment">/* for memset4*/./spa
  4 30./a>#include <linux/seq_file.h./a>> .spa
 class="comment">/* for seq_printf4*/./spa
  4 31./a>#include <linux/lru_cache.h./a>>o4 32./a>o4 33./a>.a href="+code=MODULE_AUTHOR" class="sref">MODULE_AUTHOR./a>(.spa
 class="string">"Philipp Reisner <phil@linbit.com>, "./spa
  4 34./a>              .spa
 class="string">"Lars Ellenberg <lars@linbit.com>"./spa
 );o4 35./a>.a href="+code=MODULE_DESCRIPTION" class="sref">MODULE_DESCRIPTION./a>(.spa
 class="string">"lru_cache - Track sets of hot objects"./spa
 );o4 36./a>.a href="+code=MODULE_LICENSE" class="sref">MODULE_LICENSE./a>(.spa
 class="string">"GPL"./spa
 );o4 37./a>o4 38./a>.spa
 class="comment">/* this is developers aid only../spa
  4 39./a>.spa
 class="comment">4* it catches concurrent access (lack of locking on4the users part)4*/./spa
  4 40./a>#define .a href="+code=PARANOIA_ENTRY" class="sref">PARANOIA_ENTRY./a>() do {           \ 4 41./a>        .a href="+code=BUG_ON" class="sref">BUG_ON./a>(!.a href="+code=lc" class="sref">lc./a>);                    \ 4 42./a>        .a href="+code=BUG_ON" class="sref">BUG_ON./a>(!.a href="+code=lc" class="sref">lc./a>->.a href="+code=nr_elements" class="sref">nr_elements./a>);       \ 4 43./a>        .a href="+code=BUG_ON" class="sref">BUG_ON./a>(.a href="+code=test_and_set_bit" class="sref">test_and_set_bit./a>(.a href="+code=__LC_PARANOIA" class="sref">__LC_PARANOIA./a>, &.a href="+code=lc" class="sref">lc./a>->.a href="+code=flags" class="sref">flags./a>)); \ 4 44./a>} while (0) 4 45./a>o4 46./a>#define .a href="+code=RETURN" class="sref">RETURN./a>(.a href="+code=x" class="sref">x./a>...)     do { \ 4 47./a>        .a href="+code=clear_bit" class="sref">clear_bit./a>(.a href="+code=__LC_PARANOIA" class="sref">__LC_PARANOIA./a>, &.a href="+code=lc" class="sref">lc./a>->.a href="+code=flags" class="sref">flags./a>); \ 4 48./a>        .a href="+code=smp_mb__after_clear_bit" class="sref">smp_mb__after_clear_bit./a>(); return .a href="+code=x" class="sref">x./a> ; } while (0) 4 49./a>o4 510"a>.spa
 class="comment">/* BUG() if e is not one of the elements tracked by lc4*/./spa
  4 51./a>#define .a href="+code=PARANOIA_LC_ELEMENT" class="sref">PARANOIA_LC_ELEMENT./a>(.a href="+code=lc" class="sref">lc./a>, .a href="+code=e" class="sref">e./a>) do { \ 4 52./a>        struct .a href="+code=lru_cache" class="sref">lru_cache./a> *.a href="+code=lc_" class="sref">lc_./a> = (.a href="+code=lc" class="sref">lc./a>);   \ 4 53./a>        struct .a href="+code=lc_element" class="sref">lc_element./a> *.a href="+code=e_" class="sref">e_./a> = (.a href="+code=e" class="sref">e./a>);    \ 4 54./a>        unsigned .a href="+code=i" class="sref">i./a> = .a href="+code=e_" class="sref">e_./a>->.a href="+code=lc_index" class="sref">lc_index./a>;      \ 4 55./a>        .a href="+code=BUG_ON" class="sref">BUG_ON./a>(.a href="+code=i" class="sref">i./a> >= .a href="+code=lc_" class="sref">lc_./a>->.a href="+code=nr_elements" class="sref">nr_elements./a>);  \ 4 56./a>        .a href="+code=BUG_ON" class="sref">BUG_ON./a>(.a href="+code=lc_" class="sref">lc_./a>->.a href="+code=lc_element" class="sref">lc_element./a>[.a href="+code=i" class="sref">i./a>] != .a href="+code=e_" class="sref">e_./a>); } while (0) 4 57./a>o4 58./a>.spa
 class="comment">/**./spa
  4 59./a>.spa
 class="comment">4* lc_create - prepares to track objects in4a
 ac  ve set./spa
  4 610"a>.spa
 class="comment">4* @nam
: descrip  ve nam
 only used in4lc_seq_printf_stats and lc_seq_dump_details./spa
  4 61./a>.spa
 class="comment">4* @e_count: number of elements allowed to be ac  ve simultaneously./spa
  4 62./a>.spa
 class="comment">4* @e_siz
: siz
 of the tracked objects./spa
  4 63./a>.spa
 class="comment">4* @e_off: offset4to the &struct lc_element member in4a tracked object./spa
  4 64./a>.spa
 class="comment">4*./spa
  4 650"a>.spa
 class="comment">4* Returns a pointer to a newly initializ
d struct lru_cache on success,./spa
  4 66./a>.spa
 class="comment">4* or NULL on (alloca4 67./a>.spa
 class="comment">4*/./spa
  4 68./a>struct .a href="+code=lru_cache" class="sref">lru_cache./a> *.a href="+code=lc_create" class="sref">lc_create./a>(const char *.a href="+code=nam
" class="sref">nam
./a>, struct .a href="+code=kmem_cache" class="sref">kmem_cache./a> *.a href="+code=cache" class="sref">cache./a>, 4 69./a>                unsigned .a href="+code=e_count" class="sref">e_count./a>, .a href="+code=siz
_t" class="sref">siz
_t./a> .a href="+code=e_siz
" class="sref">e_siz
./a>, .a href="+code=siz
_t" class="sref">siz
_t./a> .a href="+code=e_off" class="sref">e_off./a>) 4 710"a>{ 4 71./a>        struct .a href="+code=hlist_head" class="sref">hlist_head./a> *.a href="+code=slot" class="sref">slot./a> = .a href="+code=NULL" class="sref">NULL./a>; 4 72./a>        struct .a href="+code=lc_element" class="sref">lc_element./a> **.a href="+code=element" class="sref">element./a> = .a href="+code=NULL" class="sref">NULL./a>; 4 73./a>        struct .a href="+code=lru_cache" class="sref">lru_cache./a> *.a href="+code=lc" class="sref">lc./a>; 4 74./a>        struct .a href="+code=lc_element" class="sref">lc_element./a> *.a href="+code=e" class="sref">e./a>; 4 75./a>        unsigned .a href="+code=cache_obj_siz
" class="sref">cache_obj_siz
./a> = .a href="+code=kmem_cache_siz
" class="sref">kmem_cache_siz
./a>(.a href="+code=cache" class="sref">cache./a>);o4 76./a>        unsigned .a href="+code=i" class="sref">i./a>;o4 77./a>o4 78./a>        .a href="+code=WARN_ON" class="sref">WARN_ON./a>(.a href="+code=cache_obj_siz
" class="sref">cache_obj_siz
./a> < .a href="+code=e_siz
" class="sref">e_siz
./a>);o4 79./a>        if (.a href="+code=cache_obj_siz
" class="sref">cache_obj_siz
./a> < .a href="+code=e_siz
" class="sref">e_siz
./a>) 4 80./a>                return .a href="+code=NULL" class="sref">NULL./a>; 4 81./a>o4 82./a>        .spa
 class="comment">/* e_count too big; would probably fail the alloca4 83./a>.spa
 class="comment">4 4444444* for typical use cases, e_count should be few thousand at most.4*/./spa
  4 84./a>        if (.a href="+code=e_count" class="sref">e_count./a> > .a href="+code=LC_MAX_ACTIVE" class="sref">LC_MAX_ACTIVE./a>) 4 85./a>                return .a href="+code=NULL" class="sref">NULL./a>; 4 86./a>o4 87./a>        .a href="+code=slot" class="sref">slot./a> = .a href="+code=kcalloc" class="sref">kcalloc./a>(.a href="+code=e_count" class="sref">e_count./a>, siz
of(struct .a href="+code=hlist_head" class="sref">hlist_head./a>), .a href="+code=GFP_KERNEL" class="sref">GFP_KERNEL./a>);o4 88./a>        if (!.a href="+code=slot" class="sref">slot./a>) 4 89./a>                goto .a href="+code=out_fail" class="sref">out_fail./a>; 4 90./a>        .a href="+code=element" class="sref">element./a> = .a href="+code=kzalloc" class="sref">kzalloc./a>(.a href="+code=e_count" class="sref">e_count./a>4* siz
of(struct .a href="+code=lc_element" class="sref">lc_element./a> *), .a href="+code=GFP_KERNEL" class="sref">GFP_KERNEL./a>);o4 91./a>        if (!.a href="+code=element" class="sref">element./a>) 4 92./a>                goto .a href="+code=out_fail" class="sref">out_fail./a>; 4 93./a>o4 94./a>        .a href="+code=lc" class="sref">lc./a> = .a href="+code=kzalloc" class="sref">kzalloc./a>(siz
of(*.a href="+code=lc" class="sref">lc./a>), .a href="+code=GFP_KERNEL" class="sref">GFP_KERNEL./a>);o4 95./a>        if (!.a href="+code=lc" class="sref">lc./a>)o4 96./a>                goto .a href="+code=out_fail" class="sref">out_fail./a>; 4 97./a>o4 98./a>        .a href="+code=INIT_LIST_HEAD" class="sref">INIT_LIST_HEAD./a>(&.a href="+code=lc" class="sref">lc./a>->.a href="+code=in_use" class="sref">in_use./a>);o4 99./a>        .a href="+code=INIT_LIST_HEAD" class="sref">INIT_LIST_HEAD./a>(&.a href="+code=lc" class="sref">lc./a>->.a href="+code=lru" class="sref">lru./a>);o4100./a>        .a href="+code=INIT_LIST_HEAD" class="sref">INIT_LIST_HEAD./a>(&.a href="+code=lc" class="sref">lc./a>->.a href="+code=free" class="sref">free./a>);o4101./a>o4102./a>        .a href="+code=lc" class="sref">lc./a>->.a href="+code=nam
" class="sref">nam
./a> = .a href="+code=nam
" class="sref">nam
./a>;o4103./a>        .a href="+code=lc" class="sref">lc./a>->.a href="+code=element_siz
" class="sref">element_siz
./a> = .a href="+code=e_siz
" class="sref">e_siz
./a>;o4104./a>        .a href="+code=lc" class="sref">lc./a>->.a href="+code=element_off" class="sref">element_off./a> = .a href="+code=e_off" class="sref">e_off./a>;o4105./a>        .a href="+code=lc" class="sref">lc./a>->.a href="+code=nr_elements" class="sref">nr_elements./a> = .a href="+code=e_count" class="sref">e_count./a>;o4106./a>        .a href="+code=lc" class="sref">lc./a>->.a href="+code=new_number" class="sref">new_number./a> = .a href="+code=LC_FREE" class="sref">LC_FREE./a>;o4107./a>        .a href="+code=lc" class="sref">lc./a>->.a href="+code=lc_cache" class="sref">lc_cache./a> = .a href="+code=cache" class="sref">cache./a>;o4108./a>        .a href="+code=lc" class="sref">lc./a>->.a href="+code=lc_element" class="sref">lc_element./a> = .a href="+code=element" class="sref">element./a>;o4109./a>        .a href="+code=lc" class="sref">lc./a>->.a href="+code=lc_slot" class="sref">lc_slot./a> = .a href="+code=slot" class="sref">slot./a>;o41.10"a>o4111./a>        .spa
 class="comment">/* prealloca4112./a>        for (.a href="+code=i" class="sref">i./a> = 0; .a href="+code=i" class="sref">i./a> < .a href="+code=e_count" class="sref">e_count./a>; .a href="+code=i" class="sref">i./a>++) { 4113./a>                void *.a href="+code=p" class="sref">p./a> = .a href="+code=kmem_cache_alloc" class="sref">kmem_cache_alloc./a>(.a href="+code=cache" class="sref">cache./a>, .a href="+code=GFP_KERNEL" class="sref">GFP_KERNEL./a>);o4114./a>                if (!.a href="+code=p" class="sref">p./a>)o4115./a>                        break;o4116./a>                .a href="+code=memset" class="sref">memset./a>(.a href="+code=p" class="sref">p./a>, 0, .a href="+code=lc" class="sref">lc./a>->.a href="+code=element_siz
" class="sref">element_siz
./a>);o4117./a>                .a href="+code=e" class="sref">e./a> = .a href="+code=p" class="sref">p./a> + .a href="+code=e_off" class="sref">e_off./a>;o4118./a>                .a href="+code=e" class="sref">e./a>->.a href="+code=lc_index" class="sref">lc_index./a> = .a href="+code=i" class="sref">i./a>;o4119./a>                .a href="+code=e" class="sref">e./a>->.a href="+code=lc_number" class="sref">lc_number./a> = .a href="+code=LC_FREE" class="sref">LC_FREE./a>;o4120./a>                .a href="+code=list_add" class="sref">list_add./a>(&.a href="+code=e" class="sref">e./a>->.a href="+code=list" class="sref">list./a>, &.a href="+code=lc" class="sref">lc./a>->.a href="+code=free" class="sref">free./a>);o4121./a>                .a href="+code=element" class="sref">element./a>[.a href="+code=i" class="sref">i./a>] = .a href="+code=e" class="sref">e./a>;o4122./a>        }o4123./a>        if (.a href="+code=i" class="sref">i./a> == .a href="+code=e_count" class="sref">e_count./a>)o4124./a>                return .a href="+code=lc" class="sref">lc./a>; 4125./a>o4126./a>        .spa
 class="comment">/* else: could not alloca4127./a>        for (.a href="+code=i" class="sref">i./a>--; .a href="+code=i" class="sref">i./a>; .a href="+code=i" class="sref">i./a>--) { 4128./a>                void *.a href="+code=p" class="sref">p./a> = .a href="+code=element" class="sref">element./a>[.a href="+code=i" class="sref">i./a>]; 4129./a>                .a href="+code=kmem_cache_free" class="sref">kmem_cache_free./a>(.a href="+code=cache" class="sref">cache./a>, .a href="+code=p" class="sref">p./a> - .a href="+code=e_off" class="sref">e_off./a>); 4130./a>        }o4131./a>        .a href="+code=kfree" class="sref">kfree./a>(.a href="+code=lc" class="sref">lc./a>);o4132./a>.a href="+code=out_fail" class="sref">out_fail./a>:o4133./a>        .a href="+code=kfree" class="sref">kfree./a>(.a href="+code=element" class="sref">element./a>);o4134./a>        .a href="+code=kfree" class="sref">kfree./a>(.a href="+code=slot" class="sref">slot./a>);o4135./a>        return .a href="+code=NULL" class="sref">NULL./a>; 4136./a>}o4137./a>o4138./a>void .a href="+code=lc_free_by_index" class="sref">lc_free_by_index./a>(struct .a href="+code=lru_cache" class="sref">lru_cache./a> *.a href="+code=lc" class="sref">lc./a>, unsigned .a href="+code=i" class="sref">i./a>)o4139./a>{ 4140./a>        void *.a href="+code=p" class="sref">p./a> = .a href="+code=lc" class="sref">lc./a>->.a href="+code=lc_element" class="sref">lc_element./a>[.a href="+code=i" class="sref">i./a>]; 4141./a>        .a href="+code=WARN_ON" class="sref">WARN_ON./a>(!.a href="+code=p" class="sref">p./a>); 4142./a>        if (.a href="+code=p" class="sref">p./a>) { 4143./a>                .a href="+code=p" class="sref">p./a> -= .a href="+code=lc" class="sref">lc./a>->.a href="+code=element_off" class="sref">element_off./a>; 4144./a>                .a href="+code=kmem_cache_free" class="sref">kmem_cache_free./a>(.a href="+code=lc" class="sref">lc./a>->.a href="+code=lc_cache" class="sref">lc_cache./a>, .a href="+code=p" class="sref">p./a>); 4145./a>        }o4146./a>}o4147./a>o4148./a>.spa
 class="comment">/**./spa
  4149./a>.spa
 class="comment">4* lc_destroy - frees memory alloca41510"a>.spa
 class="comment">4* @lc: the lru cache to destroy./spa
  4151./a>.spa
 class="comment">4*/./spa
  4152./a>void .a href="+code=lc_destroy" class="sref">lc_destroy./a>(struct .a href="+code=lru_cache" class="sref">lru_cache./a> *.a href="+code=lc" class="sref">lc./a>)o4153./a>{ 4154./a>        unsigned .a href="+code=i" class="sref">i./a>; 4155./a>        if (!.a href="+code=lc" class="sref">lc./a>)o4156./a>                return; 4157./a>        for (.a href="+code=i" class="sref">i./a> = 0; .a href="+code=i" class="sref">i./a> < .a href="+code=lc" class="sref">lc./a>->.a href="+code=nr_elements" class="sref">nr_elements./a>; .a href="+code=i" class="sref">i./a>++) 4158./a>                .a href="+code=lc_free_by_index" class="sref">lc_free_by_index./a>(.a href="+code=lc" class="sref">lc./a>, .a href="+code=i" class="sref">i./a>); 4159./a>        .a href="+code=kfree" class="sref">kfree./a>(.a href="+code=lc" class="sref">lc./a>->.a href="+code=lc_element" class="sref">lc_element./a>); 4160./a>        .a href="+code=kfree" class="sref">kfree./a>(.a href="+code=lc" class="sref">lc./a>->.a href="+code=lc_slot" class="sref">lc_slot./a>); 4161./a>        .a href="+code=kfree" class="sref">kfree./a>(.a href="+code=lc" class="sref">lc./a>);o4162./a>}o4163./a>o4164./a>.spa
 class="comment">/**./spa
  41650"a>.spa
 class="comment">4* lc_reset4- does a full reset4for @lc and the hash table slots../spa
  4166./a>.spa
 class="comment">4* @lc: the lru cache to opera4167./a>.spa
 class="comment">4*./spa
  4168./a>.spa
 class="comment">4* It is roughly the equivalent of re-alloca4169./a>.spa
 class="comment">4* basically a short cut4to lc_destroy(lc); lc4= lc_create(...);./spa
  41710"a>.spa
 class="comment">4*/./spa
  4171./a>void .a href="+code=lc_reset" class="sref">lc_reset./a>(struct .a href="+code=lru_cache" class="sref">lru_cache./a> *.a href="+code=lc" class="sref">lc./a>)o4172./a>{ 4173./a>        unsigned .a href="+code=i" class="sref">i./a>; 4174./a>o4175./a>        .a href="+code=INIT_LIST_HEAD" class="sref">INIT_LIST_HEAD./a>(&.a href="+code=lc" class="sref">lc./a>->.a href="+code=in_use" class="sref">in_use./a>);o4176./a>        .a href="+code=INIT_LIST_HEAD" class="sref">INIT_LIST_HEAD./a>(&.a href="+code=lc" class="sref">lc./a>->.a href="+code=lru" class="sref">lru./a>);o4177./a>        .a href="+code=INIT_LIST_HEAD" class="sref">INIT_LIST_HEAD./a>(&.a href="+code=lc" class="sref">lc./a>->.a href="+code=free" class="sref">free./a>);o4178./a>        .a href="+code=lc" class="sref">lc./a>->.a href="+code=used" class="sref">used./a> = 0;o4179./a>        .a href="+code=lc" class="sref">lc./a>->.a href="+code=hits" class="sref">hits./a> = 0;o4180./a>        .a href="+code=lc" class="sref">lc./a>->.a href="+code=misses" class="sref">misses./a> = 0;o4181./a>        .a href="+code=lc" class="sref">lc./a>->.a href="+code=starving" class="sref">starving./a> = 0;o4182./a>        .a href="+code=lc" class="sref">lc./a>->.a href="+code=dirty" class="sref">dirty./a> = 0;o4183./a>        .a href="+code=lc" class="sref">lc./a>->.a href="+code=changed" class="sref">changed./a> = 0;o4184./a>        .a href="+code=lc" class="sref">lc./a>->.a href="+code=flags" class="sref">flags./a> = 0;o4185./a>        .a href="+code=lc" class="sref">lc./a>->.a href="+code=changing_element" class="sref">changing_element./a> = .a href="+code=NULL" class="sref">NULL./a>; 4186./a>        .a href="+code=lc" class="sref">lc./a>->.a href="+code=new_number" class="sref">new_number./a> = .a href="+code=LC_FREE" class="sref">LC_FREE./a>;o4187./a>        .a href="+code=memset" class="sref">memset./a>(.a href="+code=lc" class="sref">lc./a>->.a href="+code=lc_slot" class="sref">lc_slot./a>, 0, siz
of(struct .a href="+code=hlist_head" class="sref">hlist_head./a>)4* .a href="+code=lc" class="sref">lc./a>->.a href="+code=nr_elements" class="sref">nr_elements./a>);o4188./a>o4189./a>        for (.a href="+code=i" class="sref">i./a> = 0; .a href="+code=i" class="sref">i./a> < .a href="+code=lc" class="sref">lc./a>->.a href="+code=nr_elements" class="sref">nr_elements./a>; .a href="+code=i" class="sref">i./a>++) { 4190./a>                struct .a href="+code=lc_element" class="sref">lc_element./a> *.a href="+code=e" class="sref">e./a> = .a href="+code=lc" class="sref">lc./a>->.a href="+code=lc_element" class="sref">lc_element./a>[.a href="+code=i" class="sref">i./a>]; 4191./a>                void *.a href="+code=p" class="sref">p./a> = .a href="+code=e" class="sref">e./a>; 4192./a>                .a href="+code=p" class="sref">p./a> -= .a href="+code=lc" class="sref">lc./a>->.a href="+code=element_off" class="sref">element_off./a>; 4193./a>                .a href="+code=memset" class="sref">memset./a>(.a href="+code=p" class="sref">p./a>, 0, .a href="+code=lc" class="sref">lc./a>->.a href="+code=element_siz
" class="sref">element_siz
./a>);o4194./a>                .spa
 class="comment">/* re-init it */./spa
  4195./a>                .a href="+code=e" class="sref">e./a>->.a href="+code=lc_index" class="sref">lc_index./a> = .a href="+code=i" class="sref">i./a>;o4196./a>                .a href="+code=e" class="sref">e./a>->.a href="+code=lc_number" class="sref">lc_number./a> = .a href="+code=LC_FREE" class="sref">LC_FREE./a>;o4197./a>                .a href="+code=list_add" class="sref">list_add./a>(&.a href="+code=e" class="sref">e./a>->.a href="+code=list" class="sref">list./a>, &.a href="+code=lc" class="sref">lc./a>->.a href="+code=free" class="sref">free./a>);o4198./a>        }o4199./a>}o42010"a>o4201./a>.spa
 class="comment">/**./spa
  4202./a>.spa
 class="comment">4* lc_seq_printf_stats - print stats about @lc into @seq./spa
  4203./a>.spa
 class="comment">4* @seq: the seq_file4to print into./spa
  4204./a>.spa
 class="comment">4* @lc: the lru cache to print statistics of./spa
  42050"a>.spa
 class="comment">4*/./spa
  4206./a>.a href="+code=siz
_t" class="sref">siz
_t./a> .a href="+code=lc_seq_printf_stats" class="sref">lc_seq_printf_stats./a>(struct .a href="+code=seq_file" class="sref">seq_file./a> *.a href="+code=seq" class="sref">seq./a>, struct .a href="+code=lru_cache" class="sref">lru_cache./a> *.a href="+code=lc" class="sref">lc./a>)o4207./a>{ 4208./a>        .spa
 class="comment">/* NOTE:./spa
  4209./a>.spa
 class="comment">444444444* total calls4to lc_get are./spa
  42110"a>.spa
 class="comment">444444444* (starving + hits + misses)./spa
  4211./a>.spa
 class="comment">444444444* misses include "dirty" count (upda4212./a>.spa
 class="comment">444444444* progress) and "changed", when this in fact lead to an successful./spa
  4213./a>.spa
 class="comment">4 4444444* upda4214./a>.spa
 class="comment">4 4444444*/./spa
  4215./a>        return .a href="+code=seq_printf" class="sref">seq_printf./a>(.a href="+code=seq" class="sref">seq./a>, .spa
 class="string">"\t%s: used:%u/%u "./spa
  4216./a>                .spa
 class="string">"hits:%lu misses:%lu starving:%lu dirty:%lu changed:%lu\n"./spa
 , 4217./a>                .a href="+code=lc" class="sref">lc./a>->.a href="+code=nam
" class="sref">nam
./a>, .a href="+code=lc" class="sref">lc./a>->.a href="+code=used" class="sref">used./a>, .a href="+code=lc" class="sref">lc./a>->.a href="+code=nr_elements" class="sref">nr_elements./a>, 4218./a>                .a href="+code=lc" class="sref">lc./a>->.a href="+code=hits" class="sref">hits./a>, .a href="+code=lc" class="sref">lc./a>->.a href="+code=misses" class="sref">misses./a>, .a href="+code=lc" class="sref">lc./a>->.a href="+code=starving" class="sref">starving./a>, .a href="+code=lc" class="sref">lc./a>->.a href="+code=dirty" class="sref">dirty./a>, .a href="+code=lc" class="sref">lc./a>->.a href="+code=changed" class="sref">changed./a>);o4219./a>}o42210"a>o4221./a>static struct .a href="+code=hlist_head" class="sref">hlist_head./a> *.a href="+code=lc_hash_slot" class="sref">lc_hash_slot./a>(struct .a href="+code=lru_cache" class="sref">lru_cache./a> *.a href="+code=lc" class="sref">lc./a>, unsigned int .a href="+code=enr" class="sref">enr./a>)o4222./a>{ 4223./a>        return  .a href="+code=lc" class="sref">lc./a>->.a href="+code=lc_slot" class="sref">lc_slot./a> + (.a href="+code=enr" class="sref">enr./a> % .a href="+code=lc" class="sref">lc./a>->.a href="+code=nr_elements" class="sref">nr_elements./a>);o4224./a>}o4225./a>o4226./a>o4227./a>.spa
 class="comment">/**./spa
  4228./a>.spa
 class="comment">4* lc_find - find element by label, if present in the hash table./spa
  4229./a>.spa
 class="comment">4* @lc: The lru_cache object./spa
  42310"a>.spa
 class="comment">4* @enr: element number./spa
  4231./a>.spa
 class="comment">4*./spa
  4232./a>.spa
 class="comment">4* Returns the pointer to an element, if the element with the requested./spa
  4233./a>.spa
 class="comment">4* "label" or element number is present in the hash table,./spa
  4234./a>.spa
 class="comment">4* or NULL if not found. Does not change the refcnt../spa
  42350"a>.spa
 class="comment">4*/./spa
  4236./a>struct .a href="+code=lc_element" class="sref">lc_element./a> *.a href="+code=lc_find" class="sref">lc_find./a>(struct .a href="+code=lru_cache" class="sref">lru_cache./a> *.a href="+code=lc" class="sref">lc./a>, unsigned int .a href="+code=enr" class="sref">enr./a>)o4237./a>{ 4238./a>        struct .a href="+code=hlist_node" class="sref">hlist_node./a> *.a href="+code=n" class="sref">n./a>;o4239./a>        struct .a href="+code=lc_element" class="sref">lc_element./a> *.a href="+code=e" class="sref">e./a>; 42410"a>o4241./a>        .a href="+code=BUG_ON" class="sref">BUG_ON./a>(!.a href="+code=lc" class="sref">lc./a>); 4242./a>        .a href="+code=BUG_ON" class="sref">BUG_ON./a>(!.a href="+code=lc" class="sref">lc./a>->.a href="+code=nr_elements" class="sref">nr_elements./a>);o4243./a>        .a href="+code=hlist_for_each_entry" class="sref">hlist_for_each_entry./a>(.a href="+code=e" class="sref">e./a>, .a href="+code=n" class="sref">n./a>, .a href="+code=lc_hash_slot" class="sref">lc_hash_slot./a>(.a href="+code=lc" class="sref">lc./a>, .a href="+code=enr" class="sref">enr./a>), .a href="+code=colision" class="sref">colision./a>) { 4244./a>                if (.a href="+code=e" class="sref">e./a>->.a href="+code=lc_number" class="sref">lc_number./a> == .a href="+code=enr" class="sref">enr./a>)o4245./a>                        return .a href="+code=e" class="sref">e./a>; 4246./a>        }o4247./a>        return .a href="+code=NULL" class="sref">NULL./a>; 4248./a>}o4249./a>o42510"a>.spa
 class="comment">/* returned element will be "recycled" immediately4*/./spa
  4251./a>static struct .a href="+code=lc_element" class="sref">lc_element./a> *.a href="+code=lc_evict" class="sref">lc_evict./a>(struct .a href="+code=lru_cache" class="sref">lru_cache./a> *.a href="+code=lc" class="sref">lc./a>)o4252./a>{ 4253./a>        struct .a href="+code=list_head" class="sref">list_head./a>  *.a href="+code=n" class="sref">n./a>;o4254./a>        struct .a href="+code=lc_element" class="sref">lc_element./a> *.a href="+code=e" class="sref">e./a>; 4255./a>o4256./a>        if (.a href="+code=list_empty" class="sref">list_empty./a>(&.a href="+code=lc" class="sref">lc./a>->.a href="+code=lru" class="sref">lru./a>))o4257./a>                return .a href="+code=NULL" class="sref">NULL./a>; 4258./a>o4259./a>        .a href="+code=n" class="sref">n./a> = .a href="+code=lc" class="sref">lc./a>->.a href="+code=lru" class="sref">lru./a>..a href="+code=prev" class="sref">prev./a>; 4260./a>        .a href="+code=e" class="sref">e./a> = .a href="+code=list_entry" class="sref">list_entry./a>(.a href="+code=n" class="sref">n./a>, struct .a href="+code=lc_element" class="sref">lc_element./a>, .a href="+code=list" class="sref">list./a>);o4261./a>o4262./a>        .a href="+code=PARANOIA_LC_ELEMENT" class="sref">PARANOIA_LC_ELEMENT./a>(.a href="+code=lc" class="sref">lc./a>, .a href="+code=e" class="sref">e./a>);o4263./a>o4264./a>        .a href="+code=list_del" class="sref">list_del./a>(&.a href="+code=e" class="sref">e./a>->.a href="+code=list" class="sref">list./a>);o4265./a>        .a href="+code=hlist_del" class="sref">hlist_del./a>(&.a href="+code=e" class="sref">e./a>->.a href="+code=colision" class="sref">colision./a>);o4266./a>        return .a href="+code=e" class="sref">e./a>; 4267./a>}o4268./a>o4269./a>.spa
 class="comment">/**./spa
  42710"a>.spa
 class="comment">4* lc_del - removes an element from4the cache./spa
  4271./a>.spa
 class="comment">4* @lc: The lru_cache object./spa
  4272./a>.spa
 class="comment">4* @e: The element to remove./spa
  4273./a>.spa
 class="comment">4*./spa
  4274./a>.spa
 class="comment">4* @e must be unused (refcnt == 0). Moves @e from4"lru" to "free" list,./spa
  42750"a>.spa
 class="comment">4* sets @e->enr to %LC_FREE../spa
  4276./a>.spa
 class="comment">4*/./spa
  4277./a>void .a href="+code=lc_del" class="sref">lc_del./a>(struct .a href="+code=lru_cache" class="sref">lru_cache./a> *.a href="+code=lc" class="sref">lc./a>, struct .a href="+code=lc_element" class="sref">lc_element./a> *.a href="+code=e" class="sref">e./a>)o4278./a>{ 4279./a>        .a href="+code=PARANOIA_ENTRY" class="sref">PARANOIA_ENTRY./a>();o4280./a>        .a href="+code=PARANOIA_LC_ELEMENT" class="sref">PARANOIA_LC_ELEMENT./a>(.a href="+code=lc" class="sref">lc./a>, .a href="+code=e" class="sref">e./a>);o4281./a>        .a href="+code=BUG_ON" class="sref">BUG_ON./a>(.a href="+code=e" class="sref">e./a>->.a href="+code=refcnt" class="sref">refcnt./a>);o4282./a>o4283./a>        .a href="+code=e" class="sref">e./a>->.a href="+code=lc_number" class="sref">lc_number./a> = .a href="+code=LC_FREE" class="sref">LC_FREE./a>;o4284./a>        .a href="+code=hlist_del_init" class="sref">hlist_del_init./a>(&.a href="+code=e" class="sref">e./a>->.a href="+code=colision" class="sref">colision./a>);o4285./a>        .a href="+code=list_move" class="sref">list_move./a>(&.a href="+code=e" class="sref">e./a>->.a href="+code=list" class="sref">list./a>, &.a href="+code=lc" class="sref">lc./a>->.a href="+code=free" class="sref">free./a>);o4286./a>        .a href="+code=RETURN" class="sref">RETURN./a>();o4287./a>}o4288./a>o4289./a>static struct .a href="+code=lc_element" class="sref">lc_element./a> *.a href="+code=lc_get_unused_element" class="sref">lc_get_unused_element./a>(struct .a href="+code=lru_cache" class="sref">lru_cache./a> *.a href="+code=lc" class="sref">lc./a>)o4290./a>{ 4291./a>        struct .a href="+code=list_head" class="sref">list_head./a> *.a href="+code=n" class="sref">n./a>;o4292./a>o4293./a>        if (.a href="+code=list_empty" class="sref">list_empty./a>(&.a href="+code=lc" class="sref">lc./a>->.a href="+code=free" class="sref">free./a>))o4294./a>                return .a href="+code=lc_evict" class="sref">lc_evict./a>(.a href="+code=lc" class="sref">lc./a>);o4295./a>o4296./a>        .a href="+code=n" class="sref">n./a> = .a href="+code=lc" class="sref">lc./a>->.a href="+code=free" class="sref">free./a>..a href="+code=next" class="sref">next./a>;o4297./a>        .a href="+code=list_del" class="sref">list_del./a>(.a href="+code=n" class="sref">n./a>);o4298./a>        return .a href="+code=list_entry" class="sref">list_entry./a>(.a href="+code=n" class="sref">n./a>, struct .a href="+code=lc_element" class="sref">lc_element./a>, .a href="+code=list" class="sref">list./a>);o4299./a>}o43010"a>o4301./a>static int .a href="+code=lc_unused_element_available" class="sref">lc_unused_element_available./a>(struct .a href="+code=lru_cache" class="sref">lru_cache./a> *.a href="+code=lc" class="sref">lc./a>)o4302./a>{ 4303./a>        if (!.a href="+code=list_empty" class="sref">list_empty./a>(&.a href="+code=lc" class="sref">lc./a>->.a href="+code=free" class="sref">free./a>))o4304./a>                return 1; .spa
 class="comment">/* something on the free list4*/./spa
  4305./a>        if (!.a href="+code=list_empty" class="sref">list_empty./a>(&.a href="+code=lc" class="sref">lc./a>->.a href="+code=lru" class="sref">lru./a>))o4306./a>                return 1;  .spa
 class="comment">/* something to evict4*/./spa
  4307./a>o4308./a>        return 0;o4309./a>}o43110"a>o4311./a>o4312./a>.spa
 class="comment">/**./spa
  4313./a>.spa
 class="comment">4* lc_get - get element by label, maybe change the act ve set./spa
  4314./a>.spa
 class="comment">4* @lc: the lru cache to opera43150"a>.spa
 class="comment">4* @enr: the label4to look up./spa
  4316./a>.spa
 class="comment">4*./spa
  4317./a>.spa
 class="comment">4* Finds an element in the cache, increases its usage count,./spa
  4318./a>.spa
 class="comment">4* "touches" and returns it../spa
  4319./a>.spa
 class="comment">4*./spa
  43210"a>.spa
 class="comment">4* I
 case the requested number is not present, it needs4to be added to the./spa
  4321./a>.spa
 class="comment">4* cache. Therefore it is possible that4a
 other element becomes evicted from./spa
  4322./a>.spa
 class="comment">4* the cache. I
 either case, the user is notified so he is able4to e.g. keep./spa
  4323./a>.spa
 class="comment">4* a persistent log of the cache changes, and therefore the objects in use../spa
  4324./a>.spa
 class="comment">4*./spa
  43250"a>.spa
 class="comment">4* Return values:./spa
  4326./a>.spa
 class="comment">4*  NULL./spa
  4327./a>.spa
 class="comment">4*     The cache was marked %LC_STARVING,./spa
  4328./a>.spa
 class="comment">4*     or the requested label4was not in the act ve set./spa
  4329./a>.spa
 class="comment">4*     and a changing transact on is still pending (@lc was marked %LC_DIRTY)../spa
  43310"a>.spa
 class="comment">4*     Or no unused or free element could be recycled (@lc will be marked as./spa
  4331./a>.spa
 class="comment">4*     %LC_STARVING, blocking further lc_get() opera< ons)../spa
  4332./a>.spa
 class="comment">4*./spa
  4333./a>.spa
 class="comment">4*  pointer to the element with the REQUESTED element number../spa
  4334./a>.spa
 class="comment">4*     In this case, it ca
 be used right4away./spa
  43350"a>.spa
 class="comment">4*./spa
  4336./a>.spa
 class="comment">4*  pointer to an UNUSED element with some different element number,./spa
  4337./a>.spa
 class="comment">4*          where that4different number may also be %LC_FREE../spa
  4338./a>.spa
 class="comment">4*./spa
  4339./a>.spa
 class="comment">4*          In this case, the cache is marked %LC_DIRTY (blocking further changes),./spa
  43410"a>.spa
 class="comment">4*          and the returned element pointer is removed from4the lru list4and./spa
  4341./a>.spa
 class="comment">4*          hash collision chains.  The user now should do wha4342./a>.spa
 class="comment">4*          is necessary../spa
  4343./a>.spa
 class="comment">4*          Then he must call lc_changed(lc,element_pointer), to finish./spa
  4344./a>.spa
 class="comment">4*          the change../spa
  43450"a>.spa
 class="comment">4*./spa
  4346./a>.spa
 class="comment">4* NOTE:>4241 href="222cla3="sref">e./a>)o4278./a>{ 4201./a>.spa
 class="comment">/**./spa
  4332./a>.spa
 class="comline" nam3  L249">4249./a>o4241 href="222cla3="srefRTY (blocwill be "recycled&q3ot; i34 href="lib/lru_cache.c#L340" nam
  L309">4309./a>}olc./a>)o4290./a/lru_cache.c#L291" idc#L278" id  L278" class="line" nam
  L278">4278./a>{ hlist_node./a> *.a href="+code=n" class="sref">n./a3 href="+c3de=lc_element" class="sr3f">lc35lass="line" nam
  L292">4292./a>o3a href="+3ode=lc" class="sref">lc.3a>)o<35ass="line" nam
  L293">4293./a>          if (.a href="+code=list_empty" class="sref">list_empty./a>(&.a href="+code=lc" class="sref">lc.3o))o        .a href="+code=hl="sref">lc./a>, .a href="+code=e" class="sref">e./a>);ochanging_element./a> = .a href="+code=NULL" class="sreevict">e./a>->.a href33./a>.sode=colision" clas33./a>.shref=./a>)o35a>        return .a h++        return .ent" class="sref">changing_element./a> = .ib/lru_cache.c#L219" id  L219" clas/a>);o4197./a>                .a href="ss="line" nam
  L289">4289./a>st      .a href="ef="+code=lc" class="sref">./a>);o4259./a> 3     3.a href="+code
 class="comment">/**./spa
  " class="3ref">lru./a>..a href="+c3de=pr3v" class="sref">prev./a>; 4260./a>    mpty./a>(&.a hreflist_del" class="srelass="line" nam
  L237">4237./a>lru_cache.c#L279" id  L279" class="line"de" class="sref">hlist_node./a> *.a href=/a>);olc_el3ment./a>, .a href="+code3list"3class="sref">l           return .a href="+code=e" clas=./a>)olc./3>, .a href="+code=e" cla3s="sr36 -= .a href="+code=lc++        return .ent" class="sref">changing_element./a> = .lc" class="sref">lc./a>->/a>);o                          return .a href="+code=e" class="sref">e./a>; );olis3./a>)36cache.c#L194" id  L19am
  L260">4260./a>    
  L218">4218./a>                .a href="+code=lc" class="sref">lc./a++/a>);o4365./a36./a>(&.a href="+c      return 1;  .spru_cache.c#L286" id  L286" class="line" nam
  L286">4286./a>        .a href="+code=RETURN" class="sref">RETURN./a>();o42href="+code=lru" class="sref">lrue" nam
  L210">42110"a>.spaot3" id 324"..." nam
  L309">4309./a>}o        return .a h      .a href="ss="line" nam
  L289">4289./a>st      .a href="refcnt./a>);o4268./a>o43110"a>o4* lc_del - r3moves36m
  L311">431++        return .ent" class="sref">changing_element./a> = .e=lc" class="sref">lc./a>->.lib/lru_cache.c#L282" id  L23nlib/lru_3b/lru_cache.c#L271" id  3271" 36
  L251">4251./a>static struct .3lru_cache3object./spa
  42110"a>.spnt becomes reref="li" cla" class="ha4*u_caki02"ouL330" class="line" nam
  L330">43310/spa
  43310/4274./a>.spa
 class="co77777777enam
  L309">4309./a>}o4304./a>                return 1m
  L302">4302./a>{ list_empty./a>(&.a hre=./a>)o427503a>.spa
 class="comment">3* set37./a>(&.a href="+c      return 1;__set_be=list_move" clas__set_be=line"class="sref">li__ref33./a>.sode=colision" c__ref33./a>.so42a href="+code=NULL" class="sr"lib/lru_cache.c#L282" id  L23b/lru_cac3e.c#L277" id  L277" clas3="lin37a>        return .a h      .a href="ss="line" nam
  L289">4289./a>st      .a href="ef="+code=lc" class="sref">./a>);olru_cache./a3 *.a 37f="lib/lru_cache.c#L249" id  L249" class=3nt" class3"sref">lc_element./a> *.3 href37m
  L310">43110"a>o4380./a37" class="line" nam
  L210">42110"a>.spit b/lru_ca class="line" n330" id  L.330" class="line" nam
  L330">43310/lib/lru_3lass="sref">PARANOIA_LC_3LEMEN37ache.c#L211" id  L211" class="line" naw narergo class=#L332"  4276./a>.sp)="lib/lr.330" class="line" nam
  L330">43310c#L281" i3  L281" class="line" nam3  L28384a
 other thread in./spa
  ref="lib/acheL246">4241 href="222cla3="sre2" class=3line" nam
  L282">4282./3>o4309./a>}oL3_FREE382>4304./a>             .a href="te198"nd_set_be=list_move" claste198"nd_set_be=line"class="sref">li__ref"lib/ode=colision" c__ref"lib/o42a href="+code=NULL" class="sr"=./a>)o42838cache.c#L194" id  L19++        return .ent" class="sref">changing_element./a> = ." id  L220" class="line" nam
/a>);o(&.a href="+c      return 1;ss="line" nam
  L289">4289./a>st      .a href="ef="+code=lc" class="sref">./a>);olc./3>->.a href="+code=fre3" cla3s="sref">free.che.c#L249" id  L249" class=3ine" nam
3 L288">4288./a>olc_element./3> *.a38">list_entry./a>(.a href="+cmpty./a>(&.a hreflist_del" class="srel./a>{ list_empty./a>(&.a hre/a>);olc_get_unused_element3/a>(s388>list_entry./a>(.a href="+ce=hlist_for_each_entry" class="sref">hlist_for_erefcnt./a>);o *.a href="3code=38
  L251">4251./a>static struct .34281./a>        .a href="+c2" ar_be=list_move" clas2" ar_be=line"class="sref">li__ref33./a>.sode=colision" c__ref33./a>.so42a href="+code=NULL" class="sr"lib/lru_cache.c#L282" id  L23a href="l3b/lru_cache.c#L293" id  3293" 39ef="lib/lru_cache.c#L283" id  L283" class="line" nam
  L283"++        return a href="+code=e" class="sref">e./a>; 4263./a>o4218./a>                .a href="+code=lc" class="sref">lc./a++/a>);oo4218./a>                .a href="+c will bref="lib/lru_cache.c#L2c will bref="libhreflist_del" class="smpty./a>(&.a href="+code=lc" class="sref">lc.3e" class=3sref">free./a>..a href="3code=3              href="lib/lru_c
  L218">4218./a>                .a href="+newa>(&.a href="+codenewa>(&hreflist_del" class="sm>hlist_node./a> *.a href="+code=lc" class="sref">lc.3ene" nam
3_cache.c#L297" id  L297"3class39ment by label, if present in the3urn .a hr3f="+code=list_entry" cla3s="sr3f">list_entry./a>(.a href="+css="line" nam
  L289">4289./a>st      .a href="refcnt./a>);olist./a>);o<3 href39ediately4*/./spa
  4251./a>static struct .4a href="+4ode=lru_cache" class="sr4f">lr40lement./a> *.a href="+code=lc_similar211./a>.sp class="line" nam
  L341">4341./a>.4ss="sref"4lc./a>)ocla"lib/lr.330" class="line" nam
  L330">43314./a>->4a href="+code=free" clas4="sre4 43314.3a>->4a L294" class="line" nam4
  L34b/lru_cache.c#L205" id  L205" c2" classconsoli.a hd>.spa
one fund as..330" class="line" nam
  L330">43314.4a>->4aref="lib/lru_cache.c#L24t_emp4ass="line" nam
  L206">4206./anam
  L309">4309./a>}o4306.ss>lc./a>)o4290try0./a/lru_cache.c#L291"try0./a/a>st8" id  L278" class="line" nam
  L278">4278./a>{ hlist_node./a> *.a href="+code=n" class="sref">n./a408" id  L408" class="line" nam
  L408">4408./a>/a>)olist_entry.m
  L293">4293./a>          if (.a href="+code=list_empty" class="sref">list_empty./a>(&.a href="+code=lc" class="sref">lc.4ru_cache.4#L311" id  L311" class="4ine" 40" class="sref">prev./a>; (.a href="+code=lc" class="sref">lc./a>, .a href="+code=e" class="sref">e./a>);ol           return ..ent" class="sref">changing_element./a> = .a href="+code=NULL" class="sreevict">e./a>->.a href33./a>.sode=colision" clas33./a>.shref=./a>)o4* lc_get - g4t ele41 -= .a href="+code=lc++        return .ent" class="sref">changing_element./a> = .ib/lru_cache.c#L219" id  L219" clas/a>);o                     return 1;ss="line" nam
  L289">4289./a>st      .a href="ef="+code=lc" class="sref">./a>);o4* @l4: the lru cache to opera4e on.41cache.c#L194"ely4*/./spa
  (&.a hreflist_del" class="srelass="line" nam
  L237">4237./a>lru_cache.c#L279" id  L279" class="line"de" class="sref">hlist_node./a> *.a href=/a>);o                return .aa href="+code=e" clas=./a>)o4* &qu4t;touches" and retu4ns it4./a>->.a href="+cod++        return .ent" class="sref">changing_element./a> = .lc" class="sref">lc./a>->/a>);olc./a>->.a href="           return .a href="+code=e" class="sref">e./a>; );o->.a href="        href="lib/lru_c
  L218">4218./a>                .a href="+code=lc" class="sref">lc./a++/a>);o4* cache. Theref4re it4203./a>                     return 1;  .spru_cache.c#L286" id  L286" class="line" nam
  L286">4286./a>        .a href="+code=RETURN" class="sref">RETURN./a>();o42href="+code=lru" class="sref">lrue" nam
  L210">42110"a>.spaot3" id 324"..." nam
  L309">4309./a>}o4* the cache. 4
 eit421ache.c#L194"ely4*/./spa
  4* a persisten4 log 42>4263./a>o4289./a>st      .a href="refcnt./a>);o4*./spa
  43264216" ily4*/./spa
  4327./a>.spa
 class="commennam
  L314">4314./a>.spa
 class="comm4a
  43nam
  L345 - te cl L339./a>4234./a>.spa
 clas4e request4d label4was not in the a4t ve 4et./spa
  4316./a>.spa
 class="comment">4*./spa
  4*./spa
  4*     Or4no un4sed or free element could be rnam
  L309">4309./a>}o4*     %LC_4TARVI4G, blo=e" class="sref">e./a>)
  L345"line" nam
  L237"
  L345/a>st8" id  L278" class="line" nam
  L278">4278./a>{ 4279./a>        .a href="+code=PARANOIA_ENTRY" class="sref">PARANOIA_ENTRY./a>();o4*.4spa
  )o4263./a>oe./a>);o4*   4 In this case, it ca
 be4used 43/a>        .a href="+code=hl  L283" class="line" nam
  L283">4283./a>        .a href="+code=e" c != href="lib/lru_c
  L218">4218./a>                .a href="+c will bref="lib/lru_cache.c#L2c will bref="libhref./a>);oBUG_ON./a>(.a href="+code=e" class="sref">e./a>->.a href="+code=refcnt" class="sref">refcnt./a>);ochanging_element./a> = .
  L345"line" nam
  L2
  L345/a>slib/lru_cache.c#L282" id  L24e
  4*          where that44iffer43line" nam
  L297">4297./a>  286./a>        .a href="+code=RETURN" clas/a>(&.a href="+code=e" class="sref">e./a>->.a h
  L218">4218./a>                .a href="+newa>(&.a href="+codenewa>(&hreflib/lru_cache.c#L282" id  L24e request4./spa
  list_entry./a>(.a href="+code=nad.a href="+code=list_ead.lass="line" nam
  L286">4286./a>        .a href="+code=RETURN" class="sref">RETURN./a>();o42href="+code=lru" class="sref">lruib/lru_cache.c#L282" id  L24e    and 4king further changes),./4pa
  438>list_entry./a>(.a href="+chist_ead.if (.a href="+code=lhist_ead.if (.lass="line" nam
  L286">4286./a>        .a href="+code=RETURN" clacde=list" class="sref">list./a>, &ad  L244" class="line" nam
  L244">4244./a>                if (.a href="+code=e" class="sref">e./a>->.a href="+cod
  L218">4218./a>                .a href="+newa>(&.a href="+codenewa>(&href)ruib/lru_cache.c#L282" id  L24e4to be a4pa
 class="comment">4*  4     43/a>(.a href="+code=lc" class
  L218">4218./a>                .a href="+c will bref="lib/lru_cache.c#L2c will bref="libhreflist_del" class="sef="+code=lc" class="sref">lc./a>->.a href="+code=lr4pa
 class4"comment">4*          ha4h col44>4281./a>        .a href="+c
  L218">4218./a>                .a href="+newa>(&.a href="+codenewa>(&hreflist_del" class="sref="+code=colision" class="sref">colision./a>);o4*         4is ne44ef="lib/lru_cache.c#L283" id2" ar_be=list_move" clas2" ar_be=line"class="sref">li__ref"lib/ode=colision" c__ref"lib/o42a href="+code=NULL" class="sr">colision./a>);oe./a>);o4*          the chan4e../s44/a>        .a href="+code=hlss="line" nam
  L289">4289./a>static struct .a href="+code=lc4#L346" id4 L346" class="line" nam
4 L3464>4346.ely4*/./spa
  e./a>)4next./a>;o4204./a>.44ment by label, if present in the4line" nam4  L249">4249./a>o4314./a>.spa
 class="comm4fRTY (blo4will be "recycled&q4ot; i44 href="lib/lru_cache.c#L340" 3nampu id  " idup clacachofCen
  L314">4314./a>.spa
 class="comm4f4to be a4L251" id  L251" class="l4ne" n44and the returned element point
  L316">4316./a>.spa
 class="comment">4*./spa
  lc4element./a> *.a href="+code=;LCent"335" id  L33pa
puL330" class="line" nam
  L330">43314a href="+4ode=lc" class="sref">lc.4a>)o<45d  L203" class="line" nam
 7e330" class="line" nam
  L330">43314amber../s4lib/lru_cache.c#L254" id4 L25445s zero,"335" id  L33nd.//lru_c#L335"342" id  class="line" nam
  L341">4341./a>.4       st4uct .a href="+code=lc_el4ment"45ru_cache.c#L325" id  L325" clasd (@lL333">4333./a>.s (ifd  L)3nd.2" ared.330" class="line" nam
  L330">43314o.spa
 class="comment">R the re335"new (post-decrd  L3) clacac.330" class="line" nam
  L330">43314o">e./a>)4href="+code=lru" class="4ref">45d  L278" class="line" nam
  Lnam
  L309">4309./a>}o41code=hlist_node" class="srefnampu 244">4244./a>     puL33>st8" id  L278" class="line" nam
  L278">4278./a>{ 4279./a>        .a href="+code=PARANOIA_ENTRY" class="sref">PARANOIA_ENTRY./a>();o4259./a> 4     4.a hre/a>)olru./a>..a href="+c4de=pr458>list_entry./a>(.a href="+cache.c#L2c./a>, .a href="+code=e" class="sref">e./a>);o4260./a>    ode=BUG_ON" class="sref">BUG_ON./a>(.a href="+code=e" class="sref">e./a>->.a href="+code=refcnt" class="sref">refcnt./a>);olc_el4ment./a>, .a href="+code4list"4class="sref">list./a>);o4283./a>        .a href="+code=e" class="sref">e./a>->.a href="+code=lc_number" clahe.c#Llib/lru_cache.c#L282" id  L24e href="+4>, .a href="+code=e" cla4s="sr46ef="lib/lru_cache.c#L283" id  L283" class="line" nam
  L283">4283./a>        .a href="+code=e" che.chref="lib/lru_c
  L218">4218./a>                .a href="+c will bref="lib/lru_cache.c#L2c will bref="libhref./a>);o4304./a>       -->4283./a>        .a href="+code=e" class="sref">e./a>->.a href="+code=lc_number" clahe.c#L./a>)olis4./a>)46cache.c#L194" id  L19" nam
  L210">42110"a>.sp//lrpit c#L335"froachofCLRU." nam
  L309">4309./a>}o4465./a46./a>(&.a href="+c      return 1;  .spru_cache.c#L286" id  L286" class="line" nam
  L286">4286./a>        .a href="+code=RETURN" class="sref">RETURN./a>();o42lline" nam
  L307">4307./a/a>);oe./a>)4  L266" class="line" nam4  L2646a>        return .a h      .a href="
  L218">4218./a>                .a href="+code=lc" class="sref">lc./a--/a>);o4268./a>o4197./a>                .a href="2" ar_be=list_move" clas2" ar_be=line"class="sref">li__ref33./a>.sode=colision" c__ref33./a>.so42a href="+code=NULL" class="sr"lib/lru_cache.c#L282" id  L24 ->.a href="+codhref="lib/lru_csmp_mb__after_2" ar_be=list_move" classmp_mb__after_2" ar_be=ef">e./a>);o4* lc_del - r4moves46m
  L311">431ely4*/./spa
  4260./a>    ss="line" nam
  L289">4289./a>st      .a href="refcnt./a>);oe./a>->.a href="+code=lc_number" class="sref">lc_number./a> = .a 4lru_cache4object./spa
  4274./a>.spa
 class="cnam
  L314">4314./a>.spa
 class="comm4;lru"4 to "free" lis4,./sp47pa
  4314./a>.spa
 class="comm4;.spa
 class="comment">4* set4716" id  L316" class="line" nam
  L316">4316./a>.spa
 class="comment">4*./spa
  4317./a>.spa
 class="commiL316">indexL325">43 id  L33pa
ousekemment">4*./spa
  lru_cache./a4 *.a 478" class="line" nam
  L328">4nam
  L309">4309./a>}olc_element./a> *.4 href47m
  Lss>lc./a>)o4290id  L303by_indexe.c#L290" id  L290" class3by_index
 >st8" id  L278" class="line" nam
  L278">4278./a>{ 42h+code=lru" class4480./a47" cla/a>)oPARANOIA_LC_4LEMEN47ne" nam
  L260">4260./a>      L283" class="line" nam
  L283">4283./a>      h+code=lru" classe./a>->.a h
  L218">4218./a>                .a href="+nr0" classef="+code=NULL" nr0" classe class="sref">lc_number./a> = .a 4c#L281" i4  L281" class="line" nam4  L2848lass="sref">list./a>);o4283./a>      L287" id  L287" class="line" nam
  L287">42l/lru_cache.c#L290" id  L290" class="li[>4283./a>      h+code=lru" class./a>);o4282./4>o4283./a>      L287" id  L287" class="line" nam
  L287">42l/lru_cache.c#L290" id  L290" class="li[>4283./a>      h+code=lru" class42l/lindexe.c#L290" id  L290index
 >s != href="lib/lru_ch+code=lru" class);oL4_FREE482>4304./a>   m
  L296">4296./a>      87" id  L287" class="line" nam
  L287">42l/lru_cache.c#L290" id  L290" class="li[>4283./a>      h+code=lru" class);o42848ru_caely4*/./spa
  lc./4>->.a href="+code=fre4" cla484327./a>.spa
 class="commennam
  L314">4314./a>.spa
 class="comm4ine" nam
4 L288">4288./a>o43namindex_of
  L314">4314./a>.spa
 class="comm4it" class4lass="sref">lc_element./4> *.a48t./spa
  4316./a>.spa
 class="comment">4*./spa
  lc_get_unused_element4/a>(s48ending (@lc was marked %LCent"335" id  L33pa
query for9">43indexLposi as./sn3naline"" class="ent">4*./spa
  4309./a>}o4281code=hlist_node" class="srefnamindex_ofe.c#L290" id  L290index_of
 >st8" id  L278" class="line" nam
  L278">4278./a>{ 4279./a>        .a href="+code=PARANOIA_ENTRY" class="sref">PARANOIA_ENTRY./a>();o)o4263./a>oBUG_ON./a>(.a href="+code=e" class="sref">e./a>->.a href="+code=refcnt" class="sref">refcnt./a>);o4304./a>   m
  L296">4296./a>    286./a>        .a href="+code=RETURN" clas/aindexe.c#L290" id  L290index
 >slib/lru_cache.c#L282" id  L24cru_cache4href="lib/lru_cache.c#L246" id494346.ely4*/./spa
  free./a>..a href="4code=49xt" class="sref">next./a>;o4314./a>.spa
 class="comm4urn .a hr4f="+code=list_entry" cla4s="sr49t./spa
  4314./a>.spa
 class="comm4u L280" c4lass="sref">list./a>);o<4 href49ending (@lc was marked %LCe  L316">4316./a>.spa
 class="comment">4*./spa
  4* Finds an e  L330" class="line" nam
  L330">43315a href="+5ode=lru_cache" class="sr5f">lr50lement./a> *.a href="+code=commindext"335" id  L33indexL
  43315ss="sref"5lc./a>)o43315s2="sref"5lref="+code=free" class=5="sre5 43315s3="sref"5l L294" class="line" nam5
  L35b/lru_cache.c#L205" id  L205" nam
  L309">4309./a>}oe./a>)s/a/lru_cache.c#L291"s/a/a>st8" id  L278" class="line" nam
  L278">4278./a>{ hlist_node./a> *.a href,st_node" class="srefindexe.c#L290" id  Lindex
 >sref="lib/lru_cache.c#L280" i5#L306" id5 L306" class="line" nam
5 L3065>4306./a>)o4508./a>        m
  L293">4293./a>          if (.a href="+code=list_empty" class="sref">list_empty./a>(&.a href="+code=lc" class="sref">lc.5ru_cache.5#L310" id  L310" class="5ine" 5am
  L310">43110"a>o431           return .indexe.c#L290" id  Lindex
 >s < 0 ||ode" class="srefindexe.c#L290" id  Lindex
 >s ass=f">e./a>->.a h
  L218">4218./a>                .a href="+nr0" classef="+code=NULL" nr0" classe clas310">43110"a>olc.5lc.54* lc_get - g5t ele51ef="lib/lru_cache.c#L283" id  .a href="+code=e" che93">4293./a>          if (3by_indexe.c#L290" id  L290" class3by_index
 >sts="sref">e./a>->.a href="+code=refcnt" class="sref">indexe.c#L290" id  Lindex
 >sr="+code=lc" class="sref">lc.5<2="sref"5pa
          .a href="+code=RETURN" clas/a>(&.a href="+code=e" class="sref">e./a>->.a hm>hlist_node./a> *.a href="+code=lc" class="sref">lc.5nt">4* @l5: the lru cache to opera5e on.51 *hist_edel_ini lass="line" nam
  L286">4286./a>        .a href="+code=RETURN" clacde=list" class="sref">list./a>, &ar="+code=lc" class="sref">lc.54286./a>        .a href="+code=RETURN" clacde=list" class="sref">list./a>, &ad  L244" class="line" nam
  L244">4244./a>                if (.a href="+code=e" class="sref">e./a>->.a href="+cef">hlist_node./a> *.a href=r="+code=lc" class="sref">lc.5<8" id  L5
  4297./a>    .spru_cache.c#L286" id  L286" class="line" nam
  L286">4286./a>        .a href="+code=RETURN" class="sref">RETURN./a>();oe./a>->.a href="+code=lc_number" cla ?ref="lib/lru_cache.c#L287" id  L287" class="line" nam
  L287">42href="+code=lru" class="sref">l :ref="lib/lru_cache.c#L287" id  L287" class="line" nam
  L287">42lline" nam
  L307">4307./a/a>);o4* &qu5t;touches" and retu5ns it5./a>-&ely4*/./spa
  prev./a>; 4314./a>.spa
 class="comm5
 class="5omment">4* cache. Theref5re it52lement./a> *.a href="+code=com   dumpid Dumpiac#./plete LRU=./a>.spa
seq"lineextual form.330" class="line" nam
  L330">43315pa
 class5"comment">4* the cache. 5
 eit52d  L203" class="line" nam
 7efe  L316">4316./a>.spa
 class="comment">4*./spa
  4* a persisten5 log 52ef="lm
  L29seq_fileREE../spa
  seq_pr../f>.spamment">4*./spa
  4* @l5omment">4*./spa
  .spf (.ing.sp_423oin usinfamment">4*./spa
  43265216" id  L316" class="line" nam
detail: fund as.REE../spa
="lib/lrent"provid.spa
dumpi#L341" idetailnam
  L332">4332./a>.spa
 class="co5#L327" id5 L327" class="line" nam
5 L3275>4327./a>.spa
 class="commennam325">43object" id  L2 id  L33nd.elasddlist_.330" class="line" nam
  L330">43315p8" id  L5f="lib/lru_cache.c#L328"5id  L528" class="line" nam
  L328">4nam
  L309">4309./a>}oe./a>)s/q dump_detailn/lru_cache.c#L291"s/q dump_detailn/a>st8" id  L278" class="liseq_file/lru_cache.c#L2seq_file" class="sref">list_eseq/lru_cache.c#L2seq"line" nam
  L279">4279./a>  e" nam
  L278">4278./a>{ 4309./a>}o4279./a>        .a href="+code=PARANOIA_ENTRY" cla)s310">43110"a>o4*     Or5no un5sed or/a>)o4*     %LC_5TARVI53lass="sref">lcode=hlist_node" class="srefnr0" classef="+code=NULL" nr0" classe claef">e./a>->.a h
  L218">4218./a>                .a href="+nr0" classef="+code=NULL" nr0" classe cla/a>);o4*.5spa
  4293./a>          if (.a href="+code=list_empty" class="sref">list_empty./a>(&.a href="+code=lc" class="sref">lc.5umber../s5a
  lc.5ut">4* @l5 In this case, it ca
 be5used 53.sp\tnn:  L202" claumber"lL333"s\nL276">4am
  L3hr      .a href="ueext id  L279" clasueext"lina/a>);o4283./a>      h+code=lru" classe./a>->.a hh+code=lru" classe./a>->.a hh+code=lru" class)o4197./a>                .a href="  .a href="+code=e" che93">4293./a>          if (3by_indexe.c#L290" id  L290" class3by_index
 >sts="sref">e./a>->.a href="+code=refcnt" class="sref">i+code=lru" class);o->.a href="+cod           return .a href="+code=e" class="sref">e./a>; (&.a href="+code=e" class="srefist_del" class="sref="+code=colision" class="sref"L./a>)o.sp\tL333"2d: s="s\n276">4am
  L3hr      .a href="i+code=lru" class);o4*  5     539lc./a>->.a href="} else./a>)o4*          ha5h col5403./a>                class="href="lib/lru_cseq_pr../f/lru_cache.c#L2seq_pr../f  if (.a href="+codeseq/lru_cache.c#L2seq"line"ass="line" nam
 u_ca>.sp\tL333"2d: L333"4u L333"4u    276">4am
  L3hr      .a href="i+code=lru" class4309./a>}o4*         5is ne54 -= .a href="+code=lc            class="href="lib/lru_ca href="+code=e" class="sref">e./a>; (&.a href="+code=e" class="srhr      .a href="refcnt./a>);oe./a>->.a href="+code=lc_number" claa/a>);ot">4* @l5nt">4*          the chan5e../s54/a>        .aa href="}a>);oment num5);o4205./a>.54ment by label, if present in the5line" nam5  L249">4249./a>osts="sref">e./a>-&g_creat  L278">4278./a>{g_creat ref=a/a>);osts="sref">e./a>-&g_clas(.a href="+code=lisclas(ref=a/a>);osts="sref">e./a>-&g_dem
 o  L220" class="l&g_dem
 o ref=a/a>);olc5element     .a href="EXPORT_SYMBO"+code=lc" classEXPORT_SYMBO"
 >sts="sref">e./a>-&g_s/a/lru_cache.c#L291"s/a/a>sa/a>);olc.5a>)o<55d  L20     .a href="EXPORT_SYMBO"+code=lc" classEXPORT_SYMBO"
 >sts="sref">e./a>-&g_del id  L279" clas&g_del/a>sa/a>);osts="sref">e./a>-&g_try0./a/lru_cache.c#L291"try0./a/a>sa/a>);o4* @l5uct .a href="+code=lc_el5ment"55ru_cac     .a href="EXPORT_SYMBO"+code=lc" classEXPORT_SYMBO"
 >sts="sref">e./a>-&g_ass="line" nam
  L237">4237./aa/a>);osts="sref">e./a>-&g_./a/lru_cache.c#L291"./a/a>sa/a>);o55d  L27     .a href="EXPORT_SYMBO"+code=lc" classEXPORT_SYMBO"
 >sts="sref">e./a>-&g_pu 244">4244./a>     puL33>sa/a>);o41"     .a href="EXPORT_SYMBO"+code=lc" classEXPORT_SYMBO"
 >sts="sref">e./a>-&g_c  L345"line" nam
  L237"
  L345/a>sa/a>);o4259./a> 5     55#L339"     .a href="EXPORT_SYMBO"+code=lc" classEXPORT_SYMBO"
 >sts="sref">e./a>-&g_   if (3by_indexe.c#L290" id  L290" class3by_index
 >sa/a>);olru./a>..a href="+c5de=pr55 href=     .a href="EXPORT_SYMBO"+code=lc" classEXPORT_SYMBO"
 >sts="sref">e./a>-&g_index_ofe.c#L290" id  L290index_of
 >sa/a>);osts="sref">e./a>-&g_seq_pr../f_ nssn/lru_cache.c#L291"s/q pr../f_ nssn
 >sa/a>);olc_el5ment./a>, .a href="+code5list"56lement     .a href="EXPORT_SYMBO"+code=lc" classEXPORT_SYMBO"
 >sts="sref">e./a>-&g_s/q dump_detailn/lru_cache.c#L291"s/q dump_detailn/a>sa/a>);o


T>43original LXR softwarerby" id >);oLXR m uni" nam ,"33nd.experilassal ver./a>rby">);o 9xp."+cux.no kindly ho);oclasd ( class/a>sd rvicesd ilc="1995.