Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs/binfmt: Convert obsolete cputime type to nsecs

Use the new nsec based cputime accessors as part of the whole cputime
conversion from cputime_t to nsecs.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Stanislaw Gruszka <sgruszka@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Wanpeng Li <wanpeng.li@hotmail.com>
Link: http://lkml.kernel.org/r/1485832191-26889-12-git-send-email-fweisbec@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Frederic Weisbecker and committed by
Ingo Molnar
cd19c364 c0e7a500

+45 -70
+2 -10
arch/mips/kernel/binfmt_elfn32.c
··· 99 99 #undef TASK_SIZE 100 100 #define TASK_SIZE TASK_SIZE32 101 101 102 - #undef cputime_to_timeval 103 - #define cputime_to_timeval cputime_to_compat_timeval 104 - static __inline__ void 105 - cputime_to_compat_timeval(const cputime_t cputime, struct compat_timeval *value) 106 - { 107 - unsigned long jiffies = cputime_to_jiffies(cputime); 108 - 109 - value->tv_usec = (jiffies % HZ) * (1000000L / HZ); 110 - value->tv_sec = jiffies / HZ; 111 - } 102 + #undef ns_to_timeval 103 + #define ns_to_timeval ns_to_compat_timeval 112 104 113 105 #include "../../../fs/binfmt_elf.c"
+2 -10
arch/mips/kernel/binfmt_elfo32.c
··· 102 102 #undef TASK_SIZE 103 103 #define TASK_SIZE TASK_SIZE32 104 104 105 - #undef cputime_to_timeval 106 - #define cputime_to_timeval cputime_to_compat_timeval 107 - static __inline__ void 108 - cputime_to_compat_timeval(const cputime_t cputime, struct compat_timeval *value) 109 - { 110 - unsigned long jiffies = cputime_to_jiffies(cputime); 111 - 112 - value->tv_usec = (jiffies % HZ) * (1000000L / HZ); 113 - value->tv_sec = jiffies / HZ; 114 - } 105 + #undef ns_to_timeval 106 + #define ns_to_timeval ns_to_compat_timeval 115 107 116 108 #include "../../../fs/binfmt_elf.c"
+2 -9
arch/parisc/kernel/binfmt_elf32.c
··· 91 91 current->thread.map_base = DEFAULT_MAP_BASE32; \ 92 92 current->thread.task_size = DEFAULT_TASK_SIZE32 \ 93 93 94 - #undef cputime_to_timeval 95 - #define cputime_to_timeval cputime_to_compat_timeval 96 - static __inline__ void 97 - cputime_to_compat_timeval(const cputime_t cputime, struct compat_timeval *value) 98 - { 99 - unsigned long jiffies = cputime_to_jiffies(cputime); 100 - value->tv_usec = (jiffies % HZ) * (1000000L / HZ); 101 - value->tv_sec = jiffies / HZ; 102 - } 94 + #undef ns_to_timeval 95 + #define ns_to_timeval ns_to_compat_timeval 103 96 104 97 #include "../../../fs/binfmt_elf.c"
+10 -16
fs/binfmt_elf.c
··· 1411 1411 static void fill_prstatus(struct elf_prstatus *prstatus, 1412 1412 struct task_struct *p, long signr) 1413 1413 { 1414 - struct timeval tv; 1415 - 1416 1414 prstatus->pr_info.si_signo = prstatus->pr_cursig = signr; 1417 1415 prstatus->pr_sigpend = p->pending.signal.sig[0]; 1418 1416 prstatus->pr_sighold = p->blocked.sig[0]; ··· 1421 1423 prstatus->pr_pgrp = task_pgrp_vnr(p); 1422 1424 prstatus->pr_sid = task_session_vnr(p); 1423 1425 if (thread_group_leader(p)) { 1424 - struct task_cputime_t cputime; 1426 + struct task_cputime cputime; 1425 1427 1426 1428 /* 1427 1429 * This is the record for the group leader. It shows the 1428 1430 * group-wide total, not its individual thread total. 1429 1431 */ 1430 - thread_group_cputime_t(p, &cputime); 1431 - cputime_to_timeval(cputime.utime, &prstatus->pr_utime); 1432 - cputime_to_timeval(cputime.stime, &prstatus->pr_stime); 1432 + thread_group_cputime(p, &cputime); 1433 + prstatus->pr_utime = ns_to_timeval(cputime.utime); 1434 + prstatus->pr_stime = ns_to_timeval(cputime.stime); 1433 1435 } else { 1434 - cputime_t utime, stime; 1436 + u64 utime, stime; 1435 1437 1436 - task_cputime_t(p, &utime, &stime); 1437 - cputime_to_timeval(utime, &prstatus->pr_utime); 1438 - cputime_to_timeval(stime, &prstatus->pr_stime); 1438 + task_cputime(p, &utime, &stime); 1439 + prstatus->pr_utime = ns_to_timeval(utime); 1440 + prstatus->pr_stime = ns_to_timeval(stime); 1439 1441 } 1440 - tv = ns_to_timeval(p->signal->cutime); 1441 - prstatus->pr_cutime.tv_sec = tv.tv_sec; 1442 - prstatus->pr_cutime.tv_usec = tv.tv_usec; 1443 1442 1444 - tv = ns_to_timeval(p->signal->cstime); 1445 - prstatus->pr_cstime.tv_sec = tv.tv_sec; 1446 - prstatus->pr_cstime.tv_usec = tv.tv_usec; 1443 + prstatus->pr_cutime = ns_to_timeval(p->signal->cutime); 1444 + prstatus->pr_cstime = ns_to_timeval(p->signal->cstime); 1447 1445 } 1448 1446 1449 1447 static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
+8 -8
fs/binfmt_elf_fdpic.c
··· 1342 1342 prstatus->pr_pgrp = task_pgrp_vnr(p); 1343 1343 prstatus->pr_sid = task_session_vnr(p); 1344 1344 if (thread_group_leader(p)) { 1345 - struct task_cputime_t cputime; 1345 + struct task_cputime cputime; 1346 1346 1347 1347 /* 1348 1348 * This is the record for the group leader. It shows the 1349 1349 * group-wide total, not its individual thread total. 1350 1350 */ 1351 - thread_group_cputime_t(p, &cputime); 1352 - cputime_to_timeval(cputime.utime, &prstatus->pr_utime); 1353 - cputime_to_timeval(cputime.stime, &prstatus->pr_stime); 1351 + thread_group_cputime(p, &cputime); 1352 + prstatus->pr_utime = ns_to_timeval(cputime.utime); 1353 + prstatus->pr_stime = ns_to_timeval(cputime.stime); 1354 1354 } else { 1355 - cputime_t utime, stime; 1355 + u64 utime, stime; 1356 1356 1357 - task_cputime_t(p, &utime, &stime); 1358 - cputime_to_timeval(utime, &prstatus->pr_utime); 1359 - cputime_to_timeval(stime, &prstatus->pr_stime); 1357 + task_cputime(p, &utime, &stime); 1358 + prstatus->pr_utime = ns_to_timeval(utime); 1359 + prstatus->pr_stime = ns_to_timeval(stime); 1360 1360 } 1361 1361 prstatus->pr_cutime = ns_to_timeval(p->signal->cutime); 1362 1362 prstatus->pr_cstime = ns_to_timeval(p->signal->cstime);
+2 -16
fs/compat_binfmt_elf.c
··· 51 51 #define elf_prstatus compat_elf_prstatus 52 52 #define elf_prpsinfo compat_elf_prpsinfo 53 53 54 - /* 55 - * Compat version of cputime_to_compat_timeval, perhaps this 56 - * should be an inline in <linux/compat.h>. 57 - */ 58 - static void cputime_to_compat_timeval(const cputime_t cputime, 59 - struct compat_timeval *value) 60 - { 61 - struct timeval tv; 62 - cputime_to_timeval(cputime, &tv); 63 - value->tv_sec = tv.tv_sec; 64 - value->tv_usec = tv.tv_usec; 65 - } 66 - 67 - #undef cputime_to_timeval 68 - #define cputime_to_timeval cputime_to_compat_timeval 69 - 54 + #undef ns_to_timeval 55 + #define ns_to_timeval ns_to_compat_timeval 70 56 71 57 /* 72 58 * To use this file, asm/elf.h must define compat_elf_check_arch.
+19 -1
include/linux/compat.h
··· 731 731 static inline bool in_compat_syscall(void) { return is_compat_task(); } 732 732 #endif 733 733 734 - #else 734 + /** 735 + * ns_to_compat_timeval - Compat version of ns_to_timeval 736 + * @nsec: the nanoseconds value to be converted 737 + * 738 + * Returns the compat_timeval representation of the nsec parameter. 739 + */ 740 + static inline struct compat_timeval ns_to_compat_timeval(s64 nsec) 741 + { 742 + struct timeval tv; 743 + struct compat_timeval ctv; 744 + 745 + tv = ns_to_timeval(nsec); 746 + ctv.tv_sec = tv.tv_sec; 747 + ctv.tv_usec = tv.tv_usec; 748 + 749 + return ctv; 750 + } 751 + 752 + #else /* !CONFIG_COMPAT */ 735 753 736 754 #define is_compat_task() (0) 737 755 static inline bool in_compat_syscall(void) { return false; }