

```C
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/sched/signal.h>
#include <linux/seq_file.h>
#include <linux/proc_fs.h>
#include <linux/moduleparam.h>
#include <linux/pid.h>
#include <linux/timekeeping.h>
#include <linux/sched/cputime.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Your Name");
MODULE_DESCRIPTION("Process time tracker module");

static int target_pid = 0;
module_param(target_pid, int, 0444);
MODULE_PARM_DESC(target_pid, "Target PID (0 = current)");

/* ================= 子孙进程时间递归统计 ================= */
static void calc_descendants_time(struct task_struct *task,
                                  u64 *utime_ns,
                                  u64 *stime_ns)
{
    struct task_struct *child;

    list_for_each_entry(child, &task->children, sibling) {

        u64 ut, st;

        /* 获取 CPU 时间（纳秒） */
        task_cputime_adjusted(child, &ut, &st);

        *utime_ns += ut;
        *stime_ns += st;

        calc_descendants_time(child, utime_ns, stime_ns);
    }
}

/* ================= proc 显示函数 ================= */
static int process_info_show(struct seq_file *m, void *v)
{
    struct task_struct *task;
    struct pid *pid_struct;

    u64 utime_ns = 0, stime_ns = 0;
    u64 desc_utime_ns = 0, desc_stime_ns = 0;

    u64 now_ns, start_ns, elapsed_ns;

    /* 获取当前时间（boottime，和 start_time 同基准） */
    now_ns = ktime_get_boottime_ns();

    /* ================= 找目标进程 ================= */
    if (target_pid <= 0) {
        task = current;
    } else {
        pid_struct = find_get_pid(target_pid);
        if (!pid_struct) {
            seq_printf(m, "PID %d not found\n", target_pid);
            return 0;
        }

        task = get_pid_task(pid_struct, PIDTYPE_PID);
        put_pid(pid_struct);

        if (!task) {
            seq_printf(m, "PID %d not found\n", target_pid);
            return 0;
        }
    }

    /* ================= 时间计算 ================= */

    start_ns = (u64)task->start_time;
    elapsed_ns = now_ns - start_ns;

    /* CPU 时间 */
    task_cputime_adjusted(task, &utime_ns, &stime_ns);

    /* ================= 输出 ================= */

    seq_printf(m, "===== Process Info =====\n");
    seq_printf(m, "PID: %d\n", task->pid);
    seq_printf(m, "Name: %s\n", task->comm);
    seq_printf(m, "Parent PID: %d\n", task->parent->pid);

    seq_printf(m, "\n===== Time Info =====\n");

    seq_printf(m, "Start time: %llu ns\n", start_ns);

    seq_printf(m, "Running time: %llu.%03llu sec\n",
               elapsed_ns / 1000000000ULL,
               (elapsed_ns % 1000000000ULL) / 1000000ULL);

    seq_printf(m, "\n-- CPU Time --\n");

    seq_printf(m, "User time: %llu.%03llu sec\n",
               utime_ns / 1000000000ULL,
               (utime_ns % 1000000000ULL) / 1000000ULL);

    seq_printf(m, "Kernel time: %llu.%03llu sec\n",
               stime_ns / 1000000000ULL,
               (stime_ns % 1000000000ULL) / 1000000ULL);

    /* ================= 子进程 ================= */

    seq_printf(m, "\n===== Descendants =====\n");

    rcu_read_lock();

    calc_descendants_time(task, &desc_utime_ns, &desc_stime_ns);

    rcu_read_unlock();

    seq_printf(m, "Total descendants user time: %llu.%03llu sec\n",
               desc_utime_ns / 1000000000ULL,
               (desc_utime_ns % 1000000000ULL) / 1000000ULL);

    seq_printf(m, "Total descendants kernel time: %llu.%03llu sec\n",
               desc_stime_ns / 1000000000ULL,
               (desc_stime_ns % 1000000000ULL) / 1000000ULL);

    /* 释放引用 */
    if (target_pid > 0 && task != current)
        put_task_struct(task);

    return 0;
}

/* ================= proc 接口 ================= */

static int process_info_open(struct inode *inode, struct file *file)
{
    return single_open(file, process_info_show, NULL);
}

static const struct proc_ops proc_fops = {
    .proc_open    = process_info_open,
    .proc_read    = seq_read,
    .proc_release = single_release,
};

/* ================= 模块初始化 ================= */

static int __init process_info_init(void)
{
    if (!proc_create("process_info", 0444, NULL, &proc_fops)) {
        pr_err("Failed to create /proc/process_info\n");
        return -ENOMEM;
    }

    pr_info("process_info loaded\n");
    return 0;
}

/* ================= 模块卸载 ================= */

static void __exit process_info_exit(void)
{
    remove_proc_entry("process_info", NULL);
    pr_info("process_info unloaded\n");
}

module_init(process_info_init);
module_exit(process_info_exit);
```

