Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp875591rwl; Wed, 29 Mar 2023 09:31:41 -0700 (PDT) X-Google-Smtp-Source: AKy350Zq19dySFNJKH1FK6CD4JWUFzePUnkNkmsCX7UarULAT6sGqU47ItHOEGDSAyU7dp5P7r+F X-Received: by 2002:a17:90a:5e4d:b0:23f:58a2:7d6d with SMTP id u13-20020a17090a5e4d00b0023f58a27d6dmr21764872pji.6.1680107501229; Wed, 29 Mar 2023 09:31:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680107501; cv=none; d=google.com; s=arc-20160816; b=BW9p6E/nxtcc9/WLKTpQsFqb72SvP4Nldh6pju5u+AH6l9F2xh3XOjCQlvmNlAUSm9 IDCKQt5hPuNH8iv32OehtsEHqYzAqHbBdtilw9pXKNOvCzaAouO8ZKba3B+7Mkhr/zoi S6ylF33t1CtOfWOEwdMzMtMbyQI52hXjKNWoD+dX0vx17z/NqNqGqmQtKD3Ko0jK38qK UMkOBpsaBlyb6nksKxoK97tEILRp99MAVB8wHz0H3QkRjtyvYZyz897uWYKTyXvfmqIP AqiEwuwu0pphsEmvyk1et2o0VuIEdIbpIhwCrMfcQXpRzVO2A8cRsNOoqi2J7dV6xxHa vjqA== 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:date:dkim-signature; bh=lQLuQ8oRir+a3T6oXaw/nm2MOVcKHkkZ1TysUB3V22U=; b=NRMfPf7SW8lCOZ90bygcqUvJ+oF3PC5OCiiB4BPeQE+QuduvBi54iRp2nGCAmZEp5z fHmPfWaa+ysOx197pYCNtfgzheOMT4dLRLf71PqIaM0T8ebFm9Dr073Z/QL4qQm1psP0 b7EVC52oFIsGJfqa36ee2zq3Y0gPOUlL9yF835IXUKaXvLFQhiv4z1NJOawaY3obs7ON 1/aML6bO76wHMNPhZHBpXfsJEUZGFVhKkqdKNjVptajVXcnEDy8HW14bqTpxWkdS4KI8 4YWl4Hb27sh7x6CAOn8FenW6MtdjyFG1Wz0AoG9Q8QLQwPi8KJjLxPxbDyNyqpyQCtXy qOUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qHYPFecc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oc6-20020a17090b1c0600b0023fc0a96e42si1705166pjb.181.2023.03.29.09.31.29; Wed, 29 Mar 2023 09:31:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qHYPFecc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229495AbjC2QJc (ORCPT + 99 others); Wed, 29 Mar 2023 12:09:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229827AbjC2QJR (ORCPT ); Wed, 29 Mar 2023 12:09:17 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E982B5B81; Wed, 29 Mar 2023 09:08:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 81054B82371; Wed, 29 Mar 2023 16:08:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2FA9C4339B; Wed, 29 Mar 2023 16:08:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680106081; bh=enJerK8BV7TZcY8hMulDr/MyR3IQQzJAjpyRyNFFxhA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qHYPFeccmSp7OVMJy6eS/srYMyeAsSwJIF+hYqDCY7yjvT/T8dihBnPwVB9uy231m SNfiI4re5lYCyFHWzblb0eqL+5qTvbgDUCgwwNl+WAsz/mqD3TTbuB6cm3NgRAnoRH dy3bsTFgrobDT3RtmnZ9QHwJENdrUQXhW/t/tpEwTge74oZ5lzzDqQMeASNKFaaxo0 CHkolqcKbXrKfNmlWOIWV8mVNWPZKAt1gvHXcj22tSW2cLQTfHNxBzj7MwWE7AyADP Vk4WFBNzn7Tw088XEbmNN8HEMedIPn09Wa7lILbBT5aGLKwPD61A9AhPga1wsEs3yv YUMFNtbv/7Blg== Date: Wed, 29 Mar 2023 18:07:58 +0200 From: Frederic Weisbecker To: "Paul E. McKenney" Cc: LKML , rcu , Uladzislau Rezki , Neeraj Upadhyay , Boqun Feng , Joel Fernandes Subject: Re: [PATCH 1/4] rcu/nocb: Protect lazy shrinker against concurrent (de-)offloading Message-ID: References: <20230322194456.2331527-1-frederic@kernel.org> <20230322194456.2331527-2-frederic@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 26, 2023 at 02:45:18PM -0700, Paul E. McKenney wrote: > On Sun, Mar 26, 2023 at 10:01:34PM +0200, Frederic Weisbecker wrote: > > > > > > /* Snapshot count of all CPUs */ > > > > > > for_each_possible_cpu(cpu) { > > > > > > struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu); > > > > > > - int _count = READ_ONCE(rdp->lazy_len); > > > > > > + int _count; > > > > > > + > > > > > > + if (!rcu_rdp_is_offloaded(rdp)) > > > > > > + continue; > > > > > > > > > > If the CPU is offloaded, isn't ->lazy_len guaranteed to be zero? > > > > > > > > > > Or can it contain garbage after a de-offloading operation? > > > > > > > > If it's deoffloaded, ->lazy_len is indeed (supposed to be) guaranteed to be zero. > > > > Bypass is flushed and disabled atomically early on de-offloading and the > > > > flush resets ->lazy_len. > > > > > > Whew! At the moment, I don't feel strongly about whether or not > > > the following code should (1) read the value, (2) warn on non-zero, > > > (3) assume zero without reading, or (4) some other option that is not > > > occurring to me. Your choice! > > > > (2) looks like a good idea! > > Sounds good to me! So since we now iterate rcu_nocb_mask after the patchset, there is no more deoffloaded rdp to check. Meanwhile I put a WARN in the new series making sure that an rdp in rcu_nocb_mask is also offloaded (heh!)