Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1094818pxu; Fri, 23 Oct 2020 23:54:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwepDnamqRYJT2uGZETRlt966H2rWif7sA8lDRfpC+teiqEV2Hd0yPtPg4mIy0qZbVMmQx/ X-Received: by 2002:a17:906:4d44:: with SMTP id b4mr5350690ejv.131.1603522450154; Fri, 23 Oct 2020 23:54:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603522450; cv=none; d=google.com; s=arc-20160816; b=tQ68opOomB8INDgSNM/2tPwqqAXXTIJBKbGg0hDcEuGgXxVU/753GwedvYleb54DaW s92qjEiH9GzHtXsx2a7gEaPxJuxV4THt1Yi6T7gQlpZrHDKI9BcL3VPdBhY5Fe0f8Yq3 pqwOP1yrGcfnxm/38ZwsDodiT9xmA/xvgirdtwSswhraNVMHHXnu8DXclC1L8ypoeLX4 eOiGcEA4yvzWxwXuJxZTd6CpGlrUKzGMgBR2ysBDzOxfGYOZo8j4Z4Bz1D48EBO1Q2pg myYNGRP+5lK5wuBHKJmvUOfkzRL8wOYKyg2HJA1JbJNTxWKhJNfrp8PzTuuJ0fIpE1c+ Z+pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=cS+Z1yDAr8AcUOGEKTdn+TykhKh9gdu61RHiIBpE4YY=; b=rzkkUh/SlL6sWIyqCmTqghp7ktwgn05oGJtfAuyuYknyG4WfuScJ9rKKNwxAeFRSHh 3RpMZyG0UxMZIeJLJ7+ICkLrLbMWkiKrWB8z7RDAiT0fx4rulUBqpP4UruyGtaRp8/Q/ ysR0jwZUEIhGfnxtcS0ErtzcVaPCX/H0ME+bhc0vXi02Hiyj6oMPe4/qzUJDZ9kN0CCy RyYM8Mng440tkUy/P8SmesXNZYTU8/zSTfXgoeUtK7oewp/dniBFCd6fAtovQQYevfBr IuEXxulPahL247lLM9N1bcYZYKZP7InzS4dVk1yqXWzExU8Ri0JOfXU0XC3l9GCybHa8 rQeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=ihNsa3Sb; 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=efficios.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m19si593072ejc.606.2020.10.23.23.52.58; Fri, 23 Oct 2020 23:54:10 -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=@efficios.com header.s=default header.b=ihNsa3Sb; 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=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755148AbgJWTyl (ORCPT + 99 others); Fri, 23 Oct 2020 15:54:41 -0400 Received: from mail.efficios.com ([167.114.26.124]:45706 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755017AbgJWTyU (ORCPT ); Fri, 23 Oct 2020 15:54:20 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 586B9279698; Fri, 23 Oct 2020 15:54:19 -0400 (EDT) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id vjAf7EqbJBQA; Fri, 23 Oct 2020 15:54:19 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 0281527980B; Fri, 23 Oct 2020 15:54:19 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 0281527980B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1603482859; bh=cS+Z1yDAr8AcUOGEKTdn+TykhKh9gdu61RHiIBpE4YY=; h=From:To:Date:Message-Id:MIME-Version; b=ihNsa3SbR1l2R43+9+NDhCMNB43YLX0ygwo3FZ1pFBE1AzV2iYbrNn12Wtm0+bnFD Eb0OeNoOm8MnsJzswTiVqY7gy4Cc6Ly+NcCrRozLmbzmfPXxGr8tau3ojDamU5hy3R P8NsNGGEcjjNkF1QxvFL9cqGW6lKHOlrwIj3LsDB99BbE34gJ3hdyG16STgv8krrZ6 v9Onu77Rq5TzawrIsPdtYZdNx86STB6iEn26qUllgN//WyQ5py38IDVfTcK6McLD8r //3WqkMVLCq7ZUGskbypyKAuY4noQPIkLCha1B98EDB8y7vm28HXrzaPyD7uZxV+LX rbYix1ymFsjpA== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id cwRlg_YJ-FoS; Fri, 23 Oct 2020 15:54:18 -0400 (EDT) Received: from localhost.localdomain (96-127-212-112.qc.cable.ebox.net [96.127.212.112]) by mail.efficios.com (Postfix) with ESMTPSA id 96F7427979B; Fri, 23 Oct 2020 15:54:18 -0400 (EDT) From: Michael Jeanson To: linux-kernel@vger.kernel.org Cc: mathieu.desnoyers@efficios.com, Michael Jeanson , Steven Rostedt , Peter Zijlstra , Alexei Starovoitov , Yonghong Song , "Paul E . McKenney" , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Joel Fernandes , bpf@vger.kernel.org Subject: [RFC PATCH 4/6] tracing: perf: add support for sleepable tracepoints Date: Fri, 23 Oct 2020 15:53:50 -0400 Message-Id: <20201023195352.26269-5-mjeanson@efficios.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201023195352.26269-1-mjeanson@efficios.com> References: <20201023195352.26269-1-mjeanson@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for converting system call enter/exit instrumentation into sleepable tracepoints, make sure that perf can handle registering to such tracepoints by explicitly disabling preemption within the perf tracepoint probes to respect the current expectations within perf ring buffer code. This change does not yet allow perf to take page faults per se within its probe, but allows its existing probes to connect to sleepable tracepoints. Co-developed-by: Mathieu Desnoyers Signed-off-by: Mathieu Desnoyers Signed-off-by: Michael Jeanson Cc: Steven Rostedt (VMware) Cc: Peter Zijlstra Cc: Alexei Starovoitov Cc: Yonghong Song Cc: Paul E. McKenney Cc: Ingo Molnar Cc: Arnaldo Carvalho de Melo Cc: Mark Rutland Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Cc: Joel Fernandes (Google) Cc: bpf@vger.kernel.org --- include/trace/perf.h | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/include/trace/perf.h b/include/trace/perf.h index dbc6c74defc3..e1d866c3a076 100644 --- a/include/trace/perf.h +++ b/include/trace/perf.h @@ -27,8 +27,8 @@ #undef __perf_task #define __perf_task(t) (__task =3D (t)) =20 -#undef DECLARE_EVENT_CLASS -#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ +#undef _DECLARE_EVENT_CLASS +#define _DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print, = tp_flags) \ static notrace void \ perf_trace_##call(void *__data, proto) \ { \ @@ -43,13 +43,16 @@ perf_trace_##call(void *__data, proto) \ int __data_size; \ int rctx; \ \ + if ((tp_flags) & TRACEPOINT_MAYSLEEP) \ + preempt_disable_notrace(); \ + \ __data_size =3D trace_event_get_offsets_##call(&__data_offsets, args); = \ \ head =3D this_cpu_ptr(event_call->perf_events); \ if (!bpf_prog_array_valid(event_call) && \ __builtin_constant_p(!__task) && !__task && \ hlist_empty(head)) \ - return; \ + goto end; \ \ __entry_size =3D ALIGN(__data_size + sizeof(*entry) + sizeof(u32),\ sizeof(u64)); \ @@ -57,7 +60,7 @@ perf_trace_##call(void *__data, proto) \ \ entry =3D perf_trace_buf_alloc(__entry_size, &__regs, &rctx); \ if (!entry) \ - return; \ + goto end; \ \ perf_fetch_caller_regs(__regs); \ \ @@ -68,8 +71,23 @@ perf_trace_##call(void *__data, proto) \ perf_trace_run_bpf_submit(entry, __entry_size, rctx, \ event_call, __count, __regs, \ head, __task); \ +end: \ + if ((tp_flags) & TRACEPOINT_MAYSLEEP) \ + preempt_enable_notrace(); \ } =20 +#undef DECLARE_EVENT_CLASS +#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ + _DECLARE_EVENT_CLASS(call, PARAMS(proto), PARAMS(args), \ + PARAMS(tstruct), PARAMS(assign), PARAMS(print), 0) + +#undef DECLARE_EVENT_CLASS_MAYSLEEP +#define DECLARE_EVENT_CLASS_MAYSLEEP(call, proto, args, tstruct, \ + assign, print) \ + _DECLARE_EVENT_CLASS(call, PARAMS(proto), PARAMS(args), \ + PARAMS(tstruct), PARAMS(assign), PARAMS(print), \ + TRACEPOINT_MAYSLEEP) + /* * This part is compiled out, it is only here as a build time check * to make sure that if the tracepoint handling changes, the --=20 2.25.1