From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D4F34C2193 for ; Thu, 8 Jan 2026 10:46:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869192; cv=none; b=SHBzvnkl7zbQrf1DvRa7beGosUk0Kk3hgB7wYcGQVX65zXhw1EhEE6wSnEJJg2eCaKZnuqe7z1NeAlARIjp5CwoPtHa7jD5SsjfOWeAx5mhUCR52GdgWjmdIAJJAYtBrMOowW2Yq4wJUZZl3aODMFcrtNYwJDvFz6BgXUh/o6Y8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869192; c=relaxed/simple; bh=8DMIYjsADq5oGXB/idiFns1XxpaSaoX5Tvu7oL8sKjg=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jeRksqEwBYkLGR77qrA6waRtVvVC+8cQ748EsJ6HkLSOxOvsZfI2KAqwR+j3dDeB5KOj6fXaMrM64QYYZcIIl6PZL+QqkrgJtntoRfzr+XqB7FJaz1qoRK3TgKVsfagfXOUMMNgQuFAq30rxaDjY2VPFJTfT2bt1LB2MhvxC+vQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=MndPWu5T; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="MndPWu5T" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-47d211aee52so3385615e9.2 for ; Thu, 08 Jan 2026 02:46:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1767869178; x=1768473978; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=ib649LYcFubip2cWtXdZTA/LYveMY5mkmekbtPClLBw=; b=MndPWu5Tg8v1AnQuFke03obzDHj1T/fA8Ms9Kp/bSOpbQLzPlHB43X36ctRqHuvFvJ W6VVri/d6obEuLhkIitK4OiPLilRsXfc2jKYWX1mQDYOi9d09qwivtLvQcuwqLykF560 zywjAQjqZrAb0bJJ2PYCZIPzoznxIivXR/QFMDQ7R94UqL05+CGDwv5ZC0w+76DR1AL7 aTp5UY52aRQIe+42yaZbYZeVBS/2nAmCHNZ3ZecoEMM13QM1kvpuWvbfW1B8ra0G+ejU 2dJECQXBhG5VIjd1k2Bcu3bRVgZnoe+vx0Gr5UyRFPlL/xEhnuQ3B/n+4nKxl67pOMiZ d4wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767869178; x=1768473978; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ib649LYcFubip2cWtXdZTA/LYveMY5mkmekbtPClLBw=; b=YItivhQYSiw52djStChLUVmnzey+9fafwx4+CYZb2tsro0bO7jMQ03l/REJIfrbOFa iXsyEy4V7v9pVPJUENhPtDryzKmJmQvPAQrzxog4loRKj2aNnL1FhAIKoxM9PLbQhuHP ntCpJYCntMBfDgC9klGeSQ3YG+lvKp68rY+LSb7v6ZLQXNbp3J+lM8MPC8UP5EReZLEm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TP id 5b1f17b1804b1-47d84b30104mr42672595e9.4.1767869178019; Thu, 08 Jan 2026 02:46:18 -0800 (PST) Received: from mordecai (dynamic-2a00-1028-83b8-1e7a-3010-3bd6-8521-caf1.ipv6.o2.cz. [2a00:1028:83b8:1e7a:3010:3bd6:8521:caf1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d86637b90sm38000875e9.2.2026.01.08.02.46.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jan 2026 02:46:17 -0800 (PST) Date: Thu, 8 Jan 2026 11:46:15 +0100 From: Petr Tesarik To: Steven Rostedt Cc: Masami Hiramatsu , Mathieu Desnoyers , Sebastian Andrzej Siewior , Clark Williams , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, Frederic Weisbecker Subject: Re: [PATCH] ring-buffer: Use a housekeeping CPU to wake up waiters Message-ID: <20260108114615.02cd0c7c@mordecai> In-Reply-To: <20260108093932.252f6bc7@mordecai> References: <20260106091039.2012108-1-ptesarik@suse.com> <20260106170405.425f469e@gandalf.local.home> <20260107085009.58fcffd4@mordecai> <20260107105137.4cf9a67e@mordecai> <20260107111709.0d115cd8@gandalf.local.home> <20260107111935.3befc296@gandalf.local.home> <20260108093932.252f6bc7@mordecai> X-Mailer: Claws Mail 4.3.1 (GTK 3.24.51; x86_64-suse-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 8 Jan 2026 09:39:32 +0100 Petr Tesarik wrote: > On Wed, 7 Jan 2026 11:19:35 -0500 > Steven Rostedt wrote: > > > On Wed, 7 Jan 2026 11:17:09 -0500 > > Steven Rostedt wrote: > > > > > Or we simply change it to: > > > > > > static inline void > > > > Actually, the above should be noinline, as it's in a slower path, and > > should not be adding logic into the cache of the fast path. > > However, to be honest, I'm surprized this is considered slow path. My > use case is to record a few selected trace events with "trace-cmd > record", which spends most time polling trace_pipe_raw. Consequently, > there is almost always a pending waiter that requires a wakeup. > > In short, irq_work_queue() is the hot path for me. > > OTOH I don't mind making it noinline, because on recent Intel and AMD > systems, a function call (noinline) is often cheaper than an increase > in L1 cache footprint (caused by inlining). But I'm confused. I have > always thought most people use tracing same way as I do. > > > > rb_irq_work_queue(struct rb_irq_work *irq_work) > > > { > > > int cpu; > > > > > > /* irq_work_queue_on() is not allowed in NMI context */ > > > if (in_nmi()) { > > > irq_work_queue(&irq_work->work, cpu); > > > return; > > > } > > Thanks for the idea. There are some downsides. IIUC there is no > fundamental reason IPIs to other CPUs cannot be sent from NMI context. > It's just a limitation of the current Linux kernel code. As such, it > may be lifted in the future, and at that point nobody will remember to > remove this condition. > > My current plan is it to keep the patch on hold and have a look why IPI > backends are not NMI-safe. In fact, I'm not even 100% sure the comment > is correct. The issue may have fixed itself e.g. by removing the last > affected architecture. ;-) This turned to be an interesting digression. Since we still support old xAPIC (not x2APIC) systems, there is a reason in hardware. The xAPIC ICR is programmed by writing to two 32-bit registers. If an NMI occurs between those two writes, we'd have to restore the upper 32 bits of ICR. Alternatively, we could queue the request if ICR write is in progress and flush the queue after finishing the write to the ICR (out of NMI context). The code could even be arch-independent... However, it's not worth the effort just for this one corner case. Besides, it seems that other people have always been aware that irq_work_queue_on() is NMI-unsafe, so in case the future brings a better reason to make it NMI-safe, there's a fair chance that all the extra code in rb_irq_work_queue() gets reviewed. Petr T