Open main menu

OpenVZ Virtuozzo Containers Wiki β

Editing RSS fractions accounting

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 47: Line 47:
  
 
In a C-like notation this would look like this:
 
In a C-like notation this would look like this:
<source lang="C">
+
<pre>
 
pb = lookup_pb(page, UB);
 
pb = lookup_pb(page, UB);
 
if (pb != NULL) {
 
if (pb != NULL) {
Line 65: Line 65:
 
list_add_tail(pb, page.pb_list);
 
list_add_tail(pb, page.pb_list);
 
page.pb_list.first = head.next;
 
page.pb_list.first = head.next;
</source>
+
</pre>
  
 
Shift increment essentially means “take one half of the currently held fraction and give it to the newbie”.
 
Shift increment essentially means “take one half of the currently held fraction and give it to the newbie”.
Line 75: Line 75:
 
; The last reference is removed
 
; The last reference is removed
 
: In this case the PB that ties page and UB must give its shift back to other PBs and be removed from list. This “giving shift back” procedure may involve three PBs and it is better described by the code example below.
 
: In this case the PB that ties page and UB must give its shift back to other PBs and be removed from list. This “giving shift back” procedure may involve three PBs and it is better described by the code example below.
<source lang="C">
+
<pre>
 
pb = lookup_pb(page, UB);
 
pb = lookup_pb(page, UB);
 
pb.refcount--;
 
pb.refcount--;
Line 92: Line 92:
 
         page.pb_list.first = tail
 
         page.pb_list.first = tail
 
}
 
}
</source>
+
</pre>
  
 
Decrementing the shifts like this means “take the fraction held by the PB going out and give it to another one; if the fraction held is too large — share it between two PBs”.
 
Decrementing the shifts like this means “take the fraction held by the PB going out and give it to another one; if the fraction held is too large — share it between two PBs”.
  
 
{{Note|cases when <code>page.pb_list</code> is becoming empty on adding a reference, or becoming empty on removing references are skipped to simplify the code examples.}}
 
{{Note|cases when <code>page.pb_list</code> is becoming empty on adding a reference, or becoming empty on removing references are skipped to simplify the code examples.}}
 
[[Category: Kernel internals]]
 

Please note that all contributions to OpenVZ Virtuozzo Containers Wiki may be edited, altered, or removed by other contributors. If you don't want your writing to be edited mercilessly, then don't submit it here.
If you are going to add external links to an article, read the External links policy first!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Templates used on this page: