History

Merge tag 'time-namespace-v5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux

Pull time namespace updates from Christian Brauner: "When time namespaces were introduced we missed to virtualize the 'btime' field in /proc/stat. This confuses tasks which are in another time namespace with a virtualized boottime which is common in some container workloads. This contains Michael's series to fix 'btime' which Thomas asked me to take through my tree. To fix 'btime' virtualization we simply subtract the offset of the time namespace's boottime from btime before printing the stats. Note that since start_boottime of processes are seconds since boottime and the boottime stamp is now shifted according to the time namespace's offset, the offset of the time namespace also needs to be applied before the process stats are given to userspace. This avoids that processes shown by tools such as 'ps' appear as time travelers in the corresponding time namespace. Selftests are included to verify that btime virtualization in /proc/stat works as expected" * tag 'time-namespace-v5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux: namespace: make timens_on_fork() return nothing selftests/timens: added selftest for /proc/stat btime fs/proc: apply the time namespace offset to /proc/stat btime timens: additional helper functions for boottime offset handling

Linus Torvalds committed 5 years ago

Commit 6d93a192 parents 0ca2ce8 5c626346 files · +92 −16Browse files

Showing the changes to kernel (2 of 6 files). Show all

Unified · Split

2 files
  1. kernel/nsproxy.c +1 −6
  2. kernel/time/namespace.c +2 −4
kernel/nsproxy.c+1−6
@@ -153,7 +153,6 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk) · 152 unmodified lines
153153 struct nsproxy *old_ns = tsk->nsproxy;
154154 struct user_namespace *user_ns = task_cred_xxx(tsk, user_ns);
155155 struct nsproxy *new_ns;
156− int ret;
157156
158157 if (likely(!(flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
159158 CLONE_NEWPID | CLONE_NEWNET |
@@ -180,11 +179,7 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk) · 20 unmodified lines
180179 if (IS_ERR(new_ns))
181180 return PTR_ERR(new_ns);
182181
183− ret = timens_on_fork(new_ns, tsk);
184− if (ret) {
185− free_nsproxy(new_ns);
186− return ret;
187− }
182+ timens_on_fork(new_ns, tsk);
188183
189184 tsk->nsproxy = new_ns;
190185 return 0;
kernel/time/namespace.c+2−4
@@ -308,22 +308,20 @@ static int timens_install(struct nsset *nsset, struct ns_common *new) · 307 unmodified lines
308308 return 0;
309309 }
310310
311−int timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk)
311+void timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk)
312312 {
313313 struct ns_common *nsc = &nsproxy->time_ns_for_children->ns;
314314 struct time_namespace *ns = to_time_ns(nsc);
315315
316316 /* create_new_namespaces() already incremented the ref counter */
317317 if (nsproxy->time_ns == nsproxy->time_ns_for_children)
318− return 0;
318+ return;
319319
320320 get_time_ns(ns);
321321 put_time_ns(nsproxy->time_ns);
322322 nsproxy->time_ns = ns;
323323
324324 timens_commit(tsk, ns);
325−
326− return 0;
327325 }
328326
329327 static struct user_namespace *timens_owner(struct ns_common *ns)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t