Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp476107lqp; Mon, 10 Jun 2024 09:32:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX4uY+nZMEWh2zsnIBV4mpHzdXRbE/MaYemXb0YRjObvYUpvTKMIv7oXXHz2CWxJLRaut98P0bB6zcw39ivovMmBszUs2iRlmYqDGwP+Q== X-Google-Smtp-Source: AGHT+IEcgpvGRTJYgQstcOra1HHSr/ubqa+sMtEQVO4ykhbOJWm5yZB5HCA4G4ZZRgdAlvrRrNde X-Received: by 2002:a05:6a00:21d0:b0:6f3:f970:9f2a with SMTP id d2e1a72fcca58-7040c65b37amr12595070b3a.10.1718037133323; Mon, 10 Jun 2024 09:32:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718037133; cv=pass; d=google.com; s=arc-20160816; b=t097mSA8YzxXvPHyE4/LAfUNUmIinswTvMZ8Gwy7lJ0xNEDZ5ARHxIgQPpGS4bUKei U7cQPmi2IwYAayqYzG7KVIxsCNYkkSRqCxRXCr91SYaBYFqurRKJks/ZJGUJYE/ZWQfj CN1IYbm11ns5Cc5q4pZUXXKcaRWksZtoMRFDZFhfqUggG5kEDX1Ke2On0rijNF+S0qzs lR8iuKK2I8o2O7aYvQ7OuY7BD+3rS76FunvxjgDYFbZBe4SsisSooKd6vS8fUvLz+0Nc zjvYL5DQxhEChW3TpahryqfOt4eEFGmzrE3bLsYJy0xofRVTnwAYY6DB6px05lVMX5JT YsVA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=BS5eTgnHlkFCzrxbZOb8hmMMzPTpAoIPnvvRf/vsaRQ=; fh=DrnLVe9OaK7N4pqdHtGyBKWYB6W1LPA6jrokFQtXADY=; b=Vr8NGP3Ci90g0a4ln8ipquiHwolPFcwD0OoAFloLrkuX7LuoHeuyla3kgwayJHp6Il HIwJVCZfU/dQdpuw4AFSvC1UmOn/T/DX4x0ZVFVhqjGEQyJBOfBBj3s6JbjE/TNBFp04 PYMqH/Wm0kEMPC3dN61eS/zZwIrWyr5GDNCr2m4HbsTv92/oSWSv40ZWeFZKPkghJE6n SNa2zoagdZMBqdD3dWTa402hWl5RfwQCzDJI4ne8iiTiib8LK70N5zaPnb4XIZ74wRpd SsYTYD9CEyLuvOmM7sP1bhH0B+lJF4HH9XdAaeFCkxd0XXJsyXzsZCDoX6NFrU4FP9q8 j5Bg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JDwXhIlv; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-208520-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208520-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-70427cc567esi4094269b3a.75.2024.06.10.09.32.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 09:32:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208520-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JDwXhIlv; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-208520-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208520-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 179CCB2D7D7 for ; Mon, 10 Jun 2024 15:57:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 50A5B1411DE; Mon, 10 Jun 2024 15:56:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JDwXhIlv" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 F359D13F450 for ; Mon, 10 Jun 2024 15:56:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718035012; cv=none; b=Gv9Sa+41eg1ryyIKf9X8Fm0gXe5R2g50UZLX+s5UpwPgkDp4FlLltbk0dRUIfys+H9cuwSGD6Tj/5VVj0TZzNFOVsJQTzHAUr6Hr3nqVmgBm88amDGhi+bOLdm+yAW1NhqsuMIol/2B1Yvc7SPT9LWxYMQReemqbMquRaGfIE+I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718035012; c=relaxed/simple; bh=xpjNp3XUnTkhabt16yBIEJ1ajLl8po3Zg+CZU1LwKJY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dw2FrrKsIhzo2fnsAqF4W3TkWrZQw5lzZAje+T9xRg8EA72VAYkq4XRTuvyUEllrdoOnr7N4OMFHnZQAIJe7553MUnmkRpdf6mdZi1futxr5rJjS7WeV2QRy1y6aRy0xR3Ck0xUdpfFnE7bHdsFJKP3sFiQ7MdKm8UfdJAZF77Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=JDwXhIlv; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718035009; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=BS5eTgnHlkFCzrxbZOb8hmMMzPTpAoIPnvvRf/vsaRQ=; b=JDwXhIlvMVrVpSLws/anjO/0yR0J6QaplzqXDq2L2Sd+YnQ8GFdVE8pgUE/6JtxrjAL7ix EBuKb6G5m5PjvK74KzTC15qZIc51Z5KPZJ9YFZL/j7kqFk8LEp1CFDNTzvHiWe7wUwhUFW iNU6voc6BOCcMqm1JNCxyF1JrvgsYhg= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-680-iHDB393jPmWTff-N5659ew-1; Mon, 10 Jun 2024 11:56:46 -0400 X-MC-Unique: iHDB393jPmWTff-N5659ew-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5D9E61954B0B; Mon, 10 Jun 2024 15:56:43 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.225.117]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 90A5A1956048; Mon, 10 Jun 2024 15:56:36 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 10 Jun 2024 17:55:12 +0200 (CEST) Date: Mon, 10 Jun 2024 17:55:05 +0200 From: Oleg Nesterov To: Frederic Weisbecker , Ingo Molnar , Nicholas Piggin , Peter Zijlstra , Phil Auld , Thomas Gleixner Cc: Chris von Recklinghausen , linux-kernel@vger.kernel.org Subject: [PING ;)] Re: [PATCH] tick/nohz_full: don't abuse smp_call_function_single() in tick_setup_device() Message-ID: <20240610155505.GA24299@redhat.com> References: <20240522151742.GA10400@redhat.com> <20240528122019.GA28794@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240528122019.GA28794@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Thomas, et al, should I redo and/or resend this patch (and the next one on top of it) ? Or what else can I do to fix this problem? Thanks, Oleg. On 05/28, Oleg Nesterov wrote: > > 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 tries to explain why this is safe (thanks Thomas!). > > Fixes: 08ae95f4fd3b ("nohz_full: Allow the boot CPU to be nohz_full") > Link: https://lore.kernel.org/all/20240522151742.GA10400@redhat.com > Signed-off-by: Oleg Nesterov > --- > kernel/time/tick-common.c | 39 +++++++++++++-------------------------- > 1 file changed, 13 insertions(+), 26 deletions(-) > > diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c > index d88b13076b79..27d0018c8b05 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,26 @@ 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 us. > */ > 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(); > 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 > } > > -- > 2.25.1.362.g51ebf55 >