starnix_sync/
lock_ordering.rs

1// Copyright 2023 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use crate::Unlocked;
6use lock_ordering_macro::lock_ordering;
7
8lock_ordering! {
9    // UninterruptibleLock represents a virtual level before which lock must be interruptible.
10    Unlocked => UninterruptibleLock,
11    // Artificial level for ResourceAccessor.add_file_with_flags(..)
12    Unlocked => ResourceAccessorLevel,
13    // Artificial level for methods in FsNodeOps/FileOps that require access to the
14    // FsNode.append_lock
15    Unlocked => BeforeFsNodeAppend,
16    BeforeFsNodeAppend => FsNodeAppend,
17    // Artificial level for file operations.
18    FsNodeAppend => FileOpsCore,
19    ResourceAccessorLevel => FileOpsCore,
20    // FileOpsCore are interruptible
21    FileOpsCore => UninterruptibleLock,
22    // Artificial lock level for {Task, CurrentTask}.release()
23    Unlocked => TaskRelease,
24    // During task release, file must be closed.
25    TaskRelease => FileOpsCore,
26    // Kernel.iptables
27    UninterruptibleLock => KernelIpTables,
28    // Kernel.swap_files
29    UninterruptibleLock => KernelSwapFiles,
30    // ThreadGroup.limits
31    ProcessGroupState => ThreadGroupLimits,
32    MmDumpable => ThreadGroupLimits,
33    // MemoryManager.dumpable
34    UninterruptibleLock => MmDumpable,
35    // ProcessGroup.mutable_state.
36    // Needs to be before TaskRelease because of the dependency in CurrentTask.release()
37    TaskRelease => ProcessGroupState,
38    UninterruptibleLock => ProcessGroupState,
39    // ProcessGroup.mutable_state. Artificial locks above need to be before it because of
40    // dependencies in DevPtsFile.{read, write, ioctl}.
41    FileOpsCore => ProcessGroupState,
42    // eBPF locks
43    UninterruptibleLock => EbpfStateLock,
44    // Userfaultfd
45    FileOpsCore => UserFaultInner,
46    UninterruptibleLock => UserFaultInner,
47    // MemoryPressureMonitor
48    UninterruptibleLock => MemoryPressureMonitor,
49    FileOpsCore => MemoryPressureMonitor,
50    MemoryPressureMonitor => MemoryPressureMonitorClientState,
51    // Fastrpc
52    UninterruptibleLock => FastrpcInnerState,
53    // MemoryXattrStorage
54    UninterruptibleLock => MemoryXattrStorageLevel,
55    // Bpf Map State objects
56    UninterruptibleLock => BpfMapStateLevel,
57    // DeviceRegistty
58    UninterruptibleLock => DeviceRegistryState,
59    FileOpsCore => DeviceRegistryState,
60
61    // Terminal Level. No lock level should ever be defined after this. Can be used for any locks
62    // that is never acquired before any other lock.
63    UninterruptibleLock => TerminalLock,
64    FileOpsCore => TerminalLock,
65}