Subversion Repositories HelenOS-doc

Rev

Rev 38 | Rev 45 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
9 bondari 1
<?xml version="1.0" encoding="UTF-8"?>
11 bondari 2
<chapter id="mm">
3
  <?dbhtml filename="mm.html"?>
9 bondari 4
 
11 bondari 5
  <title>Memory management</title>
9 bondari 6
 
26 bondari 7
  <section>
11 bondari 8
    <title>Virtual memory management</title>
9 bondari 9
 
10
    <section>
35 bondari 11
      <title>Introduction</title>
12
 
13
      <para>Virtual memory is a special memory management technique, used by
14
      kernel to achieve a bunch of mission critical goals. <itemizedlist>
15
          <listitem>
16
             Isolate each task from other tasks that are running on the system at the same time.
17
          </listitem>
18
 
19
          <listitem>
20
             Allow to allocate more memory, than is actual physical memory size of the machine.
21
          </listitem>
22
 
23
          <listitem>
24
             Allowing, in general, to load and execute two programs that are linked on the same address without complicated relocations.
25
          </listitem>
26
        </itemizedlist></para>
38 bondari 27
 
39 bondari 28
      <para><!--
29
 
38 bondari 30
                TLB shootdown ASID/ASID:PAGE/ALL.
31
                TLB shootdown requests can come in asynchroniously
32
                so there is a cache of TLB shootdown requests. Upon cache overflow TLB shootdown ALL is executed
33
 
34
 
35
                <para>
36
                        Address spaces. Address space area (B+ tree). Only for uspace. Set of syscalls (shrink/extend etc).
37
                        Special address space area type - device - prohibits shrink/extend syscalls to call on it.
38
                        Address space has link to mapping tables (hierarchical - per Address space, hash - global tables).
39
                </para>
40
 
41
--></para>
35 bondari 42
    </section>
43
 
44
    <section>
45
      <title>Paging</title>
46
 
47
      <para>Virtual memory is usually using paged memory model, where virtual
48
      memory address space is divided into the <emphasis>pages</emphasis>
49
      (usually having size 4096 bytes) and physical memory is divided into the
39 bondari 50
      frames (same sized as a page, of course). Each page may be mapped to
51
      some frame and then, upon memory access to the virtual address, CPU
52
      performs <emphasis>address translation</emphasis> during the instruction
35 bondari 53
      execution. Non-existing mapping generates page fault exception, calling
54
      kernel exception handler, thus allowing kernel to manipulate rules of
55
      memory access. Information for pages mapping is stored by kernel in the
56
      <link linkend="page_tables">page tables</link></para>
57
 
58
      <para>The majority of the architectures use multi-level page tables,
59
      which means need to access physical memory several times before getting
60
      physical address. This fact would make serios performance overhead in
61
      virtual memory management. To avoid this <link linkend="tlb">Traslation
62
      Lookaside Buffer (TLB)</link> is used.</para>
63
 
64
      <para>At the moment HelenOS does not support swapping.</para>
65
 
39 bondari 66
      <para>- pouzivame vypadky stranky k alokaci ramcu on-demand v ramci
67
      as_area - na architekturach, ktere to podporuji, podporujeme non-exec
68
      stranky</para>
35 bondari 69
    </section>
70
 
71
    <section>
11 bondari 72
      <title>Address spaces</title>
9 bondari 73
 
35 bondari 74
      <section>
75
        <title>Address spaces and areas</title>
76
 
39 bondari 77
        <para>- adresovy prostor se sklada z tzv. address space areas
35 bondari 78
        usporadanych v B+stromu; tyto areas popisuji vyuzivane casti
79
        adresoveho prostoru patrici do user address space. Kazda cast je dana
39 bondari 80
        svoji bazovou adresou, velikosti a flagy (rwx/dd).</para>
35 bondari 81
 
82
        <para>- uzivatelske thready maji moznost manipulovat se svym adresovym
83
        prostorem (vytvaret/resizovat/sdilet) as_areas pomoci syscallu</para>
84
      </section>
85
 
86
      <section>
87
        <title>Address Space ID (ASID)</title>
88
 
89
        <para>- nektery hardware umoznuje rozlisit ruzne adresove prostory od
90
        sebe (cilem je maximalizovat vyuziti TLB); dela to tak, ze s kazdou
91
        polozkou TLB/strankovacich tabulek sdruzi identifikator adresoveho
92
        prostoru (ASID, RID, ppc32 ???). Tyto id mivaji ruznou sirku: 8-bitu
93
        az 24-bitu (kolik ma ppc32?)</para>
94
 
95
        <para>- kernel tomu rozumi a sam pouziva abstrakci ASIDu (na ia64 to
96
        je napr. cislo odvozene od RIDu, na mips32 to je ASID samotny);
97
        existence ASIDu je nutnou podminkou pouziti _global_ page hash table
98
        mechanismu.</para>
99
 
100
        <para>- na vsech arch. plati, ze asidu je mnohem mene, nez teoreticky
101
        pocet soucasne bezicich tasku ~ adresovych prostoru, takze je
102
        implementovan mechanismus, ktery umoznuje jednomu adresovemu prostoru
103
        ASID odebrat a pridelit ho jinemu</para>
104
 
105
        <para>- vztah task ~ adresovy prostor: teoreticky existuje moznost, ze
106
        je adresovy prostor sdilen vice tasky, avsak tuto moznost nepouzivame
107
        a neni ani nijak osetrena. Tim padem plati, ze kazdy task ma vlastni
108
        adresovy prostor</para>
109
      </section>
9 bondari 110
    </section>
111
 
112
    <section>
11 bondari 113
      <title>Virtual address translation</title>
9 bondari 114
 
35 bondari 115
      <section id="page_tables">
116
        <title>Page tables</title>
34 bondari 117
 
35 bondari 118
        <para>HelenOS kernel has two different approaches to the paging
119
        implementation: <emphasis>4 level page tables</emphasis> and
120
        <emphasis>global hash tables</emphasis>, which are accessible via
121
        generic paging abstraction layer. This division was caused by the
122
        major architectural differences between different platforms.</para>
34 bondari 123
 
35 bondari 124
        <formalpara>
125
          <title>4-level page tables</title>
34 bondari 126
 
35 bondari 127
          <para>4-level page tables are the generalization of the hardware
128
          capabilities of the certain platforms. <itemizedlist>
129
              <listitem>
130
                 ia32 uses 2-level page tables, with full hardware support.
131
              </listitem>
34 bondari 132
 
35 bondari 133
              <listitem>
134
                 amd64 uses 4-level page tables, also coming with full hardware support.
135
              </listitem>
136
 
137
              <listitem>
138
                 mips and ppc32 have 2-level tables, software simulated support.
139
              </listitem>
140
            </itemizedlist></para>
141
        </formalpara>
142
 
143
        <formalpara>
144
          <title>Global hash tables</title>
145
 
146
          <para>- global page hash table: existuje jen jedna v celem systemu
147
          (vyuziva ji ia64), pozn. ia64 ma zatim vypnuty VHPT. Pouziva se
148
          genericke hash table s oddelenymi collision chains</para>
149
        </formalpara>
150
 
151
        <para>Thanks to the abstract paging interface, there is possibility
152
        left have more paging implementations, for example B-Tree page
153
        tables.</para>
154
      </section>
155
 
156
      <section id="tlb">
157
        <title>Translation Lookaside buffer</title>
158
 
159
        <para>- TLB cachuji informace ve strankovacich tabulkach; alternativne
160
        se lze na strankovaci tabulky (ci ruzne hw rozsireni [e.g. VHPT, ppc32
161
        hw hash table]) divat jako na velke TLB</para>
162
 
163
        <para>- pri modifikaci mapovani nebo odstraneni mapovani ze
164
        strankovacich tabulek je potreba zajistit konsistenci TLB a techto
165
        tabulek; nutne delat na vsech CPU; na to mame zjednodusenou verzi TLB
166
        shootdown mechanismu; je to variace na algoritmus popsany zde: D.
167
        Black et al., "Translation Lookaside Buffer Consistency: A Software
168
        Approach," Proc. Third Int'l Conf. Architectural Support for
169
        Programming Languages and Operating Systems, 1989, pp. 113-122.</para>
170
 
171
        <para>- nutno poznamenat, ze existuji odlehcenejsi verze TLB shootdown
172
        algoritmu</para>
173
      </section>
174
    </section>
26 bondari 175
  </section>
9 bondari 176
 
26 bondari 177
  <!-- End of VM -->
24 bondari 178
 
26 bondari 179
  <section>
180
    <!-- Phys mem -->
181
 
11 bondari 182
    <title>Physical memory management</title>
9 bondari 183
 
24 bondari 184
    <section id="zones_and_frames">
185
      <title>Zones and frames</title>
186
 
