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