Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2976237imu; Sun, 9 Dec 2018 14:06:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xn3k2rXXW1/Ek7JH+UAFW7BLQFTn89gU8AownaL4sfJqNFwGY9DrWdCg6rSvgkDO4xBa/t X-Received: by 2002:a17:902:bc3:: with SMTP id 61mr9899186plr.15.1544393184031; Sun, 09 Dec 2018 14:06:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544393184; cv=none; d=google.com; s=arc-20160816; b=0wM1GANjrYNjomWPew3i0SJi3BFts+1MY7wwJWimxAHfeI+W4VyHNJgYq8PyvO9ePA 16EVWDhoub+afrvRYwORKou8t+KVlSsB49qTJCy4j3vipBGGytl0ZcXbDC9GQuQbEPas IMo5BPuIKKyBiM06+UfINQPgeM1Tq2+t7UBpFRSDzbYx/nIqr1bzsZRnvdzBfZGGV7yM sdqNW7BiYompxVg8mLe5rKG5uQqLJ+NmmK0YmUjmQSdoHPn+m4qDlnJQ/0pAw2Z9/n41 YLzHIFiYFZB1HkP1gqJS4Uo+XZw5hXBg4IV54v/YMBKYOrNnOoQzlGk0eattm5n3PVnZ 9iFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=p7wHRpes/y2sPpIr1LlBAGLmZWh42QqwzpD5f/DPKEE=; b=Sfs+eMPpro3TFK7jAn0l7l3VZQ5Iu2Yd8+KWRhj+meLamCvKXO/xEyTsuDHjw/IE1+ Goz/59a4LEEG+NEGCr/nVpZPVEAr+KHbzXB2NIihe7meyv5YdgkoFukFtSLaWWHlPBo7 yFslTw0ZTuJ1PBtWKnXYCgTp44P20Pvsz16zKa2/2vJDQjghAHTezZ4kZoTfMRnc8Cce 3hqWjoDTDeuyD/qt22P9jFxi3u/Wy4LLczIAuV97j6T7NZuZNuLmZ9/FBIVWPz5jbyI1 dXe/ob/3DCfO3i2QDFrZ95WC5haMCV1oZeW9TBcdEm9HOxYhVrNBjHy+1VyAPLAWYV47 A6tQ== 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 q16si6046272pfh.138.2018.12.09.14.06.08; Sun, 09 Dec 2018 14:06:23 -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 S1727392AbeLIWDl (ORCPT + 99 others); Sun, 9 Dec 2018 17:03:41 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35608 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726585AbeLIVz2 (ORCPT ); Sun, 9 Dec 2018 16:55:28 -0500 Received: from pub.yeoldevic.com ([81.174.156.145] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gW72q-0002im-WF; Sun, 09 Dec 2018 21:55:25 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gW72l-0003hN-Mo; Sun, 09 Dec 2018 21:55:19 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Catalin Marinas" , "Rafael J. Wysocki" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 321/328] cpuidle: Do not access cpuidle_devices when !CONFIG_CPU_IDLE In-Reply-To: X-SA-Exim-Connect-IP: 81.174.156.145 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.62-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Catalin Marinas commit 9bd616e3dbedfc103f158197c8ad93678849b1ed upstream. The cpuidle_devices per-CPU variable is only defined when CPU_IDLE is enabled. Commit c8cc7d4de7a4 ("sched/idle: Reorganize the idle loop") removed the #ifdef CONFIG_CPU_IDLE around cpuidle_idle_call() with the compiler optimising away __this_cpu_read(cpuidle_devices). However, with CONFIG_UBSAN && !CONFIG_CPU_IDLE, this optimisation no longer happens and the kernel fails to link since cpuidle_devices is not defined. This patch introduces an accessor function for the current CPU cpuidle device (returning NULL when !CONFIG_CPU_IDLE) and uses it in cpuidle_idle_call(). Signed-off-by: Catalin Marinas Signed-off-by: Rafael J. Wysocki Signed-off-by: Ben Hutchings --- include/linux/cpuidle.h | 3 +++ kernel/sched/idle.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -146,6 +146,8 @@ extern int cpuidle_play_dead(void); extern void cpuidle_use_deepest_state(bool enable); extern struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev); +static inline struct cpuidle_device *cpuidle_get_device(void) +{return __this_cpu_read(cpuidle_devices); } #else static inline void disable_cpuidle(void) { } static inline int cpuidle_select(struct cpuidle_driver *drv, @@ -179,6 +181,7 @@ static inline int cpuidle_play_dead(void static inline void cpuidle_use_deepest_state(bool enable) {} static inline struct cpuidle_driver *cpuidle_get_cpu_driver( struct cpuidle_device *dev) {return NULL; } +static inline struct cpuidle_device *cpuidle_get_device(void) {return NULL; } #endif #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -76,7 +76,7 @@ void __weak arch_cpu_idle(void) */ static void cpuidle_idle_call(void) { - struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices); + struct cpuidle_device *dev = cpuidle_get_device(); struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); int next_state, entered_state; bool broadcast;