summaryrefslogtreecommitdiffhomepage
path: root/pkg/refsvfs2/refs_template.go
diff options
context:
space:
mode:
authorDean Deng <deandeng@google.com>2021-05-12 13:21:47 -0700
committergVisor bot <gvisor-bot@google.com>2021-05-12 13:23:48 -0700
commit07e32fa6967370ef29327417fd941c5130335fbc (patch)
treea247be2ff83e165aef27edc05d26980290dbf96e /pkg/refsvfs2/refs_template.go
parent2f6e85ddec08e6d44c07eaf2b63a9887cb666d84 (diff)
Document design details for refsvfs2 template.
PiperOrigin-RevId: 373437576
Diffstat (limited to 'pkg/refsvfs2/refs_template.go')
-rw-r--r--pkg/refsvfs2/refs_template.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/pkg/refsvfs2/refs_template.go b/pkg/refsvfs2/refs_template.go
index 3fbc91aa5..1102c8adc 100644
--- a/pkg/refsvfs2/refs_template.go
+++ b/pkg/refsvfs2/refs_template.go
@@ -13,7 +13,7 @@
// limitations under the License.
// Package refs_template defines a template that can be used by reference
-// counted objects.
+// counted objects. The template comes with leak checking capabilities.
package refs_template
import (
@@ -40,6 +40,14 @@ var obj *T
// Refs implements refs.RefCounter. It keeps a reference count using atomic
// operations and calls the destructor when the count reaches zero.
//
+// NOTE: Do not introduce additional fields to the Refs struct. It is used by
+// many filesystem objects, and we want to keep it as small as possible (i.e.,
+// the same size as using an int64 directly) to avoid taking up extra cache
+// space. In general, this template should not be extended at the cost of
+// performance. If it does not offer enough flexibility for a particular object
+// (example: b/187877947), we should implement the RefCounter/CheckedObject
+// interfaces manually.
+//
// +stateify savable
type Refs struct {
// refCount is composed of two fields: