Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1013431rbb; Sun, 25 Feb 2024 15:16:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVwRQhNvE47ijzi1TfV11xDPYbQTjEo1pjWIkj+pp+WjJuCUemT01GWIDt/AIpdFo3lcH+at5Z8fzwE5EBeCUrzIi5NPvNiXMRadVgDxg== X-Google-Smtp-Source: AGHT+IGx6RUOmCT9L8geR3+1suL40/qSS0nrAHXW2zllpsU0MyzCf8rAbYJCKVCAsD0k58k0oaba X-Received: by 2002:a50:fc0b:0:b0:565:66df:b25a with SMTP id i11-20020a50fc0b000000b0056566dfb25amr4971006edr.17.1708903004262; Sun, 25 Feb 2024 15:16:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708903004; cv=pass; d=google.com; s=arc-20160816; b=mqq17EYruLDVN11ZkObFhegQGq0rpEtcVpVV5fPUJUCMkF3/gkQR9zfEockxm2UYQ+ 7+D9YwDlN5MLY5lV3YtLWpj7KOzvhTqC4OWlQJnGoDKZUAyIF3eOFPcP0pEwXU8dJvHe IunQoFTltbATyloDk/FERcfrtJYcPtaQAqQc0pHjiW0M/gLpMQpOA45yQ328i0ENUeFv 0jbuZztFhG1Wi+z8PoajnuZCftxJl4TvcQmPssyg42RmfBeoSrMZRBTRdKBD+gXscYCm icrQsQhyrDVmVVGY8HfIqRHJbcb/BIbZAeNtfl4jZq+TSVmiBtekMZE+V4C0ys+6UEZE CIbw== 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=32PBNjbxtnXDVrDZlxu6pNH0KE8j3mQZCqSzuvfBD2Q=; fh=9AYDxpIF3ws21qQDvjghHSFUuXpDdpq2Zh/SbnasVRo=; b=euLY9q4VW995qzgJ5KlQ0FqKDycice2IgaWb5dB/pPxJMD+2+sBcUTvFtHGrrCFPHS ukjrZ+QdUAL6od+86L1sbZLbBMXFP0kZ/fBX6waRYsCFW0xrdPgW2FqzrpPsqz+nLiq1 ylZYK8v15X+2E8SjK6fSaPT95cSI37qpvDywkSyRShVZR5Zm+VhyD2ntLV1emUNPOj33 yzcURMg5mepT9kiUrzP7MXXnM5x9lG7YXjzFxshIYFeplQo41DtoMDccWUpefrdxqpeX 8MOMi7+bhaIh1Ux1zZDTonGY+lr/KS4kEEukywTXL7QmbBdh+JkNobyy63tIbudMS7gG ysBg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FjV4lzBy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80338-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80338-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id bd4-20020a056402206400b00560a161d4e2si1583930edb.232.2024.02.25.15.16.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 15:16:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80338-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FjV4lzBy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80338-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80338-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 am.mirrors.kernel.org (Postfix) with ESMTPS id EBAFA1F234A9 for ; Sun, 25 Feb 2024 22:57:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D4E7347F57; Sun, 25 Feb 2024 22:55:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FjV4lzBy" 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 006C03F9D4 for ; Sun, 25 Feb 2024 22:55:37 +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=1708901738; cv=none; b=TCgh7xR+igrK7ibkNdiUR3ttmYxImWq3W6dAJkUC0alqxh7cXFmP6pfRGiN6v2vRHLfVVJdWgi+juu89cbg4JizNf4nnoeMh0ichRtUtfzgiCVnDS4aJYvtvl7c6IlzYS3wtUbOJQeBbUqOiCiIlKiUeXiNg9xJkUIVGgbtust0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708901738; c=relaxed/simple; bh=ENJnGfyd2+EEzXokoqGcyz6LV1lezsDunVEKa8lSN3M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PKn/cXKTG+g6+NH4PSdn0Kd7JI2xwWOe3DW/DXYBLiZ9izuzgdCwLX3wUURyrbz5B4bMFSHdjqkwnRJ3rGL+GREKHkyR44E7pJHX8Kya9qQ8iV/hnKnbN22osdfCYApFTPZk9+7XWSxYxxNvuSMNWlZzcuYtVAyZ9mdOKmB+9iM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FjV4lzBy; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A8B7C433C7; Sun, 25 Feb 2024 22:55:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708901737; bh=ENJnGfyd2+EEzXokoqGcyz6LV1lezsDunVEKa8lSN3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FjV4lzBy+48yVJ6MtN08wD5bGhgv4/sVSxjayzSEscmTLWMCAtNbmZGo4tj3+eeDn /rYrbsD1m1OkVKe1DKtywblm8kGzLWXyntzuo8iACq7Pw1/JJKaCfw5XY9r8jimH34 sKxEcyC18kmKMe0pjf3dXNiHklF3An4HXXPBx50+tA9v4jJn7BoIBtFuAp2VFSZe42 di97SQZPDeW9OjlIHgeyEVGwgNiQpn32IjkaAO6XS1BOxDguoLGTT1GU5XDEReGwTl 0NF3HpA96e56ii9CwwxARG7S35TlGwWy+yGUQK18dmb/NRdm+ni9KojQZkluy4Aq/Q dHAL9rpt2Jf2Q== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Thomas Gleixner , Ingo Molnar , Anna-Maria Behnsen , Peng Liu , Joel Fernandes Subject: [PATCH 11/16] tick: Move got_idle_tick away from common flags Date: Sun, 25 Feb 2024 23:55:03 +0100 Message-ID: <20240225225508.11587-12-frederic@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240225225508.11587-1-frederic@kernel.org> References: <20240225225508.11587-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. Reviewed-by: Thomas Gleixner 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