Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp624198lqb; Fri, 24 May 2024 08:23:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU8biigeg403acDeU4oTG1j3qffET5AYOa5V1XA9sIMSsGCI0cfgfo2BzPQS9B9/izTPUKLneLQwS7mW/ZSqt3UAzxrMgDpiwteaewa3w== X-Google-Smtp-Source: AGHT+IFqJPZcUOQmbYQG1Zn/PI0vCjFEvNQko1T0QGSq2DBirGSrWs/CySrSJvMtMcxPX2P4VoBY X-Received: by 2002:a05:6870:1797:b0:24c:5169:913b with SMTP id 586e51a60fabf-24ca11de651mr2696509fac.20.1716564183982; Fri, 24 May 2024 08:23:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716564183; cv=pass; d=google.com; s=arc-20160816; b=gN1kPXHzqGrXhbeZn1KvVYbgSaZZRKZrndPO2Td8TPEIUr9rqpMCYmQnia2DxmoiSJ UQPWhYm+0jKnRfHTHHniwfzg9mL67UYCE2drtCAn4yPSNIOlHGIVR7wnjASDX+olqri8 flRNd4sRY0EfsKlmyBqzCvrCEjqWKv0tJ7S6J8JcpvioGsCxcebARJBNvJvEMmelNxAX 7bPkAqCtK6Uk8ET6ATLXhgxzc8dc0KNVk+5iRxkqq22X9GmRL6b7YvzHVKz/AOeXXdBX UIzuehuIlDfXf3Hq58DVDDoAL+icbRc2wc1Ga7kXSrxouxvzKdQFFHOs1097kcxUDGYz BGDA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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=fj4JzdTmMbEAk0JsJqzDP3EDOLLTqDAsa3ePtb3XrO0=; fh=jl9scrPkBR4ieL6VwYO3hFybKBAqaka/Z0uY6lxD/fQ=; b=XK2LT9Yar81lv9wm1oEmrsuT/cXRtP4bK6pZ36PZumZju42pqNKNhxVeGQ0TnlCuL6 MnnoobPRMUnP8j2fINOn5JqH32fUViH5ArBm0OAwAPlB6JSJJkhAqAxNU0+qUYg8IgwV j4ZZuPZ3E4CMSjA8NmOEXVQyfHIwcNAG8ufQYXAIYFef31lmdCL4tdVuwXUmx3ZgKsDc l86EmOBDPo/norT/dmTMUcECM0cZb+xJGA+TV2tsmvMILis2yTtavLJZ9/TV+OY5wbPH uq24OoqUXvsWENr9CyNy0hoKrKqAnajuIkwpdqR+R47nICBvSk9vV86yT9IU0BRRE4d9 13+g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ElhUYfZu; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-188850-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188850-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ada2fe7eead31-48a3a3f87b7si407981137.711.2024.05.24.08.23.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 08:23:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-188850-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ElhUYfZu; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-188850-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188850-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id ACF2A1C209F4 for ; Fri, 24 May 2024 15:23:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DD31812E1CA; Fri, 24 May 2024 15:22:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ElhUYfZu" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1590112DDB3 for ; Fri, 24 May 2024 15:22:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716564140; cv=none; b=J0BDvBliNuc7uVZp+Czd7PDr2OA7w27Z5o5/Xy2bcLQf1RpsO/NsG+McnE2W97TE/RR04TlL6WPD4S/qxS/GJWJx3nXgdQ3AxPrD31QJqvRn8pAIO+eWMH9ngZsisKEhbRGxtXcP5DRstYbPwDOF9ln7ZDTmNRq3ifs0CB3I3bQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716564140; c=relaxed/simple; bh=rERK38A3YDvE0CAtapMe8mxNsMbKVDTYsfNJyVUOTa4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=klFPraF4oCOfLfYQ2kNd5ilqqZxCEbg1O4SxxExaVp/+pp6KxyMe/8rkOVYO4m+8nEtYSNL6HLbex+PnHVVA+MK7i+IT3zyPbu2xOeKXK5ab94j9StFOcYHpQi4+MqBO3MAu+rlHtoDFrHiSIJEv48+ITZF4b0/QTNda0yu4jXI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ElhUYfZu; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DD2CC2BBFC; Fri, 24 May 2024 15:22:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716564139; bh=rERK38A3YDvE0CAtapMe8mxNsMbKVDTYsfNJyVUOTa4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ElhUYfZuIxVWE1d2d0zdwnEg7VPJNUsIIgjeECn2Fw/Hvej4YemstEuJNSoS/Kkxo 7l93U+MDDNuD8o/Rhpt2yTkhjaxJZqt/Y8XQZT3jqcJduPneQT8KohIiWg/FZcCF1e ZVDj7DSKX3YI/dwbzpO+naqp99zbM+zywVaXb2y94KrvXZ09bEMVEhiLkSSM44wkyy A3KgKSHwmot2fTmevA9UzzM8L8SS3Pr7oz0n5zryc7F0ntQAu+XQhRd2sLea9puqLl 2wX8orrpDm9jZkjbgxVae8jBoWmogBw0kEv0XOvVpQ4JMBxIm9l8qZInw7AAi86AC0 HL4TbNnOkVc6g== Date: Fri, 24 May 2024 17:22:16 +0200 From: Frederic Weisbecker To: Oleg Nesterov Cc: Thomas Gleixner , Ingo Molnar , Nicholas Piggin , Peter Zijlstra , Phil Auld , Chris von Recklinghausen , linux-kernel@vger.kernel.org Subject: Re: sched/isolation: tick_take_do_timer_from_boot() calls smp_call_function_single() with irqs disabled Message-ID: References: <20240522151742.GA10400@redhat.com> <20240523132358.GA1965@redhat.com> <87h6eneeu7.ffs@tglx> <20240524141018.GA14261@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: <20240524141018.GA14261@redhat.com> Le Fri, May 24, 2024 at 04:10:52PM +0200, Oleg Nesterov a ?crit : > Hi Thomas, > > On 05/24, Thomas Gleixner wrote: > > > > >> But I don't even understand why exactly we need smp_call_function()... > > > > It's not required at all. > > > > >> Race with tick_nohz_stop_tick() on boot CPU which can set > > >> tick_do_timer_cpu = TICK_DO_TIMER_NONE? Is it really bad? > > > > This can't happen. > > > > > And is it supposed to happen if tick_nohz_full_running ? > > > > > > tick_sched_do_timer() and can_stop_idle_tick() claim that > > > TICK_DO_TIMER_NONE is not possible in this case... > > > > What happens during boot is: > > > > 1) The boot CPU takes the do_timer duty when it installs its > > clockevent device > > > > 2) The boot CPU does not give up the duty because of this > > condition in can_stop_idle_tick(): > > > > if (tick_nohz_full_enabled()) { > > if (tick_cpu == cpu) > > return false; > > Yes, I have looked at this code too. But I failed to understand its > callers, even tick_nohz_idle_stop_tick() which doesn't even call this > function when ts->timer_expires != 0. > > This code is too tricky for me, I still don't follow the logic. > Damn, I can't even remember the names of all these functions ;) > > > > So, once again, could you explain why the patch below is wrong? > > > > > - tick_take_do_timer_from_boot(); > > > tick_do_timer_boot_cpu = -1; > > > - WARN_ON(READ_ONCE(tick_do_timer_cpu) != cpu); > > > + WRITE_ONCE(tick_do_timer_cpu, cpu); > > > > This part is perfectly fine. > > Great, thanks! I'll write the changelog and send the patch tomorrow. > > > > --- a/kernel/time/tick-sched.c > > > +++ b/kernel/time/tick-sched.c > > > @@ -1014,6 +1014,9 @@ static void tick_nohz_stop_tick(struct tick_sched *ts, int cpu) > > > */ > > > tick_cpu = READ_ONCE(tick_do_timer_cpu); > > > if (tick_cpu == cpu) { > > > +#ifdef CONFIG_NO_HZ_FULL > > > + WARN_ON_ONCE(tick_nohz_full_running); > > > +#endif > > > > WARN_ON_ONCE(tick_nohz_full_enabled()); > > > > which spares the ugly #ifdef? > > Yes but tick_nohz_full_enabled() depends on context_tracking_key, and > context_tracking_enabled() is false without CONFIG_CONTEXT_TRACKING_USER. > I didn't even try to check if it is selected by NO_HZ_FULL and how do > they play together. Yes it is! You can rely on it. Thanks.