34 bondari 187
      <para><!--graphic fileref="images/mm2.png" /--><!--graphic fileref="images/buddy_alloc.svg" format="SVG" /--></para>
26 bondari 188
 
189
      <para>On some architectures not whole physical memory is available for
190
      conventional usage. This limitations require from kernel to maintain a
191
      table of available and unavailable ranges of physical memory addresses.
192
      Main idea of zones is in creating memory zone entity, that is a
193
      continuous chunk of memory available for allocation. If some chunk is
194
      not available, we simply do not put it in any zone.</para>
195
 
196
      <para>Zone is also serves for informational purposes, containing
197
      information about number of free and busy frames. Physical memory
198
      allocation is also done inside the certain zone. Allocation of zone
199
      frame must be organized by the <link linkend="frame_allocator">frame
200
      allocator</link> associated with the zone.</para>
201
 
202
      <para>Some of the architectures (mips32, ppc32) have only one zone, that
203
      covers whole physical memory, and the others (like ia32) may have
204
      multiple zones. Information about zones on current machine is stored in
205
      BIOS hardware tables or can be hardcoded into kernel during compile
206
      time.</para>
24 bondari 207
    </section>
208
 
209
    <section id="frame_allocator">
210
      <title>Frame allocator</title>
211
 
39 bondari 212
      <para><mediaobject id="frame_alloc">
213
          <imageobject role="html">
214
            <imagedata fileref="images/frame_alloc.png" format="PNG" />
215
          </imageobject>
216
 
217
          <imageobject role="fop">
218
            <imagedata fileref="images.vector/frame_alloc.svg" format="SVG" />
219
          </imageobject>
220
        </mediaobject></para>
221
 
26 bondari 222
      <formalpara>
223
        <title>Overview</title>
24 bondari 224
 
26 bondari 225
        <para>Frame allocator provides physical memory allocation for the
226
        kernel. Because of zonal organization of physical memory, frame
227
        allocator is always working in context of some zone, thus making
228
        impossible to allocate a piece of memory, which lays in different
229
        zone, which cannot happen, because two adjacent zones can be merged
230
        into one. Frame allocator is also being responsible to update
231
        information on the number of free/busy frames in zone. Physical memory
232
        allocation inside one <link linkend="zones_and_frames">memory
233
        zone</link> is being handled by an instance of <link
234
        linkend="buddy_allocator">buddy allocator</link> tailored to allocate
235
        blocks of physical memory frames.</para>
236
      </formalpara>
24 bondari 237
 
26 bondari 238
      <formalpara>
239
        <title>Allocation / deallocation</title>
24 bondari 240
 
26 bondari 241
        <para>Upon allocation request, frame allocator tries to find first
242
        zone, that can satisfy the incoming request (has required amount of
243
        free frames to allocate). During deallocation, frame allocator needs
244
        to find zone, that contain deallocated frame. This approach could
245
        bring up two potential problems: <itemizedlist>
246
            <listitem>
247
               Linear search of zones does not any good to performance, but number of zones is not expected to be high. And if yes, list of zones can be replaced with more time-efficient B-tree.
248
            </listitem>
24 bondari 249
 
26 bondari 250
            <listitem>
251
               Quickly find out if zone contains required number of frames to allocate and if this chunk of memory is properly aligned. This issue is perfectly solved bu the buddy allocator.
252
            </listitem>
253
          </itemizedlist></para>
254
      </formalpara>
255
    </section>
17 jermar 256
 
34 bondari 257
    <section id="buddy_allocator">
258
      <title>Buddy allocator</title>
17 jermar 259
 
34 bondari 260
      <section>
261
        <title>Overview</title>
17 jermar 262
 
39 bondari 263
        <para><mediaobject id="buddy_alloc">
264
            <imageobject role="html">
265
              <imagedata fileref="images/buddy_alloc.png" format="PNG" />
266
            </imageobject>
267
 
268
            <imageobject role="fop">
269
              <imagedata fileref="images.vector/buddy_alloc.svg" format="SVG" />
270
            </imageobject>
271
          </mediaobject></para>
272
 
34 bondari 273
        <para>In buddy allocator, memory is broken down into power-of-two
274
        sized naturally aligned blocks. These blocks are organized in an array
275
        of lists in which list with index i contains all unallocated blocks of
276
        the size <mathphrase>2<superscript>i</superscript></mathphrase>. The
277
        index i is called the order of block. Should there be two adjacent
