Skip to content

Commit

Permalink
fs/binfmt: Convert obsolete cputime type to nsecs
Browse files Browse the repository at this point in the history
Use the new nsec based cputime accessors as part of the whole cputime
conversion from cputime_t to nsecs.

Signed-off-by: Frederic Weisbecker <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Fenghua Yu <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Martin Schwidefsky <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Rik van Riel <[email protected]>
Cc: Stanislaw Gruszka <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: Wanpeng Li <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
fweisbec authored and Ingo Molnar committed Feb 1, 2017
1 parent c0e7a50 commit cd19c36
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 70 deletions.
12 changes: 2 additions & 10 deletions arch/mips/kernel/binfmt_elfn32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
12 changes: 2 additions & 10 deletions arch/mips/kernel/binfmt_elfo32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
11 changes: 2 additions & 9 deletions arch/parisc/kernel/binfmt_elf32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
26 changes: 10 additions & 16 deletions fs/binfmt_elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions fs/binfmt_elf_fdpic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 2 additions & 16 deletions fs/compat_binfmt_elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 19 additions & 1 deletion include/linux/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down

0 comments on commit cd19c36

Please sign in to comment.