From patchwork Sat Dec 4 09:52:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12656427 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBC22C433F5 for ; Sat, 4 Dec 2021 09:53:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 103906B0080; Sat, 4 Dec 2021 04:53:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B31B6B0081; Sat, 4 Dec 2021 04:53:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E95116B0082; Sat, 4 Dec 2021 04:53:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0213.hostedemail.com [216.40.44.213]) by kanga.kvack.org (Postfix) with ESMTP id DB9906B0080 for ; Sat, 4 Dec 2021 04:53:19 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 8BC911828C636 for ; Sat, 4 Dec 2021 09:53:09 +0000 (UTC) X-FDA: 78879648498.19.105E6D8 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by imf17.hostedemail.com (Postfix) with ESMTP id 11D28F000090 for ; Sat, 4 Dec 2021 09:53:08 +0000 (UTC) Received: by mail-pj1-f49.google.com with SMTP id j5-20020a17090a318500b001a6c749e697so6617205pjb.1 for ; Sat, 04 Dec 2021 01:53:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GW6b3sF6GwXHhqR55kptdOe2KtH0uXmQ535WwxRDhsU=; b=eX8Wa48ra4eTAbUzCOJnNU1tZ8LQ+5YwkjMF4cC9JNp6JnMctLCfNTRZ7InZ0I+Qgw FVfECKW4F52lrzjt3vh137DZkIUoY7hB47gSfr/K9H2QoqO7465U7lEdZiIizj/JYnFk bRoRZO41cYRH7VnyoUgkvvtsKAQWU5ZI23WV9EZiRrldtZERlW98OTwXF+tHGZgWjmMX VZ8ZbEgTX590IeapTCgsueZoPBhgDl+0oMTt7QfPhE5JvJ06Zi4kfRFyaSkQQ/Ajklu3 uz1hArULEkefVEcgnMPS3o8gHsHiWGlBc4of8r6zd0yOpf6s9sWt4D2fMJk6/PdQTdMu e0yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GW6b3sF6GwXHhqR55kptdOe2KtH0uXmQ535WwxRDhsU=; b=AEtydIwyhvn/fe+l663SjdO2DMY/pVLHN6dW0Q9YpTI9DfwahbrKwSX7EPU/MF05ez pUmFXAWl4cnigP3z7FW1pyCS4gXAUqTk5HlDZ+v3nKWjM48ZrcZRq6gqjrlXB+OLBV4u a5nbUafaV3b0X49xeLj+bi3+1U2Kn7GZQnWPrDxucx3lwWnxj9p7b1YchBnA9WjMpS/t xLMRQGu3Ba0stz/4OaWKlDOzZhmnlo5YAvd2Mn56UggLrWZemP/ZQGt43t4RyYClhHrB HxwH2XiYU2B13M5+5EpihFAA6G8/pEqSBWAR7qVcfmTvXuJcgydFu7qgKbxfouDlDc4I V5lA== X-Gm-Message-State: AOAM532JxpvxWjiJLAyjw7V0di0toH1qvZ3znBgTCebenfAnKv3O0WKZ VQsbIC0ePnd4c328xz18OjY= X-Google-Smtp-Source: ABdhPJw12fabYSRxUnXmqlFx9H8BClcqkjFEXyD2Xgc+LCeTuaPuNjEU+nngQzdL92YKIn8kJzo0XA== X-Received: by 2002:a17:903:18d:b0:142:8ab:d11f with SMTP id z13-20020a170903018d00b0014208abd11fmr29233302plg.47.1638611588164; Sat, 04 Dec 2021 01:53:08 -0800 (PST) Received: from vultr.guest ([45.76.74.237]) by smtp.gmail.com with ESMTPSA id ms15sm4343198pjb.26.2021.12.04.01.53.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Dec 2021 01:53:07 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org, rostedt@goodmis.org, keescook@chromium.org, pmladek@suse.com, david@redhat.com, arnaldo.melo@gmail.com, andrii.nakryiko@gmail.com Cc: linux-mm@kvack.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Yafang Shao , Mathieu Desnoyers , Alexei Starovoitov , Michal Miroslaw , Peter Zijlstra , Matthew Wilcox , Al Viro Subject: [PATCH -mm 1/5] elfcore: replace old hard-code 16 with TASK_COMM_LEN_16 Date: Sat, 4 Dec 2021 09:52:52 +0000 Message-Id: <20211204095256.78042-2-laoar.shao@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211204095256.78042-1-laoar.shao@gmail.com> References: <20211204095256.78042-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 11D28F000090 X-Stat-Signature: yoyy6g1y4juqz9jibar6rp7xbkc3tfjd Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=eX8Wa48r; spf=pass (imf17.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.216.49 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1638611588-961534 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: A new macro TASK_COMM_LEN_16 is introduced for the old hard-coded 16 to make it more grepable. As explained above this marco, the difference between TASK_COMM_LEN and TASK_COMM_LEN_16 is that TASK_COMM_LEN_16 must be a fixed size 16 and can't be changed. Signed-off-by: Yafang Shao Cc: Mathieu Desnoyers Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: Andrii Nakryiko Cc: Michal Miroslaw Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Matthew Wilcox Cc: David Hildenbrand Cc: Al Viro Cc: Kees Cook Cc: Petr Mladek --- include/linux/elfcore-compat.h | 8 ++------ include/linux/elfcore.h | 9 ++------- include/linux/sched.h | 5 +++++ 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/include/linux/elfcore-compat.h b/include/linux/elfcore-compat.h index 54feb64e9b5d..69fa1a728964 100644 --- a/include/linux/elfcore-compat.h +++ b/include/linux/elfcore-compat.h @@ -5,6 +5,7 @@ #include #include #include +#include /* * Make sure these layouts match the linux/elfcore.h native definitions. @@ -43,12 +44,7 @@ struct compat_elf_prpsinfo __compat_uid_t pr_uid; __compat_gid_t pr_gid; compat_pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid; - /* - * The hard-coded 16 is derived from TASK_COMM_LEN, but it can't be - * changed as it is exposed to userspace. We'd better make it hard-coded - * here. - */ - char pr_fname[16]; + char pr_fname[TASK_COMM_LEN_16]; char pr_psargs[ELF_PRARGSZ]; }; diff --git a/include/linux/elfcore.h b/include/linux/elfcore.h index 746e081879a5..d3bb4bd3c985 100644 --- a/include/linux/elfcore.h +++ b/include/linux/elfcore.h @@ -65,13 +65,8 @@ struct elf_prpsinfo __kernel_gid_t pr_gid; pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid; /* Lots missing */ - /* - * The hard-coded 16 is derived from TASK_COMM_LEN, but it can't be - * changed as it is exposed to userspace. We'd better make it hard-coded - * here. - */ - char pr_fname[16]; /* filename of executable */ - char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */ + char pr_fname[TASK_COMM_LEN_16]; /* filename of executable */ + char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */ }; static inline void elf_core_copy_regs(elf_gregset_t *elfregs, struct pt_regs *regs) diff --git a/include/linux/sched.h b/include/linux/sched.h index c79bd7ee6029..8d963a50a2a8 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -279,6 +279,11 @@ struct task_group; * BPF programs. */ enum { + /* + * For the old hard-coded 16, which is exposed to userspace and can't + * be changed. + */ + TASK_COMM_LEN_16 = 16, TASK_COMM_LEN = 16, }; From patchwork Sat Dec 4 09:52:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12656429 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E8BAC433F5 for ; Sat, 4 Dec 2021 09:54:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4853E6B0081; Sat, 4 Dec 2021 04:53:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 434A06B0082; Sat, 4 Dec 2021 04:53:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2D5C26B0083; Sat, 4 Dec 2021 04:53:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0056.hostedemail.com [216.40.44.56]) by kanga.kvack.org (Postfix) with ESMTP id 214276B0081 for ; Sat, 4 Dec 2021 04:53:21 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id E25B018404103 for ; Sat, 4 Dec 2021 09:53:10 +0000 (UTC) X-FDA: 78879648540.19.68777DA Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by imf02.hostedemail.com (Postfix) with ESMTP id 7E17280006 for ; Sat, 4 Dec 2021 09:53:10 +0000 (UTC) Received: by mail-pl1-f176.google.com with SMTP id z6so3781689plk.6 for ; Sat, 04 Dec 2021 01:53:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=y/3OH0dv1UtiAFVROi6oJBNv875tsxlRHeEufUcGAE8=; b=SarWfOANlxY+W1wqzZLUdID9Fc3MKFpV03tydsm+v0n8XUl+dcwUDrvIiMoajZcN/8 VygHDL+xUCD/1rvmo4SnyP2WVPTJltzUxeDFRhWIJHSlIvbTENzg7A49yvMRspqt5kk8 GWVUqC9U/qbUiBA4LeT7O45VG2yDScE5EQzmMgDgJMB5jqBMFmaal7UuUJ8u5dmPdTGJ 83XteKkH/SE6b6jtPaiEtlYD5dVEae4/oo0qaR3E0V++A3XlLVER+QRX6/53iexk+IaZ enzhxKb+F6Nw1Uik2BMvUPFslykGrZv3WzczdX1dvZ252t/S6+BIi0RphSKjA3DDhb8S sXlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=y/3OH0dv1UtiAFVROi6oJBNv875tsxlRHeEufUcGAE8=; b=S1y8G9npAw+AfNOTueWP/CI/ru4MydHcsERC2EeyvsBVC6JenBCcDS+wJc6DNCeMGm wvPA63Va1oU9EapbQxxeXURqdv8JFIan7qiFS+4rVVALFF/hD6FLOdTHquYVzcs3Qb2z LrW31vLIxL6cnpJiGy4ikuVzJJxMug8mIPRem6JM+WY9pn/r/cXMZxr8uBrl35rixNqv Nd5x0TBDArTJbOYlDOkVVrzczgEsaoQczTTbU1ME+mvbUEaoF07fBIeIxFQ4d8ygoyKB 1lzWKihNN2kAn3BjJQSrjpkjXnF2dEK7Dk5Uq9XwRWnQ4jGz66sdOv9mgBNl3LlYa7hT xrKA== X-Gm-Message-State: AOAM532Bjb2I1yi/taci6U+tebVcJ1hSk/tYXJFdopMWDSNxquKRCrvZ vUROp62mMKHe5/l5KU2kVHw= X-Google-Smtp-Source: ABdhPJyWUyZ8FNI0GA/R20IXskf5Z9SPmJGG1ragdsZ42JEvCLKUvt/9eoB/AkMYg6APTu6I88aWLA== X-Received: by 2002:a17:902:e806:b0:142:830:eaa4 with SMTP id u6-20020a170902e80600b001420830eaa4mr28670068plg.16.1638611589538; Sat, 04 Dec 2021 01:53:09 -0800 (PST) Received: from vultr.guest ([45.76.74.237]) by smtp.gmail.com with ESMTPSA id ms15sm4343198pjb.26.2021.12.04.01.53.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Dec 2021 01:53:09 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org, rostedt@goodmis.org, keescook@chromium.org, pmladek@suse.com, david@redhat.com, arnaldo.melo@gmail.com, andrii.nakryiko@gmail.com Cc: linux-mm@kvack.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Yafang Shao , Mathieu Desnoyers , Alexei Starovoitov , Michal Miroslaw , Peter Zijlstra , Matthew Wilcox , Al Viro Subject: [PATCH -mm 2/5] cn_proc: replaced old hard-coded 16 with TASK_COMM_LEN_16 Date: Sat, 4 Dec 2021 09:52:53 +0000 Message-Id: <20211204095256.78042-3-laoar.shao@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211204095256.78042-1-laoar.shao@gmail.com> References: <20211204095256.78042-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 7E17280006 X-Stat-Signature: 83w518jb5sachkqu44r63szxr4qd5rmh Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=SarWfOAN; spf=pass (imf02.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.214.176 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1638611590-670071 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This TASK_COMM_LEN_16 has the same meaning with the macro defined in linux/sched.h, but we can't include linux/sched.h in a UAPI header, so we should specifically define it in the cn_proc.h. Signed-off-by: Yafang Shao Cc: Mathieu Desnoyers Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: Andrii Nakryiko Cc: Michal Miroslaw Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Matthew Wilcox Cc: David Hildenbrand Cc: Al Viro Cc: Kees Cook Cc: Petr Mladek Acked-by: Steven Rostedt (VMware) --- include/uapi/linux/cn_proc.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/cn_proc.h b/include/uapi/linux/cn_proc.h index db210625cee8..6dcccaed383f 100644 --- a/include/uapi/linux/cn_proc.h +++ b/include/uapi/linux/cn_proc.h @@ -21,6 +21,8 @@ #include +#define TASK_COMM_LEN_16 16 + /* * Userspace sends this enum to register with the kernel that it is listening * for events on the connector. @@ -110,7 +112,7 @@ struct proc_event { struct comm_proc_event { __kernel_pid_t process_pid; __kernel_pid_t process_tgid; - char comm[16]; + char comm[TASK_COMM_LEN_16]; } comm; struct coredump_proc_event { From patchwork Sat Dec 4 09:52:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12656431 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB6F7C433F5 for ; Sat, 4 Dec 2021 09:54:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F7206B0082; Sat, 4 Dec 2021 04:53:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A6006B0083; Sat, 4 Dec 2021 04:53:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 56EDC6B0085; Sat, 4 Dec 2021 04:53:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0238.hostedemail.com [216.40.44.238]) by kanga.kvack.org (Postfix) with ESMTP id 48A516B0082 for ; Sat, 4 Dec 2021 04:53:22 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 00A5D89943 for ; Sat, 4 Dec 2021 09:53:12 +0000 (UTC) X-FDA: 78879648624.12.858921D Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf28.hostedemail.com (Postfix) with ESMTP id A2E39900009A for ; Sat, 4 Dec 2021 09:53:11 +0000 (UTC) Received: by mail-pl1-f171.google.com with SMTP id b11so3751112pld.12 for ; Sat, 04 Dec 2021 01:53:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7KNky9vHErqn9OL9wm+gliP7fCGte3KeREk90aKC+mg=; b=qsHK5Wp3DDnxrHGKr78oHp3IvG22FXMQ6WLWibND/E4BbWM4VRjvkAOOeDurq/WY2z fOAeQgN/6YWcrKHrMoT2GS3f/Mc7fS1YBcI7oD9q/GKw3m0e4Gr7c3s5n9lB2VkrNMed UtdMn06egm/MpTXviwqTxAIO6ehe3o5MT9YHEmmQK93GlVRGSN/qnBnuwpCcK3S2inJR sNVFHTPd4HdI4Szm8nxVoxpw6iVU0r3IcOYsT4R/5ZyjNtEvX64EtfZ9S8u1M/a9WdG0 7yz9zKW0X0SDPHB1FlCbkCy7K4rbSCIL3m6c7UPYgDAJtWjwtq1TMgbS7AcjwwbYPHSl mbpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7KNky9vHErqn9OL9wm+gliP7fCGte3KeREk90aKC+mg=; b=fmywEOIbJcXVBya719/G+umXHC519ScFLU1MYp58U3zHIkJ0u3EyaxNHB608jRmsI1 b0hGPQFFbFkRbH5Xo0ninpZbuiL2Gl6FgiYBgtWs9At14Cr1LrmPCLeBBNv9JphfGjsz goZ3c0FUvpkEnM8yAXBVAIxXeuFaRB0eikfDZh6dfbppnt/yDTsSCAAghZcbVkzJwpTZ ojWSuYm2ZyfRAMb9fKQvQBk+l57PIX7jEzy5NPCwVCdTjiFupVp+QlM6dn62TP/QYLJ+ DauleMwr8TDmrRJXskEUb6mJ108v41pvi4fNrH4j+y5dwevRL3eiruCGmUC4iHEgfxki RJeQ== X-Gm-Message-State: AOAM533vR56uag8lKvkWu1dRDtTGNSqjWJxxI+QQctBuZRl+BTMBih9h J92559AkabvylLhRXPj3bsY= X-Google-Smtp-Source: ABdhPJwqg6pKyGYMoMdlo2j7xJDfBIjTYhK1gMRW2j6TUtLmctuFv3TisafzMoi0MWS2K97dkPcYqQ== X-Received: by 2002:a17:902:bcc4:b0:141:bfc4:ada with SMTP id o4-20020a170902bcc400b00141bfc40adamr28918047pls.20.1638611590852; Sat, 04 Dec 2021 01:53:10 -0800 (PST) Received: from vultr.guest ([45.76.74.237]) by smtp.gmail.com with ESMTPSA id ms15sm4343198pjb.26.2021.12.04.01.53.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Dec 2021 01:53:10 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org, rostedt@goodmis.org, keescook@chromium.org, pmladek@suse.com, david@redhat.com, arnaldo.melo@gmail.com, andrii.nakryiko@gmail.com Cc: linux-mm@kvack.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Yafang Shao , Mathieu Desnoyers , Alexei Starovoitov , Michal Miroslaw , Peter Zijlstra , Matthew Wilcox , Al Viro Subject: [PATCH -mm 3/5] samples/bpf/tracex2: replace hard-coded 16 with TASK_COMM_LEN Date: Sat, 4 Dec 2021 09:52:54 +0000 Message-Id: <20211204095256.78042-4-laoar.shao@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211204095256.78042-1-laoar.shao@gmail.com> References: <20211204095256.78042-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Stat-Signature: q141d5m1spm5pkwawfztak1zx4g5ejk6 Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=qsHK5Wp3; spf=pass (imf28.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: A2E39900009A X-HE-Tag: 1638611591-880738 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The comm used in tracex2 should have the same size with the comm in task_struct, we'd better define the size of it as TASK_COMM_LEN to make it more grepable. linux/sched.h can be included in tracex2 kernel code, but it can't be included in tracex2 userspace code. So a new marco TASK_COMM_LEN is defined in tracex2 userspace code. Signed-off-by: Yafang Shao Cc: Mathieu Desnoyers Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: Andrii Nakryiko Cc: Michal Miroslaw Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Matthew Wilcox Cc: David Hildenbrand Cc: Al Viro Cc: Kees Cook Cc: Petr Mladek --- samples/bpf/tracex2_kern.c | 3 ++- samples/bpf/tracex2_user.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/samples/bpf/tracex2_kern.c b/samples/bpf/tracex2_kern.c index 5bc696bac27d..51dbaf765cd5 100644 --- a/samples/bpf/tracex2_kern.c +++ b/samples/bpf/tracex2_kern.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -65,7 +66,7 @@ static unsigned int log2l(unsigned long v) } struct hist_key { - char comm[16]; + char comm[TASK_COMM_LEN]; u64 pid_tgid; u64 uid_gid; u64 index; diff --git a/samples/bpf/tracex2_user.c b/samples/bpf/tracex2_user.c index 1626d51dfffd..b728a946d83d 100644 --- a/samples/bpf/tracex2_user.c +++ b/samples/bpf/tracex2_user.c @@ -12,6 +12,7 @@ #define MAX_INDEX 64 #define MAX_STARS 38 +#define TASK_COMM_LEN 16 /* my_map, my_hist_map */ static int map_fd[2]; @@ -28,7 +29,7 @@ static void stars(char *str, long val, long max, int width) } struct task { - char comm[16]; + char comm[TASK_COMM_LEN]; __u64 pid_tgid; __u64 uid_gid; }; From patchwork Sat Dec 4 09:52:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12656433 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6AA0CC433EF for ; Sat, 4 Dec 2021 09:55:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E49A66B0083; Sat, 4 Dec 2021 04:53:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DF9236B0085; Sat, 4 Dec 2021 04:53:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C9AD56B0087; Sat, 4 Dec 2021 04:53:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0184.hostedemail.com [216.40.44.184]) by kanga.kvack.org (Postfix) with ESMTP id BC7556B0083 for ; Sat, 4 Dec 2021 04:53:23 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 894168249980 for ; Sat, 4 Dec 2021 09:53:13 +0000 (UTC) X-FDA: 78879648666.10.2FCC679 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf20.hostedemail.com (Postfix) with ESMTP id 40A70D0000A7 for ; Sat, 4 Dec 2021 09:53:13 +0000 (UTC) Received: by mail-pf1-f176.google.com with SMTP id x5so5349634pfr.0 for ; Sat, 04 Dec 2021 01:53:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jc/1UqX6dBziNJTgW2IO/F7rtsTi2nR5UyyzWa0yaTY=; b=OPS6Tq0grzniAtkhVxBUnYGlNHe2LHenEl9GBTJUtoQpFmZ4NpGLdXZjKUgC7IZqdL ZKWU9aSUkUqHoSXlb9199RCCbprlEwAz/eREA8MLQnnkIgsEEY3qPvF/NMesCapvpCTL CDJI0dUFjTdXdtPWz0FFQdAtRz26RuQoiQvkBRzKFySMAH48+WOoxFj1q+RcM1mq8PJA 4HpF89d8G613VAWp+7lBQWZzOShQCn6ZJ9mRR7ESbX0eCDt7rNkgILW7w1PQEFJhi3gT yF3ugmTHCdttEto30CCqoAPVMIpMK7h+XNAJYJWgzLuqIe2i7V6I3L23Amzdh+sY9Pc8 tOmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jc/1UqX6dBziNJTgW2IO/F7rtsTi2nR5UyyzWa0yaTY=; b=DIVP5gxxxxFzIQkCt2ZJIGHgAYMaPJHvtB71zGyld2bzlv/j+L5sNSHccZYhn/XRnQ TE5h/mT++WQlC9fBqB7u6Ls/S+IAnCV80wol5V1MF10fDFAwOZNXLBJxTm9Wbc097LVO OJRwAYYtTb5UilVOoDDl8ayIubRuiqSSSCJElKL0Vc38jMSYqfKl8CmwYwh+2tGe8sgQ 5qP9ygWcmV19hSgbgiMUW/fpzHtKEdCGTn4OIQi6sAp5PHeZMSyUFYq6sp4PUYWm1xud 1/aX7nOrV/P2/GAOitoWyrxdha2ISG3f4QuUMi2uPfoswIiPvyy2WPoAim6LX4gW37Al mpEQ== X-Gm-Message-State: AOAM532xhxq0tl+tnsjMqNJxQBskdKc3ol4PtdloXEOeGkWeEJYNzWUX IrPGEHfSy6KFYipegRc/PjU= X-Google-Smtp-Source: ABdhPJxOtpMKrYAZBUYRY5WFF9PUZ3+zcvLt12isc0/o9+IZvyummoBi6CX2Z881q/Ptmt968HlHTw== X-Received: by 2002:a63:1107:: with SMTP id g7mr8918770pgl.108.1638611592149; Sat, 04 Dec 2021 01:53:12 -0800 (PST) Received: from vultr.guest ([45.76.74.237]) by smtp.gmail.com with ESMTPSA id ms15sm4343198pjb.26.2021.12.04.01.53.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Dec 2021 01:53:11 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org, rostedt@goodmis.org, keescook@chromium.org, pmladek@suse.com, david@redhat.com, arnaldo.melo@gmail.com, andrii.nakryiko@gmail.com Cc: linux-mm@kvack.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Yafang Shao , Mathieu Desnoyers , Alexei Starovoitov , Michal Miroslaw , Peter Zijlstra , Matthew Wilcox , Al Viro Subject: [PATCH -mm 4/5] tools/perf: replace hard-coded 16 with TASK_COMM_LEN Date: Sat, 4 Dec 2021 09:52:55 +0000 Message-Id: <20211204095256.78042-5-laoar.shao@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211204095256.78042-1-laoar.shao@gmail.com> References: <20211204095256.78042-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 40A70D0000A7 X-Stat-Signature: kn8sji6snfujnm6x6iue8735yab5a5rp Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=OPS6Tq0g; spf=pass (imf20.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1638611593-831296 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: evsel-tp-sched will verify the task comm len in sched:sched_switch and sched:sched_wakeup tracepoints. The len must be same with TASK_COMM_LEN defined in linux/sched.h. In order to make it grepable, we'd better replace the hard-coded 16 with TASK_COMM_LEN. Signed-off-by: Yafang Shao Cc: Mathieu Desnoyers Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: Andrii Nakryiko Cc: Michal Miroslaw Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Matthew Wilcox Cc: David Hildenbrand Cc: Al Viro Cc: Kees Cook Cc: Petr Mladek --- tools/perf/tests/evsel-tp-sched.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c index cf4da3d748c2..83e0ce2e676f 100644 --- a/tools/perf/tests/evsel-tp-sched.c +++ b/tools/perf/tests/evsel-tp-sched.c @@ -5,6 +5,8 @@ #include "tests.h" #include "debug.h" +#define TASK_COMM_LEN 16 + static int evsel__test_field(struct evsel *evsel, const char *name, int size, bool should_be_signed) { struct tep_format_field *field = evsel__field(evsel, name); @@ -43,7 +45,7 @@ static int test__perf_evsel__tp_sched_test(struct test_suite *test __maybe_unuse return -1; } - if (evsel__test_field(evsel, "prev_comm", 16, false)) + if (evsel__test_field(evsel, "prev_comm", TASK_COMM_LEN, false)) ret = -1; if (evsel__test_field(evsel, "prev_pid", 4, true)) @@ -55,7 +57,7 @@ static int test__perf_evsel__tp_sched_test(struct test_suite *test __maybe_unuse if (evsel__test_field(evsel, "prev_state", sizeof(long), true)) ret = -1; - if (evsel__test_field(evsel, "next_comm", 16, false)) + if (evsel__test_field(evsel, "next_comm", TASK_COMM_LEN, false)) ret = -1; if (evsel__test_field(evsel, "next_pid", 4, true)) @@ -73,7 +75,7 @@ static int test__perf_evsel__tp_sched_test(struct test_suite *test __maybe_unuse return -1; } - if (evsel__test_field(evsel, "comm", 16, false)) + if (evsel__test_field(evsel, "comm", TASK_COMM_LEN, false)) ret = -1; if (evsel__test_field(evsel, "pid", 4, true)) From patchwork Sat Dec 4 09:52:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12656435 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14847C433F5 for ; Sat, 4 Dec 2021 09:56:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 410656B0085; Sat, 4 Dec 2021 04:53:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C0466B0087; Sat, 4 Dec 2021 04:53:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 260686B0088; Sat, 4 Dec 2021 04:53:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0106.hostedemail.com [216.40.44.106]) by kanga.kvack.org (Postfix) with ESMTP id 179116B0085 for ; Sat, 4 Dec 2021 04:53:25 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D5BA71841B9F1 for ; Sat, 4 Dec 2021 09:53:14 +0000 (UTC) X-FDA: 78879648708.27.347214B Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by imf22.hostedemail.com (Postfix) with ESMTP id 985B51903 for ; Sat, 4 Dec 2021 09:53:14 +0000 (UTC) Received: by mail-pg1-f172.google.com with SMTP id r5so5538520pgi.6 for ; Sat, 04 Dec 2021 01:53:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=czJoVryBJuRcT/ehuX/TDIeW+lRJT86wq9/OvXnh70g=; b=E6qLZya8+ifZxNJOIPiTCTofzYjJThBlfeuM51/2mqfsnjW5NtrNTz/6a0nEh7jmKU VGTTs3/RbA7s8syhuDBh+k70qRK3hetMq9n8itSkvFJ+mtTIN0Uc+WJOANDPdKHwH8vs k8udbqT/eL9Tzpjtsu+6e9o/SLIkzrLwPCDSvquIL+N5FwmpTXeP1wqnmE7nQK/1dJZO ksP728T5KeU42m8NPGDNz1UCB83nn0OrhifZgrDL+dypJQ5KxuroJ3f30wEMYdTajgp1 tA72KBktvSwUiATQBi7Hc+gb1PlQJIXCz0eUPuwixg5JmBdOEYIRfpkwowmfkmIn30dq VNVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=czJoVryBJuRcT/ehuX/TDIeW+lRJT86wq9/OvXnh70g=; b=uA6CmUYTetKxCy7Kr7fDpfVqINHulEArs5rS9/FSqLtSiEQVomS4t8hesgJur/+QnH N7p3ZEeeN7hDDX61FWvP2BottJAHUdsvlPbq3dDf/BLse+Od8zLZeM9/ss6a60coRTBF DpReybAIgW8Kal/QclQ2rnFmTccYYLyRVj3N4WQjNfdrxtXwYlmtBnxtkz2YxsHV2Zm5 RO9LrZ9vGRKL3wYlVZSUHYufivNQEyaKKbslyxiFvtZgTqdB2/pS2FlZdwcXiTW8NEz7 y7NQb+Q+bGppTlr6vRKQZsNftEo2sR3XhtvtPHedPrlqnUMiTg5F81F6hgRgEky4hoqG E9QQ== X-Gm-Message-State: AOAM533VjjFXBXlQeie5x6qNds3WcgwcyoKmZS1ATfRmGv52IJ8asdSx oQfVC3WYt60FlPnRr2Ut28A= X-Google-Smtp-Source: ABdhPJxzLifxgl4vQbzEDYn+z7ENKxXxDFCDs3LmIROFaOViZ6d6BbSiRJPdAV7fU9k00bDw17QoEA== X-Received: by 2002:a65:6790:: with SMTP id e16mr8839078pgr.112.1638611593497; Sat, 04 Dec 2021 01:53:13 -0800 (PST) Received: from vultr.guest ([45.76.74.237]) by smtp.gmail.com with ESMTPSA id ms15sm4343198pjb.26.2021.12.04.01.53.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Dec 2021 01:53:13 -0800 (PST) From: Yafang Shao To: akpm@linux-foundation.org, rostedt@goodmis.org, keescook@chromium.org, pmladek@suse.com, david@redhat.com, arnaldo.melo@gmail.com, andrii.nakryiko@gmail.com Cc: linux-mm@kvack.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Yafang Shao , Mathieu Desnoyers , Alexei Starovoitov , Michal Miroslaw , Peter Zijlstra , Matthew Wilcox , Al Viro Subject: [PATCH -mm 5/5] bpf/progs: replace hard-coded 16 with TASK_COMM_LEN Date: Sat, 4 Dec 2021 09:52:56 +0000 Message-Id: <20211204095256.78042-6-laoar.shao@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211204095256.78042-1-laoar.shao@gmail.com> References: <20211204095256.78042-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Stat-Signature: yo7aie3sjdchbeakz4x9ytummiotq89r Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=E6qLZya8; spf=pass (imf22.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.215.172 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 985B51903 X-HE-Tag: 1638611594-405643 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The comm used in these bpf progs should have the same size with the comm field in struct task_struct defined in linux/sched.h. We'd better define the size as TASK_COMM_LEN to make it more grepable. The bpf progs kernel code can inlcude vmlinux.h generated by BTF CO-RE to use TASK_COMM_LEN, while the userspace code can't include it so TASK_COMM_LEN is specifically defined in the userspace code. In order to fix redefinitions caused by the new included vmlinux.h, some headers are removed and some structs are renamed. Signed-off-by: Yafang Shao Cc: Mathieu Desnoyers Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: Andrii Nakryiko Cc: Michal Miroslaw Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Matthew Wilcox Cc: David Hildenbrand Cc: Al Viro Cc: Kees Cook Cc: Petr Mladek --- tools/testing/selftests/bpf/prog_tests/ringbuf.c | 9 +++++---- .../testing/selftests/bpf/prog_tests/ringbuf_multi.c | 8 +++++--- .../selftests/bpf/prog_tests/sk_storage_tracing.c | 3 ++- .../testing/selftests/bpf/prog_tests/test_overhead.c | 3 ++- .../selftests/bpf/prog_tests/trampoline_count.c | 3 ++- .../selftests/bpf/progs/test_core_reloc_kernel.c | 11 +++++------ tools/testing/selftests/bpf/progs/test_ringbuf.c | 8 ++++---- .../testing/selftests/bpf/progs/test_ringbuf_multi.c | 8 ++++---- .../selftests/bpf/progs/test_sk_storage_tracing.c | 4 ++-- 9 files changed, 31 insertions(+), 26 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/ringbuf.c b/tools/testing/selftests/bpf/prog_tests/ringbuf.c index 9a80fe8a6427..39e43245db0a 100644 --- a/tools/testing/selftests/bpf/prog_tests/ringbuf.c +++ b/tools/testing/selftests/bpf/prog_tests/ringbuf.c @@ -15,14 +15,15 @@ #include "test_ringbuf.lskel.h" #define EDONE 7777 +#define TASK_COMM_LEN 16 static int duration = 0; -struct sample { +struct sample_ringbuf { int pid; int seq; long value; - char comm[16]; + char comm[TASK_COMM_LEN]; }; static int sample_cnt; @@ -39,7 +40,7 @@ static int atomic_xchg(int *cnt, int val) static int process_sample(void *ctx, void *data, size_t len) { - struct sample *s = data; + struct sample_ringbuf *s = data; atomic_inc(&sample_cnt); @@ -83,7 +84,7 @@ static void *poll_thread(void *input) void test_ringbuf(void) { - const size_t rec_sz = BPF_RINGBUF_HDR_SZ + sizeof(struct sample); + const size_t rec_sz = BPF_RINGBUF_HDR_SZ + sizeof(struct sample_ringbuf); pthread_t thread; long bg_ret = -1; int err, cnt, rb_fd; diff --git a/tools/testing/selftests/bpf/prog_tests/ringbuf_multi.c b/tools/testing/selftests/bpf/prog_tests/ringbuf_multi.c index e945195b24c9..cb592555513f 100644 --- a/tools/testing/selftests/bpf/prog_tests/ringbuf_multi.c +++ b/tools/testing/selftests/bpf/prog_tests/ringbuf_multi.c @@ -4,19 +4,21 @@ #include #include "test_ringbuf_multi.skel.h" +#define TASK_COMM_LEN 16 + static int duration = 0; -struct sample { +struct sample_ringbuf { int pid; int seq; long value; - char comm[16]; + char comm[TASK_COMM_LEN]; }; static int process_sample(void *ctx, void *data, size_t len) { int ring = (unsigned long)ctx; - struct sample *s = data; + struct sample_ringbuf *s = data; switch (s->seq) { case 0: diff --git a/tools/testing/selftests/bpf/prog_tests/sk_storage_tracing.c b/tools/testing/selftests/bpf/prog_tests/sk_storage_tracing.c index 547ae53cde74..dbbdbf4400d7 100644 --- a/tools/testing/selftests/bpf/prog_tests/sk_storage_tracing.c +++ b/tools/testing/selftests/bpf/prog_tests/sk_storage_tracing.c @@ -11,11 +11,12 @@ #define LO_ADDR6 "::1" #define TEST_COMM "test_progs" +#define TASK_COMM_LEN 16 struct sk_stg { __u32 pid; __u32 last_notclose_state; - char comm[16]; + char comm[TASK_COMM_LEN]; }; static struct test_sk_storage_tracing *skel; diff --git a/tools/testing/selftests/bpf/prog_tests/test_overhead.c b/tools/testing/selftests/bpf/prog_tests/test_overhead.c index 123c68c1917d..7fe60ec12fc4 100644 --- a/tools/testing/selftests/bpf/prog_tests/test_overhead.c +++ b/tools/testing/selftests/bpf/prog_tests/test_overhead.c @@ -6,6 +6,7 @@ #include #define MAX_CNT 100000 +#define TASK_COMM_LEN 16 static __u64 time_get_ns(void) { @@ -67,7 +68,7 @@ void test_test_overhead(void) struct bpf_object *obj; struct bpf_link *link; int err, duration = 0; - char comm[16] = {}; + char comm[TASK_COMM_LEN] = {}; if (CHECK_FAIL(prctl(PR_GET_NAME, comm, 0L, 0L, 0L))) return; diff --git a/tools/testing/selftests/bpf/prog_tests/trampoline_count.c b/tools/testing/selftests/bpf/prog_tests/trampoline_count.c index fc146671b20a..da83f7408aa8 100644 --- a/tools/testing/selftests/bpf/prog_tests/trampoline_count.c +++ b/tools/testing/selftests/bpf/prog_tests/trampoline_count.c @@ -5,6 +5,7 @@ #include #define MAX_TRAMP_PROGS 38 +#define TASK_COMM_LEN 16 struct inst { struct bpf_object *obj; @@ -51,7 +52,7 @@ void serial_test_trampoline_count(void) int err, i = 0, duration = 0; struct bpf_object *obj; struct bpf_link *link; - char comm[16] = {}; + char comm[TASK_COMM_LEN] = {}; /* attach 'allowed' trampoline programs */ for (i = 0; i < MAX_TRAMP_PROGS; i++) { diff --git a/tools/testing/selftests/bpf/progs/test_core_reloc_kernel.c b/tools/testing/selftests/bpf/progs/test_core_reloc_kernel.c index 145028b52ad8..7b1bb73c3501 100644 --- a/tools/testing/selftests/bpf/progs/test_core_reloc_kernel.c +++ b/tools/testing/selftests/bpf/progs/test_core_reloc_kernel.c @@ -1,8 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2019 Facebook -#include -#include +#include #include #include #include @@ -23,11 +22,11 @@ struct core_reloc_kernel_output { int comm_len; }; -struct task_struct { +struct task_struct_reloc { int pid; int tgid; - char comm[16]; - struct task_struct *group_leader; + char comm[TASK_COMM_LEN]; + struct task_struct_reloc *group_leader; }; #define CORE_READ(dst, src) bpf_core_read(dst, sizeof(*(dst)), src) @@ -35,7 +34,7 @@ struct task_struct { SEC("raw_tracepoint/sys_enter") int test_core_kernel(void *ctx) { - struct task_struct *task = (void *)bpf_get_current_task(); + struct task_struct_reloc *task = (void *)bpf_get_current_task(); struct core_reloc_kernel_output *out = (void *)&data.out; uint64_t pid_tgid = bpf_get_current_pid_tgid(); uint32_t real_tgid = (uint32_t)pid_tgid; diff --git a/tools/testing/selftests/bpf/progs/test_ringbuf.c b/tools/testing/selftests/bpf/progs/test_ringbuf.c index eaa7d9dba0be..45b28965f3a5 100644 --- a/tools/testing/selftests/bpf/progs/test_ringbuf.c +++ b/tools/testing/selftests/bpf/progs/test_ringbuf.c @@ -1,16 +1,16 @@ // SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2020 Facebook -#include +#include #include char _license[] SEC("license") = "GPL"; -struct sample { +struct sample_ringbuf { int pid; int seq; long value; - char comm[16]; + char comm[TASK_COMM_LEN]; }; struct { @@ -39,7 +39,7 @@ SEC("fentry/__x64_sys_getpgid") int test_ringbuf(void *ctx) { int cur_pid = bpf_get_current_pid_tgid() >> 32; - struct sample *sample; + struct sample_ringbuf *sample; int zero = 0; if (cur_pid != pid) diff --git a/tools/testing/selftests/bpf/progs/test_ringbuf_multi.c b/tools/testing/selftests/bpf/progs/test_ringbuf_multi.c index 197b86546dca..7c9db148f168 100644 --- a/tools/testing/selftests/bpf/progs/test_ringbuf_multi.c +++ b/tools/testing/selftests/bpf/progs/test_ringbuf_multi.c @@ -1,16 +1,16 @@ // SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2020 Facebook -#include +#include #include char _license[] SEC("license") = "GPL"; -struct sample { +struct sample_ringbuf { int pid; int seq; long value; - char comm[16]; + char comm[TASK_COMM_LEN]; }; struct ringbuf_map { @@ -55,7 +55,7 @@ SEC("tp/syscalls/sys_enter_getpgid") int test_ringbuf(void *ctx) { int cur_pid = bpf_get_current_pid_tgid() >> 32; - struct sample *sample; + struct sample_ringbuf *sample; void *rb; int zero = 0; diff --git a/tools/testing/selftests/bpf/progs/test_sk_storage_tracing.c b/tools/testing/selftests/bpf/progs/test_sk_storage_tracing.c index 6dc1f28fc4b6..cc41a09e3130 100644 --- a/tools/testing/selftests/bpf/progs/test_sk_storage_tracing.c +++ b/tools/testing/selftests/bpf/progs/test_sk_storage_tracing.c @@ -9,7 +9,7 @@ struct sk_stg { __u32 pid; __u32 last_notclose_state; - char comm[16]; + char comm[TASK_COMM_LEN]; }; struct { @@ -27,7 +27,7 @@ struct { __type(value, int); } del_sk_stg_map SEC(".maps"); -char task_comm[16] = ""; +char task_comm[TASK_COMM_LEN] = ""; SEC("tp_btf/inet_sock_set_state") int BPF_PROG(trace_inet_sock_set_state, struct sock *sk, int oldstate,