Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6557292rwb; Mon, 5 Dec 2022 14:14:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf6j6jEArdQVpL69OArfpEdAb0wKUvE66Mj+dKy0+n3LAsAA5Kf7QHR9zvtzfJK7B3DQWOjE X-Received: by 2002:a17:902:e807:b0:186:fb90:5774 with SMTP id u7-20020a170902e80700b00186fb905774mr67583011plg.137.1670278442072; Mon, 05 Dec 2022 14:14:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670278442; cv=none; d=google.com; s=arc-20160816; b=sSOa/cWQIhNxuf1gIQgB9OUSI8xNAduMRxYN9a0HlQRYuuNxfT5RXhRFIj3/+dflHd NI73Q68ore3otRGKTy3ktggWypI4VzM9A330EUbP1T2s+Z509T8c5QJHKD5ZuoGdSFlz gBtcfIBJQHZl/y0wlIN/KVFi4gXcwTVSOne7ICMMAkc3A21Jgu0DrvhhaFRrgXVbyNWw 3rec/GFgVtnw/ed3sGjgINkXDK8bSj9UuIBdC+xrpqfkGg/demZ3X1XHh70uW6679691 NNboqc+LYPjM5rGMKe+qEkrEmxjPf9rse2HIpcap4c0j84ifcTd7tgX4/0FAC2zt8qRC Ksmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=LhRP0dKNdzz4vY4YqJwY0FRiDKhUxOO8wi0VxR08aWc=; b=HpHPxsP7xJxr/Lo9sA4pgf1b/s1hdvzvI5ybOGcgd0D54REp3EbuaPKagL/3KexSsk YVKYYtU1K0+C+4V7x6rga3HKbxQTOE/H4/5JWyIG2kccGPZ03SlbqL0jkZZM72B34RlA UbYkE372K8LmvvNENWqr9WugcxYSznOJ1aBSrw8iph4C0epSC5+9TcaT7nAvKQGMuqFk yFQa0GHajrq+Z0e84krPyeiSP8CC8KZMNHzacdQiVJV1UvmK7Acy0LbmspxYjRqimX0J MTcWLiDg50W1GtryxjOnpyR0SIcE2eRZDpdnyRDH1XsZuFRYpmwfpyXvXmK0yhxtknr6 f9Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=iauDUWXr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s3-20020a632143000000b00476c718a6b4si15885208pgm.453.2022.12.05.14.13.51; Mon, 05 Dec 2022 14:14:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=iauDUWXr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232720AbiLEVRZ (ORCPT + 80 others); Mon, 5 Dec 2022 16:17:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232544AbiLEVRX (ORCPT ); Mon, 5 Dec 2022 16:17:23 -0500 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C6962BB23; Mon, 5 Dec 2022 13:17:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1670275040; bh=E/xyV8U24nd/vaCi3wVkaU0Zn3uE8TKj3J2Nc9PgcbM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=iauDUWXrswxfHQrnQ5qZYI4tGiGslhFi2w1MfbWpptVSabM0BP7fziQ2UFn0XNUhE evcIdVaeSlAc2e9uFel2y9km93GmSrRSde3gMnXVYRilxovMrOC3WJkwYx5gihNpOY b9EyFnawIIz4VhPYTecc/n6G0iQGAKT1e7/tnX9IqP78OqFI/cQr+9ljIk5CnmsUIK Ej904knfN0L0CdAT/t3uobYnDBZkfaz1VQueeSgnpP9vB+bIFdohFOG5IROUSe7itq EqkWFSxn4QLSGmU1JPgRUPtzje4Dp3nB81GMnRx5tzM9tm5RLs8kklGsaQ542KAZba Tui3jYo45aKUg== Received: from [172.16.0.118] (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4NQxFr2ySJzZ7j; Mon, 5 Dec 2022 16:17:20 -0500 (EST) Message-ID: Date: Mon, 5 Dec 2022 16:17:38 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH v5 02/11] tracing/user_events: Track fork/exec/exit for mm lifetime Content-Language: en-US To: Beau Belgrave , rostedt@goodmis.org, mhiramat@kernel.org, dcook@linux.microsoft.com, alanau@linux.microsoft.com, brauner@kernel.org, akpm@linux-foundation.org Cc: linux-trace-devel@vger.kernel.org, linux-kernel@vger.kernel.org References: <20221205210017.23440-1-beaub@linux.microsoft.com> <20221205210017.23440-3-beaub@linux.microsoft.com> From: Mathieu Desnoyers In-Reply-To: <20221205210017.23440-3-beaub@linux.microsoft.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-12-05 16:00, Beau Belgrave wrote: > During tracefs discussions it was decided instead of requiring a mapping > within a user-process to track the lifetime of memory descriptors we > should hook the appropriate calls. Do this by adding the minimal stubs > required for task fork, exec, and exit. Currently this is just a NOP. > Future patches will implement these calls fully. Reviewed-by: Mathieu Desnoyers > > Suggested-by: Mathieu Desnoyers > Signed-off-by: Beau Belgrave > --- > fs/exec.c | 2 ++ > include/linux/sched.h | 5 +++++ > include/linux/user_events.h | 16 +++++++++++++++- > kernel/exit.c | 2 ++ > kernel/fork.c | 2 ++ > 5 files changed, 26 insertions(+), 1 deletion(-) > > diff --git a/fs/exec.c b/fs/exec.c > index a0b1f0337a62..75ca6fbd195c 100644 > --- a/fs/exec.c > +++ b/fs/exec.c > @@ -64,6 +64,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -1842,6 +1843,7 @@ static int bprm_execve(struct linux_binprm *bprm, > current->fs->in_exec = 0; > current->in_execve = 0; > rseq_execve(current); > + user_events_execve(current); > acct_update_integrals(current); > task_numa_free(current, false); > return retval; > diff --git a/include/linux/sched.h b/include/linux/sched.h > index ffb6eb55cd13..61ed2f9deb26 100644 > --- a/include/linux/sched.h > +++ b/include/linux/sched.h > @@ -69,6 +69,7 @@ struct sighand_struct; > struct signal_struct; > struct task_delay_info; > struct task_group; > +struct user_event_mm; > > /* > * Task state bitmask. NOTE! These bits are also > @@ -1528,6 +1529,10 @@ struct task_struct { > union rv_task_monitor rv[RV_PER_TASK_MONITORS]; > #endif > > +#ifdef CONFIG_USER_EVENTS > + struct user_event_mm *user_event_mm; > +#endif > + > /* > * New fields for task_struct should be added above here, so that > * they are included in the randomized portion of task_struct. > diff --git a/include/linux/user_events.h b/include/linux/user_events.h > index 036b360f3d97..3d747c45d2fa 100644 > --- a/include/linux/user_events.h > +++ b/include/linux/user_events.h > @@ -12,7 +12,21 @@ > #include > > #ifdef CONFIG_USER_EVENTS > -#else > +struct user_event_mm { > +}; > #endif > > +static inline void user_events_fork(struct task_struct *t, > + unsigned long clone_flags) > +{ > +} > + > +static inline void user_events_execve(struct task_struct *t) > +{ > +} > + > +static inline void user_events_exit(struct task_struct *t) > +{ > +} > + > #endif /* _LINUX_USER_EVENTS_H */ > diff --git a/kernel/exit.c b/kernel/exit.c > index 35e0a31a0315..0bfadc26d278 100644 > --- a/kernel/exit.c > +++ b/kernel/exit.c > @@ -67,6 +67,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -769,6 +770,7 @@ void __noreturn do_exit(long code) > > coredump_task_exit(tsk); > ptrace_event(PTRACE_EVENT_EXIT, code); > + user_events_exit(tsk); > > validate_creds_for_do_exit(tsk); > > diff --git a/kernel/fork.c b/kernel/fork.c > index 08969f5aa38d..a4be76276ccb 100644 > --- a/kernel/fork.c > +++ b/kernel/fork.c > @@ -97,6 +97,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -2487,6 +2488,7 @@ static __latent_entropy struct task_struct *copy_process( > > trace_task_newtask(p, clone_flags); > uprobe_copy_process(p, clone_flags); > + user_events_fork(p, clone_flags); > > copy_oom_score_adj(clone_flags, p); > -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com