From patchwork Wed Jan 31 23:11:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 195052 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:106:209c:c626 with SMTP id mn5csp90503dyc; Wed, 31 Jan 2024 15:31:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IEgY5I6suYlwULAvls5Ew44W3tYBahmVYbypRPPJmzouDeBcFtR5aBZRDO7UqgHUWCitnvO X-Received: by 2002:a37:e30d:0:b0:784:93d:c905 with SMTP id y13-20020a37e30d000000b00784093dc905mr963532qki.25.1706743882083; Wed, 31 Jan 2024 15:31:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706743882; cv=pass; d=google.com; s=arc-20160816; b=vFqFK9gbPuce8wLRW1UR2NEsl1go1TRxpTVSjUgIUPUd7d/SOTShc5GyQ5pA5tpQpp GqwUjJ1OX1Z/zfqD+dk6aInceCIz8A3jHEmJ8W95WTlLWxFKYdqpCpdsnUgZJfIDtRvy FKxQg0DrWdyNhOTwJmjy4ObCXPxBg7ukoWP4OPEO6Y6dzQ8tAvHa90PTrOLR6aV1yTAd 5+itZfFYNTmWBEzH6G9xWynmpPEp2panACnHu9e6pF2ekBqMpAXqVSpkjIvZusvCnMgo qBkCbVxtY+mEafiX6bcmImWKsVb5AFP/jDxiAJgjTb0xiHWkrZHyuLer5NLV5dg9Wnhc 5qnw== 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=e0jm8O4mpaMhoJPc+134gmfVNgtq7zfpKWki8r+aFi8=; b=iKVOEUR0eOtbsp1D1v8/TmVxY334p3dXBQznTucUtHNzCmSjstVggLET5DrpNJgKvw UrqAE47GeW+cGQmiM2nkZgvKz6Alad+MvBli7Nu4BSGSVO/qAlib8OxW1xQj2Iil0Qg0 0CTTzScsblURRAzd3GsqyxcsqOVCBRUvpzRNNB8VmBGZ5oCiO3Mur4BFQBgEc2/6P94X TpHxfCp1j5N6a/h6iGw46ItQpyNmNeUDmioIoMfLvJSdFcgTVy6m5WdxKc53fNDaFDTS PP+P0SVrlqiKXqfMOYWwIE3NYaEOnIeF0eaRrxNPUTRAuaLsKbO+HFBspGpHuA0jH3Ru 6BsA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="FoLMS/qV"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47355-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47355-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCUFSt9BnZKaQ8UbZVdcPvMhauLHgJZUW1hUwNb6DJ/RS3JufRay9acJzzJj1HMQ6lXI2laIlJbu6tuvlN3VDAOsHb8ddA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id q2-20020a05620a038200b0078321c60d62si6427008qkm.762.2024.01.31.15.31.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 15:31:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47355-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="FoLMS/qV"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47355-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47355-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 9B7F11C27A56 for ; Wed, 31 Jan 2024 23:30:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 330CC3B7A9; Wed, 31 Jan 2024 23:11:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FoLMS/qV" 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 7B76D12FF6E for ; Wed, 31 Jan 2024 23:11:51 +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=1706742711; cv=none; b=chNKGfPzykxl4KEsRGV0PfZHFy5SAGibRecDZodojej7GFdN9tNsfJ8tpM0VdMfRQ01Z1chDJAma9k6BiG4wyy6anNPnOFT8giuonP13EFWpJxh5QmDsCWZZXTOJnursbRVopHEWHky/ne4g9BwyCdno/AT226kIATyzwd/6cKw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706742711; c=relaxed/simple; bh=ENJnGfyd2+EEzXokoqGcyz6LV1lezsDunVEKa8lSN3M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eDVhSEUSV7jlK8EhgbeIvMxJqc4wG0/qxy5dTHD84UkN8NxKVfVHW5Bb4VvErWLvPTxtRjiFkANezAMPW3gfa6XlNapKBNLDBPA3Apsq+MH6YqXFQ9y6sWWNvP87bDe080RKn8dK4OEItqa7tnqY0Hw2CCENqKbF5Riik7JfLQ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FoLMS/qV; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6ABABC43390; Wed, 31 Jan 2024 23:11:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706742711; bh=ENJnGfyd2+EEzXokoqGcyz6LV1lezsDunVEKa8lSN3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FoLMS/qVXCgH12a1Qre5TUQYW2zMqW7aif3QRBnwmKnh/CwClddGFrVOQ3/wHBehZ TpOsRQfoWIKxlSNiYGI7h0xrDjIIm/aMCRmehB12wpuZWLFxlU8AAP/+oEqCya/Eck q5TvYxnTcFLJTVE47WljMBjsX8Fj1t2gjHmGIioovO9JI7rN7iPCy2h9VTQvwk81jP NqefnWqWuoMD56dIHL6vDQa+qUT+ckIMaRM6Ilo/TJQsdN9nkWAPCbggi6v2zRTuu2 peEAgUekX9mf6T7XW5fduGkpFukgYKmfkn49+VIj2KBdP74xgTa5idCqhdx+/ZdJvn QzTpk1RI/c65g== 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: Thu, 1 Feb 2024 00:11:16 +0100 Message-ID: <20240131231120.12006-12-frederic@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131231120.12006-1-frederic@kernel.org> References: <20240131231120.12006-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: 1789650672949759873 X-GMAIL-MSGID: 1789650672949759873 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;