Received: by 2002:ab2:715a:0:b0:1fd:c064:50c with SMTP id l26csp24617lqm; Mon, 10 Jun 2024 11:27:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVTn6rOC6NCY/e6J2XWXLHg1W7+dmwnSh9iX3GasZt91j4dgXfB/HeZTULfnH5ydf19x6gNCr4ktL/pTEAsVsMHXrCMS+o62BvoRrBZWQ== X-Google-Smtp-Source: AGHT+IG6z8Anyl6PhCuA3W8gIVf1reF5vY8DQ/Wl7xImY5lOwKNY0lsVFzSF+V54HNLOiMzmPck4 X-Received: by 2002:a05:6a20:4c88:b0:1af:b093:ffbf with SMTP id adf61e73a8af0-1b86c2c18f8mr388760637.31.1718044062007; Mon, 10 Jun 2024 11:27:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718044061; cv=pass; d=google.com; s=arc-20160816; b=AZP737lIKaLx03PlWXXuUEcUqs9iROjarSMfIunRJ+UJgDQaEXoevA9fZfVlw225k2 gnJtbk4Yp0JhlvULErMpqmakumgpUS9DqENAB2f+eZMgCNg7sP6nwMcSGQUOGmgqn58r 32+IRxNMIz0YFi9sCWD5EYGFw0YmehM++jAb+bD2Pb2rvBiPEQ8baHA1mP/jz8FgETrw DgphcR811+v8uQ8GnMVtcFvDxObLTbPjbLdLkBxsLEV/3TPVu+JxK0BDPeHw1A4bSgzE 0fHQU+U5V+MC4Oi3xeDOGEgGGDl9AUEmwcrogmAVJDLV+v++2Zod24N2vCsTfPbYS3/h T0Zw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=a1rbopp/c/YrNiZNFagLV/gFV+MgNRT3mcwHObKLgRI=; fh=ATpvoUf8OyvEgDuGyWBWH/LUIpxA5cNrSNqoyP/zn1Y=; b=In7AQvDBgQGDO8UqUkg5f/V5niQKQfRBGRd2wMRqwulz7O/T7iqsjRpLtmkq4x6thj sDozGtV0pOas0o3Pht2HUefAKawVLd09/tmIbYy4/BqcRmJbJI38FwG+tv4XmUk6hYy8 peYCX3W5UY0togjvyKbfStE2f3vd7jJiwJ1cIgPr0k7O3FScaRdA1eQqxr41xfZVJ3y6 hhjZgNYXHhzMK3897VxdyqAoYt3VDoPQaq6nvKHQA1cpj+RUvWET4HUd1RjUIBhgLb+o bcWNplk5rZ5Qhalrkcg5E+XuHcHMZLFe0lHDUQo/vN41tFydspYpmS1BQTWu0DuAezwf A8Bg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Hojsg24F; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-208732-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208732-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d2e1a72fcca58-704137b864esi4396253b3a.339.2024.06.10.11.27.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 11:27:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208732-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Hojsg24F; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-208732-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208732-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 53394282335 for ; Mon, 10 Jun 2024 18:26:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BEE7115A8; Mon, 10 Jun 2024 18:26:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Hojsg24F"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="XZx53xQD" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 4CFB3147C74; Mon, 10 Jun 2024 18:26:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718043986; cv=none; b=dHt1KY3IzQ22q91xIr3fK+Oe068k2LkE4AngfNlVZyZrVSUZgBm0a4klTLIXjEmMxg57Hm4+UIZNG78fHZbBTapSnAv4tLJTJTs8pwZU3fGtYR8s4XcUewSxlKa3eSiZTxc6870pw1MIdly+V/RLQG/CytV3YUFrWXFe2NgOSpg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718043986; c=relaxed/simple; bh=NB6uKNBRhesh/bGHTHz2+3wjDrsHamI6Xa28lGDgbsw=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=p5qVS0p5asxD55pARrAYc8+QcLn5TvrAMZ9nxcj6DC/jyHJZz6l5xBNH4sS+Y94slkv6eTD0nZu0UjLOuHa9uMudNi44jO3SnzRHSsStJ0gSNi5fKdZJh8YIOCM1M7eo82bpegUsTyIaTb7SDSmFMwy38XtEonyaUKPxS2in7qs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Hojsg24F; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=XZx53xQD; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Mon, 10 Jun 2024 18:26:21 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1718043982; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a1rbopp/c/YrNiZNFagLV/gFV+MgNRT3mcwHObKLgRI=; b=Hojsg24FHmyk6jBZsFSg8IB1jk6uAX4vZ5j2UQojuxC3ndeuLA36N0zqQ0SIWJDT4zxjne sdCKO7q6+kzZXjuGDYStVn0WrZilvY+Pj6hOPC7RVOE5a3zHz/pXo/AJdXGSV8sy8UDHLt TWxosrARZj9DWy+iuURAkU/KeVbhxixUDmOMZkA3qH1Fbqzp6M7ea2TtX1I3zZayFAwuKI pNx4NTxNRh1EKIbSp7+ESCGIsIh+8j0pT5JqyWS8IZ0xiDSVRzc/RYvILj9MUnURvcbDqq xiYKpuUAV6RZkdD+Hs8ZyRjFfKJG0QS1zsE4WcvfToU5mvv9vZLU2M2EN4ZHjQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1718043982; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a1rbopp/c/YrNiZNFagLV/gFV+MgNRT3mcwHObKLgRI=; b=XZx53xQDUpG6t+jL5MHuF7ji2YT5CTF0BLom+DDsJ6itdcT/rPwLGhJU9PO4hUpDHXx0+k H1EurmWdUtSSxhCQ== From: "tip-bot2 for Oleg Nesterov" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/urgent] tick/nohz_full: Don't abuse smp_call_function_single() in tick_setup_device() Cc: Oleg Nesterov , Thomas Gleixner , stable@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240528122019.GA28794@redhat.com> References: <20240528122019.GA28794@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <171804398181.10875.7931386382573929520.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the timers/urgent branch of tip: Commit-ID: 07c54cc5988f19c9642fd463c2dbdac7fc52f777 Gitweb: https://git.kernel.org/tip/07c54cc5988f19c9642fd463c2dbdac7fc52f777 Author: Oleg Nesterov AuthorDate: Tue, 28 May 2024 14:20:19 +02:00 Committer: Thomas Gleixner CommitterDate: Mon, 10 Jun 2024 20:18:13 +02:00 tick/nohz_full: Don't abuse smp_call_function_single() in tick_setup_device() After the recent commit 5097cbcb38e6 ("sched/isolation: Prevent boot crash when the boot CPU is nohz_full") the kernel no longer crashes, but there is another problem. In this case tick_setup_device() calls tick_take_do_timer_from_boot() to update tick_do_timer_cpu and this triggers the WARN_ON_ONCE(irqs_disabled) in smp_call_function_single(). Kill tick_take_do_timer_from_boot() and just use WRITE_ONCE(), the new comment explains why this is safe (thanks Thomas!). Fixes: 08ae95f4fd3b ("nohz_full: Allow the boot CPU to be nohz_full") Signed-off-by: Oleg Nesterov Signed-off-by: Thomas Gleixner Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20240528122019.GA28794@redhat.com Link: https://lore.kernel.org/all/20240522151742.GA10400@redhat.com --- kernel/time/tick-common.c | 42 ++++++++++++-------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c index d88b130..a47bcf7 100644 --- a/kernel/time/tick-common.c +++ b/kernel/time/tick-common.c @@ -178,26 +178,6 @@ void tick_setup_periodic(struct clock_event_device *dev, int broadcast) } } -#ifdef CONFIG_NO_HZ_FULL -static void giveup_do_timer(void *info) -{ - int cpu = *(unsigned int *)info; - - WARN_ON(tick_do_timer_cpu != smp_processor_id()); - - tick_do_timer_cpu = cpu; -} - -static void tick_take_do_timer_from_boot(void) -{ - int cpu = smp_processor_id(); - int from = tick_do_timer_boot_cpu; - - if (from >= 0 && from != cpu) - smp_call_function_single(from, giveup_do_timer, &cpu, 1); -} -#endif - /* * Setup the tick device */ @@ -221,19 +201,25 @@ static void tick_setup_device(struct tick_device *td, tick_next_period = ktime_get(); #ifdef CONFIG_NO_HZ_FULL /* - * The boot CPU may be nohz_full, in which case set - * tick_do_timer_boot_cpu so the first housekeeping - * secondary that comes up will take do_timer from - * us. + * The boot CPU may be nohz_full, in which case the + * first housekeeping secondary will take do_timer() + * from it. */ if (tick_nohz_full_cpu(cpu)) tick_do_timer_boot_cpu = cpu; - } else if (tick_do_timer_boot_cpu != -1 && - !tick_nohz_full_cpu(cpu)) { - tick_take_do_timer_from_boot(); + } else if (tick_do_timer_boot_cpu != -1 && !tick_nohz_full_cpu(cpu)) { tick_do_timer_boot_cpu = -1; - WARN_ON(READ_ONCE(tick_do_timer_cpu) != cpu); + /* + * The boot CPU will stay in periodic (NOHZ disabled) + * mode until clocksource_done_booting() called after + * smp_init() selects a high resolution clocksource and + * timekeeping_notify() kicks the NOHZ stuff alive. + * + * So this WRITE_ONCE can only race with the READ_ONCE + * check in tick_periodic() but this race is harmless. + */ + WRITE_ONCE(tick_do_timer_cpu, cpu); #endif }