From nobody Thu Apr 16 10:47:29 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B290643CEDD; Sat, 28 Feb 2026 10:56:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772276211; cv=none; b=vAzPa4BFie3+2CxuLtWnAtKGpJj4s1I3JYIv4WszhvcGH8yCgWWTy985QWO7XY0XRFCb/S4RVtVUdc7Eqm06qAOJrXNG7DxSqXfaYCrDtfR6BBLi/gwM5cgg9S+bF1o0tYJLjdEVHpUSt6kkzOUPnZV/B//do7pmKMK/t2tVaSM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772276211; c=relaxed/simple; bh=J2bK3NI+/EJ1hKabXhgvW73K41p9idZYxNHa+tTpIwk=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=nbciVkjtiBb3DRebG1oeQF4mI/9o8JJTp6hWSwJpJ3z0HdouBdN4zKsLyk+qP6aVE6TkzoAJeiWPpNeS+zaawaqd15W+UZ//oRgSDbUrM3ggS+f07h5DsrsTp+7FZZkisLzCJJAf6j/8zyYgGZWprW5dALsf54eFuGMWg7aElOk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ivXllBkt; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=oyIFzC3X; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ivXllBkt"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="oyIFzC3X" Date: Sat, 28 Feb 2026 10:56:48 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1772276209; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3ziPHWkxEacC3eI1p7yUm3ecTg8ey2n2a+q3NyFiZ1o=; b=ivXllBktRDy65LQUKlkcD6axhq1r7etG4EVhLGLVvUqGbqwHdAAzaEBj0TlMrb4IadnNwI 6IYpn3MB3Bu8uf9iZWtfeqt5ttta55u8tlfZxstqeybTwSsBo57uFMD8uFRFSkfzdMxuvs PVNGW0H7jfNgv8JeEoBejNNR6Sah3lOhrKsU0EFyXcWfqnCaK66ftbJgnZ+hPiRK/R3R1u cDWt8pcJZsurns6RUQmV8xvfbfd2GVwHU2+CA/B4K11s2BdFbgBfxhm9o6BKSFC+TvGNlF dKWyY3v47fgY5Kgft56ZGZrxPMhy5VLLGo3onsakD2k8AqVIQOM/0X80W6uP6Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1772276209; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3ziPHWkxEacC3eI1p7yUm3ecTg8ey2n2a+q3NyFiZ1o=; b=oyIFzC3XzNaDmDbKGMd5kyWfmqUC+YNN25NU7cA0g5uK9tE4XVlRw2h40v157wSwo/rtN+ s2MrNgXIkud2nRBQ== From: "tip-bot2 for Namhyung Kim" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf/core: Try to allocate task_ctx_data quickly Cc: Namhyung Kim , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260211223222.3119790-3-namhyung@kernel.org> References: <20260211223222.3119790-3-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177227620828.1647592.5545880097120712984.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the perf/core branch of tip: Commit-ID: bec2ee2390c95ed0c44494340464e69e79802e4a Gitweb: https://git.kernel.org/tip/bec2ee2390c95ed0c44494340464e69e7= 9802e4a Author: Namhyung Kim AuthorDate: Wed, 11 Feb 2026 14:32:20 -08:00 Committer: Peter Zijlstra CommitterDate: Fri, 27 Feb 2026 16:40:21 +01:00 perf/core: Try to allocate task_ctx_data quickly The attach_global_ctx_data() has O(N^2) algorithm to allocate the context data for each thread. This caused perfomance problems on large systems with O(100k) threads. Because kmalloc(GFP_KERNEL) can go sleep it cannot be called under the RCU lock. So let's try with GFP_NOWAIT first so that it can proceed in normal cases. Signed-off-by: Namhyung Kim Signed-off-by: Peter Zijlstra (Intel) Link: https://patch.msgid.link/20260211223222.3119790-3-namhyung@kernel.org --- kernel/events/core.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index 90b0c93..d357714 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -5489,6 +5489,12 @@ again: cd =3D NULL; } if (!cd) { + /* + * Try to allocate context quickly before + * traversing the whole thread list again. + */ + if (!attach_task_ctx_data(p, ctx_cache, true, GFP_NOWAIT)) + continue; get_task_struct(p); goto alloc; }