Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1576840 > unrolled thread

[PATCH 14/53] sched/headers: Move 'struct user_struct' definition and APIs to the new <linux/sched/user.h> header

Started byIngo Molnar <mingo@kernel.org>
First post2017-02-08 19:50 +0100
Last post2017-02-08 22:30 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 14/53] sched/headers: Move 'struct user_struct' definition and APIs to the new <linux/sched/user.h> header Ingo Molnar <mingo@kernel.org> - 2017-02-08 19:50 +0100
    Re: [PATCH 14/53] sched/headers: Move 'struct user_struct' definition  and APIs to the new <linux/sched/user.h> header Linus Torvalds <torvalds@linux-foundation.org> - 2017-02-08 21:20 +0100
      Re: [PATCH 14/53] sched/headers: Move 'struct user_struct'  definition and APIs to the new <linux/sched/user.h> header Ingo Molnar <mingo@kernel.org> - 2017-02-08 22:30 +0100

#1576840 — [PATCH 14/53] sched/headers: Move 'struct user_struct' definition and APIs to the new <linux/sched/user.h> header

FromIngo Molnar <mingo@kernel.org>
Date2017-02-08 19:50 +0100
Subject[PATCH 14/53] sched/headers: Move 'struct user_struct' definition and APIs to the new <linux/sched/user.h> header
Message-ID<t8Ftx-3Sf-43@gated-at.bofh.it>
'struct user_struct' was added to sched.h historically, but it's actually
entirely independent of task_struct and of scheduler details, so move
it to its own header.

Fix up .c files using those facilities.

Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 include/linux/sched.h      | 57 ---------------------------------------------------------
 include/linux/sched/user.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 57 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 07f905a9e88a..966c53903eff 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -349,7 +349,6 @@ extern void io_schedule(void);
 void __noreturn do_task_dead(void);
 
 struct nsproxy;
-struct user_namespace;
 
 #ifdef CONFIG_MMU
 extern void arch_pick_mmap_layout(struct mm_struct *mm);
@@ -481,53 +480,6 @@ struct thread_group_cputimer {
 #include <linux/rwsem.h>
 struct autogroup;
 
-/*
- * Some day this will be a full-fledged user tracking system..
- */
-struct user_struct {
-	atomic_t __count;	/* reference count */
-	atomic_t processes;	/* How many processes does this user have? */
-	atomic_t sigpending;	/* How many pending signals does this user have? */
-#ifdef CONFIG_INOTIFY_USER
-	atomic_t inotify_watches; /* How many inotify watches does this user have? */
-	atomic_t inotify_devs;	/* How many inotify devs does this user have opened? */
-#endif
-#ifdef CONFIG_FANOTIFY
-	atomic_t fanotify_listeners;
-#endif
-#ifdef CONFIG_EPOLL
-	atomic_long_t epoll_watches; /* The number of file descriptors currently watched */
-#endif
-#ifdef CONFIG_POSIX_MQUEUE
-	/* protected by mq_lock	*/
-	unsigned long mq_bytes;	/* How many bytes can be allocated to mqueue? */
-#endif
-	unsigned long locked_shm; /* How many pages of mlocked shm ? */
-	unsigned long unix_inflight;	/* How many files in flight in unix sockets */
-	atomic_long_t pipe_bufs;  /* how many pages are allocated in pipe buffers */
-
-#ifdef CONFIG_KEYS
-	struct key *uid_keyring;	/* UID specific keyring */
-	struct key *session_keyring;	/* UID's default session keyring */
-#endif
-
-	/* Hash table maintenance information */
-	struct hlist_node uidhash_node;
-	kuid_t uid;
-
-#if defined(CONFIG_PERF_EVENTS) || defined(CONFIG_BPF_SYSCALL)
-	atomic_long_t locked_vm;
-#endif
-};
-
-extern int uids_sysfs_init(void);
-
-extern struct user_struct *find_user(kuid_t);
-
-extern struct user_struct root_user;
-#define INIT_USER (&root_user)
-
-
 struct backing_dev_info;
 struct reclaim_state;
 
@@ -1908,15 +1860,6 @@ extern struct task_struct *find_task_by_vpid(pid_t nr);
 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
 		struct pid_namespace *ns);
 
-/* per-UID process charging. */
-extern struct user_struct * alloc_uid(kuid_t);
-static inline struct user_struct *get_uid(struct user_struct *u)
-{
-	atomic_inc(&u->__count);
-	return u;
-}
-extern void free_uid(struct user_struct *);
-
 #include <asm/current.h>
 
 extern void xtime_update(unsigned long ticks);
diff --git a/include/linux/sched/user.h b/include/linux/sched/user.h
index 83238e5ddadd..c3824e6780e5 100644
--- a/include/linux/sched/user.h
+++ b/include/linux/sched/user.h
@@ -3,4 +3,62 @@
 
 #include <linux/sched.h>
 
