Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp807837lqt; Tue, 19 Mar 2024 04:45:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUutKbkkAavZyXuSVR5pyV6X0Ghx2tx27wPhlPY+/Pk2XvdE523f4o/Cvd+XGoJwnSTXULUMEbjuxLFNLEGOycehuZA9KffSF85lhDelA== X-Google-Smtp-Source: AGHT+IGwXyXJyv9wJDL4s9XTFvTg0K/3rsFtzxP+vIKPZvTzUiHQpbCtLskKVNSlnZUIKDOrPPY/ X-Received: by 2002:a05:6a20:7f8d:b0:1a1:3651:8234 with SMTP id d13-20020a056a207f8d00b001a136518234mr13140321pzj.60.1710848748820; Tue, 19 Mar 2024 04:45:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710848748; cv=pass; d=google.com; s=arc-20160816; b=dFtmkkVWFpfYqWQmGE7EKXQkUcNqsjEfeSIWg8fBNik4ZsYKdm5s42zZUVIe0IWkte PoKnp9BaLtOyHi/U2NjSWlhQc1FMk6vxX4TYOvdCvFxhHEeAd9OQPsQjJFBWlusRBVYo wrqIhnguVIeSXQZeNy4X4uCGSZZvjLSaTfi2Ro4VGxquQcNFfg9h54S/AfmH5+BaZlS4 0FnavGKcbHoQIWpKCvkToejfwYdejCH9owtv6C6jc8pu/XlNG64aw+XTf+YMUvtpE85P i+1aJFo9gZwldb15ROQ+NRwei5HSbPx7QShgnSsdnmLecW2SNRLJgKlj4jdCO8pQxjdZ Vs5A== 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; bh=xa7kcwbq/YCSQRQDeCdozDzZH+bLAWK/TS21bRMVVpY=; fh=wObB+PfjDNfkiNfmhn53a2BO2y7Rdlp4d97VzllClQE=; b=Nw1m7FypdAdmwZiRdjbVOYhFPOvTADfChPfCIrQTYMqsX2SCQiGe0f9AA1bZ8IsRV6 9oJ2zKu0QPIls/WF5aAkCU1NcIgZ8RkrowIDoJVF6HtAXSaLceunNRWuiGHgNGp+pc+h TNznW6laO0lJXp9wYG4tuOncQPGkWuErkJKw502FFCDj4KaB202lYWT62TAIQM+cDvbW ar7GdOJtg4182jBXjO56wVWx/1lhkOfx1DIWHDszRJgQ80MMVGn4admLwfpPQr6eLiAK t79apVBytmi4G0pKnO5umtCCjs7shr1uUZ9+rREJeQTSvK09LxLQxPBkrXQMpHW246yF jpTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-107480-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107480-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id bv69-20020a632e48000000b005e271b946a6si9736089pgb.765.2024.03.19.04.45.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 04:45:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-107480-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; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-107480-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107480-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com 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 6F5FF283B62 for ; Tue, 19 Mar 2024 11:45:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E4CA7F474; Tue, 19 Mar 2024 11:45:44 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 765A51CD13 for ; Tue, 19 Mar 2024 11:45:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710848744; cv=none; b=hhdkHWOO1Qb6Bvi5JB5HEtyqQL1wCOWfekhU/4qclKt+jtdWViq+3ZreUbBRhqdk+Lt7JKAKHQ7NjBmcGKBcyI85LOUK1qpL4e314gq/YZVYqhLQz59j3Di/NPYNUFXaBrM4TVXoRQOWNU92gIQrM6QkHh+OpPXdpw/ZoKKRHgs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710848744; c=relaxed/simple; bh=+pqyA3fJ6tcbDlL7z/QlW0zjx2SAHzb+A9tHoI6tAZM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HZA+AhL6dVXgNHK9I94Yr7Awt8//ltKkCaHxeIKQniDy97UwelcCnR+buCSN9dk1t74YChZI/EMXYw1qpaGuAz5SRkAIu7g3m3yjnRFyqXHZYK//viR1DdUvDW3L1UJ09WqDcNjfyWxK9bl6purnGAM7FTjom117HS+u35vWilo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4B7A2106F; Tue, 19 Mar 2024 04:46:14 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.70.223]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 66DDA3F67D; Tue, 19 Mar 2024 04:45:34 -0700 (PDT) Date: Tue, 19 Mar 2024 11:45:15 +0000 From: Mark Rutland To: "Paul E. McKenney" Cc: Steven Rostedt , Ankur Arora , linux-kernel@vger.kernel.org, tglx@linutronix.de, peterz@infradead.org, torvalds@linux-foundation.org, akpm@linux-foundation.org, luto@kernel.org, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, willy@infradead.org, mgorman@suse.de, jpoimboe@kernel.org, jgross@suse.com, andrew.cooper3@citrix.com, bristot@kernel.org, mathieu.desnoyers@efficios.com, glaubitz@physik.fu-berlin.de, anton.ivanov@cambridgegreys.com, mattst88@gmail.com, krypton@ulrich-teichert.org, David.Laight@aculab.com, richard@nod.at, jon.grimm@amd.com, bharata@amd.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com Subject: Tasks RCU, ftrace, and trampolines (was: Re: [PATCH 00/30] PREEMPT_AUTO: support lazy rescheduling) Message-ID: References: <2b735ba4-8081-4ddb-9397-4fe83143d97f@paulmck-laptop> <20240221131901.69c80c47@gandalf.local.home> <8f30ecd8-629b-414e-b6ea-b526b265b592@paulmck-laptop> <20240221151157.042c3291@gandalf.local.home> <53020731-e9a9-4561-97db-8848c78172c7@paulmck-laptop> <1ec4dc29-8868-4d82-8c5e-c17ad025bc22@paulmck-laptop> <5641c2f4-3453-4b04-ab0d-db9e5b464b9c@paulmck-laptop> <91437fa8-c192-4a71-8073-bdd9c3889926@paulmck-laptop> 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: <91437fa8-c192-4a71-8073-bdd9c3889926@paulmck-laptop> Hi Paul, On Fri, Mar 01, 2024 at 05:16:33PM -0800, Paul E. McKenney wrote: > The networking NAPI code ends up needing special help to avoid starving > Tasks RCU grace periods [1]. I am therefore revisiting trying to make > Tasks RCU directly detect trampoline usage, but without quite as much > need to identify specific trampolines... > > I am putting this information in a Google document for future > reference [2]. > > Thoughts? Sorry for the long delay! I've been looking into this general area over the last couple of weeks due to the latent bugs I mentioned in: https://lore.kernel.org/lkml/Zenx_Q0UiwMbSAdP@FVFF77S0Q05N/ I was somewhat hoping that staring at the code for long enough would result in an ephinany (and a nice simple-to-backport solution for the latent issues), but so far that has eluded me. I believe some of those cases will need to use synchronize_rcu_tasks() and we might be able to make some structural changes to minimize the number of times we'd need to synchronize (e.g. having static ftrace call ops->func from the ops pointer, so we can switch ops+func atomically), but those look pretty invasive so far. I haven't been able to come up with "a precise and completely reliable way to determine whether the current preemption occurred within a trampoline". Since preemption might occur within a trampoline's callee that eventually returns back to the trampoline, I believe that'll either depend on having a reliable stacktrace or requiring the trampoline to dynamically register/unregister somewhere around calling other functions. That, and we do also care about those callees themselves, and it's not just about the trampolines... On arm64, we kinda have "permanent trampolines", as our DYNAMIC_FTRACE_WILL_CALL_OPS implementation uses a common trampoline. However, that will tail-call direct functions (and those could also be directly called from ftrace callsites), so we don't have a good way of handling those without a change to the direct func calling convention. I assume that permanent trampolines wouldn't be an option on architectures where trampolines are a spectre mitigation. Mark. > Thanx, Paul > > [1] https://lore.kernel.org/all/Zd4DXTyCf17lcTfq@debian.debian/ > [2] https://docs.google.com/document/d/1kZY6AX-AHRIyYQsvUX6WJxS1LsDK4JA2CHuBnpkrR_U/edit?usp=sharing