From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Rafael J. Wysocki" Subject: Re: [PATCH 2/2] PM / arch: x86: MSR_IA32_ENERGY_PERF_BIAS sysfs interface Date: Thu, 09 May 2019 19:18:28 +0200 Message-ID: <1627338.1fd8ofggM8@kreacher> References: <1637073.gl2OfxWTjI@aspire.rjw.lan> <1762575.ER2xjzr9E1@aspire.rjw.lan> <20190509102315.GA31824@splinter> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Return-path: In-Reply-To: <20190509102315.GA31824@splinter> Sender: linux-kernel-owner@vger.kernel.org To: Ido Schimmel Cc: x86 , LKML , Len Brown , Linux PM , Srinivas Pandruvada , Laura Abbott , Thomas Gleixner , Peter Zijlstra , Ingo Molnar , Simon Schricker , Borislav Petkov , Hannes Reinecke List-Id: linux-pm@vger.kernel.org On Thursday, May 9, 2019 12:23:15 PM CEST Ido Schimmel wrote: > On Thu, Mar 21, 2019 at 11:20:17PM +0100, Rafael J. Wysocki wrote: > > +static struct attribute *intel_epb_attrs[] = { > > + &dev_attr_energy_perf_bias.attr, > > + NULL > > +}; > > + > > +static const struct attribute_group intel_epb_attr_group = { > > + .name = power_group_name, > > + .attrs = intel_epb_attrs > > +}; > > + > > static int intel_epb_online(unsigned int cpu) > > { > > + struct device *cpu_dev = get_cpu_device(cpu); > > + > > intel_epb_restore(); > > + if (!cpuhp_tasks_frozen) > > + sysfs_merge_group(&cpu_dev->kobj, &intel_epb_attr_group); > > + > > return 0; > > } > > > > static int intel_epb_offline(unsigned int cpu) > > { > > - return intel_epb_save(); > > + struct device *cpu_dev = get_cpu_device(cpu); > > + > > + if (!cpuhp_tasks_frozen) > > + sysfs_unmerge_group(&cpu_dev->kobj, &intel_epb_attr_group); > > + > > + intel_epb_save(); > > + return 0; > > } > > Hi, > > I just booted net-next and got the following NULL pointer dereference > [1] during boot. I believe it is caused by this patch. I think you're right, sorry about this. > CONFIG_PM is disabled in my config which means 'power_group_name' is > defined as NULL. When I enable CONFIG_PM the issue is not reproduced. So does the patch below fix it for you? --- arch/x86/kernel/cpu/intel_epb.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) Index: linux-pm/arch/x86/kernel/cpu/intel_epb.c =================================================================== --- linux-pm.orig/arch/x86/kernel/cpu/intel_epb.c +++ linux-pm/arch/x86/kernel/cpu/intel_epb.c @@ -97,6 +97,7 @@ static void intel_epb_restore(void) wrmsrl(MSR_IA32_ENERGY_PERF_BIAS, (epb & ~EPB_MASK) | val); } +#ifdef CONFIG_PM static struct syscore_ops intel_epb_syscore_ops = { .suspend = intel_epb_save, .resume = intel_epb_restore, @@ -193,6 +194,25 @@ static int intel_epb_offline(unsigned in return 0; } +static inline void register_intel_ebp_syscore_ops(void) +{ + register_syscore_ops(&intel_epb_syscore_ops); +} +#else /* !CONFIG_PM */ +static int intel_epb_online(unsigned int cpu) +{ + intel_epb_restore(); + return 0; +} + +static int intel_epb_offline(unsigned int cpu) +{ + return intel_epb_save(); +} + +static inline void register_intel_ebp_syscore_ops(void) {} +#endif + static __init int intel_epb_init(void) { int ret; @@ -206,7 +226,7 @@ static __init int intel_epb_init(void) if (ret < 0) goto err_out_online; - register_syscore_ops(&intel_epb_syscore_ops); + register_intel_ebp_syscore_ops(); return 0; err_out_online: From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00F16C04AB1 for ; Thu, 9 May 2019 17:18:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CFE56217D7 for ; Thu, 9 May 2019 17:18:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726714AbfEIRSc (ORCPT ); Thu, 9 May 2019 13:18:32 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:44037 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726620AbfEIRSc (ORCPT ); Thu, 9 May 2019 13:18:32 -0400 Received: from 79.184.254.161.ipv4.supernova.orange.pl (79.184.254.161) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.213) id dde0ba7bd4127124; Thu, 9 May 2019 19:18:29 +0200 From: "Rafael J. Wysocki" To: Ido Schimmel Cc: x86 , LKML , Len Brown , Linux PM , Srinivas Pandruvada , Laura Abbott , Thomas Gleixner , Peter Zijlstra , Ingo Molnar , Simon Schricker , Borislav Petkov , Hannes Reinecke Subject: Re: [PATCH 2/2] PM / arch: x86: MSR_IA32_ENERGY_PERF_BIAS sysfs interface Date: Thu, 09 May 2019 19:18:28 +0200 Message-ID: <1627338.1fd8ofggM8@kreacher> In-Reply-To: <20190509102315.GA31824@splinter> References: <1637073.gl2OfxWTjI@aspire.rjw.lan> <1762575.ER2xjzr9E1@aspire.rjw.lan> <20190509102315.GA31824@splinter> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Message-ID: <20190509171828.YfzSBsUQ9Ret4tsVZEUY0gl1466qgFMue21beDJQq8I@z> On Thursday, May 9, 2019 12:23:15 PM CEST Ido Schimmel wrote: > On Thu, Mar 21, 2019 at 11:20:17PM +0100, Rafael J. Wysocki wrote: > > +static struct attribute *intel_epb_attrs[] = { > > + &dev_attr_energy_perf_bias.attr, > > + NULL > > +}; > > + > > +static const struct attribute_group intel_epb_attr_group = { > > + .name = power_group_name, > > + .attrs = intel_epb_attrs > > +}; > > + > > static int intel_epb_online(unsigned int cpu) > > { > > + struct device *cpu_dev = get_cpu_device(cpu); > > + > > intel_epb_restore(); > > + if (!cpuhp_tasks_frozen) > > + sysfs_merge_group(&cpu_dev->kobj, &intel_epb_attr_group); > > + > > return 0; > > } > > > > static int intel_epb_offline(unsigned int cpu) > > { > > - return intel_epb_save(); > > + struct device *cpu_dev = get_cpu_device(cpu); > > + > > + if (!cpuhp_tasks_frozen) > > + sysfs_unmerge_group(&cpu_dev->kobj, &intel_epb_attr_group); > > + > > + intel_epb_save(); > > + return 0; > > } > > Hi, > > I just booted net-next and got the following NULL pointer dereference > [1] during boot. I believe it is caused by this patch. I think you're right, sorry about this. > CONFIG_PM is disabled in my config which means 'power_group_name' is > defined as NULL. When I enable CONFIG_PM the issue is not reproduced. So does the patch below fix it for you? --- arch/x86/kernel/cpu/intel_epb.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) Index: linux-pm/arch/x86/kernel/cpu/intel_epb.c =================================================================== --- linux-pm.orig/arch/x86/kernel/cpu/intel_epb.c +++ linux-pm/arch/x86/kernel/cpu/intel_epb.c @@ -97,6 +97,7 @@ static void intel_epb_restore(void) wrmsrl(MSR_IA32_ENERGY_PERF_BIAS, (epb & ~EPB_MASK) | val); } +#ifdef CONFIG_PM static struct syscore_ops intel_epb_syscore_ops = { .suspend = intel_epb_save, .resume = intel_epb_restore, @@ -193,6 +194,25 @@ static int intel_epb_offline(unsigned in return 0; } +static inline void register_intel_ebp_syscore_ops(void) +{ + register_syscore_ops(&intel_epb_syscore_ops); +} +#else /* !CONFIG_PM */ +static int intel_epb_online(unsigned int cpu) +{ + intel_epb_restore(); + return 0; +} + +static int intel_epb_offline(unsigned int cpu) +{ + return intel_epb_save(); +} + +static inline void register_intel_ebp_syscore_ops(void) {} +#endif + static __init int intel_epb_init(void) { int ret; @@ -206,7 +226,7 @@ static __init int intel_epb_init(void) if (ret < 0) goto err_out_online; - register_syscore_ops(&intel_epb_syscore_ops); + register_intel_ebp_syscore_ops(); return 0; err_out_online: