Merge tag 'pci-v6.16-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci
[linux-block.git] / include / linux / sched / user.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
8703e8a4
IM
2#ifndef _LINUX_SCHED_USER_H
3#define _LINUX_SCHED_USER_H
4
de8deb0a
IM
5#include <linux/uidgid.h>
6#include <linux/atomic.h>
1e1c1583 7#include <linux/percpu_counter.h>
fc371912 8#include <linux/refcount.h>
bef3efbe 9#include <linux/ratelimit.h>
8703e8a4 10
bcbb6a5b
IM
11/*
12 * Some day this will be a full-fledged user tracking system..
13 */
14struct user_struct {
fc371912 15 refcount_t __count; /* reference count */
bcbb6a5b 16#ifdef CONFIG_EPOLL
1e1c1583 17 struct percpu_counter epoll_watches; /* The number of file descriptors currently watched */
bcbb6a5b 18#endif
bcbb6a5b
IM
19 unsigned long unix_inflight; /* How many files in flight in unix sockets */
20 atomic_long_t pipe_bufs; /* how many pages are allocated in pipe buffers */
21
bcbb6a5b
IM
22 /* Hash table maintenance information */
23 struct hlist_node uidhash_node;
24 kuid_t uid;
25
a91dbff5 26#if defined(CONFIG_PERF_EVENTS) || defined(CONFIG_BPF_SYSCALL) || \
3c5a1b6f 27 defined(CONFIG_NET) || defined(CONFIG_IO_URING) || \
ce5a23c8 28 defined(CONFIG_VFIO_PCI_ZDEV_KVM) || IS_ENABLED(CONFIG_IOMMUFD)
bcbb6a5b
IM
29 atomic_long_t locked_vm;
30#endif
29e44f45
DH
31#ifdef CONFIG_WATCH_QUEUE
32 atomic_t nr_watches; /* The number of watches this user currently has */
33#endif
bef3efbe
LT
34
35 /* Miscellaneous per-user rate limit */
36 struct ratelimit_state ratelimit;
bcbb6a5b
IM
37};
38
39extern int uids_sysfs_init(void);
40
41extern struct user_struct *find_user(kuid_t);
42
43extern struct user_struct root_user;
44#define INIT_USER (&root_user)
45
46
47/* per-UID process charging. */
48extern struct user_struct * alloc_uid(kuid_t);
49static inline struct user_struct *get_uid(struct user_struct *u)
50{
fc371912 51 refcount_inc(&u->__count);
bcbb6a5b
IM
52 return u;
53}
54extern void free_uid(struct user_struct *);
55
8703e8a4 56#endif /* _LINUX_SCHED_USER_H */