Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp618253pxb; Wed, 24 Feb 2021 10:19:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwrTV5yG93kPnkIoRz0/1fWpvedsmTXaDcHdyKxMfWrnKtR4YjCKfHklLZ5a9KSYDyqXmah X-Received: by 2002:a17:907:75e7:: with SMTP id jz7mr21061157ejc.158.1614190745793; Wed, 24 Feb 2021 10:19:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614190745; cv=none; d=google.com; s=arc-20160816; b=neRdrigcitspnXYM0YWLFbx1+/3Ri0OWUf27Ehvh508bgNpQagLcCdMPgv9Wak1dfL X3rcEhF34JUPLOC3vPmaa2a0E032yEz7QEqgHwdGlixpc4R7grYn7ppY4OCC7nPbPIsI MhMerDUCKsb6Z6xLWf1rEwEBJpBLevfowmd8//WZ4lFXsCs17J1p/sZvP8JYKU1c/bnH vUuUDxB6gp3yC4vPV6eBG1mqNrjPwC/ceB7IQ1sxN6eRyDI38Wwec3jfdsJ7AUifMWil 7aijfP1Ymp7WweJpQZUttrR6oedOZNxk/ClaoZRwabekE3QfzzTz7lgxof/CqsAn/JY6 Uszg== 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:subject:cc:to:from:date; bh=5sj/F7bnWXufi7gvr5QUQR3JaT8IvNqmaroiiKfGzFc=; b=iZGsehUPxskOFII3OHlnzl7MXBZyqLNs5qKVC0BiQGyH4qOaOD1xf3skbpmYfgs1xb Iwm70qh7Hj/2j5I+F89dAvy2l4onDyfXu0KCiyL8evEnddNjoRrgFo1lWxjsTxsjenWZ IcEqU34vJHhR2azgbwKRUs1wo5/vg2uQNrfMlhRCzHbTYQ5LTgpZUwvkKBJATlMiTsB7 F19m1xaaC+wqhQtI4H3K81Eqraota4YlTDZAH7W8gAPAk7lgcU7ttdqYZOc1h0oJhWlI zclTTPyDEg3u1Uk12XNoSQzvZ7fV8I3pnxIIOQ1IpvqULGiI3wjXOZIQJ/9Med9PBz+J CWSw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i23si1603364edy.402.2021.02.24.10.18.42; Wed, 24 Feb 2021 10:19:05 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229599AbhBXSOy (ORCPT + 99 others); Wed, 24 Feb 2021 13:14:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:57860 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234451AbhBXSOt (ORCPT ); Wed, 24 Feb 2021 13:14:49 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6CC8164EDD; Wed, 24 Feb 2021 18:14:07 +0000 (UTC) Date: Wed, 24 Feb 2021 13:14:05 -0500 From: Steven Rostedt To: Mathieu Desnoyers Cc: Michael Jeanson , linux-kernel , Peter Zijlstra , Alexei Starovoitov , Yonghong Song , paulmck , Ingo Molnar , acme , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , "Joel Fernandes, Google" , bpf Subject: Re: [RFC PATCH 0/6] [RFC] Faultable tracepoints (v2) Message-ID: <20210224131405.20d64b49@gandalf.local.home> In-Reply-To: <915297635.2997.1614185975415.JavaMail.zimbra@efficios.com> References: <20210218222125.46565-1-mjeanson@efficios.com> <20210223211639.670db85c@gandalf.local.home> <083bce0f-bd66-ab83-1211-be9838499b45@efficios.com> <915297635.2997.1614185975415.JavaMail.zimbra@efficios.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 24 Feb 2021 11:59:35 -0500 (EST) Mathieu Desnoyers wrote: > > As a prototype solution, what I've done currently is to copy the user-space > data into a kmalloc'd buffer in a preparation step before disabling preemption > and copying data over into the per-cpu buffers. It works, but I think we should > be able to do it without the needless copy. > > What I have in mind as an efficient solution (not implemented yet) for the LTTng > kernel tracer goes as follows: > > #define COMMIT_LOCAL 0 > #define COMMIT_REMOTE 1 > > - faultable probe is called from system call tracepoint [ preemption/blocking/migration is allowed ] > - probe code calculate the length which needs to be reserved to store the event > (e.g. user strlen), > > - preempt disable -> [ preemption/blocking/migration is not allowed from here ] > - reserve_cpu = smp_processor_id() > - reserve space in the ring buffer for reserve_cpu > [ from that point on, we have _exclusive_ access to write into the ring buffer "slot" > from any cpu until we commit. ] > - preempt enable -> [ preemption/blocking/migration is allowed from here ] > So basically the commit position here doesn't move until this task is scheduled back in and the commit (remote or local) is updated. To put it in terms of the ftrace ring buffer, where we have both a commit page and a commit index, and it only gets moved by the first one to start a commit stack (that is, interrupts that interrupted a write will not increment the commit). Now, I'm not sure how LTTng does it, but I could see issues for ftrace to try to move the commit pointer (the pointer to the new commit page), as the design is currently dependent on the fact that it can't happen while commits are taken place. Are the pages of the LTTng indexed by an array of pages? -- Steve