Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp466311rdb; Sat, 27 Jan 2024 14:54:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNPDJCNZr71uTQuEpQkFMzTTEw0J4WWQiOrjbUIxTa0i7ILu/lixtiSFF7txQ/64kbSyRb X-Received: by 2002:a05:622a:181c:b0:42a:9c72:ae50 with SMTP id t28-20020a05622a181c00b0042a9c72ae50mr68854qtc.3.1706396098101; Sat, 27 Jan 2024 14:54:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706396098; cv=pass; d=google.com; s=arc-20160816; b=BjqZXet69aU0BqT22JM40usbC0pX9B0Fj8vls4Ri6ksbuBn4EyhnyV8hLyjeI1afP8 Ts1XW1YwCum9arO7K1lf9VqE1Ju3rWVdpGk95U6NfXuoFp9kNsuYeewfMQmUcHaWBg6p BIUQb66OYEPCyEFs1jFaFrZxAdQxn4nsjOq310TYhkKxFA9ExKSK5oYYZ1SIvYhCKS11 +BUw6+NX4ukSnMm3YqCJJhSwYv6PuAZV5/JJagU53kLj1sGIcGhfB/hS2EMKwWqssvZ7 RWjHc9Y7DFxTh2pewCPGNT68jMHmsTD4sjGJHyP7E7KZwWnuV7hqwBrwqMRy19T/Rf5T CZCw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=V/ZnbDe5kXZxwyHNfq/GFAJLc2tqXqUooBIAi8FIxkw=; fh=0nPBwQUQIKmmJQvx3DdripK/N+myCaMIQyxCvqOskZE=; b=I39PssvEvuBLVN8CVh3Q8zQGAF/+Fct2Lice3/3v4WSsncWhAOE0zr1nShxg86cBek DboYSINeKllKw26gULQJUgUHa5HqrExIys7xi6F05wRlT1r/6cXlrvQji0DJuPn3dfwx pGF4mYJ0RPRlGgjIrs9OcXKdL90bfJd0ua8JnlSHgOTWfNJjrcksJzj5hWgC3U5Syq1q MVGLX3cIaC9RjyeP980SXmgv23jRzBvW+gT9Fw0b66K2xroY2zU2HL9n3HUH11qiXLmK C8WJpZbIZ81DumfyYH/7BfgSewvgreTpNqPn1AP0z5ormS3geO7MsNi7ChUiZ3aaFt2d /qBQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="PS1aeVR/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-41438-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41438-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w9-20020a05622a190900b0042a920dc76fsi1743237qtc.411.2024.01.27.14.54.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jan 2024 14:54:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41438-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="PS1aeVR/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-41438-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41438-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D5E1E1C22123 for ; Sat, 27 Jan 2024 22:54:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CE76F1F612; Sat, 27 Jan 2024 22:54:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PS1aeVR/" 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 DF5BB1B5A2 for ; Sat, 27 Jan 2024 22:54:49 +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=1706396090; cv=none; b=BweTKEpWHoXFzYthx6+Bx1wJKcHFlTC02baHOxqynKm7fiUHZ8I3tDwADXICXl8OmSzJdu0wEuXN36YtS+mCYF3CMpathuZtVRVt3Q1qcdEXX/0Rltl+z3Tyibkgi4S7lRQTcOieLi5HyVbQC7D7dLRMTPbCGPT6RtcgsBHc57M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706396090; c=relaxed/simple; bh=370I368JkEbf62IfBIhLWjkUe3JoHqmbaGLHUsRzWC0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sbtJxrRbTuuHhAAecAX4HKOBVfqToKJk66ufKatOjdjDFzvZQPEAxXzCtD5Wia1eYvS2tQraR3oCsLD2JDWv0zJ+rHWjU/h/pyP64SGwwOeyEZau9m6DsUxHySpX0YmrPWcj01N0O5KCwRqkP/InLAhBUgRdR7oUsiRiFukx8Ho= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PS1aeVR/; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2B5DC433F1; Sat, 27 Jan 2024 22:54:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706396089; bh=370I368JkEbf62IfBIhLWjkUe3JoHqmbaGLHUsRzWC0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PS1aeVR/n42M1nk6sozs9oDvVvNPkI0dzOfqWPoe1F9jWCRiTPSXGMCQ0Zs2rJDNF p9roPhxObuboqnI6f4nKBdN+dNKHEadHb0epQJ1BJDkl8v54l0RPBFe6U0fQXZz+wi 8TXkwmcwCPxqCWNTCTqcnfyblcouLrY9UNIwBw0iLBWev3ydGWOqteCZLOZ1UinfV+ AqcN1iYe60TTfUSI8MiEfYx9iWcuVAnVQokqpMXyDp0C4Efw50ijnhNUhIt7HpbCNf BiWxN7IyO5SHFvwnq4G89ifDSieBrfmAmcYKVdL4XWD01SPhb8dUnVBSnBKa76bHUT 88Nzw0R8rMuUw== Date: Sat, 27 Jan 2024 23:54:46 +0100 From: Frederic Weisbecker To: Anna-Maria Behnsen Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , John Stultz , Thomas Gleixner , Eric Dumazet , "Rafael J . Wysocki" , Arjan van de Ven , "Paul E . McKenney" , Rik van Riel , Steven Rostedt , Sebastian Siewior , Giovanni Gherdovich , Lukasz Luba , "Gautham R . Shenoy" , Srinivas Pandruvada , K Prateek Nayak , Boqun Feng Subject: Re: [PATCH v10 18/20] timers: Implement the hierarchical pull model Message-ID: References: <20240115143743.27827-1-anna-maria@linutronix.de> <20240115143743.27827-19-anna-maria@linutronix.de> 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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240115143743.27827-19-anna-maria@linutronix.de> Le Mon, Jan 15, 2024 at 03:37:41PM +0100, Anna-Maria Behnsen a ?crit : > +static bool tmigr_inactive_up(struct tmigr_group *group, > + struct tmigr_group *child, > + void *ptr) > +{ > + union tmigr_state curstate, newstate, childstate; > + struct tmigr_walk *data = ptr; > + bool walk_done; > + u8 childmask; > + > + childmask = data->childmask; > + curstate.state = atomic_read(&group->migr_state); > + childstate.state = 0; > + > + do { So I got the confirmation from Boqun (+Cc) and Paul that a failing cmpxchg may not order the load of the old value against subsequent loads. And that may apply to atomic_try_cmpxchg() as well. Therefore you not only need to turn group->migr_state read into an atomic_read_acquire() but you also need to do this on each iteration of this loop. For example you can move the read_acquire right here. Thanks. > + if (child) > + childstate.state = atomic_read(&child->migr_state); > + > + newstate = curstate; > + walk_done = true; > + > + /* Reset active bit when the child is no longer active */ > + if (!childstate.active) > + newstate.active &= ~childmask; > + > + if (newstate.migrator == childmask) { > + /* > + * Find a new migrator for the group, because the child > + * group is idle! > + */ > + if (!childstate.active) { > + unsigned long new_migr_bit, active = newstate.active; > + > + new_migr_bit = find_first_bit(&active, BIT_CNT); > + > + if (new_migr_bit != BIT_CNT) { > + newstate.migrator = BIT(new_migr_bit); > + } else { > + newstate.migrator = TMIGR_NONE; > + > + /* Changes need to be propagated */ > + walk_done = false; > + } > + } > + } > + > + newstate.seq++; > + > + WARN_ON_ONCE((newstate.migrator != TMIGR_NONE) && !(newstate.active)); > + > + } while (!atomic_try_cmpxchg(&group->migr_state, &curstate.state, newstate.state));