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    // Userfaultfd
43    FileOpsCore => UserFaultInner,
44    UninterruptibleLock => UserFaultInner,
45    // MemoryPressureMonitor
46    UninterruptibleLock => MemoryPressureMonitor,
47    FileOpsCore => MemoryPressureMonitor,
48    MemoryPressureMonitor => MemoryPressureMonitorClientState,
49    // Fastrpc
50    UninterruptibleLock => FastrpcInnerState,
51    // MemoryXattrStorage
52    UninterruptibleLock => MemoryXattrStorageLevel,
53    // DeviceRegistty
54    UninterruptibleLock => DeviceRegistryState,
55    FileOpsCore => DeviceRegistryState,
56
57    // Terminal Level. No lock level should ever be defined after this. Can be used for any locks
58    // that is never acquired before any other lock.
59    UninterruptibleLock => TerminalLock,
60    FileOpsCore => TerminalLock,
61
62    // eBPF locks
63    UninterruptibleLock => EbpfStateLock,
64    UninterruptibleLock => EbpfMapStateLevel,
65    EbpfStateLock => EbpfSuspendLock,
66    EbpfMapStateLevel => EbpfSuspendLock,
67}