Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp182873pxb; Thu, 12 Aug 2021 13:50:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySp1vGl45J9rP35eV7nJJZ3xNFG1sR194rBVnwwys27vasXdemJLmweYbL+gEVBaenbevF X-Received: by 2002:aa7:cb8a:: with SMTP id r10mr7961077edt.237.1628801448875; Thu, 12 Aug 2021 13:50:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628801448; cv=none; d=google.com; s=arc-20160816; b=N/V+R5TLzD/UWP/LL/m1JrN3wqndrS3+SMy7U6eVLV/lMCI4lvv4jPm4JRQBCBE7hx 07hZmYltBK0U0os36wj/OTcJNBqEtSuOtcySBbyfNuAtIPOOaqSqyI29QSWfqucz+u/X PVI+NDAILDT1R7OUyntfFn4leKBhkYl7BCdqFp0bqfIXqxEPEyVSGzmanmqO5yyJQRSN Sfg4z+25zpgFP12vTI+1fu1vnUSWQYAkyF5msbCaeel4jcjnnr04cuNV8n5uHxgIhnaX zM9fl018E9QBcKhT9pUl6AW02E2dOYlemx7S55H27GIZXq6UQuPYCZTdngNTVVx/CUWb RC4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=E3exK/lR6t6Dbvglgzd+Bf4fBmwMv8kRs9nn23PWQEM=; b=cqYrpTk4aIOl+bCvepSuXt8ZDgtKL/VApOucixwS//Iu2xvKFo6n/RtkAlgJKIDISA jOVTtbk/uCnwpzCtl9YuW7Trlw1m+6Nt9IF4NWksqkdzrV0l+v0VhUwLXjflG2dTa4FA 7aCeNlNprbvC2WYunBDINhlL18UgzazVLKz9LDgSFOOFkexDiVd6mYnBaClfvvbBd3cO wyu1iqHFnGw3bQkDQtRDBwEZ1QgmfVNH6fDbw3oPfKAHHdJqNyQlJz9fZYEH/Nv+VSj/ jl0qeiMjpkaFSj8weILi6XviQjjzNog25ksvguyWG89eaifJPf6w85JtxCtjiDDGxVVy Kwfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Y5+HA1E7; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=fGdZmd5Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q3si3824646edr.145.2021.08.12.13.50.26; Thu, 12 Aug 2021 13:50:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Y5+HA1E7; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=fGdZmd5Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233915AbhHLUbx (ORCPT + 99 others); Thu, 12 Aug 2021 16:31:53 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:60820 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbhHLUbw (ORCPT ); Thu, 12 Aug 2021 16:31:52 -0400 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1628800285; 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=E3exK/lR6t6Dbvglgzd+Bf4fBmwMv8kRs9nn23PWQEM=; b=Y5+HA1E7/u03PL+rCmCOnL0fuU0NGWloBEApwv/NAeO539dTI4eIAHDQ7UffnNc7BGxQZN nrGM1fsHU3yuVuKfvQWF2D5Ejz6Okg9isd05fkK43VLJDD/WECYPRjJguWQm4avSCHs6+4 S2jkpBcy0aC860MvdA1DCsENgnQVzi9su5gUkVXimJFC5F8pyid0KN1uC68v4YsXivM5Gr T4VuDBTZCQrl3wsiyIlLZL0lOZfr2Gfo5cT1Go5P89+Zlr1qaALAan1z4CRXAyHLF+fOjP exEuyFre2N8bABLKdf38w8ab2klvsDG51/y3tkngXg0U0USFu989Bv7w+Y59hQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1628800285; 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=E3exK/lR6t6Dbvglgzd+Bf4fBmwMv8kRs9nn23PWQEM=; b=fGdZmd5Z/lT71YUoVKW/uI0bHV+P9lahndmDL6ArS1FXRZSi/vrkVQzCG502PnHJqbHHwP cHGPWrJr8U4MCmAw== To: Mike Galbraith , linux-kernel@vger.kernel.org, linux-tip-commits@vger.kernel.org Cc: Peter Zijlstra , x86@kernel.org, Marek Szyprowski Subject: [PATCH] hrtimer: Use raw_cpu_ptr() in clock_was_set() In-Reply-To: <87a6lmiwi0.ffs@tglx> References: <20210713135158.054424875@linutronix.de> <162861133759.395.7795246170325882103.tip-bot2@tip-bot2> <7dfb3b15af67400227e7fa9e1916c8add0374ba9.camel@gmx.de> <87a6lmiwi0.ffs@tglx> Date: Thu, 12 Aug 2021 22:31:24 +0200 Message-ID: <875ywacsmb.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org clock_was_set() can be invoked from preemptible context. Use raw_cpu_ptr() to check whether high resolution mode is active or not. It does not matter whether the task migrates after acquiring the pointer. Fixes: e71a4153b7c2 ("hrtimer: Force clock_was_set() handling for the HIGHRES=n, NOHZ=y case") Reported-by: Mike Galbraith Signed-off-by: Thomas Gleixner --- kernel/time/hrtimer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -944,10 +944,11 @@ static bool update_needs_ipi(struct hrti */ void clock_was_set(unsigned int bases) { + struct hrtimer_cpu_base *cpu_base = raw_cpu_ptr(&hrtimer_bases); cpumask_var_t mask; int cpu; - if (!hrtimer_hres_active() && !tick_nohz_active) + if (!__hrtimer_hres_active(cpu_base) && !tick_nohz_active) goto out_timerfd; if (!zalloc_cpumask_var(&mask, GFP_KERNEL)) { @@ -958,9 +959,9 @@ void clock_was_set(unsigned int bases) /* Avoid interrupting CPUs if possible */ cpus_read_lock(); for_each_online_cpu(cpu) { - struct hrtimer_cpu_base *cpu_base = &per_cpu(hrtimer_bases, cpu); unsigned long flags; + cpu_base = &per_cpu(hrtimer_bases, cpu); raw_spin_lock_irqsave(&cpu_base->lock, flags); if (update_needs_ipi(cpu_base, bases))