Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp850603lqe; Sun, 7 Apr 2024 06:54:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWX9HyD2OCfur2jaCczL0UXBaM5AlxEzhmOIQqIR1P5Fb81uNDkNXrnpbxk1q94+8UEiImZTmG6CjKT0xclc1ZMXP8W2ZUsKQ5NN3XWbg== X-Google-Smtp-Source: AGHT+IGbLiOOOE7hrVsrhYo4/8heCoz8i1I2xELGd23ddBYFbbSzTRQBXjY6RnCzY2/QDYVVYPs3 X-Received: by 2002:a17:907:944b:b0:a51:cc20:c626 with SMTP id dl11-20020a170907944b00b00a51cc20c626mr1287803ejc.24.1712498075552; Sun, 07 Apr 2024 06:54:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712498075; cv=pass; d=google.com; s=arc-20160816; b=vTG5T9ZD1N0ucDgBOFFYH31BNMP7LQKNd6ymhnoHPRqTNiutiCnFPqA7Btumq6M0Vq PWSDUdP/fWUYBrZex2eeDaimYv3r7nZblrw4iV+JM7Tm4GhYEa/B+BDJOel5Gl4Lji2q J0g50ajwcuQC6yLCAOmlb0DKQlzeZnAxS+3j67P3zbfnvkRoCWJqF2H+Kpz9IM42msJ8 XZ1W3xOfD02Oim5MceTTJ6nIrNx+C0mrYyXgkCcwPzqfnGtRV3goT/IDGn43X4yByE/p 0Pd5kkQhJvfexFqXq+FwqYhDOknF/Cjz3uY9Bo4q7J9G5FOKMP/Jm4JzYYVOwAkBb5js 5krw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:references:message-id:subject:cc:to:from:date :dkim-signature; bh=88iwLBU2e6djTkjvz8Wf+ZEeZw4XISzU7qQzK/TLfNA=; fh=2InlgaUf6YM4x7N5en8bF5Ts9/p78k4HiB3/TZmHd4c=; b=1Lf5GheeQbets2lx4YxzzaL2Ij46zMPtLeM8bufilf77Pyf26suRjuP/cn6yD2FY7Y JWXTyfBXUjX4fu4lf6RdCUGCFuRgSmABSuJ9hdiS+Zw+LOK4O6cS+oM2p+Pp+IATPBEA UN7zKI45bPvkmh6LS78JPghXoobbli4avvZsPL3Hg3qd0QnDBus7SxR5T8jUOY7i8TbT vlRuMiC6QyKtgBz3urqkdHE/9Q5mfdT653QHWRxHZaW0hMQ4kl9MF3UVPvOmwMRc86PJ NHhjqA2ZlbPfaPp3dPyYwxelp7FGBPduB1mDFccCjlcYYaUzfOEJAWSuBKSlY9byQ5Qq 2zKg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UNEuwH7k; 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-134511-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134511-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id hs17-20020a1709073e9100b00a51c46012bdsi1152303ejc.498.2024.04.07.06.54.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 06:54:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-134511-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UNEuwH7k; 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-134511-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134511-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 am.mirrors.kernel.org (Postfix) with ESMTPS id E322C1F21353 for ; Sun, 7 Apr 2024 13:54:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EBA6338384; Sun, 7 Apr 2024 13:54:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UNEuwH7k" 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 474F011720 for ; Sun, 7 Apr 2024 13:54:25 +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=1712498068; cv=none; b=BJKmPUc41i2JS+0IteRvF4vZQ/6lh2V2QE6cq6pbFgSvNyDgNKT+XajLHQy1hYNAmIiswB9JaLNv+Q6uGxAwLVJweLjSdMoLD0pmRqVe/l/lfDuAWWozhIRHyCuNyqkcYWaPpdfKWxd1WzifX5mCVp8XEx5Fjw8MYb9dL8PcMAs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712498068; c=relaxed/simple; bh=jxBqjjbPajszaEdq2fwpE6x+8A0oeppI3j2mrb+v9n4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KHnIyXCBSTh1ysOeNLSNimBiuswPHIN2oGAWkPC8ERCJXy2COlaON9RvYpRXx+IZm4MNJNo/5TVyfLPI9cFDs8BPhvFBSFnezOgsDOICFqiFjtyZ93f7mGo3uUA0lT/wP1FTVNhohPyXZkRf+d48Q5AG7qFTCMHq+WvVXv84r/E= 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=UNEuwH7k; 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=1712498065; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=88iwLBU2e6djTkjvz8Wf+ZEeZw4XISzU7qQzK/TLfNA=; b=UNEuwH7kSvj89Z+q0/HDLUbYf07g5yLb8+SJXmNcHtpaZr3mlEMZxyBErV60uUaRTyuKuk 30hI6OL7EZswthPcy4yElqEvIvwfbCE0LoOWOtn+YgmaT9gGqf4QZfUmhNTuizTL0MAm3f 7ktMEwjLf3ZAUH2ZQMIVRAKHpjITEpk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-66-upORUUgENOS-LCzNvktl5Q-1; Sun, 07 Apr 2024 09:54:23 -0400 X-MC-Unique: upORUUgENOS-LCzNvktl5Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id C692A104457C; Sun, 7 Apr 2024 13:54:22 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.224.79]) by smtp.corp.redhat.com (Postfix) with SMTP id B63031C21915; Sun, 7 Apr 2024 13:54:18 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Sun, 7 Apr 2024 15:52:57 +0200 (CEST) Date: Sun, 7 Apr 2024 15:52:48 +0200 From: Oleg Nesterov To: Frederic Weisbecker Cc: Nick Piggin , Tejun Heo , Leonardo Bras , Thomas Gleixner , Peter Zijlstra , Ingo Molnar , Lai Jiangshan , linux-kernel@vger.kernel.org, Junyao Zhao , Chris von Recklinghausen Subject: Re: Nohz_full on boot CPU is broken (was: Re: [PATCH v2 1/1] wq: Avoid using isolated cpus' timers on queue_delayed_work) Message-ID: <20240407135248.GB10796@redhat.com> References: <20240130010046.2730139-2-leobras@redhat.com> <20240402105847.GA24832@redhat.com> <20240403203814.GD31764@redhat.com> <20240405140449.GB22839@redhat.com> <20240407130914.GA10796@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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240407130914.GA10796@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 On 04/07, Oleg Nesterov wrote: > > On 04/05, Frederic Weisbecker wrote: > > > > +Cc Nick > > > > Le Fri, Apr 05, 2024 at 04:04:49PM +0200, Oleg Nesterov a ?crit : > > > On 04/03, Oleg Nesterov wrote: > > > > > > > > > > OTOH, Documentation/timers/no_hz.rst says > > > > > > > > > > > > Therefore, the > > > > > > boot CPU is prohibited from entering adaptive-ticks mode. Specifying a > > > > > > "nohz_full=" mask that includes the boot CPU will result in a boot-time > > > > > > error message, and the boot CPU will be removed from the mask. > > > > > > > > > > > > and this doesn't match the reality. > > > > > > > > > > Don't some archs allow the boot CPU to go down too tho? If so, this doesn't > > > > > really solve the problem, right? > > > > > > > > I do not know. But I thought about this too. > > > > > > > > In the context of this discussion we do not care if the boot CPU goes down. > > > > But we need at least one housekeeping CPU after cpu_down(). The comment in > > > > cpu_down_maps_locked() says > > > > > > > > Also keep at least one housekeeping cpu onlined > > > > > > > > but it checks HK_TYPE_DOMAIN, and I do not know (and it is too late for me > > > > to try to read the code ;) if housekeeping.cpumasks[HK_TYPE_TIMER] can get > > > > empty or not. > > > > > > This nearly killed me, but I managed to convince myself we shouldn't worry > > > about cpu_down(). > > > > > > HK_FLAG_TIMER implies HK_FLAG_TICK. > > > > > > HK_FLAG_TICK implies tick_nohz_full_setup() which sets > > > tick_nohz_full_mask = non_housekeeping_mask. > > > > > > When tick_setup_device() is called on a housekeeping CPU it does > > > > > > 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; > > > > > > > > > and this sets tick_do_timer_cpu = first-housekeeping-cpu. > > > > > > cpu_down(tick_do_timer_cpu) will fail, tick_nohz_cpu_down() will nack it. > > > > > > So cpu_down() can't make housekeeping.cpumasks[HK_FLAG_TIMER] empty and I > > > still think that the change below is the right approach. > > > > > > But probably WARN_ON() in housekeeping_any_cpu() makes sense anyway. > > > > > > What do you think? > > > > Good analysis on this nasty housekeeping VS tick code. I promised so many > > times to cleanup this mess but things keep piling up. > > > > It is indeed possible for the boot CPU to be a nohz_full CPU and as > > you can see, it's only half-working. This is so ever since: > > > > 08ae95f4fd3b (nohz_full: Allow the boot CPU to be nohz_full) > > Thanks... So this is intentional. I was confused by > > Therefore, the > boot CPU is prohibited from entering adaptive-ticks mode. Specifying a > "nohz_full=" mask that includes the boot CPU will result in a boot-time > error message, and the boot CPU will be removed from the mask. > > from Documentation/timers/no_hz.rst > > > I would love > > to revert that now but I don't know if anyone uses this and have it working > > by chance somewhere... Should we continue to support a broken feature? Can we > > break user ABI if it's already half-broken? > > Well, the changelog says > > nohz_full has been trialed at a large supercomputer site and found to > significantly reduce jitter. In order to deploy it in production, they > need CPU0 to be nohz_full > > so I guess this feature has users. > > But after the commit aae17ebb53cd3da ("workqueue: Avoid using isolated cpus' > timers on queue_delayed_work") the kernel will crash at boot time if the boot > CPU is nohz_full. > > So we need a workaround at least. I am starting to think I will send a trivial > patch which changes __queue_delayed_work() to validate the cpu returned by > housekeeping_any_cpu(HK_TYPE_TIMER). > > But perhaps something like below makes more sense as a (stupid) workaround? Or simply diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index 373d42c707bc..e912555c6fc8 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -46,7 +46,11 @@ int housekeeping_any_cpu(enum hk_type type) if (cpu < nr_cpu_ids) return cpu; - return cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask); + cpu = cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask); + if (cpu < nr_cpu_ids) + return cpu; + + WARN_ON_ONCE(system_state == SYSTEM_RUNNING); } } return smp_processor_id();