Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp1931256lqb; Mon, 27 May 2024 02:10:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU/xBBoJsVPwjAU5PxDXDkXcFuWTdxcBiKJIRHGrAkbvBBK9M4hsglJiICglMxutkg1F/hEuLDzG5sCtq0ES4RPGCvf5S2/MNrNz6KdJQ== X-Google-Smtp-Source: AGHT+IHmalRtahyaZVsWCFdYmV0ls0cOtKsJuz0YgOdvkvSHPkjd6pxO6yetkGf7/h+rix4JvAoZ X-Received: by 2002:a17:902:e80f:b0:1f4:9054:7eae with SMTP id d9443c01a7336-1f490548a45mr25813935ad.52.1716801034926; Mon, 27 May 2024 02:10:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716801034; cv=pass; d=google.com; s=arc-20160816; b=pUnuFL9rga9maBIhZHOcoOrwvEoBFynk/PeiJl/R5v4wdfLJLIeOcbrxHRWk1o1ENB 6PkiGmVpExysiTGKVVLEe9u7UV9wz+mxWq0gCk9AvE16Yc/TM06jy3V8rhXImORfBihX nZUQaXJLp87zIstKy+AYYbz3jDIowa+CD7PSDudUY/lrUIkaePHAafdtaaPmc+NRQccZ Cg4eK7tN4d6QM9AWZLBlu89tU+aRQjYl8U87LTKeVz2Ow0vsheLkDxHnq1bSDHRTQmPN zcoJDuNF6OXuhtPOrKiT1WMPuEZG7QEtT/srZwRts0+3m9hqyKhgc8oPwwzw4SrOyntE bFKA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:references:from:subject:cc:to:message-id:date :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=NA5MA9ElT4onBZOSJ0vxjjNzsU+x3HhymHgEqsmUdos=; fh=Xj9jC0em7lHgnMYp5zAGNBu5iIqYmiFiybIuhhetYzQ=; b=cM15e61N8t9nAr2y/u5L786XZF8979ClYBXVTvTk38D0dxJpczL/IaxThNQwj97LGM sz4p+7NtasnzOUP6HUfKVeUugTdsiihv31emjGfQEa6f4UPJ7xTIffqW2GUcqIlPkJhK kDzx+acj26xvrPGqfo3I5qRR7fnja/9MIIhVOWmeZeUxNNr/joko+4coTV55ywJP84jT y9ZSI4lNjvQ5WNIF/l1LyjUn4HLTeknC9nnIFaYYlrTADpjrl4toCvS0aSHeo6Ed+eJV T0Ro0ET60JrW+BLWzLz1AKv/cmlNZu3t5AWjdrMw9MnkZxyY7MMwx6C4ckMPBvgXCzN2 zAgA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DW4HkYj2; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-190292-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190292-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c786fafsi56363725ad.76.2024.05.27.02.10.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 02:10:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190292-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DW4HkYj2; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-190292-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190292-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 CEE11B208A1 for ; Mon, 27 May 2024 09:10:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 97919763EC; Mon, 27 May 2024 09:10:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DW4HkYj2" Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4AC1D6A33D for ; Mon, 27 May 2024 09:10:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716801016; cv=none; b=pP9rVf4NHYoANhZgK6Tbe2jv8M046nmg48Ec5Dzu4QS5u/XvrkbYfZJs0drZpiZRotw2bDSo5Drqm5zLpISdhQrERuYSTSgktYxyBRMUqIYewBE3yxHoSIp4ONrjNG6qbbv/WbnRCc6rMRObE52SYd4Jo76NuxEphaq0W8KSmRM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716801016; c=relaxed/simple; bh=2/Fn/nQA+bYoCF4HHO6FlwIqD+6UmhDLh22fdqRy5Ko=; h=Mime-Version:Content-Type:Date:Message-Id:To:Cc:Subject:From: References:In-Reply-To; b=gDbvoU8g2h8PpJ2zd8kSWu+FAKb/rJLvkiJrWYNQgUe5cU9NMTRLxb6YHukDvSB03imMftN7FBbyMgTe4Df/TPyRZ/0Y3NkugIhLFEwQxH+GPTppE18WakC2gY9VEjVchSTdjdPkZfFWOCNwKMmDvNTHz22sppu3IzZY7aqSnnw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DW4HkYj2; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-6fcbd812b33so1578231b3a.3 for ; Mon, 27 May 2024 02:10:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716801014; x=1717405814; darn=vger.kernel.org; h=in-reply-to:references:from:subject:cc:to:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=NA5MA9ElT4onBZOSJ0vxjjNzsU+x3HhymHgEqsmUdos=; b=DW4HkYj27+uhblDmps4JXTVbXDcOv/RiMjyGpM0B9uMuZrkEN0+zI0kE3ba0Q8tJwN F0aSJbuTo5ZZvsDJSZYjtVdIbaeRp7RLny1JDupMRCDb6VHOkAPZqiQ2Epuyi3fCrfMx 44WB/2WfPlPhi/SuJrrxWwyCH2p5kLmeS/n3usVDHkOEcn5Zx2FEHVFIOxBSikCvB+sm TUUmNZvA9wXWn6xhjWQvCkLwOWu7ZXXeyMZkYl+Fz+WUoWBhycOas+IHUSs3vyH9kX0t AcEwAcGy0RiFplzv2DDrCjvwh8TiL2EncQeY6CBV7M5hEmYpcSEsNC0xq3t82ZyRfTjI rvhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716801014; x=1717405814; h=in-reply-to:references:from:subject:cc:to:message-id:date :content-transfer-encoding:mime-version:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=NA5MA9ElT4onBZOSJ0vxjjNzsU+x3HhymHgEqsmUdos=; b=Fr/uecnN2A/rY0bWu62QHff5cqqYEFmblsZfOODviHAQdnAWBN1D3jxjCt1O9bGoCb EYerdP+LYcyn/9Ifx9wdWMQ3FBOH2O09mbdVblVWqR0QDJMxtkS32M+TOibdul0NppLJ yAzBQr+iIbPu4WnM2j9RRYA8NDIU6FLIY9Tajt06Vj0abK7NY22f4uR2tKQ5VAbsoVly T0bY9gLrBIxuU0ssx4iCykTek3mADlth+gaWTOJtimZIUapAHoJ7bvLvtSH9mgCDdvqe VMOlqdpm/hFCsWPHOtpKQjZOmCi+7Lq0pQnkxfUrSNlzJsESiNJtBZ7uqm0eBhDPRCsd 9aog== X-Forwarded-Encrypted: i=1; AJvYcCXNErn0hdzFs2c+EFItuF9X+XJI3TLP+FyWDNEdN3pWeK/PDaffwc/sUc4xpI4O/l3XFIXLJ7dbXRGblk3+bGdlBPvHhea3biDuRl6X X-Gm-Message-State: AOJu0YxKzFTAtQwOr9t3BRHE+BhaUTsf2bBJr4l3ZruLGYGXn/A7Y8/p 8N2VMn/rBlSPJf8tEWwiqJDnWG1671rfmOJwICM3E4kLzOJ/+45e X-Received: by 2002:a05:6a00:2792:b0:6f3:86ac:5eae with SMTP id d2e1a72fcca58-6f8f41b3b81mr6789895b3a.28.1716801014490; Mon, 27 May 2024 02:10:14 -0700 (PDT) Received: from localhost (110-175-65-7.tpgi.com.au. [110.175.65.7]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f8fbd3dbdesm4660838b3a.18.2024.05.27.02.10.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 27 May 2024 02:10:14 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 27 May 2024 19:10:07 +1000 Message-Id: To: "Thomas Gleixner" , "Oleg Nesterov" , "Frederic Weisbecker" Cc: "Ingo Molnar" , "Peter Zijlstra" , "Phil Auld" , "Chris von Recklinghausen" , Subject: Re: sched/isolation: tick_take_do_timer_from_boot() calls smp_call_function_single() with irqs disabled From: "Nicholas Piggin" X-Mailer: aerc 0.17.0 References: <20240522151742.GA10400@redhat.com> <20240523132358.GA1965@redhat.com> <87h6eneeu7.ffs@tglx> <20240524183700.GA17065@redhat.com> <87v832dfw1.ffs@tglx> In-Reply-To: <87v832dfw1.ffs@tglx> On Sat May 25, 2024 at 8:06 AM AEST, Thomas Gleixner wrote: > On Fri, May 24 2024 at 20:37, Oleg Nesterov wrote: > > > I've already had a few beers today, I know I'll regret about this > > email tomorrow, but I can't resist ;) > > You won't regret it. :) > > > On 05/24, Frederic Weisbecker wrote: > > But again, again. tick_sched_do_timer() says > > > > * If nohz_full is enabled, this should not happen because the > > * 'tick_do_timer_cpu' CPU never relinquishes. > > > > so I guess it is not supposed to happen? > > Right. It does not happen because the kernel starts with jiffies as > clocksource except on S390. The jiffies clocksource is not qualified to > switch over to NOHZ mode for obvious reasons. But even on S390 which has > a truly usable and useful clocksource the tick stays periodic to begin > with. Why? > > The NOHZ ready notification happens late in the boot process via: > fs_initcall(clocksource_done_booting) > > So by the time that happens, the secondary CPUs are up and have taken > over the do timer duty. > > [ 0.600381] smp: Bringing up secondary CPUs ... > > .... > > [ 1.917842] clocksource: Switched to clocksource kvm-clock > [ 1.918548] clocksource_done_booting: Switched to NOHZ // debug printk > > This is the point where tick_nohz_activate() is called first time and > that does: > > tick_sched_flag_set(ts, TS_FLAG_NOHZ); > > So up to this point the tick is never stopped neither on housekeeping > nor on NOHZ FULL CPUs: > > tick_nohz_full_update_tick() > if (!tick_sched_flag_test(ts, TS_FLAG_NOHZ)) > return; > > > And. My main question was: how can smp_call_function_single() help??? > > It's useless. > > > Why do we actually need it? > > We do not. > > As explained above there is also nothing extra to fix contrary to > Frederics fears. > > Even in the case that a command line limitation restricts the number of > CPUs such that there is no housekeeping CPU onlined during > smp_init(). That is checked in the isolation init code which clears > nohz_full_running in that case. Nothing to see there either. > > So all this needs is the simple: > > diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c > index d88b13076b79..dab17d756fd8 100644 > --- a/kernel/time/tick-common.c > +++ b/kernel/time/tick-common.c > @@ -229,11 +209,9 @@ static void tick_setup_device(struct tick_device *td= , > if (tick_nohz_full_cpu(cpu)) > tick_do_timer_boot_cpu =3D cpu; > =20 > - } else if (tick_do_timer_boot_cpu !=3D -1 && > - !tick_nohz_full_cpu(cpu)) { > - tick_take_do_timer_from_boot(); > + } else if (tick_do_timer_boot_cpu !=3D -1 && !tick_nohz_full_cpu(cpu))= { > + WRITE_ONCE(tick_do_timer_cpu, cpu); > tick_do_timer_boot_cpu =3D -1; > - WARN_ON(READ_ONCE(tick_do_timer_cpu) !=3D cpu); > #endif > } > > along with the removal of the SMP function call voodoo programming gunk, > a lengthy changelog and a bunch of useful comments. I might not have tested that path on powerpc since it should not switch clockevent driver (or clocksource either I think) at least on 64-bit. Explains the smp_call_function warning if you are testing on x86 :/ Thanks, Nick