Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp2212lqi; Wed, 6 Mar 2024 08:28:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXXsqx4XYtlV7zuZJQee2vDh2z+y34Lc9ZwT9U64F8GB7yitagyaGLDAoYSIhUTlYj3d+lKshxwbAGihRd3fLYUZFA+ESLLrx/TkvaH1g== X-Google-Smtp-Source: AGHT+IGH6I07+feC9lvINCZRAQRrA1bb9kuKC5ZBEU43dAo923ZkJ9XpERas6lMpiE1Bd0n37s4R X-Received: by 2002:a05:6808:2189:b0:3c1:35f2:ecb9 with SMTP id be9-20020a056808218900b003c135f2ecb9mr6420280oib.49.1709742484744; Wed, 06 Mar 2024 08:28:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709742484; cv=pass; d=google.com; s=arc-20160816; b=eHieMLhdCUYWR21AKITMBl10ehBY3tprqYWLTup05iDEZiShpAQVMe3l+pj6XYoJta dJ6zgNAxxw9bUO0rMSkwH+5vtxFXG2zimo01WnwNQgfgYhQp9MPFr72JcGY2m0tBwg8y 28jDoqBTEvNXUfnvQMp5GmrYl2rz2tuiFafHXE6fXKfhhXoKMUVFGShBSO5LXWLIl5HA JF4purPz2/kOU1Mft+e+2QcA5P5NeD8/N9c6q8iNl0vZbzuWBx5hH9DSDoumYHUOdDgo L1xSnw8I7U/sdWCZW4OmHS2T9nYx7Wyh0fzM/5ZXcZ6eusk3LrwtFKBwtWMzBZUuj2zn DZUA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Qq0ZtexNxpqXmJ0kJjb5KXzEzVccS/X7T7j4szDJEtQ=; fh=CO9ttk9sdK3V8u8po2WKgbGwvMzad3objf/nrRSYqf0=; b=TEQG1sAPbJDzVdNusl0ENIIyb5JFyxD8vIVI33FL620fsR4OyzqBUTjEWxzXzU8958 Pi4/KM4uOZyFkm5E13fL2ZKx7Vm2KkSoJuh9sF6GdJwmw2q5LxPiGordz4CfGimE4+BN mbVktngsz8YdIr+QeoP1rjK/dRYZoZqvm8vtHVXvrNJLL3qGD8Chx4uCeMlNWu18hqxf 3T0voOJZ4Upahlir36I0it1h/yuy+AXXuxk2KVjYbOu8vjeiatV1hzMU+2dO+Fwh6bBS B6+aPvMmXUqZhAQaLkbYiEQPXBIoA2OzTdNqijLN48sgDqeZtVUZya/p1JeuGgk+89xY CweQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nhZld4lG; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-94266-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94266-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j5-20020a634a45000000b005dcc8a3fdc5si12184436pgl.485.2024.03.06.08.28.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 08:28:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94266-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=@kernel.org header.s=k20201202 header.b=nhZld4lG; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-94266-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94266-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 5EF2B288A01 for ; Wed, 6 Mar 2024 16:27:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6BD25137C31; Wed, 6 Mar 2024 16:27:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nhZld4lG" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8FAA6137927; Wed, 6 Mar 2024 16:27:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709742430; cv=none; b=UiqHFEWsjS9+U/DSAEBp2MZlhWFKpksXn8VWzEFXPpwaPiOUslY+sebuwYdlL666q6UYebRn3wF3rOuVJmNubAi2Ui8QXfJoa4AVgfS3j5jNl/I87DhukLHp0/CNMPHCsChHEv+Sf5EyPMaijl071W1VY/bomLikeC9cwHzhs6s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709742430; c=relaxed/simple; bh=mST0baNuDZQDxdlBh3gFG3t11nxhv4188xlTctM8KAI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=r4l08d/VMcu+rO5DdqUhcDeAKa54zxY6W0GJfRR0pemUxw/JBcWc0Wf3Z8ii57jj4dkwDktSVO0ZRjc+VgWKOaEprMwgc7Cx0rqU6msdZa+iIJFfzocGPWDHV4Hn+e1hWdxF6Ikwt30YVTfEcphzkSPrm/QYTjgSwVS22NcgQlg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nhZld4lG; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0319C43394; Wed, 6 Mar 2024 16:27:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709742430; bh=mST0baNuDZQDxdlBh3gFG3t11nxhv4188xlTctM8KAI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nhZld4lG7GINhc9K+uHkPNx96orLDEa10TFZ8fEVhsgtrQGnohY+sjOGAJeqHRUk0 EunhC94QsqjPcgQJIBoTGD+jl+/oBLty/HOXPxhSDDx0ILhdXmjg3OV4oqSyBifmEg fx8vh9KvS7IBDFmGCka2nhjMkPRLCctoO2ukJYxMlSqD0OGibw+RXKhWQxdT/CmCPX dKHXpLknEXw4ezT7k+4mUhxBxC+BbY9q94jfHImJVTIAC76bg+YAPhzQeVuK8VH4el VjK/aIAMMvuaG0KfflRxexmg7SG8eKGpm0uULUJyAotL8fN0VJ7N/BS9hTPX0DE24s NoWoYQntpKEkw== Date: Wed, 6 Mar 2024 13:27:06 -0300 From: Arnaldo Carvalho de Melo To: Sebastian Andrzej Siewior Cc: Mike Galbraith , Peter Zijlstra , Marco Elver , linux-rt-users@vger.kernel.org, Linux Kernel Mailing List , Juri Lelli , Clark Williams , Alessandro Carminati , Thomas Gleixner , Artem Savkov Subject: Re: 'perf test sigtrap' failing on PREEMPT_RT_FULL Message-ID: References: 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=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Mar 06, 2024 at 10:06:30AM -0300, Arnaldo Carvalho de Melo wrote: > > In Thu, 4 Jan 2024 19:35:57 -0300, Arnaldo Carvalho de Melo wrote: > > > +++ b/kernel/events/core.c > > > @@ -6801,7 +6801,7 @@ static void perf_pending_task(struct callback_head *head) > > > * If we 'fail' here, that's OK, it means recursion is already disabled > > > * and we won't recurse 'further'. > > > */ > > >- preempt_disable_notrace(); > > >+ migrate_disable(); > > > rctx = perf_swevent_get_recursion_context(); > > > Pardon my ignorance, is it safe to call preempt_count() with preemption > > enabled on PREEMPT_RT, or at least in the context being discussed here? > > > Because: > > > perf_swevent_get_recursion_context() > > get_recursion_context() > > interrupt_context_level() > > preempt_count() > > > And: > > > int perf_swevent_get_recursion_context(void) > > { > > struct swevent_htable *swhash = this_cpu_ptr(&swevent_htable); > > > > return get_recursion_context(swhash->recursion); > > } > > Seems to be enough because perf_pending_task is a irq_work callback and s/irq_work/task_work/ but that also doesn't reentry, I think > that is guaranteed not to reentry? > > Artem's tests with a RHEL kernel seems to indicate that, ditto for my, > will test with upstream linux-6.8.y-rt. > > But there is a lot more happening in perf_sigtrap and I'm not sure if > the irq_work callback gets preempted we would not race with something > else. > > Marco, Mike, ideas? Looking at: commit ca6c21327c6af02b7eec31ce4b9a740a18c6c13f Author: Peter Zijlstra Date: Thu Oct 6 15:00:39 2022 +0200 perf: Fix missing SIGTRAPs Marco reported: Due to the implementation of how SIGTRAP are delivered if perf_event_attr::sigtrap is set, we've noticed 3 issues: 1. Missing SIGTRAP due to a race with event_sched_out() (more details below). 2. Hardware PMU events being disabled due to returning 1 from perf_event_overflow(). The only way to re-enable the event is for user space to first "properly" disable the event and then re-enable it. 3. The inability to automatically disable an event after a specified number of overflows via PERF_EVENT_IOC_REFRESH. The worst of the 3 issues is problem (1), which occurs when a pending_disable is "consumed" by a racing event_sched_out(), observed as follows: ------------------------------------------------------------- That its what introduces perf_pending_task(), I'm now unsure we can just disable migration, as event_sched_out() seems to require being called under a raw_spin_lock and that disables preemption... - Arnaldo