hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/kernel/acct.c
....@@ -25,7 +25,7 @@
2525 * Now we silently close acct_file on attempt to reopen. Cleaned sys_acct().
2626 * XTerms and EMACS are manifestations of pure evil. 21/10/98, AV.
2727 *
28
- * Fixed a nasty interaction with with sys_umount(). If the accointing
28
+ * Fixed a nasty interaction with sys_umount(). If the accounting
2929 * was suspeneded we failed to stop it on umount(). Messy.
3030 * Another one: remount to readonly didn't stop accounting.
3131 * Question: what should we do if we have CAP_SYS_ADMIN but not
....@@ -40,7 +40,7 @@
4040 * is one more bug... 10/11/98, AV.
4141 *
4242 * Oh, fsck... Oopsable SMP race in do_process_acct() - we must hold
43
- * ->mmap_sem to walk the vma list of current->mm. Nasty, since it leaks
43
+ * ->mmap_lock to walk the vma list of current->mm. Nasty, since it leaks
4444 * a struct file opened for write. Fixed. 2/6/2000, AV.
4545 */
4646
....@@ -263,12 +263,12 @@
263263 * sys_acct - enable/disable process accounting
264264 * @name: file name for accounting records or NULL to shutdown accounting
265265 *
266
- * Returns 0 for success or negative errno values for failure.
267
- *
268266 * sys_acct() is the only system call needed to implement process
269267 * accounting. It takes the name of the file where accounting records
270268 * should be written. If the filename is NULL, accounting will be
271269 * shutdown.
270
+ *
271
+ * Returns: 0 for success or negative errno values for failure.
272272 */
273273 SYSCALL_DEFINE1(acct, const char __user *, name)
274274 {
....@@ -416,6 +416,7 @@
416416 {
417417 struct pacct_struct *pacct = &current->signal->pacct;
418418 u64 elapsed, run_time;
419
+ time64_t btime;
419420 struct tty_struct *tty;
420421
421422 /*
....@@ -448,7 +449,8 @@
448449 }
449450 #endif
450451 do_div(elapsed, AHZ);
451
- ac->ac_btime = get_seconds() - elapsed;
452
+ btime = ktime_get_real_seconds() - elapsed;
453
+ ac->ac_btime = clamp_t(time64_t, btime, 0, U32_MAX);
452454 #if ACCT_VERSION==2
453455 ac->ac_ahz = AHZ;
454456 #endif
....@@ -539,13 +541,13 @@
539541 if (group_dead && current->mm) {
540542 struct vm_area_struct *vma;
541543
542
- down_read(&current->mm->mmap_sem);
544
+ mmap_read_lock(current->mm);
543545 vma = current->mm->mmap;
544546 while (vma) {
545547 vsize += vma->vm_end - vma->vm_start;
546548 vma = vma->vm_next;
547549 }
548
- up_read(&current->mm->mmap_sem);
550
+ mmap_read_unlock(current->mm);
549551 }
550552
551553 spin_lock_irq(&current->sighand->siglock);
....@@ -584,9 +586,7 @@
584586 }
585587
586588 /**
587
- * acct_process
588
- *
589
- * handles process accounting for an exiting task
589
+ * acct_process - handles process accounting for an exiting task
590590 */
591591 void acct_process(void)
592592 {