Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp941173lqp; Thu, 21 Mar 2024 23:53:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUop6mWzz4ZdbDFCkkC+2LYoC28IJAx15FGwL4xGEtNogBaB/uhWaUeostjr9BS/mUW61B6WxUx/Hy9WDmsltilTZeAWhRBP51JG39kIg== X-Google-Smtp-Source: AGHT+IGCUpYQzgf7KTc8LKnM6Kw1Oz/o9ICev7A674wN4Ezn6wUlY0gA5S6YDszyrSJjSQ8I0LC8 X-Received: by 2002:a17:902:b187:b0:1e0:188c:ad4f with SMTP id s7-20020a170902b18700b001e0188cad4fmr1378008plr.26.1711090418802; Thu, 21 Mar 2024 23:53:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711090418; cv=pass; d=google.com; s=arc-20160816; b=EhnMQLWpIftpVqTvzVPeH8tyE1TSHmYZh5reqEXFv/xgTfuOXN+qYIPil9E5jc1mJl 4RicrFIoSJxtm/zFHfIXU6l9VCSYs8UxpMdGL3XHC0ai/HUo/Kom+2HmoE7MchKHM0OI 6BhCmWrgAHnXfxUVe/tExcVte2u49lt1GWeJdFDRASBRpio6fcuBMHzU6bLhxzO6pEMF qltAkVW2A+P0/9O5oNYik3UGquIOW3PQhzi79DFA4+iy+iIAI06VT6CBvUMolBv5TugL 5BYnzW8FR97a6d5vyY1ywzC1ntrh/EpqRl4n8GhXQtktAFis215tgT93F7zrpIGoKeR4 xm7w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:dkim-signature:dkim-signature:from; bh=rP0uMrbdvGuw0gaehpXjO7C2OkXyANk5+OleJCkDezM=; fh=shuUCmE+hQsLem2SGJGjn0zib0LKOC3uV8i8/kUZ968=; b=lWPzdSEARWw2+yX8jkKupQgbGUNl8VNELJAeTxFHycnG2xN+37LNeQ/g1tgQXteuYw V950pYSVc3sh60WXzAKxPJ/3L32jnbI/BKo/60lHHiE5rvAYX6S2PvTb75GG9c+P0Tzp UlKJRZrhV8XorB6+hCij+TIWYb0BY6KfQH/f6+rXZaSpJCrMRVn0uARARRfayu4Fko4C vGcluN6UTXeXTl1eS61QrZj97YOYY0YtJ3j8We8svW6J7haahdVh5c7Xip0C6dANveUV /gw8XZMtKMZqGn3aZSL+0HIJQn8MEOnotQnFUToZJkmeKMAi6MA76UPix+gM0xIbgfdz CmZQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pR9WjbU0; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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-111033-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111033-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d15-20020a170902ef0f00b001e021f4570bsi1387547plx.179.2024.03.21.23.53.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 23:53:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111033-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pR9WjbU0; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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-111033-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111033-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 3321E283A80 for ; Fri, 22 Mar 2024 06:52:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A6A5E171A3; Fri, 22 Mar 2024 06:52:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="pR9WjbU0"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="s3klKYcv" 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 D3E4612E59; Fri, 22 Mar 2024 06:52:15 +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=1711090338; cv=none; b=SxFUiGFJDN9Wtht8HM0eFePdsO/jrDDgQf2HdJfoAwsonZmMoYgCO9+fiT7SjuqYC2kJXvglKoO44WuVbUmajo6l9wCu4xyFeDdmOx8oy8eYs2y9l8aeIeaztgSnDc7RkotVkEaBy28VDZYGPks9RM2ZLlXrrLK7m2ngdN0VRD0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711090338; c=relaxed/simple; bh=uov7lUYJCh+xUy0eBkN2SDq6BsxY/KiedSXqxnqt6Ec=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N3vJcTSjZYp5lmvlFe6suLronx63CNUCuF1r0A1XMY3gzJaO6KgYWASAzf/o92G80NWsu30zylpUf00KcUWof9kySyTTfBtM7062zQWUGgqDDvDLsGskCnwbvMrw0fgyAGIlV9SuM88+yTay/ZxBvcN5UYB8mwgWCV8/VetW+zo= 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=pR9WjbU0; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=s3klKYcv; 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 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1711090333; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rP0uMrbdvGuw0gaehpXjO7C2OkXyANk5+OleJCkDezM=; b=pR9WjbU03BbCeOem1TuBr2e6C7jaLNauCxLnF5XgP5ZhDp7XaaH0wgwJmCrVRGOxE/I2AL j5yfVXuEa7B6Omy+hMJykSwI5AZI5FN4D7DR6LDK6NxxBdYe9o/WVCE5LXcjQrd7di5skl cebauT/DOQF20QlMC57965lnysNDLBNZndO4bqOovKOVZESBYibrkE++T90+pk7i5Er+Ks jPtyhlvc7iXtTNQXnAGO36tStjqYwt58HSCZjRxdQFrUkPOklM+434eyKgcM1b7QQ8biE6 HoCF0xOn4FnMIxtIYLcOmP/a+EOdP7tfX5rLpBPxfFfxvaej3EzDYjoeHcok8g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1711090333; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rP0uMrbdvGuw0gaehpXjO7C2OkXyANk5+OleJCkDezM=; b=s3klKYcvmpZ02aC2i9WAA1dxbfKQJSWzlaRIm754CJy9I49OjjGVVaQQRn3wyB67ZDtww9 geTI6AuIaE7TelBw== To: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Adrian Hunter , Alexander Shishkin , Arnaldo Carvalho de Melo , Ian Rogers , Ingo Molnar , Jiri Olsa , Marco Elver , Mark Rutland , Namhyung Kim , Peter Zijlstra , Thomas Gleixner , Sebastian Andrzej Siewior , Arnaldo Carvalho de Melo Subject: [PATCH v3 1/4] perf: Move irq_work_queue() where the event is prepared. Date: Fri, 22 Mar 2024 07:48:21 +0100 Message-ID: <20240322065208.60456-2-bigeasy@linutronix.de> In-Reply-To: <20240322065208.60456-1-bigeasy@linutronix.de> References: <20240322065208.60456-1-bigeasy@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Only if perf_event::pending_sigtrap is zero, the irq_work accounted by increminging perf_event::nr_pending. The member perf_event::pending_addr might be overwritten by a subsequent event if the signal was not yet delivered and is expected. The irq_work will not be enqeueued again because it has a check to be only enqueued once. Move irq_work_queue() to where the counter is incremented and perf_event::pending_sigtrap is set to make it more obvious that the irq_work is scheduled once. Tested-by: Marco Elver Tested-by: Arnaldo Carvalho de Melo Signed-off-by: Sebastian Andrzej Siewior --- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index f0f0f71213a1d..c7a0274c662c8 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -9595,6 +9595,7 @@ static int __perf_event_overflow(struct perf_event *e= vent, if (!event->pending_sigtrap) { event->pending_sigtrap =3D pending_id; local_inc(&event->ctx->nr_pending); + irq_work_queue(&event->pending_irq); } else if (event->attr.exclude_kernel && valid_sample) { /* * Should not be able to return to user space without @@ -9614,7 +9615,6 @@ static int __perf_event_overflow(struct perf_event *e= vent, event->pending_addr =3D 0; if (valid_sample && (data->sample_flags & PERF_SAMPLE_ADDR)) event->pending_addr =3D data->addr; - irq_work_queue(&event->pending_irq); } =20 READ_ONCE(event->overflow_handler)(event, data, regs); --=20 2.43.0