mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bradley Morgan <brads@mainlining.org>
To: Balbir Singh <balbirs@nvidia.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	Bradley Morgan <brads@mainlining.org>
Subject: [PATCH 4/4] taskstats: use div_u64() for the elapsed time in tgid_stats_add_task()
Date: Sun,  1 Nov 2026 00:57:43 +0000	[thread overview]
Message-ID: <20261101005743.3022780-4-brads@mainlining.org> (raw)
In-Reply-To: <20261101005743.3022780-1-brads@mainlining.org>

tgid_stats_add_task() converts utime and stime with div_u64() and the
elapsed time with do_div(), two ways of doing the same 64-bit divide four
lines apart.  do_div() clobbers its first argument, which is the only
reason delta needs a statement of its own.  Both end up at a native
divide on 64-bit and at __div64_32() on 32-bit, so this is only about
picking one.

Signed-off-by: Bradley Morgan <brads@mainlining.org>
---
 kernel/taskstats.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index 9e11f92216861..2d4ecb9a89a91 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -226,8 +226,7 @@ static void tgid_stats_add_task(struct taskstats *stats,
 	/* calculate task elapsed time in nsec */
 	delta = now_ns - tsk->start_time;
 	/* Convert to micro seconds */
-	do_div(delta, NSEC_PER_USEC);
-	stats->ac_etime += delta;
+	stats->ac_etime += div_u64(delta, NSEC_PER_USEC);
 
 	task_cputime(tsk, &utime, &stime);
 	stats->ac_utime += div_u64(utime, NSEC_PER_USEC);
-- 
2.53.0

      parent reply	other threads:[~2026-11-01  0:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-01  0:56 [PATCH 0/4] taskstats: four more tidy-ups in the genl path Bradley Morgan
2026-11-01  0:57 ` [PATCH 1/4] taskstats: use nla_put_u32() in mk_reply() Bradley Morgan
2026-11-01  0:57   ` [PATCH 2/4] taskstats: take the inode once in exe_add_tsk() Bradley Morgan
2026-11-01  0:57   ` [PATCH 3/4] taskstats: reuse na in cgroupstats_user_cmd() Bradley Morgan
2026-11-01  0:57   ` Bradley Morgan [this message]

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=20261101005743.3022780-4-brads@mainlining.org \
    --to=brads@mainlining.org \
    --cc=akpm@linux-foundation.org \
    --cc=balbirs@nvidia.com \
    --cc=linux-kernel@vger.kernel.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®