Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp381123pxb; Wed, 22 Sep 2021 04:28:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwf7ERldxYmF82i9AsbNEjtR/dal7pMwrO/NdWsDexMjIcGrKA6F7bqRX60dBPpGZSoYm5u X-Received: by 2002:a5e:9810:: with SMTP id s16mr3966996ioj.171.1632310122026; Wed, 22 Sep 2021 04:28:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632310122; cv=none; d=google.com; s=arc-20160816; b=jyBS9DpCfe0MYcZNM+rEIB2uA4xCB+64lgIYkpvF5GQNwpeE7j3p6SwO152KcOjMLU IVih8pq8M4wVth0ezg2aOWydxjxcLeKsX4D2Uos1rSdE9NabVNczzVWwxeZPHZA2HUQj BWTMFiB4riVdtMb/KUoSr/qbaal8dJtgnK1/IxXDzXlm3LgI9WQOY4+oMYj6hVPd0wx5 f7sE9f9dK0vN6vzwgXGG8YcwsFyZTQVvGW5kuxbTLUogUDZX2JwNHxgfa+Pb7okPDUuD t2MCk0JbCptT6wK/TTIo+nTP8WOnrvLqhUaZCeoKfYA06btQ9cPFfnxPWKvZHHuEuRcg hUnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature :dkim-signature:date; bh=lZv1FAoayMtDLfu2V7KCrqzRbBVSYCgTHmUKvw7n0TI=; b=eGbTIvtsTErzGeSSa44JTrIOX7VkEQW0nD3KvW3TgxrAgDI4jn3jCBm6neLrykgf2w D5S2WPcwyD6hfQf2eBxKsJqjuE3XCBaN0mbgiknInkAEzQLwDL6xEitXDE72rEgaEByQ y9l654OndXvAE8BQ/z5UdI1BcmN+NyNgpHxYf1PKFRzGjn6WsmnWL6+Rmu1jfxztMcQA LgJE/iyrc1SdWmsgvYKj1h+aGOQ8bFKt9OYFWy/kTprWtWJFYSTg8hDm9j6RlHWrRjQ4 RzjhbWgxNk9zBHk+e/QNxN56Lny7JQE4toK+Klck/IGi4f4JhV8af4mH8eD8CsqVKk/D u7FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="RpD/ipNJ"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l10si2650283ios.26.2021.09.22.04.28.30; Wed, 22 Sep 2021 04:28:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="RpD/ipNJ"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235602AbhIVL3G (ORCPT + 99 others); Wed, 22 Sep 2021 07:29:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235422AbhIVL3F (ORCPT ); Wed, 22 Sep 2021 07:29:05 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5F3FC061574; Wed, 22 Sep 2021 04:27:35 -0700 (PDT) Date: Wed, 22 Sep 2021 13:27:31 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1632310053; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lZv1FAoayMtDLfu2V7KCrqzRbBVSYCgTHmUKvw7n0TI=; b=RpD/ipNJU/V9C8NM3rFlIfTfc8M6xHrRUWi49VqPb3sh6C71LywYxpfd4c/7X9bo/j12F8 zdfVJHeas6gDOPwHpvsH1kIk7Jg7lgUXm8xFFqjxVvX4CxkbyYryzABeG+SnTEMmaOJNaV K68O647TSPE3haj1p6pWz12nF1wdfDtzv1JG8d0dvs+Jna/oXnfsrhU2chW4v1f0D/Gd3z 6sAlUkZhZH8klmLYYyTEIM9KdrA7rFTfVqxiYqkCmNiuCWhB2oJrx1EA9dLaRplVMYUi9g t0HqJK0dkFWEDEJB9w99dGm+SZfXaRF1yWMWAPLeKW1RK3H9RDy7wpFAVmwhQA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1632310053; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lZv1FAoayMtDLfu2V7KCrqzRbBVSYCgTHmUKvw7n0TI=; b=vgdtmoLl6YC6cvTD52PgjGrxZM3dH+++Cx9uLI+f6wmGz0BblrypMUyshFohdUyDgLH21H nTbLXEYftIkFqwDw== From: Sebastian Andrzej Siewior To: Frederic Weisbecker Cc: Thomas Gleixner , Valentin Schneider , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, rcu@vger.kernel.org, linux-rt-users@vger.kernel.org, Catalin Marinas , Will Deacon , Ingo Molnar , Peter Zijlstra , Steven Rostedt , Daniel Bristot de Oliveira , "Paul E. McKenney" , Josh Triplett , Mathieu Desnoyers , Davidlohr Bueso , Lai Jiangshan , Joel Fernandes , Anshuman Khandual , Vincenzo Frascino , Steven Price , Ard Biesheuvel , Boqun Feng , Mike Galbraith Subject: Re: rcu/tree: Protect rcu_rdp_is_offloaded() invocations on RT Message-ID: <20210922112731.dvauvxlhx5suc7qd@linutronix.de> References: <20210811201354.1976839-1-valentin.schneider@arm.com> <20210811201354.1976839-4-valentin.schneider@arm.com> <874kae6n3g.ffs@tglx> <87pmt163al.ffs@tglx> <20210921234518.GB100318@lothringen> <20210922063208.ltf7sdou4tr5yrnc@linutronix.de> <20210922111012.GA106513@lothringen> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210922111012.GA106513@lothringen> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-09-22 13:10:12 [+0200], Frederic Weisbecker wrote: > On Wed, Sep 22, 2021 at 08:32:08AM +0200, Sebastian Andrzej Siewior wrote: > > On 2021-09-22 01:45:18 [+0200], Frederic Weisbecker wrote: > > > > > > Also while at it, I'm asking again: traditionally softirqs could assume that > > > manipulating a local state was safe against !irq_count() code fiddling with > > > the same state on the same CPU. > > > > > > Now with preemptible softirqs, that assumption can be broken anytime. RCU was > > > fortunate enough to have a warning for that. But who knows how many issues like > > > this are lurking? > > > > If "local state" is modified then it is safe as long as it is modified > > within a local_bh_disable() section. And we are in this section while > > invoking a forced-threaded interrupt. The special part about RCU is > > that it is used in_irq() as part of core-code. > > But local_bh_disable() was deemed for protecting from interrupting softirqs, > not the other way around (softirqs being preempted by other tasks). The latter > semantic is new and nobody had that in mind until softirqs have been made > preemptible. > > For example: > > CPU 0 > ----------------------------------------------- > SOFTIRQ RANDOM TASK > ------ ----------- > int *X = &per_cpu(CPUX, 0) int *X = &per_cpu(CPUX, 0) > int A, B; WRITE_ONCE(*X, 0); > WRITE_ONCE(*X, 1); > A = READ_ONCE(*X); > B = READ_ONCE(*X); > > > We used to have the guarantee that A == B. That's not true anymore. Now > some new explicit local_bh_disable() should be carefully placed on RANDOM_TASK > where it wasn't necessary before. RCU is not that special in this regard. The part with rcutree.use_softirq=0 on RT does not make it any better, right? So you rely on some implicit behaviour which breaks with RT such as: CPU 0 ----------------------------------------------- RANDOM TASK-A RANDOM TASK-B ------ ----------- int *X = &per_cpu(CPUX, 0) int *X = &per_cpu(CPUX, 0) int A, B; spin_lock(&D); spin_lock(&C); WRITE_ONCE(*X, 0); A = READ_ONCE(*X); WRITE_ONCE(*X, 1); B = READ_ONCE(*X); while spinlock C and D are just random locks not related to CPUX but it just happens that they are held at that time. So for !RT you guarantee that A == B while it is not the case on RT. Sebastian