278
        equally sized blocks in list <mathphrase>i</mathphrase> (i.e.
279
        buddies), the buddy allocator would coalesce them and put the
280
        resulting block in list <mathphrase>i + 1</mathphrase>, provided that
281
        the resulting block would be naturally aligned. Similarily, when the
282
        allocator is asked to allocate a block of size
283
        <mathphrase>2<superscript>i</superscript></mathphrase>, it first tries
284
        to satisfy the request from list with index i. If the request cannot
285
        be satisfied (i.e. the list i is empty), the buddy allocator will try
286
        to allocate and split larger block from list with index i + 1. Both of
287
        these algorithms are recursive. The recursion ends either when there
288
        are no blocks to coalesce in the former case or when there are no
289
        blocks that can be split in the latter case.</para>
17 jermar 290
 
34 bondari 291
        <!--graphic fileref="images/mm1.png" format="EPS" /-->
17 jermar 292
 
34 bondari 293
        <para>This approach greatly reduces external fragmentation of memory
294
        and helps in allocating bigger continuous blocks of memory aligned to
295
        their size. On the other hand, the buddy allocator suffers increased
296
        internal fragmentation of memory and is not suitable for general
297
        kernel allocations. This purpose is better addressed by the <link
298
        linkend="slab">slab allocator</link>.</para>
299
      </section>
17 jermar 300
 
34 bondari 301
      <section>
302
        <title>Implementation</title>
17 jermar 303
 
34 bondari 304
        <para>The buddy allocator is, in fact, an abstract framework wich can
305
        be easily specialized to serve one particular task. It knows nothing
306
        about the nature of memory it helps to allocate. In order to beat the
307
        lack of this knowledge, the buddy allocator exports an interface that
308
        each of its clients is required to implement. When supplied an
309
        implementation of this interface, the buddy allocator can use
310
        specialized external functions to find buddy for a block, split and
311
        coalesce blocks, manipulate block order and mark blocks busy or
39 bondari 312
        available. For precize documentation of this interface, refer to
313
        <emphasis>"HelenOS Generic Kernel Reference Manual"</emphasis>.</para>
17 jermar 314
 
34 bondari 315
        <formalpara>
316
          <title>Data organization</title>
17 jermar 317
 
34 bondari 318
          <para>Each entity allocable by the buddy allocator is required to
319
          contain space for storing block order number and a link variable
320
          used to interconnect blocks within the same order.</para>
15 bondari 321
 
34 bondari 322
          <para>Whatever entities are allocated by the buddy allocator, the
323
          first entity within a block is used to represent the entire block.
324
          The first entity keeps the order of the whole block. Other entities
325
          within the block are assigned the magic value
326
          <constant>BUDDY_INNER_BLOCK</constant>. This is especially important
327
          for effective identification of buddies in one-dimensional array
328
          because the entity that represents a potential buddy cannot be
329
          associated with <constant>BUDDY_INNER_BLOCK</constant> (i.e. if it
330
          is associated with <constant>BUDDY_INNER_BLOCK</constant> then it is
331
          not a buddy).</para>
15 bondari 332
 
34 bondari 333
          <para>Buddy allocator always uses first frame to represent frame
334
          block. This frame contains <varname>buddy_order</varname> variable
335
          to provide information about the block size it actually represents (
336
          <mathphrase>2<superscript>buddy_order</superscript></mathphrase>
337
          frames block). Other frames in block have this value set to magic
338
          <constant>BUDDY_INNER_BLOCK</constant> that is much greater than
339
          buddy <varname>max_order</varname> value.</para>
15 bondari 340
 
34 bondari 341
          <para>Each <varname>frame_t</varname> also contains pointer member
342
          to hold frame structure in the linked list inside one order.</para>
343
        </formalpara>
15 bondari 344
 
34 bondari 345
        <formalpara>
346
          <title>Allocation algorithm</title>
15 bondari 347
 
34 bondari 348
          <para>Upon <mathphrase>2<superscript>i</superscript></mathphrase>
349
          frames block allocation request, allocator checks if there are any
350
          blocks available at the order list <varname>i</varname>. If yes,
351
          removes block from order list and returns its address. If no,
352
          recursively allocates
353
          <mathphrase>2<superscript>i+1</superscript></mathphrase> frame
354
          block, splits it into two
355
          <mathphrase>2<superscript>i</superscript></mathphrase> frame blocks.
356
          Then adds one of the blocks to the <varname>i</varname> order list
357
          and returns address of another.</para>
358
        </formalpara>
