mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-24 14:30:43 -08:00
Mps integ from br/unfixed-summary:
MPS design/shield: write a guide, plus links to initial ideas. MPS mps.h: (comment-only) Clarify that format class A and B are alive and well. It's only the _typename_ "mps_fmt_[AB]_t" that is deprecated, and mps_fmt_[AB]_s* should be used instead. (The old terse "deprecated" mislead me every time I saw it). MPS design/message: (cosmetic) centred h1 doc-title "MPS to Client Message Protocol" Copied from Perforce Change: 161321 ServerID: perforce.ravenbrook.com
This commit is contained in:
commit
d87f237dd9
3 changed files with 191 additions and 5 deletions
|
|
@ -189,7 +189,8 @@ typedef struct mps_fmt_A_s {
|
|||
mps_fmt_isfwd_t isfwd;
|
||||
mps_fmt_pad_t pad;
|
||||
} mps_fmt_A_s;
|
||||
typedef struct mps_fmt_A_s *mps_fmt_A_t; /* deprecated */
|
||||
typedef struct mps_fmt_A_s *mps_fmt_A_t;
|
||||
/* type-name mps_fmt_A_t is deprecated: use mps_fmt_A_s* instead */
|
||||
|
||||
typedef struct mps_fmt_B_s {
|
||||
mps_align_t align;
|
||||
|
|
@ -201,7 +202,8 @@ typedef struct mps_fmt_B_s {
|
|||
mps_fmt_pad_t pad;
|
||||
mps_fmt_class_t mps_class;
|
||||
} mps_fmt_B_s;
|
||||
typedef struct mps_fmt_B_s *mps_fmt_B_t; /* deprecated */
|
||||
typedef struct mps_fmt_B_s *mps_fmt_B_t;
|
||||
/* type-name mps_fmt_B_t is deprecated: use mps_fmt_B_s* instead */
|
||||
|
||||
|
||||
typedef struct mps_fmt_auto_header_s {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<head>
|
||||
|
||||
<title>MPS to client message protocol</title>
|
||||
<title>MPS to Client Message Protocol</title>
|
||||
|
||||
</head>
|
||||
|
||||
|
|
@ -26,15 +26,17 @@
|
|||
|
||||
<hr />
|
||||
|
||||
<h1>MPS to Client Message Protocol</h1>
|
||||
|
||||
</div>
|
||||
|
||||
<p>This document contains a <a href="#guide">guide</a> to the MPS Client Message Protocol, followed by the historical <a href="#initial-design">initial design</a>. References, History, Copyright and License are <a href="#section-A">at the end</a>.</p>
|
||||
<p>This document contains a <a href="#guide">guide</a> to the MPS to Client Message Protocol, followed by the historical <a href="#initial-design">initial design</a>. References, History, Copyright and License are <a href="#section-A">at the end</a>.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<h1> <a id="guide">Guide</a> </h1>
|
||||
|
||||
<p> Readership: any MPS Developer. </p>
|
||||
<p> Readership: any MPS developer. Not confidential. </p>
|
||||
|
||||
<h2> Introduction </h2>
|
||||
|
||||
|
|
|
|||
182
mps/design/shield/index.html
Normal file
182
mps/design/shield/index.html
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<title>MPS Shield</title>
|
||||
|
||||
</head>
|
||||
|
||||
<body bgcolor="#FFFFFF" text="#000000" link="#000099" vlink="#660066" alink="#FF0000">
|
||||
|
||||
<div align="center">
|
||||
|
||||
<p>
|
||||
<a href="/">Ravenbrook</a> /
|
||||
<a href="/project/">Projects</a> /
|
||||
<a href="/project/mps/">Memory Pool System</a> /
|
||||
<a href="/project/mps/master/">Master Product Sources</a> /
|
||||
<a href="/project/mps/master/design/">Design Documents</a>
|
||||
</p>
|
||||
|
||||
<p><i><a href="/project/mps/">Memory Pool System Project</a></i></p>
|
||||
|
||||
<hr />
|
||||
|
||||
<h1>MPS Shield</h1>
|
||||
|
||||
</div>
|
||||
|
||||
<p>This document contains a <a href="#guide">guide</a> to the MPS Shield. There is no historical initial design, but in its place there are some early ideas and discussions: <a href="#initial-ideas">initial ideas</a>. References, History, Copyright and License are <a href="#section-A">at the end</a>.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<h1> <a id="guide">Guide</a> </h1>
|
||||
|
||||
<p> Readership: any MPS developer. Not confidential. </p>
|
||||
|
||||
<h2> Introduction </h2>
|
||||
|
||||
<p>For incremental collection, we need <strong>separate control</strong> of collector access and mutator (client) access to memory. (The collector must be able to incrementally scan objects, without the mutator being able to see them yet).</p>
|
||||
|
||||
<p>Unfortunately common OSs do not support different access levels (protection maps) for different parts of the same process.</p>
|
||||
|
||||
<p>The MPS Shield is an abstraction that does extra work to overcome this limitation, and give the rest of the MPS the illusion that we can control collector and mutator access separately.</p>
|
||||
|
||||
|
||||
<h2>Control of mutator access: Raise, Lower, Suspend, Resume</h2>
|
||||
|
||||
<p>The MPS uses <strong>ShieldRaise</strong> and <strong>ShieldLower</strong> to forbid or permit the mutator access to object memory (that is, memory allocated by MPS):</p>
|
||||
|
||||
<p>ShieldRaise(mode) prevents the mutator accessing the memory in the specified mode (read, write, or both).</p>
|
||||
|
||||
<p>ShieldLower(mode) allows the mutator to access the memory in the specified mode (read, write, or both).</p>
|
||||
|
||||
<p>If the mutator attempts an access that hits a shield, the MPS gets a barrier hit (aka fault, interrupt, exception, etc), quickly does some necessary work, and then makes the access succeed.</p>
|
||||
|
||||
|
||||
<p>Some objects (eg. registers) cannot be hardware protected: the only way to prevent mutator access to them is to halt all mutator threads. The MPS uses <strong>ShieldSuspend</strong> and <strong>ShieldResume</strong> to do this.</p>
|
||||
|
||||
|
||||
<h2>Control of collector access: Enter, Leave, Expose, Cover</h2>
|
||||
|
||||
<p>When the collector wants to access object memory (that is, memory allocated by MPS), it must call <strong>ShieldEnter</strong>, then wrap any accesses with a <strong>ShieldExpose</strong> / <strong>ShieldCover</strong> pair, and finally call <strong>ShieldLeave</strong>.</p>
|
||||
|
||||
<p>ShieldExpose might for example be called around:</p>
|
||||
<ul>
|
||||
<li>format-scan (when Scanning);</li>
|
||||
<li>format-skip (when marking grains in a non-moving Fix);</li>
|
||||
<li>format-isMoved, AddrCopy (aka memcpy), and format-move (during a copying Fix);</li>
|
||||
<li>format-pad (during reclaim).</li>
|
||||
</ul>
|
||||
|
||||
<p>Note that there is no need to call ShieldExpose when accessing pool management memory such as bit tables etc. This is not object memory, is never (legally) accessed by the mutator, and so is never shielded.</p>
|
||||
|
||||
<p>On common OSs, the only way to allow collector access is to allow access from the whole process, including the mutator. So if the shield is asked to allow collector access but deny mutator access, it will halt all mutator threads to prevent any mutator access. The MPS Shield performs suspension and restart; normal collector code does not need to worry about it.</p>
|
||||
|
||||
<p>Collector code can make multiple sequential, overlapping, or nested calls to ShieldExpose on the same segment. (Each must be balanced by a ShieldCover before ShieldLeave is called). A usage count is maintained in seg->depth: a positive "depth" means a positive number of outstanding reasons why the segment must be exposed to the collector.</p>
|
||||
|
||||
<p>When the usage count reaches zero, the Shield could re-instate hardware protection. However, as a performance-improving hysteresis, it defers this, maintaining a cache of the last 16 times a segment no longer had a reason to be collector-accessible. Presence in the cache counts as a 'reason': segments in the cache have seg->depth increased by one. As segments get pushed out of the cache, or at ShieldLeave, this artificial 'reason' is decremented from seg->depth, and (if depth is now zero) the deferred reinstatement of hardware protection happens.</p>
|
||||
|
||||
<p>So whenever hardware protection is temporarily removed to allow collector access, there is a 'nurse' that will ensure this protection is re-established: the nurse is either the balancing ShieldCover call in collector code, or an entry in the shield cache.</p>
|
||||
|
||||
<p><em class="note">[Why is there a fixed-size cache? This is not the simple approach! All we need is a chain of segs that might need their hardware protection to be sync'd with their shield mode. Head in the shield, and one pointer in each seg struct. I guess we try hard to avoid bloating SegStruct. But is 16 the right size? A cache-miss wastes two kernel calls. RHSK 2006-12-19]</em></p>
|
||||
|
||||
<p><em class="note">[Also, I don't like the cache code. For example, why does ShieldFlush break out early if arena->shDepth is 0? This should never happen until the cache is completely flushed, ie. we have reached shCacheLimit. Why does ShieldFlush not reset shCacheLimit? Why does flush() silently accept NULL cache entries? RHSK 2006-12-19]</em></p>
|
||||
|
||||
<p><em class="note">[Also, why is seg->depth never checked for overflow? It is only a 4-bit-wide bit field, currently. RHSK 2006-12-19]</em></p>
|
||||
|
||||
<hr />
|
||||
|
||||
<h1> <a id="initial-ideas">Initial Ideas</a> </h1>
|
||||
|
||||
<p>See this very helpful
|
||||
<a href="/project/mps/mail/1995/11/30/15-07/0.txt">overview of protected tracing</a>
|
||||
<sup><a href="../../manual/wiki/index.html#not-publicly-available" title="this document is not publicly available">∅</a></sup>.
|
||||
Note that this overview is old, and the details may be inaccurate.</p>
|
||||
|
||||
<p>See
|
||||
<a href="/project/mps/doc/2002-06-18/obsolete-mminfo/mminfo/idea/shield/index.txt">idea.shield</a>
|
||||
<sup><a href="../../manual/wiki/index.html#not-publicly-available" title="this document is not publicly available">∅</a></sup>.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
<h2><a id="section-A" name="section-A">A. References</a></h2>
|
||||
|
||||
<!-- Template Entry
|
||||
|
||||
<table>
|
||||
|
||||
<tr valign="top">
|
||||
|
||||
<td>[<a id="ref-#REF#" name="ref-#REF#" href="#REF_URL#">#REF_NAME#</a>]</td>
|
||||
|
||||
<td>
|
||||
"#REF_TITLE#";
|
||||
#REF_AUTHOR#;
|
||||
<URL: <a href="#REF_URL#">#REF_URL#</a>>;
|
||||
#REF_DATE#.
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<h2><a id="section-B" name="section-B">B. Document History</a></h2>
|
||||
|
||||
<table>
|
||||
|
||||
<tr valign="top">
|
||||
<td>2006-12-19</td>
|
||||
<td><a href="mailto:rhsk@ravenbrook.com">RHSK</a></td>
|
||||
<td>Created: Guide, plus links to initial ideas.</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
<h2><a id="section-C" name="section-C">C. Copyright and License</a></h2>
|
||||
|
||||
<p> This document is copyright © 2006 <a href="http://www.ravenbrook.com/">Ravenbrook Limited</a>. All rights reserved. This is an open source license. Contact Ravenbrook for commercial licensing options. </p>
|
||||
|
||||
<p> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: </p>
|
||||
|
||||
<ol>
|
||||
|
||||
<li> Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. </li>
|
||||
|
||||
<li> Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. </li>
|
||||
|
||||
<li> Redistributions in any form must be accompanied by information on how to obtain complete source code for the this software and any accompanying software that uses this software. The source code must either be included in the distribution or be available for no more than the cost of distribution plus a nominal fee, and must be freely redistributable under reasonable conditions. For an executable file, complete source code means the source code for all modules it contains. It does not include source code for modules or files that typically accompany the major components of the operating system on which the executable file runs. </li>
|
||||
|
||||
</ol>
|
||||
|
||||
<p> <strong> This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement, are disclaimed. In no event shall the copyright holders and contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage. </strong> </p>
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<div align="center">
|
||||
|
||||
<p><code>$Id$</code></p>
|
||||
|
||||
<p>
|
||||
<a href="/">Ravenbrook</a> /
|
||||
<a href="/project/">Projects</a> /
|
||||
<a href="/project/mps/">Memory Pool System</a> /
|
||||
<a href="/project/mps/master/">Master Product Sources</a> /
|
||||
<a href="/project/mps/master/design/">Design Documents</a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue