Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1331624 > unrolled thread
| Started by | riel@redhat.com |
|---|---|
| First post | 2016-02-11 02:10 +0100 |
| Last post | 2016-02-11 02:30 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 2/4] acct,time: change indentation in __acct_update_integrals riel@redhat.com - 2016-02-11 02:10 +0100
Re: [PATCH 2/4] acct,time: change indentation in __acct_update_integrals Joe Perches <joe@perches.com> - 2016-02-11 02:30 +0100
| From | riel@redhat.com |
|---|---|
| Date | 2016-02-11 02:10 +0100 |
| Subject | [PATCH 2/4] acct,time: change indentation in __acct_update_integrals |
| Message-ID | <r0NVE-1Am-3@gated-at.bofh.it> |
From: Rik van Riel <riel@redhat.com>
Change the indentation in __acct_update_integrals to make the function
a little easier to read.
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Rik van Riel <riel@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@redhat.com>
---
kernel/tsacct.c | 51 ++++++++++++++++++++++++++-------------------------
1 file changed, 26 insertions(+), 25 deletions(-)
diff --git a/kernel/tsacct.c b/kernel/tsacct.c
index 460ee2bbfef3..d12e815b7bcd 100644
--- a/kernel/tsacct.c
+++ b/kernel/tsacct.c
@@ -125,31 +125,32 @@ void xacct_add_tsk(struct taskstats *stats, struct task_struct *p)
static void __acct_update_integrals(struct task_struct *tsk,
cputime_t utime, cputime_t stime)
{
- if (likely(tsk->mm)) {
- cputime_t time, dtime;
- unsigned long flags;
- u64 delta;
-
- local_irq_save(flags);
- time = stime + utime;
- dtime = time - tsk->acct_timexpd;
- /* Avoid division: cputime_t is often in nanoseconds already. */
- delta = cputime_to_nsecs(dtime);
-
- if (delta < TICK_NSEC)
- goto out;
-
- tsk->acct_timexpd = time;
- /*
- * Divide by 1024 to avoid overflow, and to avoid division.
- * The final unit reported to userspace is Mbyte-usecs,
- * the rest of the math is done in xacct_add_tsk.
- */
- tsk->acct_rss_mem1 += delta * get_mm_rss(tsk->mm) >> 10;
- tsk->acct_vm_mem1 += delta * tsk->mm->total_vm >> 10;
- out:
- local_irq_restore(flags);
- }
+ cputime_t time, dtime;
+ unsigned long flags;
+ u64 delta;
+
+ if (!likely(tsk->mm))
+ return;
+
+ local_irq_save(flags);
+ time = stime + utime;
+ dtime = time - tsk->acct_timexpd;
+ /* Avoid division: cputime_t is often in nanoseconds already. */
+ delta = cputime_to_nsecs(dtime);
+
+ if (delta < TICK_NSEC)
+ goto out;
+
+ tsk->acct_timexpd = time;
+ /*
+ * Divide by 1024 to avoid overflow, and to avoid division.
+ * The final unit reported to userspace is Mbyte-usecs,
+ * the rest of the math is done in xacct_add_tsk.
+ */
+ tsk->acct_rss_mem1 += delta * get_mm_rss(tsk->mm) >> 10;
+ tsk->acct_vm_mem1 += delta * tsk->mm->total_vm >> 10;
+out:
+ local_irq_restore(flags);
}
/**
--
2.5.0
[toc] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2016-02-11 02:30 +0100 |
| Subject | Re: [PATCH 2/4] acct,time: change indentation in __acct_update_integrals |
| Message-ID | <r0Of0-1Jz-9@gated-at.bofh.it> |
| In reply to | #1331624 |
On Wed, 2016-02-10 at 20:08 -0500, riel@redhat.com wrote: > Change the indentation in __acct_update_integrals to make the function > a little easier to read. trivia: > diff --git a/kernel/tsacct.c b/kernel/tsacct.c [] > @@ -125,31 +125,32 @@ void xacct_add_tsk(struct taskstats *stats, struct task_struct *p) [] > + if (!likely(tsk->mm)) > + return; Using if (unlikely(!tsk->mm)) return; would be a lot more common. (~150:1 in the kernel sources)
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web