Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2582217iof; Wed, 8 Jun 2022 07:57:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLailG0ongDjBTKO0FCBbeQ+xOB2QkrZjZkxdUmxZjPEDo4iCToOY/sQ1c1y7Y5980N2RP X-Received: by 2002:a17:90a:4e82:b0:1ea:3f61:51b with SMTP id o2-20020a17090a4e8200b001ea3f61051bmr3774564pjh.16.1654700246105; Wed, 08 Jun 2022 07:57:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654700246; cv=none; d=google.com; s=arc-20160816; b=xVlVbdrMtvKqLB2e3HLrDHvBCp+atXB2waRnqSnLFRNvPKNVLuZQUgjoiW8C4xSCHa +IMoAIFtcj1ao4Fv/cFEg35mS4fQOgYK4/vlcKQ3P9G/aJNZDlznTgv2UPd2VxEmSPON DNPj8U6GbZBIcyot2Zgfcg/oUeCJcwo2Em888aT18LMdRchJ/op61Tk4SECkU7NoKk83 7IwtNx/EhEBOCWDJJ/htMEFatAYnoY5fhY91xDIqhNBg2nQvgK47OBFByxOhVGw3wkMA fo78+8O32HPx4ia10BESD9NsM7IEYOauCB0t9j6UI0FL/7ZP1A6Duj5Z4s1v+RdAUqfY gngA== 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=NchvkgkD2cRDjNYuWPrDh0u4OmGDKiGwoQzSr+RANBw=; b=eT2kqScsWUahNB5bnuvI+uMuyoFsjpYg9vgsMakkwlLbjAUlku+ITc2DD1aQqzUl9o Mo02FaAXBtRGAQWYvQy5TdpqlvgEG1vVOPkGBASY2zrSfSB0KZo4kPeYTIdKT0KRGW3T xQWqhD6p1uXtR/OH358/qBCfIuX4TWjeaha9fxhkczj4WX9Zei7TwIqElrsSy5bUOwQ1 +JPpdzdiYyFx/AY4n5KBS17JRhNkNLGAY3ioeRFJu/OIyEkH6cTcKFoi1PKGwWWToEL3 9ohDKDBt7xGLKEyX6U+yupuwFMt11shb0DIZ5umHAPHfnv65lfZNsNH+euRt9UihCHcz Iykw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cn8iuI5X; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id l8-20020a170903120800b001624d7f36acsi31358901plh.592.2022.06.08.07.57.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 07:57:26 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cn8iuI5X; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 71A2139A3D4; Wed, 8 Jun 2022 07:29:42 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241324AbiFHO3g (ORCPT + 99 others); Wed, 8 Jun 2022 10:29:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241114AbiFHO3d (ORCPT ); Wed, 8 Jun 2022 10:29:33 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5FCF387E1A for ; Wed, 8 Jun 2022 07:29:32 -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 A114DB827F2 for ; Wed, 8 Jun 2022 14:29:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 216DEC3411F; Wed, 8 Jun 2022 14:29:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654698570; bh=uws+ie4Fbfs/5O39siHC/uos7UXYKD7x9GmCRv+0GQE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cn8iuI5XO3zN5Q7dpWwvJLDTVO6EcG17sJDeBgoPKtWlNeBwttdM4UpiwMN/Pf6sz UWMLujFADiQnIj0E2ElYksxSDS3uZO+4sVBp6uzkRHs1U+oBk0ujAJ2eQtcoFcQmYL BpdNs+blozz8DlGsW75zKABvPDwfJUORF7P+St0DiaNQWRXVqbLRakkWuzCjLap9sr BmJJZR1gRu0ceGRAl8YdwLKHoDUbU5aB2PyumaUCwNWrF8BMwKUKwIGeT+6JDeOxAZ LZx3vY1860PnxZ/yCfIHdVN4OXoF45W1gG1QY9CEKbxqTQ28TJ39FYQTUwWfRgY7yb 8SAp6fSJk2ULA== Date: Wed, 8 Jun 2022 16:29:27 +0200 From: Frederic Weisbecker To: nicolas saenz julienne Cc: LKML , Peter Zijlstra , Phil Auld , Alex Belits , Xiongfeng Wang , Neeraj Upadhyay , Thomas Gleixner , Yu Liao , Boqun Feng , "Paul E . McKenney" , Marcelo Tosatti , Paul Gortmaker , Uladzislau Rezki , Joel Fernandes , Mark Rutland Subject: Re: [PATCH 20/21] rcu/context_tracking: Merge dynticks counter and context tracking states Message-ID: <20220608142927.GA1735086@lothringen> References: <20220519145823.618983-1-frederic@kernel.org> <20220519145823.618983-21-frederic@kernel.org> <315b0b80f7f541b99a49a9fecb743874f31d95ba.camel@kernel.org> <20220531142335.GA1272449@lothringen> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 Tue, May 31, 2022 at 06:15:36PM +0200, nicolas saenz julienne wrote: > On Tue, 2022-05-31 at 16:23 +0200, Frederic Weisbecker wrote: > > But idle at least is an exception and CONTEXT_IDLE will remain during the > > interrupt handling. It's not that trivial to handle the idle case because > > ct_irq_exit() needs to know that it is called between ct_idle_enter() and > > ct_idle_exit(). > > Just for the record, this behaviour was already here regardless of this series, > so it's not something it needs to fix. Right. > > Something like this should work, right? > > ct_idle_enter() > //IRQ or NMI > if (__ct_state() == CONTEXT_IDLE) > ct_idle_exit() Right but that's one more costly operation (atomic_add_return()) > ct_irq_enter() Ideally this should increment by RCU_DYNTICKS_IDX - CONTEXT_IDLE > ... > ct_irq_exit() And this should increment by RCU_DYNTICKS_IDX + CONTEXT_IDLE I guess the CONTEXT_IDLE state should be remembered on some per cpu variable somewhere. BTW one interesting optimization to do when an idle interrupt leads to setting need_resched() would be to have: idle_loop() { while (!need_resched) { rcu_idle_enter(); mwait(); //IRQ { rcu_irq_enter(); do_irq()... //set need_resched() rcu_irq_exit() // but no need to do the atomic_add_return() here // since we want to keep RCU watching as we'll // escape from idle } rcu_idle_exit() // and no need to do the atomic_add_return() here either That's two expensive operations spared for a pretty common event. > if (needs_update_state()) //using irqentry_state_t for ex. > ct_idle_entry() > ct_idle_exit() > > Note that it's not a big issue as we can work around this behaviour by checking > through dynticks whether a CPU is really idle. > > Do you think it's worth fixing nonetheless? Nothing urgent for sure. > > Regards, > Nicolas