From patchwork Fri Mar 7 17:48:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Pandruvada X-Patchwork-Id: 3793771 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BD4BB9F35F for ; Fri, 7 Mar 2014 17:46:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EE2C6202F2 for ; Fri, 7 Mar 2014 17:46:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1C582202EA for ; Fri, 7 Mar 2014 17:46:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752302AbaCGRqD (ORCPT ); Fri, 7 Mar 2014 12:46:03 -0500 Received: from mga02.intel.com ([134.134.136.20]:16819 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751818AbaCGRqB (ORCPT ); Fri, 7 Mar 2014 12:46:01 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 07 Mar 2014 09:46:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,609,1389772800"; d="scan'208";a="495965209" Received: from spandruv-desktop.jf.intel.com ([10.7.199.159]) by orsmga002.jf.intel.com with ESMTP; 07 Mar 2014 09:45:59 -0800 From: Srinivas Pandruvada To: rjw@rjwysocki.net Cc: linux-pm@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH] PowerCap / RAPL : Use async init Date: Fri, 7 Mar 2014 09:48:49 -0800 Message-Id: <1394214529-11369-1-git-send-email-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 1.7.11.7 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The rapl_init function takes around 58ms per domain. This change reduce this by introducing async_schedule. Only disadvanatge is that only presence of RAPL feature is checked for succesful module init. If there is any other error, it will simply not create powercap sysfs files, but module will still return success. Signed-off-by: Srinivas Pandruvada --- drivers/powercap/intel_rapl.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/powercap/intel_rapl.c b/drivers/powercap/intel_rapl.c index 61b51e1..3b11c6f 100644 --- a/drivers/powercap/intel_rapl.c +++ b/drivers/powercap/intel_rapl.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -1364,16 +1365,10 @@ static struct notifier_block rapl_cpu_notifier = { .notifier_call = rapl_cpu_callback, }; -static int __init rapl_init(void) +static void __init rapl_init_async(void *unused, async_cookie_t cookie) { int ret = 0; - if (!x86_match_cpu(rapl_ids)) { - pr_err("driver does not support CPU family %d model %d\n", - boot_cpu_data.x86, boot_cpu_data.x86_model); - - return -ENODEV; - } /* prevent CPU hotplug during detection */ get_online_cpus(); ret = rapl_detect_topology(); @@ -1382,14 +1377,27 @@ static int __init rapl_init(void) if (rapl_register_powercap()) { rapl_cleanup_data(); - ret = -ENODEV; goto done; } register_hotcpu_notifier(&rapl_cpu_notifier); done: put_online_cpus(); - return ret; +} + +static int __init rapl_init(void) +{ + + if (!x86_match_cpu(rapl_ids)) { + pr_err("driver does not support CPU family %d model %d\n", + boot_cpu_data.x86, boot_cpu_data.x86_model); + + return -ENODEV; + } + + async_schedule(rapl_init_async, NULL); + + return 0; } static void __exit rapl_exit(void)