Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp539693ybv; Sat, 22 Feb 2020 08:54:11 -0800 (PST) X-Google-Smtp-Source: APXvYqwCBYyFpBtHRmWgIkZyPqp8yU8SXUiqVssEAB1kNqAKu95O/Y/l1t5CoMxwEuX/HcoURJrt X-Received: by 2002:a9d:6544:: with SMTP id q4mr31964814otl.269.1582390451662; Sat, 22 Feb 2020 08:54:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582390451; cv=none; d=google.com; s=arc-20160816; b=peDVODEO5yQbY0kNG7cXeg9Sg71Z1sc50cmAZA235rhByNgPSDwwVRoQsIJcQnRHCh Qdku/smlM7LD5a/ngmYndBDFVRsUWKmSEKZ56ByX3T7XPDvtJYXhIGZxKmfnK0f+AnUe T68C7tqdi9zBbIdqXV5AS2hSHLmOnPMfU3OaiqAg07TqQ0jE0xaL9fzHCXIiFQDnOuP8 omxyvH3vmV0HDtREclM0z4CEKcV+lAScgdzdQzcnfzVRN1JBATzdt4FaE3dJxZIgECK9 PckUC83nRZOw1yBh4Cr7CWTKpbPHdeJVVQoHFrCf5xo/GqMgqvTQ/VkvFrOMdS3075qX LruQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version; bh=G1WGHMkP8/oRmF4zUZAb3KGatOM3TLjF4A+3QFjugyk=; b=PzTuf85mUI3ln91QY4RBa4T7bgIljKyprUNTwp/8KtZe82exUJvop2MelNiEFSBA/3 ata+LlOP+bx90k4DRLnuaaAcj7NPacV8wLS38a3dkWiGPVOBFf7oiHRJMhvtrMgqNqqw cedhOl41RE2RIC1XMAECdO8KcghppFwJTnLBF1IjQKxrCiqt6ORwBzlwyFCQ73k7AUC9 XcElOy/2IYUpIwoe7ySup/2mLKi8Qs4BPbSyzTvmw7OYdrUEtme5M0wFLViBajByFY3Z fTyv6jqrZlwjaUv/KqHEJeLUxZBRgt6+3eJwuv+0NyQtbhV1FIjqUgOMnjQ8yNzabp+b W74w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 64si3540810otx.50.2020.02.22.08.53.58; Sat, 22 Feb 2020 08:54:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726701AbgBVQxv convert rfc822-to-8bit (ORCPT + 99 others); Sat, 22 Feb 2020 11:53:51 -0500 Received: from mail.fireflyinternet.com ([77.68.26.236]:55608 "EHLO fireflyinternet.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726198AbgBVQxv (ORCPT ); Sat, 22 Feb 2020 11:53:51 -0500 X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from localhost (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP (TLS) id 20315157-1500050 for multiple; Sat, 22 Feb 2020 16:53:32 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT To: Srinivas Pandruvada , bp@alien8.de, hpa@zytor.com, mingo@redhat.com, tglx@linutronix.de, tony.luck@intel.com From: Chris Wilson In-Reply-To: <20200222162432.497201-1-srinivas.pandruvada@linux.intel.com> Cc: x86@kernel.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada References: <20200222162432.497201-1-srinivas.pandruvada@linux.intel.com> Message-ID: <158239041049.15220.2836895127344585201@skylake-alporthouse-com> User-Agent: alot/0.6 Subject: Re: [PATCH] x86/mce/therm_throt: Handle case where throttle_active_work() is called on behalf of an offline CPU Date: Sat, 22 Feb 2020 16:53:30 +0000 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Srinivas Pandruvada (2020-02-22 16:24:32) > During cpu-hotplug test with CONFIG_PREEMPTION and CONFIG_DEBUG_PREEMPT > enabled, Chris reported error: > > BUG: using smp_processor_id() in preemptible [00000000] code: kworker/1:0/17 > caller is throttle_active_work+0x12/0x280 > > Here throttle_active_work() is a work queue callback scheduled with > schedule_delayed_work_on(). This will not cause this error for the use > of smp_processor_id() under normal conditions as there is a check for > "current->nr_cpus_allowed == 1". > But when the target CPU is offline the workqueue becomes unbound. > Then the work queue callback can be scheduled on another CPU and the > error is printed for the use of smp_processor_id() in preemptible context. > > When the workqueue is not getting called on the target CPU, simply return. > This is done by adding a cpu field in the _thermal_state struct and match > the current CPU id. > > Once workqueue is scheduled, prevent CPU offline. In this way, the log > bits are checked and cleared on the correct CPU. Also use get_cpu() to > get current CPU id and prevent preemption before we finish processing. > > Fixes: f6656208f04e ("x86/mce/therm_throt: Optimize notifications of thermal throttle") > Reported-by: Chris Wilson > Signed-off-by: Srinivas Pandruvada > Reviewed-by: Tony Luck I've pushed the patch to our CI, but it's not a frequent occurrence, so it may be some time before I can state a t-b with any confidence. -Chris