15 bondari 359
 
34 bondari 360
        <formalpara>
361
          <title>Deallocation algorithm</title>
17 jermar 362
 
34 bondari 363
          <para>Check if block has so called buddy (another free
364
          <mathphrase>2<superscript>i</superscript></mathphrase> frame block
365
          that can be linked with freed block into the
366
          <mathphrase>2<superscript>i+1</superscript></mathphrase> block).
367
          Technically, buddy is a odd/even block for even/odd block
368
          respectively. Plus we can put an extra requirement, that resulting
369
          block must be aligned to its size. This requirement guarantees
370
          natural block alignment for the blocks coming out the allocation
371
          system.</para>
9 bondari 372
 
34 bondari 373
          <para>Using direct pointer arithmetics,
374
          <varname>frame_t::ref_count</varname> and
375
          <varname>frame_t::buddy_order</varname> variables, finding buddy is
376
          done at constant time.</para>
377
        </formalpara>
378
      </section>
26 bondari 379
    </section>
380
 
15 bondari 381
    <section id="slab">
11 bondari 382
      <title>Slab allocator</title>
9 bondari 383
 
26 bondari 384
      <section>
34 bondari 385
        <title>Overview</title>
9 bondari 386
 
34 bondari 387
        <para><termdef><glossterm>Slab</glossterm> represents a contiguous
388
        piece of memory, usually made of several physically contiguous
389
        pages.</termdef> <termdef><glossterm>Slab cache</glossterm> consists
390
        of one or more slabs.</termdef></para>
391
 
26 bondari 392
        <para>The majority of memory allocation requests in the kernel are for
393
        small, frequently used data structures. For this purpose the slab
34 bondari 394
        allocator is a perfect solution. The basic idea behind the slab
26 bondari 395
        allocator is to have lists of commonly used objects available packed
396
        into pages. This avoids the overhead of allocating and destroying
34 bondari 397
        commonly used types of objects such threads, virtual memory structures
398
        etc. Also due to the exact allocated size matching, slab allocation
399
        completely eliminates internal fragmentation issue.</para>
26 bondari 400
      </section>
24 bondari 401
 
26 bondari 402
      <section>
34 bondari 403
        <title>Implementation</title>
9 bondari 404
 
39 bondari 405
        <para><mediaobject id="slab_alloc">
406
            <imageobject role="html">
407
              <imagedata fileref="images/slab_alloc.png" format="PNG" />
408
            </imageobject>
409
 
410
            <imageobject role="fop">
411
              <imagedata fileref="images.vector/slab_alloc.svg" format="SVG" />
412
            </imageobject>
413
          </mediaobject></para>
414
 
26 bondari 415
        <para>The SLAB allocator is closely modelled after <ulink
416
        url="http://www.usenix.org/events/usenix01/full_papers/bonwick/bonwick_html/">
417
        OpenSolaris SLAB allocator by Jeff Bonwick and Jonathan Adams </ulink>
418
        with the following exceptions: <itemizedlist>
419
            <listitem>
420
               empty SLABS are deallocated immediately (in Linux they are kept in linked list, in Solaris ???)
421
            </listitem>
422
 
423
            <listitem>
424
               empty magazines are deallocated when not needed (in Solaris they are held in linked list in slab cache)
425
            </listitem>
426
          </itemizedlist> Following features are not currently supported but
427
        would be easy to do: <itemizedlist>
428
            <listitem>
429
               - cache coloring
430
            </listitem>
431
 
432
            <listitem>
34 bondari 433
               - dynamic magazine grow (different magazine sizes are already supported, but we would need to adjust allocation strategy)
26 bondari 434
            </listitem>
435
          </itemizedlist></para>
436
 
34 bondari 437
        <section>
438
          <title>Magazine layer</title>
26 bondari 439
 
34 bondari 440
          <para>Due to the extensive bottleneck on SMP architures, caused by
441
          global SLAB locking mechanism, making processing of all slab
442
          allocation requests serialized, a new layer was introduced to the
443
          classic slab allocator design. Slab allocator was extended to
444
          support per-CPU caches 'magazines' to achieve good SMP scaling.
445
          <termdef>Slab SMP perfromance bottleneck was resolved by introducing
446
          a per-CPU caching scheme called as <glossterm>magazine
447
          layer</glossterm></termdef>.</para>
26 bondari 448
 
34 bondari 449
          <para>Magazine is a N-element cache of objects, so each magazine can
