Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1243346lql; Tue, 12 Mar 2024 11:08:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXfnmRVYFyvoxhPGx9edDJ5kn4iw3CHuDM5uxQc+NkR6euOHnA6MiQW/KaCq/cghbKffwepcL04RIdzDtuEaVjvy15rkAxOBpr+bdXVKw== X-Google-Smtp-Source: AGHT+IGg7AsC45sCPads9XHU+JfkjR2Xbme0Eova+WvXJvgaSBFnRyorvAA5H29GLYfPx1b0mV07 X-Received: by 2002:a05:6a00:3c8b:b0:6e6:1df9:af92 with SMTP id lm11-20020a056a003c8b00b006e61df9af92mr180773pfb.14.1710266921276; Tue, 12 Mar 2024 11:08:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710266921; cv=pass; d=google.com; s=arc-20160816; b=Z1CJ/czsv5s2ktEBLIk8vW5KMRAm1zoGbl6uAvMxQeVXjss9dmaq227Xagq5JoHpA+ j11o/njxwiMOQg9TVqprbnCc9zxbDJBVy6wBaXcnv7DliOuiRoRDrh7HdIBOJiIy58XR DgpB0DQ968OcXWr5bFH8YaaPGkVOZ8oLr5DJ/qse8a9svno0Nt3ReIJROypWXJ3Qa4ol 3tFj+R6F1hUJuH1cn9kiF/S0l7F3achfK66GbaAAL+GCYSd8lWQcXPk8SSNSmiijswcw w8+rvpSRDzAVVUGXQRHijOW5iu2HbdrCsGLIuWbqJSSNlhq9bf76ZKpEppUGYiLp3Kub OvAQ== 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=cilliUvb2Cn2gGk/iiSGOkFamBoPX3ao5SvmN4nWZEc=; b=GVMijAcARU0gchdOjrVYCxlLw2PXfGKghJcQXqIsDRLswGXQx8vy6BYcEQOULL4osz OUn3mIA7dfNZIWwJhmhMcweZfoSeK0tp0XlDWlPujo0bvcOc2/vvmQ8I9RXHLZblYExC ydKs8+uoBm90B2uNiGcPhsyRolxZV1Ya9iMNYK+0EdAxRDmT/xYPX4UrhWA3hhY5Ahy4 K16D7jN8muIPP8qP2x8twBsj4UylDhqBgM8yyK1C2SdZT4CLEEa46SfsmhHpWIm6NNeS 8ToOoiLeD1v1VrY87s0+66Yv1HQJ6z9vLPLikOxe1+HH3deq+yt8hxJN0MzA8Zj2I58L x/iQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=FlRpaK8V; 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-100629-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100629-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 a18-20020a056a000c9200b006e6a51c0c1csi1635432pfv.334.2024.03.12.11.08.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 11:08:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-100629-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=FlRpaK8V; 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-100629-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100629-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 6E1CEB229DF for ; Tue, 12 Mar 2024 18:08:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5B8F5139589; Tue, 12 Mar 2024 18:08:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="FlRpaK8V"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="zkQxTGQN" 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 0CA6B1386C9; Tue, 12 Mar 2024 18:08:20 +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=1710266902; cv=none; b=TjR0yoR63k8thHBZpGlKzluSDfDM4tVeX09TCgcxHvWdKswgk2GKu4E9xnFJdmnNQX+xtj2eaYkkSP9AUykgl3yQMxqyqOIsUqPmtW/BSxplSepNPjUGTb4kzk1r95Us0DyTLtcRbwvF9vFLZ/8FqA6DiQyGllC+EntJXi0Fvgg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710266902; c=relaxed/simple; bh=1x/H3KVUUkvLDmgpGS1Nke9B7aI3HIltrKV+AEtaWUg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zzjoo7CXlaKlcGfK2EIwT+/sBmeVZGt2ua9lkBOJeqT9QDeEIiJ24wh47EIq85ZlCkTZbnlJkoobj0EFf5onWjsmUHadzL+u1B7ZHs1OLYmOdcp5gOVuwzmPL9D/qNP6rdD0yFqyXA/MGRrfcksYJl15+j91DQdHjz+wA5JefjA= 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=FlRpaK8V; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=zkQxTGQN; 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=1710266899; 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=FlRpaK8V0LL+grFWiufBw6+J4iYqdxrDkwuneWjK1G48cxiZtepWKEOa2k/7TPhSwRz6Gn EpYwmF4LUCXk4zVE0Ij+6iIHU5lVhQ45qExcy9z7ToJiRHyoomz9F9nOK6dpk1b7uNFsCm DoxYXnkzrainnR3BdfiydZwdEXUWSibSQPn+bZfv8z2rZz7T54sLUAYWB96ltn4hH+AoXe cwVGdm6r233oUFOFnzQzHE1gfHNPNQIutPXx356RU5QUAfo4axFH8h5ZPKnSImGgM2yQRJ R7HPpcIPlxzDiZqb6/JDY6fj524+48V33G+N6kv6X3ojPtmI3JAcjpypEhZgMw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1710266899; 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=zkQxTGQNAcgLTsONtHCfBggjrEVyeFiJ7l+Hc7dC1ndjspI4TpWGszvL4/I+7FHgYNvTKT A/Z9i0hwgXo8WxCw== 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 Subject: [PATCH v2 1/4] perf: Move irq_work_queue() where the event is prepared. Date: Tue, 12 Mar 2024 19:01:49 +0100 Message-ID: <20240312180814.3373778-2-bigeasy@linutronix.de> In-Reply-To: <20240312180814.3373778-1-bigeasy@linutronix.de> References: <20240312180814.3373778-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