From: Magnus Lindholm <linmag7@gmail.com>
To: richard.henderson@linaro.org, mattst88@gmail.com,
linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org
Cc: linmag7@gmail.com
Subject: [PATCH 13/14] alpha: use generic getrusage for OSF resource accounting
Date: Tue, 3 Nov 2026 22:35:19 +0100 [thread overview]
Message-ID: <20261103214120.1099893-14-linmag7@gmail.com> (raw)
In-Reply-To: <20261103214120.1099893-1-linmag7@gmail.com>
Use getrusage() for OSF resource accounting. This intentionally aligns
osf_getrusage() accounting with getrusage(2): RUSAGE_SELF covers the whole
thread group rather than only the calling thread, and ru_maxrss, block
I/O and context-switch counts are populated instead of remaining zero.
CPU times use the generic microsecond conversion instead of the previous
jiffy rounding.
Keep the OSF structure layout and the existing RUSAGE_SELF/RUSAGE_CHILDREN
selector restriction. Share result conversion with osf_wait4() and remove
the jiffy-based time conversion.
Signed-off-by: Magnus Lindholm <linmag7@gmail.com>
---
arch/alpha/kernel/osf_sys.c | 56 ++++++++++++++-------------------------------
1 file changed, 17 insertions(+), 39 deletions(-)
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index 61d8061762133f5e128d8538cf104dfede57ea6d..c08796f627332e4562a30557dee700052d03c0e7 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -15,7 +15,7 @@
#include <linux/sched/signal.h>
#include <linux/sched/mm.h>
#include <linux/sched/task_stack.h>
-#include <linux/sched/cputime.h>
+#include <linux/resource.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/smp.h>
@@ -960,13 +960,6 @@ put_tv_to_tv32(struct timeval32 __user *o, struct __kernel_old_timeval *i)
sizeof(struct timeval32));
}
-static inline void
-jiffies_to_timeval32(unsigned long jiffies, struct timeval32 *value)
-{
- value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
- value->tv_sec = jiffies / HZ;
-}
-
SYSCALL_DEFINE2(osf_gettimeofday, struct timeval32 __user *, tv,
struct timezone __user *, tz)
{
@@ -1062,37 +1055,27 @@ struct rusage32 {
long ru_nivcsw; /* involuntary " */
};
+static int put_rusage32(struct rusage32 __user *ru, struct rusage *r)
+{
+ if (put_tv_to_tv32(&ru->ru_utime, &r->ru_utime))
+ return -EFAULT;
+ if (put_tv_to_tv32(&ru->ru_stime, &r->ru_stime))
+ return -EFAULT;
+ if (copy_to_user(&ru->ru_maxrss, &r->ru_maxrss,
+ sizeof(*ru) - offsetof(struct rusage32, ru_maxrss)))
+ return -EFAULT;
+ return 0;
+}
+
SYSCALL_DEFINE2(osf_getrusage, int, who, struct rusage32 __user *, ru)
{
- struct rusage32 r;
- u64 utime, stime;
- unsigned long utime_jiffies, stime_jiffies;
+ struct rusage r;
if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN)
return -EINVAL;
- memset(&r, 0, sizeof(r));
- switch (who) {
- case RUSAGE_SELF:
- task_cputime(current, &utime, &stime);
- utime_jiffies = nsecs_to_jiffies(utime);
- stime_jiffies = nsecs_to_jiffies(stime);
- jiffies_to_timeval32(utime_jiffies, &r.ru_utime);
- jiffies_to_timeval32(stime_jiffies, &r.ru_stime);
- r.ru_minflt = current->min_flt;
- r.ru_majflt = current->maj_flt;
- break;
- case RUSAGE_CHILDREN:
- utime_jiffies = nsecs_to_jiffies(current->signal->cutime);
- stime_jiffies = nsecs_to_jiffies(current->signal->cstime);
- jiffies_to_timeval32(utime_jiffies, &r.ru_utime);
- jiffies_to_timeval32(stime_jiffies, &r.ru_stime);
- r.ru_minflt = current->signal->cmin_flt;
- r.ru_majflt = current->signal->cmaj_flt;
- break;
- }
-
- return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0;
+ getrusage(current, who, &r);
+ return put_rusage32(ru, &r);
}
SYSCALL_DEFINE4(osf_wait4, pid_t, pid, int __user *, ustatus, int, options,
@@ -1104,12 +1087,7 @@ SYSCALL_DEFINE4(osf_wait4, pid_t, pid, int __user *, ustatus, int, options,
return err;
if (!ur)
return err;
- if (put_tv_to_tv32(&ur->ru_utime, &r.ru_utime))
- return -EFAULT;
- if (put_tv_to_tv32(&ur->ru_stime, &r.ru_stime))
- return -EFAULT;
- if (copy_to_user(&ur->ru_maxrss, &r.ru_maxrss,
- sizeof(struct rusage32) - offsetof(struct rusage32, ru_maxrss)))
+ if (put_rusage32(ur, &r))
return -EFAULT;
return err;
}
--
2.43.0
next prev parent reply other threads:[~2026-11-03 21:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 21:35 [PATCH 00/14] alpha: fix entry bugs and consolidate generic helpers Magnus Lindholm
2026-11-03 21:35 ` [PATCH 01/14] alpha: fix saved registers in page-fault oops dumps Magnus Lindholm
2026-11-03 21:35 ` [PATCH 02/14] alpha: report syscall errors correctly to audit Magnus Lindholm
2026-11-03 21:35 ` [PATCH 03/14] alpha: preserve rolled-back registers for SIGSYS Magnus Lindholm
2026-11-03 21:35 ` [PATCH 04/14] alpha: fix syscall restart eligibility Magnus Lindholm
2026-11-03 21:35 ` [PATCH 05/14] alpha: distinguish skipped syscalls from invalid numbers Magnus Lindholm
2026-11-03 21:35 ` [PATCH 06/14] alpha: dispatch system calls from C Magnus Lindholm
2026-11-03 21:35 ` [PATCH 07/14] alpha: use generic entry helpers for interrupts and exceptions Magnus Lindholm
2026-11-03 21:35 ` [PATCH 08/14] alpha: use generic syscall exit for new tasks Magnus Lindholm
2026-11-03 21:35 ` [PATCH 09/14] alpha: remove obsolete core dump register hooks Magnus Lindholm
2026-11-03 21:35 ` [PATCH 10/14] alpha: use generic syscall audit classification Magnus Lindholm
2026-11-03 21:35 ` [PATCH 11/14] alpha: use generic ptrace memory writes Magnus Lindholm
2026-11-03 21:35 ` [PATCH 12/14] alpha: use memparse for memory size options Magnus Lindholm
2026-11-03 21:35 ` Magnus Lindholm [this message]
2026-11-03 21:35 ` [PATCH 14/14] alpha: use generic CPU device registration Magnus Lindholm
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=20261103214120.1099893-14-linmag7@gmail.com \
--to=linmag7@gmail.com \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mattst88@gmail.com \
--cc=richard.henderson@linaro.org \
/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
all inboxes | Powered by JetHome®