linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Ingo Molnar <mingo@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Tony Luck <tony.luck@intel.com>,
	Wanpeng Li <wanpeng.li@hotmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Paul Mackerras <paulus@samba.org>,
	Fenghua Yu <fenghua.yu@intel.com>, Rik van Riel <riel@redhat.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Stanislaw Gruszka <sgruszka@redhat.com>
Subject: [PATCH RESEND 12/36] binfmt: Convert obsolete cputime type to nsecs
Date: Tue, 31 Jan 2017 04:09:27 +0100	[thread overview]
Message-ID: <1485832191-26889-12-git-send-email-fweisbec@gmail.com> (raw)
In-Reply-To: <1485832191-26889-1-git-send-email-fweisbec@gmail.com>
In-Reply-To: <1485751603-15913-1-git-send-email-fweisbec@gmail.com>

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

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Stanislaw Gruszka <sgruszka@redhat.com>
Cc: Wanpeng Li <wanpeng.li@hotmail.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 arch/mips/kernel/binfmt_elfn32.c  | 12 ++----------
 arch/mips/kernel/binfmt_elfo32.c  | 12 ++----------
 arch/parisc/kernel/binfmt_elf32.c | 11 ++---------
 fs/binfmt_elf.c                   | 26 ++++++++++----------------
 fs/binfmt_elf_fdpic.c             | 16 ++++++++--------
 fs/compat_binfmt_elf.c            | 18 ++----------------
 include/linux/compat.h            | 20 +++++++++++++++++++-
 7 files changed, 45 insertions(+), 70 deletions(-)

diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
index 9c7f3e1..4a2ff39 100644
--- a/arch/mips/kernel/binfmt_elfn32.c
+++ b/arch/mips/kernel/binfmt_elfn32.c
@@ -99,15 +99,7 @@ jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
 #undef TASK_SIZE
 #define TASK_SIZE TASK_SIZE32
 
-#undef cputime_to_timeval
-#define cputime_to_timeval cputime_to_compat_timeval
-static __inline__ void
-cputime_to_compat_timeval(const cputime_t cputime, struct compat_timeval *value)
-{
-	unsigned long jiffies = cputime_to_jiffies(cputime);
-
-	value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
-	value->tv_sec = jiffies / HZ;
-}
+#undef ns_to_timeval
+#define ns_to_timeval ns_to_compat_timeval
 
 #include "../../../fs/binfmt_elf.c"
diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
index 1ab3432..3916404 100644
--- a/arch/mips/kernel/binfmt_elfo32.c
+++ b/arch/mips/kernel/binfmt_elfo32.c
@@ -102,15 +102,7 @@ jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
 #undef TASK_SIZE
 #define TASK_SIZE TASK_SIZE32
 
-#undef cputime_to_timeval
-#define cputime_to_timeval cputime_to_compat_timeval
-static __inline__ void
-cputime_to_compat_timeval(const cputime_t cputime, struct compat_timeval *value)
-{
-	unsigned long jiffies = cputime_to_jiffies(cputime);
-
-	value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
-	value->tv_sec = jiffies / HZ;
-}
+#undef ns_to_timeval
+#define ns_to_timeval ns_to_compat_timeval
 
 #include "../../../fs/binfmt_elf.c"
diff --git a/arch/parisc/kernel/binfmt_elf32.c b/arch/parisc/kernel/binfmt_elf32.c
index 00dc66f..f2adcf3 100644
--- a/arch/parisc/kernel/binfmt_elf32.c
+++ b/arch/parisc/kernel/binfmt_elf32.c
@@ -91,14 +91,7 @@ struct elf_prpsinfo32
 	current->thread.map_base = DEFAULT_MAP_BASE32; \
 	current->thread.task_size = DEFAULT_TASK_SIZE32 \
 