+struct key;
+
+/*
+ * Some day this will be a full-fledged user tracking system..
+ */
+struct user_struct {
+	atomic_t __count;	/* reference count */
+	atomic_t processes;	/* How many processes does this user have? */
+	atomic_t sigpending;	/* How many pending signals does this user have? */
+#ifdef CONFIG_INOTIFY_USER
+	atomic_t inotify_watches; /* How many inotify watches does this user have? */
+	atomic_t inotify_devs;	/* How many inotify devs does this user have opened? */
+#endif
+#ifdef CONFIG_FANOTIFY
+	atomic_t fanotify_listeners;
+#endif
+#ifdef CONFIG_EPOLL
+	atomic_long_t epoll_watches; /* The number of file descriptors currently watched */
+#endif
+#ifdef CONFIG_POSIX_MQUEUE
+	/* protected by mq_lock	*/
+	unsigned long mq_bytes;	/* How many bytes can be allocated to mqueue? */
+#endif
+	unsigned long locked_shm; /* How many pages of mlocked shm ? */
+	unsigned long unix_inflight;	/* How many files in flight in unix sockets */
+	atomic_long_t pipe_bufs;  /* how many pages are allocated in pipe buffers */
+
+#ifdef CONFIG_KEYS
+	struct key *uid_keyring;	/* UID specific keyring */
+	struct key *session_keyring;	/* UID's default session keyring */
+#endif
+
+	/* Hash table maintenance information */
+	struct hlist_node uidhash_node;
+	kuid_t uid;
+
+#if defined(CONFIG_PERF_EVENTS) || defined(CONFIG_BPF_SYSCALL)
+	atomic_long_t locked_vm;
+#endif
+};
+
+extern int uids_sysfs_init(void);
+
+extern struct user_struct *find_user(kuid_t);
+
+extern struct user_struct root_user;
+#define INIT_USER (&root_user)
+
+
+/* per-UID process charging. */
+extern struct user_struct * alloc_uid(kuid_t);
+static inline struct user_struct *get_uid(struct user_struct *u)
+{
+	atomic_inc(&u->__count);
+	return u;
+}
+extern void free_uid(struct user_struct *);
+
 #endif /* _LINUX_SCHED_USER_H */
-- 
2.7.4

[toc] | [next] | [standalone]


#1577019 — Re: [PATCH 14/53] sched/headers: Move 'struct user_struct' definition and APIs to the new <linux/sched/user.h> header

FromLinus Torvalds <torvalds@linux-foundation.org>
Date2017-02-08 21:20 +0100
SubjectRe: [PATCH 14/53] sched/headers: Move 'struct user_struct' definition and APIs to the new <linux/sched/user.h> header
Message-ID<t8GSC-4S1-25@gated-at.bofh.it>
In reply to#1576840
On Wed, Feb 8, 2017 at 10:44 AM, Ingo Molnar <mingo@kernel.org> wrote:
> 'struct user_struct' was added to sched.h historically, but it's actually
> entirely independent of task_struct and of scheduler details, so move
> it to its own header.

Hmm. I wonder if this would make more sense not even under the
"<linux/sched/xyz>" hierarchy. It has nothing to do with the
scheduling at all, really.

Small nit and can be left for later.

            Linus

[toc] | [prev] | [next] | [standalone]


#1577085 — Re: [PATCH 14/53] sched/headers: Move 'struct user_struct' definition and APIs to the new <linux/sched/user.h> header

FromIngo Molnar <mingo@kernel.org>
Date2017-02-08 22:30 +0100
SubjectRe: [PATCH 14/53] sched/headers: Move 'struct user_struct' definition and APIs to the new <linux/sched/user.h> header
Message-ID<t8HYl-5wK-15@gated-at.bofh.it>
In reply to#1577019
* Linus Torvalds <torvalds@linux-foundation.org> wrote:

> On Wed, Feb 8, 2017 at 10:44 AM, Ingo Molnar <mingo@kernel.org> wrote:
> > 'struct user_struct' was added to sched.h historically, but it's actually
> > entirely independent of task_struct and of scheduler details, so move
> > it to its own header.
> 
> Hmm. I wonder if this would make more sense not even under the
> "<linux/sched/xyz>" hierarchy. It has nothing to do with the
> scheduling at all, really.
> 
> Small nit and can be left for later.

Yeah. Some of the others could be moved to include/linux/ as well, such as:

   <linux/sched/jobctl.h> => <linux/jobctl.h>
   <linux/sched/xacct.h>  => <linux/xacct.h>
   <linux/sched/user.h>   => <linux/user.h>

All of these are pretty unrelated to scheduling, they just happen to be about 
fields that are in task_struct.

<linux/user.h> already exists, it wraps asm/user.h - I suspect the 
<linux/sched/user.h> bits can just be appended to it, plus a header guard.

Thanks,

	Ingo

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web