Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1984652lqe; Tue, 9 Apr 2024 06:38:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVV7LKxdmp22AlynG0bl0eD49n8yfiWRjhyx70lgQukwtLRDAISBTBfvDbO5CqjTOOD3XzCfSZi9d1WyipGnwjjtdm2tGE5OWJq5gBhCA== X-Google-Smtp-Source: AGHT+IFPZzhAuNOw21Mtbxs7IiKiEq3G5i2mzjM0LElvnJ6mPvxTHDSKH7y5A5alQL0zCAUX+yDF X-Received: by 2002:a17:907:96ab:b0:a51:b326:ed42 with SMTP id hd43-20020a17090796ab00b00a51b326ed42mr7850814ejc.54.1712669890118; Tue, 09 Apr 2024 06:38:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712669890; cv=pass; d=google.com; s=arc-20160816; b=VYtG81RWGA9rh+ydFPCJ32U9TQhw5OXIps+7R9fA8PJXjZq+4D2JdcBfhWyDTCdth+ kN5+Ob0eEfEoh8B0WDkczP/9saY7LTWl/mHHI6mOceyFgY5qJ0Ubh1j4YGuCG/T8lf75 dbHIDCBL6FkoZqOtm5cDJ20eukz1mOg5vkyzBH95cAlrTn9czxVAQFDelewIP8/ovF3H Ssw5fyWhCcixreoHVQ2mUbXbpwfidoVhl3fdpmbcEYCy1+oEQ/Bs28eloCFOruJadxFZ zm2DPq0S+p7dfDUUAKThbLLyFHpJ0XermMCt5xAee9O4PtbpPn3eHCWID4dC4KmysRnn j6/A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:dkim-signature :dkim-signature:date; bh=9SMVgpEWOLLh7oySvccsorrgvMSBwV0srF8b/SH3+RY=; fh=5ZgsBp531Z/TnicYuMjJd/Em595GtQzH4MQc5+/9Dho=; b=Ulx6JF1gi/IriBUvNWNegqVgT/2pn16vyyGM2ttLhVpZJLEayg5p0ejmw7cpvTD9f3 IDJr6vLd7Pn6HFWR67jBk+d8hXvL48pL7+2vn9V4nsJUb8yJAZwVfR+kVeDagOdhRPhZ hUUuqOL0CF/w/0qR426IyJgM5RLyyC4ZlA89p5qiwij8dg5S+JaE4aVLtib4WI7UIgQv UoSFE/JoJxQsP7sz1A3U9yTMctqZqZRy2F3S2f/LkuO67oD17WxBvhLhrM9KHOwXOM9A R3YAeu6WnmH2yF+xOgseDoxK2CzncNc1hRf8lSlXGsuyz2Nz9apdPop5fMPz/T4KCPWb Xm9A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=nIC9LRyw; dkim=neutral (no key) header.i=@linutronix.de; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-136968-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136968-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id t25-20020a1709063e5900b00a5199178ba6si4584483eji.383.2024.04.09.06.38.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 06:38:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136968-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=nIC9LRyw; dkim=neutral (no key) header.i=@linutronix.de; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-136968-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136968-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 414221F21AFC for ; Tue, 9 Apr 2024 13:37:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 024E9131736; Tue, 9 Apr 2024 13:33:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="nIC9LRyw"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="plxGPPUi" 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 B870D13118C; Tue, 9 Apr 2024 13:33:39 +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=1712669621; cv=none; b=SWkLUybGChpiWPIaRlKUr9yft2A7QiJrlRzCBF8gqe+s1BHu0uUeeXhrIVLQVNGC38GMU9DcImf4z1DN5cJf4zURrjcU2+d6NA70R7GF1faqMDDOeAsP5pdHc9v3MaF1gc46twsRwFzvQDnXA+N0+RRX2Fl7AU+I264Y6ZLmbDA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712669621; c=relaxed/simple; bh=pWQnQ9LXN4+KTgXHpwSd2PzBppm7znjsfC8WNvHWtjQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=X/NepFyaJjMBGWh9yd5W9hatsdWdhIFBvo95Y+ydWeuZGyFBQg5LuHB+CfyK0OSWraQfJFsTsfYLdqiJ/ytRch2m/wvuFOvZuNGmKt87K0yMXK3GR2OuIUmbBnF8dDX1xJ70WkZsPooXrnDHnIrjGQxRB0+j1kw/DqEATgRRQ08= 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=nIC9LRyw; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=plxGPPUi; 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 Date: Tue, 9 Apr 2024 15:33:36 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1712669618; h=from:from: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=9SMVgpEWOLLh7oySvccsorrgvMSBwV0srF8b/SH3+RY=; b=nIC9LRywVeMI/z6XQ+u9lIdyMZ/5bXgDOvx6IbXX81fygT6yE6vTF6krHnYgNVr6CIv80g tHZ6pZuIiX1PHZK39sZF/t9OIPzaIBTSYeYSVZzVXP75+dK1QaRRqKb58KLjHWDc5pg9T0 4nLTBBtBt+7mKJxDdPYwtBEjmE/GydCh9BUQx6EqOJq/AAfhmUiwBqxuxs4SL9J2Cc2Wg5 L+xkxPoO1Nmq81wazQOoOMd4RBIBZk3CcmEo2JLi4AeqFZAHixoAa7RQ5joF2bOEBdUWBC WXmLVS6bJPMC58hShMKlbj3gjgCoe3JZ8v46yaYB4Kn562gzBsKqKB7XD8U4Xg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1712669618; h=from:from: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=9SMVgpEWOLLh7oySvccsorrgvMSBwV0srF8b/SH3+RY=; b=plxGPPUitPqhGo4DexbruoCSFELJK1rx3Z2L0afSobUiuIyjZelu3pAQ9uxPnyJmPRgd5z W71JKLViKvlKn7BQ== From: Sebastian Andrzej Siewior To: Frederic Weisbecker Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Adrian Hunter , Alexander Shishkin , Arnaldo Carvalho de Melo , Ian Rogers , Ingo Molnar , Jiri Olsa , Marco Elver , Mark Rutland , Namhyung Kim , Peter Zijlstra , Thomas Gleixner , Arnaldo Carvalho de Melo Subject: Re: [PATCH v3 3/4] perf: Remove perf_swevent_get_recursion_context() from perf_pending_task(). Message-ID: <20240409133336.Y4Io-16-@linutronix.de> References: <20240322065208.60456-1-bigeasy@linutronix.de> <20240322065208.60456-4-bigeasy@linutronix.de> <20240409062501.h4rA_ck4@linutronix.de> <20240409105405.TXUU--_W@linutronix.de> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: On 2024-04-09 14:00:49 [+0200], Frederic Weisbecker wrote: > Le Tue, Apr 09, 2024 at 12:54:05PM +0200, Sebastian Andrzej Siewior a =C3= =A9crit : > > On 2024-04-09 12:35:46 [+0200], Frederic Weisbecker wrote: > > > > > > @@ -6800,10 +6792,6 @@ static void perf_pending_task(struct cal= lback_head *head) > > > > > > local_dec(&event->ctx->nr_pending); > > > > > > } > > > > > > =20 > > > > > > - if (rctx >=3D 0) > > > > > > - perf_swevent_put_recursion_context(rctx); > > > > > > - preempt_enable_notrace(); > > > > >=20 > > > > > Well, if a software event happens during perf_sigtrap(), the task= work > > > > > may be requeued endlessly and the task may get stuck in task_work= _run()... > > > >=20 > > > > The last time I checked it had no users in the task context. How wo= uld > > > > that happen? > > >=20 > > > I guess many tracepoint events would do the trick. Such as trace_lock= _acquire() > > > for example. > >=20 > > So the perf_trace_buf_alloc() is invoked from that trace point and > > avoids the recursion. And any trace event from within perf_sigtrap() > > would trigger the endless loop? >=20 > No sure I'm following: >=20 > 1) event->perf_event_overflow() -> task_work_add() > //return to userspace > 2) task_work_run() -> perf_pending_task() -> perf_sigtrap() -> tracepoint= event > -> perf_event_overflow() -> task_work_add() > 3) task_work_run() -> perf_pending_task() -> etc... > > What am I missing? Yes, that is what I tried to say. Anyway, I misunderstood the concept before. That means we need to keep that counter here and a migrate_disable() is needed to avoid CPU migration which is sad. > Thanks. Sebastian