Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1051486lqj; Mon, 3 Jun 2024 08:46:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWWqryROYeuCBpFezN0oy/IKJJUxPCzvX14qOSlHIHTExltDvsH2q1FoziuZLtrOODuN6rYHA6LB7jrwFHtmFVx9MFF/U0v6JXCz2SiHQ== X-Google-Smtp-Source: AGHT+IEi84NugWhhpCkTmOKCbZQfqBiXC/LSdhZzgfL9eCbXyTgsVjBGlzHoM+DqD3EFHZvEgief X-Received: by 2002:a05:6a00:1784:b0:702:59fc:47cd with SMTP id d2e1a72fcca58-70259fc4b01mr6421403b3a.16.1717429605849; Mon, 03 Jun 2024 08:46:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717429605; cv=pass; d=google.com; s=arc-20160816; b=Fa1/6xRD24MVaPmq20vH+Cd3cRE41ZEH6Yne/7bR4daELnFnERvm2EAwD0xDgml0+w yp7CneRPpHPQ2KwmHCoUkmZNpTrMuzu/GVQq30rhhmJOqfgmBlj6WvE0orXQY5FP0JU1 mQ0NevUbfefFDl1eQShKztzAgg8MtLJWaCUX2RbVvrRVHxoM71CQhbn7jCBirG8lFRdx 2Fv+u6TRw6y+YAYH1JbBbBMcbY5mfTcKIKjjl0tXOIn5EsFTrmJsYnpYll6u3QTd/nlY IRelfFISwAzDIdLoDVus/HHmWNtQzXbfXeEW9CwRKiKwZnvZetOd2tXyXcV4OnzCDH5d 2ZZg== 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=xhdofQNjL+lCEu875vUgkpWMiLC309LRMUAE+8RleL8=; fh=DrnLVe9OaK7N4pqdHtGyBKWYB6W1LPA6jrokFQtXADY=; b=hNrH+reAwOudd3UYiEWMDWojL0b2e3WObFS0Wou0be7uGaIChoXEX36nbRLr1v895m Te/nLWRbKJDN/eYuMnZBIgmu/8CWiy4a6B8C3aPf319cxyaShf0AZyoGQRpVOZmRi6HS NcxGoncHtvPDzKe42m6YO9ocSCXvonXrEUb04pCZ6pYkDTfZ6GL+7XLmcTARKkxoksK6 5pN7BYF9CCrHWvcheCATtzeakcA6pH6g8yddWEM8X151zbbhmyZI3tisfhVcNRCRIdLk T7wUGOSsklaZp+kM5LTqIg0xv6Dn92KTmeC9X6+L5cwKLZcdCPfpbWJ/G5lAqU4WIu+j KNsQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="CDT5G8/+"; 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-199373-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199373-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-70242d5edf8si485252b3a.375.2024.06.03.08.46.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 08:46:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199373-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="CDT5G8/+"; 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-199373-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199373-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 6199CB21C5F for ; Mon, 3 Jun 2024 15:37:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E9A28130ACF; Mon, 3 Jun 2024 15:37:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CDT5G8/+" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 78AE4882B for ; Mon, 3 Jun 2024 15:37:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717429056; cv=none; b=uiiANW2rxOwXMw9pJSUtLCSeszNP5zvo1bk28nnUAIp3m/6ApELPKHNb3tJvBFsKOahfVHGX20o0I0xDLiF6mMt9G3Zs3lCQDwRd7olIx12tNP7nikJ2W+JcCGcwo7aZ/np1whwm3qvqO0uZvA42p+gFbQgd3XQR0wo9VC96ki0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717429056; c=relaxed/simple; bh=H02pkg0cMo/O8ZymvJcklLrUWLpS0iRiFxI+1Per87Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jUl5cEfegZykl9hRZEdy6iU1nhCMke12geioocFJ5YnTc1j3l7Izr8IadRRNlzdRIDBFuT6LgYzneuwWu6dpnVi3g4M94Ll+AeJN3g9ZOr76BpvbXW1qLC7PSnWfI5ZUqqxFyxBcMRgd1GeJV5eKEdyt8CZ6KaU+7eJdfHcvekg= 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=CDT5G8/+; arc=none smtp.client-ip=170.10.129.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=1717429053; 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=xhdofQNjL+lCEu875vUgkpWMiLC309LRMUAE+8RleL8=; b=CDT5G8/+SnCvNg/R83JuCJfUbfkXfWEe4dSWRiTJ8RkKOMmDJ7sSqDE91NFHZCX03ayU5P A4gWXPpGymEVdcRkfMv1DTpKkjQpFrvFJ9+bsob/f1e1F9dsC+RVCbG5pl/Egqd7TzGYlC Y/Kr+yyt04CQTro3bPqJzFqhagCgqhM= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-631-qBjBMv9tO8uM6_WGQghMQw-1; Mon, 03 Jun 2024 11:37:30 -0400 X-MC-Unique: qBjBMv9tO8uM6_WGQghMQw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 9D2163806703; Mon, 3 Jun 2024 15:37:29 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.225.103]) by smtp.corp.redhat.com (Postfix) with SMTP id 41103404F585; Mon, 3 Jun 2024 15:37:27 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 3 Jun 2024 17:36:00 +0200 (CEST) Date: Mon, 3 Jun 2024 17:35:57 +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: [PATCH v2] tick/nohz_full: turn tick_do_timer_boot_cpu into boot_cpu_is_nohz_full Message-ID: <20240603153557.GA8311@redhat.com> References: <20240522151742.GA10400@redhat.com> <20240528122019.GA28794@redhat.com> <20240530124032.GA26833@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: <20240530124032.GA26833@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 We don't need to record the cpu number of the nohz_full boot CPU, a simple boolean is enough. We could even kill it, the "else if" branch could check tick_nohz_full_cpu(tick_do_timer_cpu) && !tick_nohz_full_cpu(cpu). Signed-off-by: Oleg Nesterov --- kernel/time/tick-common.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c index 27d0018c8b05..82c1b2206631 100644 --- a/kernel/time/tick-common.c +++ b/kernel/time/tick-common.c @@ -49,15 +49,6 @@ ktime_t tick_next_period; * procedure also covers cpu hotplug. */ int tick_do_timer_cpu __read_mostly = TICK_DO_TIMER_BOOT; -#ifdef CONFIG_NO_HZ_FULL -/* - * tick_do_timer_boot_cpu indicates the boot CPU temporarily owns - * tick_do_timer_cpu and it should be taken over by an eligible secondary - * when one comes online. - */ -static int tick_do_timer_boot_cpu __read_mostly = -1; -#endif - /* * Debugging: see timer_list.c */ @@ -192,6 +183,7 @@ static void tick_setup_device(struct tick_device *td, * First device setup ? */ if (!td->evtdev) { + static bool boot_cpu_is_nohz_full __read_mostly; /* * If no cpu took the do_timer update, assign it to * this cpu: @@ -199,18 +191,14 @@ static void tick_setup_device(struct tick_device *td, if (READ_ONCE(tick_do_timer_cpu) == TICK_DO_TIMER_BOOT) { WRITE_ONCE(tick_do_timer_cpu, cpu); tick_next_period = ktime_get(); -#ifdef CONFIG_NO_HZ_FULL /* * 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_do_timer_boot_cpu = -1; + boot_cpu_is_nohz_full = tick_nohz_full_cpu(cpu); + } else if (boot_cpu_is_nohz_full && !tick_nohz_full_cpu(cpu)) { + boot_cpu_is_nohz_full = false; /* * The boot CPU will stay in periodic (NOHZ disabled) * mode until clocksource_done_booting() called after @@ -221,7 +209,6 @@ static void tick_setup_device(struct tick_device *td, * check in tick_periodic() but this race is harmless. */ WRITE_ONCE(tick_do_timer_cpu, cpu); -#endif } /* -- 2.25.1.362.g51ebf55