.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * tsacct.c - System accounting over taskstats interface |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) Jay Lan, <jlan@sgi.com> |
---|
5 | | - * |
---|
6 | | - * |
---|
7 | | - * This program is free software; you can redistribute it and/or modify |
---|
8 | | - * it under the terms of the GNU General Public License as published by |
---|
9 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
10 | | - * (at your option) any later version. |
---|
11 | | - * |
---|
12 | | - * This program is distributed in the hope that it will be useful, |
---|
13 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | | - * GNU General Public License for more details. |
---|
16 | | - * |
---|
17 | 6 | */ |
---|
18 | 7 | |
---|
19 | 8 | #include <linux/kernel.h> |
---|
.. | .. |
---|
35 | 24 | const struct cred *tcred; |
---|
36 | 25 | u64 utime, stime, utimescaled, stimescaled; |
---|
37 | 26 | u64 delta; |
---|
| 27 | + time64_t btime; |
---|
38 | 28 | |
---|
39 | 29 | BUILD_BUG_ON(TS_COMM_LEN < TASK_COMM_LEN); |
---|
40 | 30 | |
---|
.. | .. |
---|
43 | 33 | /* Convert to micro seconds */ |
---|
44 | 34 | do_div(delta, NSEC_PER_USEC); |
---|
45 | 35 | stats->ac_etime = delta; |
---|
46 | | - /* Convert to seconds for btime */ |
---|
47 | | - do_div(delta, USEC_PER_SEC); |
---|
48 | | - stats->ac_btime = get_seconds() - delta; |
---|
| 36 | + /* Convert to seconds for btime (note y2106 limit) */ |
---|
| 37 | + btime = ktime_get_real_seconds() - div_u64(delta, USEC_PER_SEC); |
---|
| 38 | + stats->ac_btime = clamp_t(time64_t, btime, 0, U32_MAX); |
---|
| 39 | + stats->ac_btime64 = btime; |
---|
| 40 | + |
---|
49 | 41 | if (tsk->flags & PF_EXITING) |
---|
50 | 42 | stats->ac_exitcode = tsk->exit_code; |
---|
51 | 43 | if (thread_group_leader(tsk) && (tsk->flags & PF_FORKNOEXEC)) |
---|