Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp590418pxj; Fri, 28 May 2021 10:36:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5gC5SAXRVQ74U+NnLF1FnU1QTCsBplJB7HT0Wha4OBOX6IagfZw9OzF1dK5XIZSWye+7V X-Received: by 2002:a17:906:40cf:: with SMTP id a15mr10205761ejk.181.1622223378683; Fri, 28 May 2021 10:36:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622223378; cv=none; d=google.com; s=arc-20160816; b=ekAYL/j4lfDFQHHfUZZ01sTnVMI+DuNgZM6+8jg7xYBqgZrrw+A37W9n5Tq8lKf8XM WVaL6JzckvBjao92/vczgRd5IZk7LOPwxInGmmkgOC4VfzRvgQiEKEw/4z7OikNdlj10 c6aRAC3pGFV8LUr+uk+cd8Fg1+y4F3xy4iZJEDgEYRKWUgboYA/r6egIuQRi7iU7S9sQ dTYiuQxPBqVpf6iuwp8bXe/ZWy9yXWhBXAWRLCpt+G5FiLvOyzPMvUvDgc/gahwLHEm4 T/2pzsmn5h+vAgFd/UfL867cHFXv5fH/yEB6FuaFHE2kp7Kb3mNK0/kq6K7fChmt4k7D xu5A== 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=jnTsycmxOGwrwfWab1VlVhTwjFK8l9Lw40eN/bQJnK4=; b=S2Wuutln12Q4oPYWIWvITkPima3h9s3irLi3G0LGPP7+8zLl43Im3gIHaq3HYYS931 KlFDvgkmv/FIR6BcTDe9sZKYawHKy0BDNE7a0Gw+fmoHNHEAXEVwq3GGP8F0oo3tbgjr z2L3oTi0VVyDyW98rBFDgpcVOB3JjrJEqvRxqdnJ1RvZg8cI7RJAoZAbO7djY5qbf7J4 mGqJFTL6seRrE2RuEL3+ucCaD6hNWpwVjAVXfTsHAos8rwoo15Gz8ovtmKiZ5abYNRMG MdlXQR1Q3ZUAB+t5z48TblsLgurdIf7nzGjhYOYA501fpclDDQqzN4sipopLV3mBiGuJ oCbg== 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 m2si5530760ejj.215.2021.05.28.10.35.55; Fri, 28 May 2021 10:36:18 -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; 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 S229481AbhE1Rec (ORCPT + 99 others); Fri, 28 May 2021 13:34:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:43658 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbhE1Rea (ORCPT ); Fri, 28 May 2021 13:34:30 -0400 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 6579A613B5; Fri, 28 May 2021 17:32:55 +0000 (UTC) Date: Fri, 28 May 2021 13:32:53 -0400 From: Steven Rostedt To: Nicolas Saenz Julienne Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, mingo@redhat.com, corbet@lwn.net, mtosatti@redhat.com Subject: Re: [RFC] trace: Add option for polling ring buffers Message-ID: <20210528133253.27c749ab@gandalf.local.home> In-Reply-To: <20210519175755.670876-1-nsaenzju@redhat.com> References: <20210519175755.670876-1-nsaenzju@redhat.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, 19 May 2021 19:57:55 +0200 Nicolas Saenz Julienne wrote: > To minimize trace's effect on isolated CPUs. That is, CPUs were only a > handful or a single, process are allowed to run. Introduce a new trace > option: 'poll-rb'. > > This option changes the heuristic used to wait for data on trace > buffers. The default one, based on wait queues, will trigger an IPI[1] > on the CPU responsible for new data, which will take care of waking up > the trace gathering process (generally trace-cmd). Whereas with > 'poll-rb' we will poll (as in busy-wait) the ring buffers from the trace > gathering process, releasing the CPUs writing trace data from doing any > wakeup work. > > This wakeup work, although negligible in the vast majority of workloads, > may cause unwarranted latencies on systems running trace on isolated > CPUs. This is made worse on PREEMPT_RT kernels, as they defer the IPI > handling into a kernel thread, forcing unwarranted context switches on > otherwise extremely busy CPUs. > > To illustrate this, tracing with PREEMPT_RT=y on an isolated CPU with a > single process pinned to it (NO_HZ_FULL=y, and plenty more isolation > options enabled). I see: > - 50-100us latency spikes with the default trace-cmd options > - 14-10us latency spikes with 'poll-rb' > - 11-8us latency spikes with no tracing at all > > The obvious drawback of 'poll-rb' is putting more pressure on the > housekeeping CPUs. Wasting cycles. Hence the notice in the documentation > discouraging its use in general. > > [1] The IPI, in this case, an irq_work, is needed since trace might run > in NMI context. Which is not suitable for wake-ups. Can't this simply be done in user-space? Set the reading of the trace buffers to O_NONBLOCK and it wont wait for buffering to happen, and should prevent it from causing the IPI wake ups. If you need this for trace-cmd, we can add a --poll option that would do this. -- Steve