Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1251790rdb; Wed, 24 Jan 2024 09:09:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IHcmK2ypYdLMWrzttvQFSV7hGZ2Lp8Q7wuiGSsGTRCouC6UgwyqBbbE67EX0oaYpk2Y/uZo X-Received: by 2002:a05:6a00:acd:b0:6db:e3da:25b3 with SMTP id c13-20020a056a000acd00b006dbe3da25b3mr4401045pfl.7.1706116196270; Wed, 24 Jan 2024 09:09:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706116196; cv=pass; d=google.com; s=arc-20160816; b=Xj073ESN2HS4W8KzDMa9mvd3XR9TvuBLkk5If6UklfaJTqYSMJFPtVhn/AmyqRxK2U ZAszSa+aXrRxT3gAFoO18FB61dWH1W0MRFjd/cPtHfTDIFHbi3yOzAJOXljNU5Pv3adP 8o4BT/81bp4rtS4Oa6rrOAr5r7VPWk+NW2QsJd29qAsCEg72e2+YQk+inyXS8rizaTlr PTGT4OrPcLKPwz2q1G8lFge86O2UiwgfSRufcD5cdycpedUDQ/e8n5xmwlBWBS4Kl2W7 vPDnC2VXzkUQ1KloAMzBtz4akadCEEQC94jV78pmkVuwWKOwhPTAssqvdOtLXZN+oODu 1ZTQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7VZuerbsDX4IqmesX+lo7p08jYxPXCDasaEk71cYJdU=; fh=9AYDxpIF3ws21qQDvjghHSFUuXpDdpq2Zh/SbnasVRo=; b=UsCRf+rlzA9q4EJ9kALRFRvmC2KmdaeuDb1zxxQ7/lt8UzwFPpVjp6cBYFckIiVtgs tcO7JfnK1jLxH9sbhW8hWHg5xooN2pCcKk3egeKYuQmxxrQ/FMFlj/m2ijwXAskU1Mrh 2uXNZHJVGP8deoKsTLFoMkLnBbNC0+32fsKMgfm3z+/qR2BF4R4mx/LVN0bgxNhhr+vA ah+SEyKFpok0YE9CyZ0f7FLMFAkLB8zqANLA8kRQ317wg1IXPigI5BFRSRJM9R4bfUee 3+JMdLIr3DZaZ+NOcMXLztIJsskG+FYX5wOJWRInWSZNaqhnLZgR2zO5hosVpbMyXfrf ZjUw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iiSLcaLQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-37390-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37390-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n5-20020a634005000000b005cdfdaa0a18si11964060pga.666.2024.01.24.09.09.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 09:09:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-37390-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iiSLcaLQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-37390-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37390-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E19B9289DA4 for ; Wed, 24 Jan 2024 17:07:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C856681AD7; Wed, 24 Jan 2024 17:05:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iiSLcaLQ" 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 055C07E782 for ; Wed, 24 Jan 2024 17:05:35 +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=1706115936; cv=none; b=Jw9B+6o31noB5LOfnpRa091yqSmbGt1bFGP7rpF+cWFAHmyAKKY8pXaHeyNvAmdRacOmViNfeWd21D7TLRukeoiBCdg+dI7fEwaxgLnCV04+GFzhamOEggPMoRLhAdwARZstckFNMBAHw7cjRC51N5XPV6+CM7TEIP+Zrufrrqk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706115936; c=relaxed/simple; bh=q9uMk1kYzNMw7MFUczwSrP/48nreFiHWAfLI4g8u4gM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rp3h3RsGKcZHWJlkFGXq8Mrj/hKVDWEHrlg08ljOlO39A6mIVJydNLnABK/nF361++UUWaoMYhNNyTE+f/tAcxB/12i3OITzaMcDB1xsGhVCZzRLX0+LcVBi6FqyoT/LIlQ8Xku0dk0k2WzRshJpdtIzUOFFq1sgASPZDitAVR8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iiSLcaLQ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FE68C433F1; Wed, 24 Jan 2024 17:05:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706115935; bh=q9uMk1kYzNMw7MFUczwSrP/48nreFiHWAfLI4g8u4gM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iiSLcaLQx4KzXnHfYnbkXLUfNdon+Rz77GiBfnJ/CRKY2fmwi7IOc3WWrkReuHGmO UB4Ti93CVUj4DdmIXvQqNOsH+E2SPdkOEVTg0lnjKJ0aLLF2CczUKyEosz6c7FokAO 5lLSmgGf8ITFUSvoqK/daOUEogfBm2En0OT1VsTyppvELjdUFqUZkX7sa+XcOcvDl5 uDzJGLuO+DyS2wXXXQiGvCtdYN8RfyhhIQJiJ7M/Zwtnkx4CSXNsuyk5n5CIMspIE+ J+KCUbz1WZrYnNLvlb5ZpxdwSYQzcSKIZtWstFz8SxFkpoiIRzjz68rHuDRrB88I0M ysSiDrjn+4cvw== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Thomas Gleixner , Ingo Molnar , Anna-Maria Behnsen , Peng Liu , Joel Fernandes Subject: [PATCH 11/15] tick: Move got_idle_tick away from common flags Date: Wed, 24 Jan 2024 18:04:55 +0100 Message-ID: <20240124170459.24850-12-frederic@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240124170459.24850-1-frederic@kernel.org> References: <20240124170459.24850-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit tick_nohz_idle_got_tick() is called by cpuidle_reflect() within the idle loop with interrupts enabled. This function modifies the struct tick_sched's bitfield "got_idle_tick". However this bitfield is stored within the same mask as other bitfields that can be modified from interrupts. Fortunately so far it looks like the only race that can happen is while writing ->got_idle_tick to 0, an interrupt fires and writes the ->idle_active field to 0. It's then possible that the interrupted write to ->got_idle_tick writes back the old value of ->idle_active back to 1. However if that happens, the worst possible outcome is that the time spent between that interrupt and the upcoming call to tick_nohz_idle_exit() is accounted as idle, which is negligible quantity. Still all the bitfield writes within this struct tick_sched's shadow mask should be IRQ-safe. Therefore move this bitfield out to its own storage to avoid further suprises. Signed-off-by: Frederic Weisbecker --- kernel/time/tick-sched.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/time/tick-sched.h b/kernel/time/tick-sched.h index 35808bbb8a47..3b555e0fa937 100644 --- a/kernel/time/tick-sched.h +++ b/kernel/time/tick-sched.h @@ -61,7 +61,6 @@ struct tick_sched { unsigned int tick_stopped : 1; unsigned int idle_active : 1; unsigned int do_timer_last : 1; - unsigned int got_idle_tick : 1; /* Tick handling: jiffies stall check */ unsigned int stalled_jiffies; @@ -73,6 +72,7 @@ struct tick_sched { ktime_t next_tick; unsigned long idle_jiffies; ktime_t idle_waketime; + unsigned int got_idle_tick; /* Idle entry */ seqcount_t idle_sleeptime_seq; -- 2.43.0