From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 6D116279DC8 for ; Wed, 11 Mar 2026 12:53:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773233635; cv=none; b=pJKa3OnGfPWN2TqlSQiDX2MO7UeoJRHLdGEX3cl8NhPQs3G07NDX5MDdJIkzS08jiQbH4a8GzT11Za/hSprvoqExolzE7aWnotaexf3EPHzOsmbBO/7uOvwSMx/Y5ENvBH83WgOl+Mb0y8tLQPcDQVf9TwMcDQs0RIRFU3pmk9s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773233635; c=relaxed/simple; bh=8FozrOzJd4aARdx14DKMa072roWvZt/aUG6mjZwTUR0=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pJ2uDr/W56aLmMdLE6pKRDf08rRvFdZRRQoyZy5cGw41U6f19KMQLQ9shavwFwITZNqDxH715kUg4q2MZ35VVOcjjGUNVrvwqua2xAbzdiF2DTXNHaY/2l76T3I9EACKk0TnRnlK8CmcS4RUEHDnkgTIzyeQ+PMxZvgAf4yFd4Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lKY981kk; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lKY981kk" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-439b9cf8cb5so9808292f8f.0 for ; Wed, 11 Mar 2026 05:53:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773233633; x=1773838433; 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=rYvluDr19g8cY3EGjzutO/A8uDQ7z+RxFTa+Y5Q3tCw=; b=lKY981kkwwKJ/Gb6XauDGtXu5FjweZU50AKsXAR+6TbsCUbCWUdT4j6Ak82Ql8E1fU 8e4QdYIB6aU2tYD0mQG7+EY9gH1GA0tLQPLZBnRVKvfCVCxN3s8eO39/aZmn+nfVEwKK Je14XNUWklpYTDZqcAhb5hQqq8OJmmeKPhYbyo7o7nq2ktmSFpDkXdkypwBytHRRft2I pyMnZSgwOT4XsrRGqm74jh8UHZYfkhKMDwlYXl7TNgNivyGHt7nYTl7Ii9ZXYCZTl20A FKkdgzIL1nLYtTGBpfnYWscrYVzKgXGdcY7uStUHIbsjA3ioBMQgCaiuCFLPOkAyiVWe C0oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773233633; x=1773838433; 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=rYvluDr19g8cY3EGjzutO/A8uDQ7z+RxFTa+Y5Q3tCw=; b=WE5v1fhgkCY3VN+c8rDaE5BipY801jh3bhkQ/lxldPpwkdSMKl7t3i6F7hrHU4JXyP zsGRzf3+mjgDMPEIkrhvD31cCJYq908DC/kthmRIGL0fdIqQF/9glqniB1CqjrCh7BGF QPRi5monJ87jeo3t5TGfDqsGI6fFdj9MSxh4OsPShBGl3JLrUUtxXsbdi5pTuAJ7ZCZA AUvR4q0bYx5witJNz8u/nqtLGX522P5MelfwESRpIN0JpDWFc7OMU62pZ6+XZhwgu9GY gmvyaf60BKBnqSw091XkNXzifNUUcFLT+Cb9kU9ox0VfHLuRsdLPbwJPTQ/32pEjAw8N stmg== X-Forwarded-Encrypted: i=1; AJvYcCWoNDC7yNdZ+t4QmrKtetg7r/7sjnNgzO/w1L2qlDEoimCKmumf70CjNTv37h+Wz0309NVqXVHFQBAs8PQ=@vger.kernel.org X-Gm-Message-State: AOJu0YztWWpMFuzglTDMxlaPO7Fpon3sBzY14xADSuqt1noXps5CVVnA Iha2d3TAla1SdRTPwV3OfUDb3xth662AN/uWxXsKeoIwGnVGrlySC3C/ X-Gm-Gg: ATEYQzyoz1wgNtSDQYF7njMQ86w/o5tgK5OMkcwXrruug2XJT6cTNHDeZ2vySWEpyYY zFoH4Y72A3R/9jgngsVXNlwsyoYrUx3ccvGt+eHMUDrvifIID0TGcNDY4XgvAq7IZLIDkmsXpjH UGdh2uZwN7bOlXyrVtIGe+rVmKm27RH0E3AY6MSzEr3a/K2nMjaoKK9Jzgx9dUO9X1H+uohRYrl +Dr//mdeR5XQVkYxvMgIbctMBaqAXyaG5NIkvBWacgXfzxqhgG2NCGS2SETU9Yefi2ga4BEMXOZ RqhlGzW9tOByDywQ4q/TiUcCIhLuMrwb3+vy262W1/jHmRW/l1WTlRJbdZacxIH78KkH8ycQkxT M4IdMTVdo3Mlgmy3sWbjVom22jCN7I7tAo6/u3skB/N85IrpgtHfY/OSq11bj+dBbkM309oAnAJ 7jB1cbxpIL7iWCU/OVSB6FJYIACIy2bUFM99kcnt88dgL0/DOLJCwMx0Zgw2sh4jC1 X-Received: by 2002:a05:6000:2482:b0:439:b932:b428 with SMTP id ffacd0b85a97d-439f81b6659mr4797322f8f.8.1773233632585; Wed, 11 Mar 2026 05:53:52 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439f818ff0fsm7048224f8f.4.2026.03.11.05.53.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2026 05:53:52 -0700 (PDT) Date: Wed, 11 Mar 2026 12:53:50 +0000 From: David Laight To: Peter Zijlstra Cc: Yafang Shao , mingo@redhat.com, will@kernel.org, boqun@kernel.org, longman@redhat.com, rostedt@goodmis.org, mhiramat@kernel.org, mark.rutland@arm.com, mathieu.desnoyers@efficios.com, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: Re: [RFC PATCH v2 0/3] disable optimistic spinning for ftrace_lock Message-ID: <20260311125350.1d89341f@pumpkin> In-Reply-To: <20260311115426.GN606826@noisy.programming.kicks-ass.net> References: <20260311115250.78488-1-laoar.shao@gmail.com> <20260311115426.GN606826@noisy.programming.kicks-ass.net> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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 Wed, 11 Mar 2026 12:54:26 +0100 Peter Zijlstra wrote: > On Wed, Mar 11, 2026 at 07:52:47PM +0800, Yafang Shao wrote: > > Recently, we resolved a latency spike issue caused by concurrently running > > bpftrace processes. The root cause was high contention on the ftrace_lock > > due to optimistic spinning. We can optimize this by disabling optimistic > > spinning for ftrace_lock. > > > > While semaphores may present similar challenges, I'm not currently aware of > > specific instances that exhibit this exact issue. Should we encounter > > problematic semaphores in production workloads, we can address them at that > > time. > > > > PATCH #1: introduce slow_mutex_[un]lock to disable optimistic spinning > > PATCH #2: add variant for rtmutex > > PATCH #3: disable optimistic spinning for ftrace_lock > > > > So I really utterly hate this. Yep... Adding the extra parameter is likely to have a measurable impact on everything else. The problematic path is obvious: find_kallsyms_symbol+142 module_address_lookup+104 kallsyms_lookup_buildid+203 kallsyms_lookup+20 print_rec+64 t_show+67 seq_read_iter+709 seq_read+165 vfs_read+165 ksys_read+103 __x64_sys_read+25 do_syscall_64+56 entry_SYSCALL_64_after_hwframe+100 The code needs to drop the ftrace_lock across t_show. Although there is a bigger issue of why on earth the code is reading the list of filter functions at all - never mind all the time. I'll do it by hand when debugging, but I'd have though anything using bpf will know exactly where to add its hooks. David