From patchwork Wed Jan 24 17:04:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 191673 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp1128998dyi; Wed, 24 Jan 2024 09:10:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IFETkXTR3wyWqsCwVa9PKXyHq0RbL2q2cVdzv1I0zmp73MWA8efTcQl9EAhQv8KIbdTNJfO X-Received: by 2002:aa7:888b:0:b0:6d9:3794:304c with SMTP id z11-20020aa7888b000000b006d93794304cmr4113705pfe.66.1706116202415; Wed, 24 Jan 2024 09:10:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706116202; cv=pass; d=google.com; s=arc-20160816; b=YRH+Q8A8q+CPKRBrPNlMXdbssUuHZCwXqKtiWqPHo5+2vce7u9zSSDIK8lfAMAqgCU Tj92Zb2QoUh2Z9ombeEXqfTa8b9Uzhc6FfHLtxaBhUR7Pj8oKmQL0yOF3+EFhZHgkDNM F3xsPTqnTcLeIjlOG06grmjdQ2dmbZo50T6CUZWBeaZlGwLCksbbbeZKnhRaBDyb2GQv tqdsW211LRLX/fxMl89j6tignEVXuiZxfkbGze4m1eDbm4G9nghjnMp1/C+Bf+QLOTg6 X+sJ4ewRpSL7yxmAwQmZSJgg5hNVhdp773aA1Qn8t+dzDWuPDTgcEqH6C3rZBYNcNAeD I8sA== 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37390-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id bs68-20020a632847000000b005cee039f233si11592085pgb.425.2024.01.24.09.10.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 09:10:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-37390-ouuuleilei=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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37390-ouuuleilei=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 B96D3284BEE for ; Wed, 24 Jan 2024 17:08:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 946DE1272DD; Wed, 24 Jan 2024 17:05:38 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788992502707331170 X-GMAIL-MSGID: 1788992502707331170 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 Reviewed-by: Thomas Gleixner --- 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;