Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2382850ybt; Fri, 3 Jul 2020 07:47:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyw0T0qbG8goywObAzp1GVIxzYhzYfoJhZhpUtYuU4DvQowVFTjRh7kp3fLNDtMfDjPLAIY X-Received: by 2002:a17:906:1a16:: with SMTP id i22mr13872630ejf.439.1593787646157; Fri, 03 Jul 2020 07:47:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593787646; cv=none; d=google.com; s=arc-20160816; b=C3ORc2Ly19x6PhrlZK5gbwYULR+2Pk55qghJMKvr/jBw7vreT1TtYHNQGvRe8uLdww A43+jDWawkJTw2GarUN1XFqpSWEwiXs8sVoVdvR1EzZkjk8g6pmMWWhO4/5ggorRELG6 tBu35R3pYFdZXp4yGyA9z+VRZoUZXUD4t51fhE/T60qndCCH17qZr24ZfLCD/GO8HU5r hC0PS3f7uLIHPtC2eXXzAX5/0hCXn60ZGslvwtk+M1hJQw+uRrdGOtyOxdK5/nvvaTNn fp56gpI2be6xiXHTzGAqXCMqT0TV3ER1ko8c7yXiGYGW8/ckmt2Ko9zU6M31sWDY9KnF HRng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=jAlHI7nujQDcm+MewjBseorEgs8Y6kyiq354ZRlVCiw=; b=jC2yUAlbihysJpK/ZQmZTPMoEmnXv0gOgFApkzb8wwulbVai90TLVGzX+JLPXBbpTB 6+he26AEmuANNeVV3NxTVHl6aq1kt0Uiq7hKJdn/b5fWsj1fXl0t1Mso92XPxmnUKHxJ g0z195ESrpNNCorLCa5XqFVWYXJXYOpXBja9xuKodQX+eVmwIkOkwyz+6NX1ial9WhD+ YTg/vC8RXJ1aojtZfoWLzafPSa25X6ClwOku5h9VfF1HpF/14SCBJgTadIccxUv4EvRT nGArotdwn5VlKTIKNRLsGWjliw5osr5OyTBEH1nO5s1lkkceCEIMR7WKxe6uFaQdwOm/ MnzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=bs3NE8v8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z19si7879409eje.612.2020.07.03.07.47.03; Fri, 03 Jul 2020 07:47:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=bs3NE8v8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726262AbgGCOp2 (ORCPT + 99 others); Fri, 3 Jul 2020 10:45:28 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:34988 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726039AbgGCOp2 (ORCPT ); Fri, 3 Jul 2020 10:45:28 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 063EgWdT010532; Fri, 3 Jul 2020 14:44:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2020-01-29; bh=jAlHI7nujQDcm+MewjBseorEgs8Y6kyiq354ZRlVCiw=; b=bs3NE8v8ixykeBj9AT5ZGqzepRu/JZ6TkFw8fRgAwlAqStI/NVDd/ZWRImHnb8djDx6c nt9r9EOFgtE3g6kc4Q2yX9nQMVdd1FV+nWA/ztJHAk1aBvDr+ziGKqRfnOCm6zhF4kwz OCvu5UlhknguTwCpO9ZDnJ4XHlblbRf/GPng4hsd/Tay0cCWwh+4hcCMFThWbGnUIK0E FkAPjbY5bLEuaQCPQycp0S1S6BVY7E0GIrBztEase6+ryuAdsZWQIC4clh1qh6xYRtKg 4gzSoW2RBb6UehzKcbBTWCpXcpVaQrRHIMXZXEygUyGaSvg3Eqqr6IzTXQ60RqI118Zl qg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 31xx1eawxs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 03 Jul 2020 14:44:43 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 063Egsfw193726; Fri, 3 Jul 2020 14:44:42 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 31xg1cjytw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Jul 2020 14:44:42 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 063Eie7P013218; Fri, 3 Jul 2020 14:44:40 GMT Received: from localhost.uk.oracle.com (/10.175.204.239) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Jul 2020 14:44:40 +0000 From: Alan Maguire To: rostedt@goodmis.org, mingo@redhat.com, ast@kernel.org, daniel@iogearbox.net Cc: kafai@fb.com, songliubraving@fb.com, yhs@fb.com, andriin@fb.com, john.fastabend@gmail.com, kpsingh@chromium.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, Alan Maguire Subject: [PATCH bpf-next 0/2] bpf: fix use of trace_printk() in BPF Date: Fri, 3 Jul 2020 15:44:26 +0100 Message-Id: <1593787468-29931-1-git-send-email-alan.maguire@oracle.com> X-Mailer: git-send-email 1.8.3.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9670 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2007030102 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9670 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1011 adultscore=0 suspectscore=0 mlxlogscore=999 cotscore=-2147483648 lowpriorityscore=0 malwarescore=0 phishscore=0 impostorscore=0 mlxscore=0 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2007030102 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Steven suggested a way to resolve the appearance of the warning banner that appears as a result of using trace_printk() in BPF [1]. Applying the patch and testing reveals all works as expected; we can call bpf_trace_printk() and see the trace messages in /sys/kernel/debug/tracing/trace_pipe and no banner message appears. Also add a test prog to verify basic bpf_trace_printk() helper behaviour. Possible future work: ftrace supports trace instances, and one thing that strikes me is that we could make use of these in BPF to separate BPF program bpf_trace_printk() output from output of other tracing activities. I was thinking something like a sysctl net.core.bpf_trace_instance, defaulting to an empty value signifying we use the root trace instance. This would preserve existing behaviour while giving a way to separate BPF tracing output from other tracing output if wanted. [1] https://lore.kernel.org/r/20200628194334.6238b933@oasis.local.home Alan Maguire (2): bpf: use dedicated bpf_trace_printk event instead of trace_printk() selftests/bpf: add selftests verifying bpf_trace_printk() behaviour kernel/trace/Makefile | 2 + kernel/trace/bpf_trace.c | 41 +++++++++++-- kernel/trace/bpf_trace.h | 34 +++++++++++ .../selftests/bpf/prog_tests/trace_printk.c | 71 ++++++++++++++++++++++ tools/testing/selftests/bpf/progs/trace_printk.c | 21 +++++++ 5 files changed, 165 insertions(+), 4 deletions(-) create mode 100644 kernel/trace/bpf_trace.h create mode 100644 tools/testing/selftests/bpf/prog_tests/trace_printk.c create mode 100644 tools/testing/selftests/bpf/progs/trace_printk.c -- 1.8.3.1