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 => ResourceAccessorAddFile,
13    // Artificial level for DeviceOps.open(..)
14    ResourceAccessorAddFile => DeviceOpen,
15    // Artificial level for several FileOps and FsNodeOps method forming a connected group
16    // because of dependencies between them: FileOps.read, FsNode.create_file_ops, ...
17    DeviceOpen => FileOpsCore,
18    // Artificial level for methods in FsNodeOps/FileOps that require access to the
19    // FsNode.append_lock
20    Unlocked => BeforeFsNodeAppend,
21    // FsNode.append_lock
22    BeforeFsNodeAppend => FsNodeAppend,
23    FsNodeAppend => FileOpsCore,
24    // FileOpsCore are interruptible
25    FileOpsCore => UninterruptibleLock,
26    // Artificial lock level for {Task, CurrentTask}.release()
27    Unlocked => TaskRelease,
28    // During task release, file must be closed.
29    TaskRelease => FileOpsCore,
30    // Kernel.iptables
31    UninterruptibleLock => KernelIpTables,
32    // Kernel.swap_files
33    UninterruptibleLock => KernelSwapFiles,
34    // ThreadGroup.limits
35    ProcessGroupState => ThreadGroupLimits,
36    MmDumpable => ThreadGroupLimits,
37    // MemoryManager.dumpable
38    UninterruptibleLock => MmDumpable,
39    // ProcessGroup.mutable_state.
40    // Needs to be before TaskRelease because of the dependency in CurrentTask.release()
41    TaskRelease => ProcessGroupState,
42    UninterruptibleLock => ProcessGroupState,
43    // ProcessGroup.mutable_state. Artificial locks above need to be before it because of
44    // dependencies in DevPtsFile.{read, write, ioctl}.
45    FileOpsCore => ProcessGroupState,
46    // Bpf locks
47    UninterruptibleLock => BpfPrograms,
48    // Userfaultfd
49    FileOpsCore => UserFaultInner,
50    UninterruptibleLock => UserFaultInner,
51    // MemoryPressureMonitor
52    UninterruptibleLock => MemoryPressureMonitor,
53    FileOpsCore => MemoryPressureMonitor,
54    MemoryPressureMonitor => MemoryPressureMonitorClientState,
55    // Fastrpc
56    UninterruptibleLock => FastrpcInnerState
57}