Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp730043lqc; Fri, 8 Mar 2024 09:58:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWZXA1+6UA4zSd5SFqqFaDn4SPeSrcni4S15NkZZYJEAd5MDdofGyZXedg3dzCoCM+LGNPYX4iSPqMf6ym1BRzucCJJ3jPmfIdVVbrPaA== X-Google-Smtp-Source: AGHT+IH0ywvS3OzeFHCGL2nkltnLwRWjV47QIEGcnYYaOnlqO5Fl5pybC0i7mp8G/pmmmzdEZPUb X-Received: by 2002:a17:902:e5c8:b0:1dc:b01e:9ae0 with SMTP id u8-20020a170902e5c800b001dcb01e9ae0mr14467182plf.14.1709920728488; Fri, 08 Mar 2024 09:58:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709920728; cv=pass; d=google.com; s=arc-20160816; b=HiA8rLc3pkTcC3KPEXEog7N3YxRL1yxeobCgJX/ldlkg063Y5PubeOX1WGBFp/bLRF WeOHxKh33oe0KVxYwDNC6p+pVdjjzedMGrXgLk6oCUNg5iB4+uvyqS/5ISoE1a6jUaMn NBhkQIMVvAX1UQMX4hYpVKZyjKreG9ZPcp58mKRM88FlrTN0AVdqgkKkLiIxdfVqjNqn 7RP6qdnQEkLAswcKMUeXvp9IpMNTqq9sDp9ulj4i0eg+I/eZhifq3MvyM7R/+VDtfaoK F+4wcBNMBXhffhGOmK9C+E+Ws8Wfu1RbvSuICEknrBfid6wOCa0UpsR9VyFZ1/8tu3zT fvxA== 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=9Hqyi2fLhMWja1cb9pKy7mpQ/l/tY6lU3b5qleZavj0=; fh=jrSksSmswlj50egdIIbF3r6LfMFKk6lXYMto3LEmDE4=; b=0HR+NM3Af6QvfMuiM94TBCJ8QoVqDf9hQSokz1wHhY4qXppgcq/t5xJ4pWQTd6CCjh lm2WtucBBwvbNsl2IhOlzosr+y8wUEMWCnULQG4J4JYfXI0ZtX157vJebeAUhGQnjacR vbR/yVzLSJGaov8i7wlI6qXUdtt/fUN1wubTeUW4Dq3PIZDtkdLCj74ozgDyvgI2mw28 ak89c9NScs0miXlIxipZKPiHZHGoCyvJMYfWsCfJAvAM8W1lfOa/zgGPdRyyZghNER1h C4SxGvvOoJXE1vxSfdEnEWIaLhNhy0u3Tpb+iSSvN3onCJ1+6wDv5gjKULbCuMJxaLPL +dsA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=v4OmJ48C; 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-97425-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97425-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id k10-20020a170902d58a00b001da240b1596si16510987plh.221.2024.03.08.09.58.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 09:58:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97425-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=v4OmJ48C; 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-97425-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97425-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 69D0DB212E1 for ; Fri, 8 Mar 2024 17:58:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C7F4055E78; Fri, 8 Mar 2024 17:58:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="v4OmJ48C"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ziHz1O9T" 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 7F0BE79E5; Fri, 8 Mar 2024 17:58:21 +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=1709920703; cv=none; b=X3cnZ5aSdNs967pbI+oUrXX7CgmujHsTCn23m4ANBu+D95NZW+1+Nqt9zZTQevCGiNWUpFvd7Gs3LlXdnj39GF3uTt5gyRc7zoddaRskOyWWavIU4z3OLBH/3+Lz3pBZDE07KaifyMakXZNlRLlHxiBK+uZB+rvT8jutLRxEmmE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709920703; c=relaxed/simple; bh=1x/H3KVUUkvLDmgpGS1Nke9B7aI3HIltrKV+AEtaWUg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HWIIBRbE6Wlwtplbd9LT+lY0YDKggmYkDZS4bAWgsL5OsK06Wpgm5k7j8kAlsBbLATHhq8gj+V8ssO8SG/V98nxnDZzfJahhai/Hk3YzZsaXy2tffl2kn16HZ599Vk+mPCnLnlrjNrCMdv5a4k2N1tGha4sJswHViTsjnDjBkjs= 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=v4OmJ48C; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ziHz1O9T; 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=1709920699; 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=9Hqyi2fLhMWja1cb9pKy7mpQ/l/tY6lU3b5qleZavj0=; b=v4OmJ48CGNYbFrppyGlC2jevaEK7plTwqLa485cAKMYLlosrVridqFwI5yxacNF9se2O7b 5NK7Htc5j7G7lkiDU4c+ZJmsDJmT1CPKU9Y21+qC/lA6fxxovNTNYUrCs67QqCrEoNeJMM WUwn5nl52erfDuoU6gBJCKRrwhICWQLeTYHwkMcmiuYdaaRKKiX8V0/BmY2tIW9jQOX7S6 xE5VzwUn0fTEoqr78KPmQv1VGw6l4Pyx0rKU8wSo9mcy8lvavd90qM4sw42xtCpkqugiBP RZlSNW6S13I0g1dHXc2/mgtUn0NdtbQUCqVlR/8c5YUGVe18Ez7VaWOeJWf1IA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1709920699; 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=9Hqyi2fLhMWja1cb9pKy7mpQ/l/tY6lU3b5qleZavj0=; b=ziHz1O9TIToov9AHtRlOrWFr0J5dlqqZrDDkGxrMnNg4PuEw92OkwV/rwvtnBUqoEVDeGt HfhYub59FMz4CxCg== 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 , Mark Rutland , Namhyung Kim , Peter Zijlstra , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH 1/4] perf: Move irq_work_queue() where the event is prepared. Date: Fri, 8 Mar 2024 18:51:27 +0100 Message-ID: <20240308175810.2894694-2-bigeasy@linutronix.de> In-Reply-To: <20240308175810.2894694-1-bigeasy@linutronix.de> References: <20240308175810.2894694-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. 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