450
          satisfy N allocations. Magazine behaves like a automatic weapon
451
          magazine (LIFO, stack), so the allocation/deallocation become simple
452
          push/pop pointer operation. Trick is that CPU does not access global
453
          slab allocator data during the allocation from its magazine, thus
454
          making possible parallel allocations between CPUs.</para>
26 bondari 455
 
34 bondari 456
          <para>Implementation also requires adding another feature as the
457
          CPU-bound magazine is actually a pair of magazines to avoid
458
          thrashing when during allocation/deallocatiion of 1 item at the
459
          magazine size boundary. LIFO order is enforced, which should avoid
460
          fragmentation as much as possible.</para>
26 bondari 461
 
34 bondari 462
          <para>Another important entity of magazine layer is a full magazine
463
          depot, that stores full magazines which are used by any of the CPU
464
          magazine caches to reload active CPU magazine. Magazine depot can be
465
          pre-filled with full magazines during initialization, but in current
466
          implementation it is filled during object deallocation, when CPU
467
          magazine becomes full.</para>
26 bondari 468
 
34 bondari 469
          <para>Slab allocator control structures are allocated from special
470
          slabs, that are marked by special flag, indicating that it should
471
          not be used for slab magazine layer. This is done to avoid possible
472
          infinite recursions and deadlock during conventional slab allocaiton
473
          requests.</para>
474
        </section>
26 bondari 475
 
34 bondari 476
        <section>
477
          <title>Allocation/deallocation</title>
26 bondari 478
 
34 bondari 479
          <para>Every cache contains list of full slabs and list of partialy
480
          full slabs. Empty slabs are immediately freed (thrashing will be
481
          avoided because of magazines).</para>
26 bondari 482
 
34 bondari 483
          <para>The SLAB allocator allocates lots of space and does not free
484
          it. When frame allocator fails to allocate the frame, it calls
485
          slab_reclaim(). It tries 'light reclaim' first, then brutal reclaim.
486
          The light reclaim releases slabs from cpu-shared magazine-list,
487
          until at least 1 slab is deallocated in each cache (this algorithm
488
          should probably change). The brutal reclaim removes all cached
489
          objects, even from CPU-bound magazines.</para>
490
 
491
          <formalpara>
492
            <title>Allocation</title>
493
 
494
            <para><emphasis>Step 1.</emphasis> When it comes to the allocation
495
            request, slab allocator first of all checks availability of memory
496
            in local CPU-bound magazine. If it is there, we would just "pop"
497
            the CPU magazine and return the pointer to object.</para>
498
 
499
            <para><emphasis>Step 2.</emphasis> If the CPU-bound magazine is
500
            empty, allocator will attempt to reload magazin, swapping it with
501
            second CPU magazine and returns to the first step.</para>
502
 
503
            <para><emphasis>Step 3.</emphasis> Now we are in the situation
504
            when both CPU-bound magazines are empty, which makes allocator to
505
            access shared full-magazines depot to reload CPU-bound magazines.
506
            If reload is succesful (meaning there are full magazines in depot)
507
            algoritm continues at Step 1.</para>
508
 
509
            <para><emphasis>Step 4.</emphasis> Final step of the allocation.
510
            In this step object is allocated from the conventional slab layer
511
            and pointer is returned.</para>
512
          </formalpara>
513
 
514
          <formalpara>
515
            <title>Deallocation</title>
516
 
517
            <para><emphasis>Step 1.</emphasis> During deallocation request,
518
            slab allocator will check if the local CPU-bound magazine is not
519
            full. In this case we will just push the pointer to this
520
            magazine.</para>
521
 
522
            <para><emphasis>Step 2.</emphasis> If the CPU-bound magazine is
523
            full, allocator will attempt to reload magazin, swapping it with
524
            second CPU magazine and returns to the first step.</para>
525
 
526
            <para><emphasis>Step 3.</emphasis> Now we are in the situation
527
            when both CPU-bound magazines are full, which makes allocator to
528
            access shared full-magazines depot to put one of the magazines to
529
            the depot and creating new empty magazine. Algoritm continues at
530
            Step 1.</para>
531
          </formalpara>
532
        </section>
26 bondari 533
      </section>
15 bondari 534
    </section>
26 bondari 535
 
536
    <!-- End of Physmem -->
537
  </section>
538
 
539
  <section>
540
    <title>Memory sharing</title>
541
 
542
    <para>Not implemented yet(?)</para>
543
  </section>
11 bondari 544
</chapter>