-#undef cputime_to_timeval
-#define cputime_to_timeval cputime_to_compat_timeval
-static __inline__ void
-cputime_to_compat_timeval(const cputime_t cputime, struct compat_timeval *value)
-{
-	unsigned long jiffies = cputime_to_jiffies(cputime);
-	value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
-	value->tv_sec = jiffies / HZ;
-}
+#undef ns_to_timeval
+#define ns_to_timeval ns_to_compat_timeval
 
 #include "../../../fs/binfmt_elf.c"
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 13cd15d..f28595f 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1411,8 +1411,6 @@ static void fill_note(struct memelfnote *note, const char *name, int type,
 static void fill_prstatus(struct elf_prstatus *prstatus,
 		struct task_struct *p, long signr)
 {
-	struct timeval tv;
-
 	prstatus->pr_info.si_signo = prstatus->pr_cursig = signr;
 	prstatus->pr_sigpend = p->pending.signal.sig[0];
 	prstatus->pr_sighold = p->blocked.sig[0];
@@ -1423,29 +1421,25 @@ static void fill_prstatus(struct elf_prstatus *prstatus,
 	prstatus->pr_pgrp = task_pgrp_vnr(p);
 	prstatus->pr_sid = task_session_vnr(p);
 	if (thread_group_leader(p)) {
-		struct task_cputime_t cputime;
+		struct task_cputime cputime;
 
 		/*
 		 * This is the record for the group leader.  It shows the
 		 * group-wide total, not its individual thread total.
 		 */
-		thread_group_cputime_t(p, &cputime);
-		cputime_to_timeval(cputime.utime, &prstatus->pr_utime);
-		cputime_to_timeval(cputime.stime, &prstatus->pr_stime);
+		thread_group_cputime(p, &cputime);
+		prstatus->pr_utime = ns_to_timeval(cputime.utime);
+		prstatus->pr_stime = ns_to_timeval(cputime.stime);
 	} else {
-		cputime_t utime, stime;
+		u64 utime, stime;
 
-		task_cputime_t(p, &utime, &stime);
-		cputime_to_timeval(utime, &prstatus->pr_utime);
-		cputime_to_timeval(stime, &prstatus->pr_stime);
+		task_cputime(p, &utime, &stime);
+		prstatus->pr_utime = ns_to_timeval(utime);
+		prstatus->pr_stime = ns_to_timeval(stime);
 	}
-	tv = ns_to_timeval(p->signal->cutime);
-	prstatus->pr_cutime.tv_sec = tv.tv_sec;
-	prstatus->pr_cutime.tv_usec = tv.tv_usec;
 
-	tv = ns_to_timeval(p->signal->cstime);
-	prstatus->pr_cstime.tv_sec = tv.tv_sec;
-	prstatus->pr_cstime.tv_usec = tv.tv_usec;
+	prstatus->pr_cutime = ns_to_timeval(p->signal->cutime);
+	prstatus->pr_cstime = ns_to_timeval(p->signal->cstime);
 }
 
 static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index e1f3734..ffca4bb 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -1342,21 +1342,21 @@ static void fill_prstatus(struct elf_prstatus *prstatus,
 	prstatus->pr_pgrp = task_pgrp_vnr(p);
 	prstatus->pr_sid = task_session_vnr(p);
 	if (thread_group_leader(p)) {
-		struct task_cputime_t cputime;
+		struct task_cputime cputime;
 
 		/*
 		 * This is the record for the group leader.  It shows the
 		 * group-wide total, not its individual thread total.
 		 */
-		thread_group_cputime_t(p, &cputime);
-		cputime_to_timeval(cputime.utime, &prstatus->pr_utime);
-		cputime_to_timeval(cputime.stime, &prstatus->pr_stime);
+		thread_group_cputime(p, &cputime);
+		prstatus->pr_utime = ns_to_timeval(cputime.utime);
+		prstatus->pr_stime = ns_to_timeval(cputime.stime);
 	} else {
-		cputime_t utime, stime;
+		u64 utime, stime;
 
-		task_cputime_t(p, &utime, &stime);
-		cputime_to_timeval(utime, &prstatus->pr_utime);
-		cputime_to_timeval(stime, &prstatus->pr_stime);
+		task_cputime(p, &utime, &stime);
+		prstatus->pr_utime = ns_to_timeval(utime);
+		prstatus->pr_stime = ns_to_timeval(stime);
 	}
 	prstatus->pr_cutime = ns_to_timeval(p->signal->cutime);
 	prstatus->pr_cstime = ns_to_timeval(p->signal->cstime);
diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
index 4d24d17..504b3c3 100644
--- a/fs/compat_binfmt_elf.c
+++ b/fs/compat_binfmt_elf.c
@@ -51,22 +51,8 @@
 #define elf_prstatus	compat_elf_prstatus
 #define elf_prpsinfo	compat_elf_prpsinfo
 
-/*
- * Compat version of cputime_to_compat_timeval, perhaps this
- * should be an inline in <linux/compat.h>.
- */
-static void cputime_to_compat_timeval(const cputime_t cputime,
-				      struct compat_timeval *value)
-{
-	struct timeval tv;
-	cputime_to_timeval(cputime, &tv);
-	value->tv_sec = tv.tv_sec;
-	value->tv_usec = tv.tv_usec;
-}
-
-#undef cputime_to_timeval
-#define cputime_to_timeval cputime_to_compat_timeval
-
+#undef ns_to_timeval
+#define ns_to_timeval ns_to_compat_timeval
 
 /*
  * To use this file, asm/elf.h must define compat_elf_check_arch.
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 6360939..9e40be5 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -731,7 +731,25 @@ asmlinkage long compat_sys_fanotify_mark(int, unsigned int, __u32, __u32,
 static inline bool in_compat_syscall(void) { return is_compat_task(); }
 #endif
 
-#else
+/**
+ * ns_to_compat_timeval - Compat version of ns_to_timeval
+ * @nsec:	the nanoseconds value to be converted
+ *
+ * Returns the compat_timeval representation of the nsec parameter.
+ */
+static inline struct compat_timeval ns_to_compat_timeval(s64 nsec)
+{
+	struct timeval tv;
+	struct compat_timeval ctv;
+
+	tv = ns_to_timeval(nsec);
+	ctv.tv_sec = tv.tv_sec;
+	ctv.tv_usec = tv.tv_usec;
+
+	return ctv;
+}
+
+#else /* !CONFIG_COMPAT */
 
 #define is_compat_task() (0)
 static inline bool in_compat_syscall(void) { return false; }
-- 
2.7.4

  parent reply	other threads:[~2017-01-31  3:18 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-30  4:46 [GIT PULL] cputime: Convert core use of cputime_t to nsecs Frederic Weisbecker
2017-01-30 14:32 ` Stanislaw Gruszka
2017-01-30 14:56   ` Frederic Weisbecker
2017-01-30 15:29     ` Stanislaw Gruszka
2017-01-31  3:09 ` [PATCH RESEND 01/36] jiffies: Reuse TICK_NSEC instead of NSEC_PER_JIFFY Frederic Weisbecker
2017-02-01  9:49   ` [tip:sched/core] " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 02/36] time: Introduce jiffies64_to_nsecs() Frederic Weisbecker
2017-02-01  9:50   ` [tip:sched/core] " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 03/36] sched: Remove unused INIT_CPUTIME macro Frederic Weisbecker
2017-02-01  9:50   ` [tip:sched/core] sched/cputime: Remove the " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 04/36] cputime: Convert kcpustat to nsecs Frederic Weisbecker
2017-02-01  9:51   ` [tip:sched/core] sched/cputime: " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 05/36] macintosh/rack-meter: Remove cputime_t internal use Frederic Weisbecker
2017-02-01  9:51   ` [tip:sched/core] macintosh/rack-meter: Convert cputime64_t use to u64 tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 06/36] cputime: Convert guest time accounting to nsecs Frederic Weisbecker
2017-02-01  9:52   ` [tip:sched/core] sched/cputime: Convert guest time accounting to nsecs (u64) tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 07/36] cputime: Special API to return old-typed cputime Frederic Weisbecker
2017-02-01  9:52   ` [tip:sched/core] sched/cputime: Introduce special task_cputime_t() " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 08/36] cputime: Convert task/group cputime to nsecs Frederic Weisbecker
2017-02-01  9:53   ` [tip:sched/core] sched/cputime: " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 09/36] alpha: Convert obsolete cputime_t " Frederic Weisbecker
2017-02-01  9:53   ` [tip:sched/core] " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 10/36] x86: Convert obsolete cputime type " Frederic Weisbecker
2017-02-01  9:54   ` [tip:sched/core] " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 11/36] isdn: " Frederic Weisbecker
2017-02-01  9:54   ` [tip:sched/core] " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` Frederic Weisbecker [this message]
2017-02-01  9:55   ` [tip:sched/core] fs/binfmt: " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 13/36] acct: " Frederic Weisbecker
2017-02-01  9:55   ` [tip:sched/core] " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 14/36] delaycct: " Frederic Weisbecker
2017-02-01  9:56   ` [tip:sched/core] " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 15/36] tsacct: " Frederic Weisbecker
2017-02-01  9:56   ` [tip:sched/core] " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 16/36] signal: " Frederic Weisbecker
2017-02-01  9:57   ` [tip:sched/core] " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 17/36] cputime: Increment kcpustat directly on irqtime account Frederic Weisbecker
2017-02-01  9:58   ` [tip:sched/core] sched/cputime: " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 18/36] posix-timers: Use TICK_NSEC instead of a dynamically ad-hoc calculated version Frederic Weisbecker
2017-02-01  9:58   ` [tip:sched/core] timers/posix-timers: " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 19/36] posix-timers: Convert internals to use nsecs Frederic Weisbecker
2017-02-01  9:59   ` [tip:sched/core] timers/posix-timers: " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 20/36] itimer: Convert internal cputime_t units to nsec Frederic Weisbecker
2017-02-01  9:59   ` [tip:sched/core] timers/itimer: " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 21/36] sched: Remove temporary cputime_t accessors Frederic Weisbecker
2017-02-01 10:00   ` [tip:sched/core] sched/cputime: " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 22/36] cputime: Push time to account_user_time() in nsecs Frederic Weisbecker
2017-02-01 10:00   ` [tip:sched/core] sched/cputime: " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 23/36] cputime: Push time to account_steal_time() " Frederic Weisbecker
2017-02-01 10:01   ` [tip:sched/core] sched/cputime: " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 24/36] cputime: Push time to account_idle_time() " Frederic Weisbecker
2017-02-01 10:01   ` [tip:sched/core] sched/cputime: " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 25/36] cputime: Push time to account_system_time() " Frederic Weisbecker
2017-02-01 10:02   ` [tip:sched/core] sched/cputime: " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 26/36] cputime: Complete nsec conversion of tick based accounting Frederic Weisbecker
2017-02-01 10:02   ` [tip:sched/core] sched/cputime: " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 27/36] vtime: Return nsecs instead of cputime_t to account Frederic Weisbecker
2017-02-01 10:03   ` [tip:sched/core] sched/cputime, " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 28/36] cputime: Remove jiffies based cputime Frederic Weisbecker
2017-02-01 10:03   ` [tip:sched/core] sched/cputime: " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 29/36] ia64: Move nsecs based cputime headers to the last arch using it Frederic Weisbecker
2017-02-01 10:04   ` [tip:sched/core] ia64, sched/cputime: Move the " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 30/36] ia64: Convert vtime to use nsec units directly Frederic Weisbecker
2017-02-01 10:04   ` [tip:sched/core] " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 31/36] ia64: Remove unused cputime definitions Frederic Weisbecker
2017-02-01 10:05   ` [tip:sched/core] ia64, sched/cputime: " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 32/36] s390: Make arch_cpu_idle_time() to return nsecs Frederic Weisbecker
2017-02-01 10:05   ` [tip:sched/core] s390, sched/cputime: " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 33/36] powerpc: Remove unused cputime definitions Frederic Weisbecker
2017-02-01 10:06   ` [tip:sched/core] powerpc, sched/cputime: " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 34/36] s390: " Frederic Weisbecker
2017-02-01 10:06   ` [tip:sched/core] s390, sched/cputime: " tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 35/36] cputime: Remove unused nsec_to_cputime Frederic Weisbecker
2017-02-01 10:07   ` [tip:sched/core] sched/cputime: Remove unused nsec_to_cputime() tip-bot for Frederic Weisbecker
2017-01-31  3:09 ` [PATCH RESEND 36/36] cputime: Remove asm generic headers Frederic Weisbecker
2017-02-01 10:07   ` [tip:sched/core] sched/cputime: Remove generic asm headers tip-bot for Frederic Weisbecker
2017-02-06 13:49 ` [GIT PULL] cputime: Convert core use of cputime_t to nsecs Frederic Weisbecker
2017-02-07  8:08   ` Ingo Molnar
2017-02-07 14:06     ` Frederic Weisbecker
2017-02-07 18:41       ` Ingo Molnar
2017-02-21  5:08 ` hejianet
2017-02-22 14:30   ` Frederic Weisbecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1485832191-26889-12-git-send-email-fweisbec@gmail.com \
    --to=fweisbec@gmail.com \
    --cc=benh@kernel.crashing.org \
    --cc=fenghua.yu@intel.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    --cc=riel@redhat.com \
    --cc=schwidefsky@de.ibm.com \
    --cc=sgruszka@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=wanpeng.li@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).