From patchwork Fri Mar 18 04:04:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 8616031 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3A309C0553 for ; Fri, 18 Mar 2016 04:04:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5F9AF2038A for ; Fri, 18 Mar 2016 04:04:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 37B562037F for ; Fri, 18 Mar 2016 04:04:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750842AbcCREEU (ORCPT ); Fri, 18 Mar 2016 00:04:20 -0400 Received: from ozlabs.org ([103.22.144.67]:49535 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750719AbcCREET convert rfc822-to-8bit (ORCPT ); Fri, 18 Mar 2016 00:04:19 -0400 Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 3qRBS14WqLz9s9W; Fri, 18 Mar 2016 15:04:17 +1100 (AEDT) Received: by localhost.localdomain (Postfix, from userid 1000) id 97738EEB216; Fri, 18 Mar 2016 15:04:17 +1100 (AEDT) Message-ID: <1458273857.6622.75.camel@neuling.org> Subject: Re: [PATCH v8 3/6] cpufreq: powernv: Remove cpu_to_chip_id() from hot-path From: Michael Neuling To: Shilpasri G Bhat , linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org Cc: ego@linux.vnet.ibm.com, linux-pm@vger.kernel.org, viresh.kumar@linaro.org, rjw@rjwysocki.net, pc@us.ibm.com, shreyas@linux.vnet.ibm.com, anton@samba.org Date: Fri, 18 Mar 2016 15:04:17 +1100 In-Reply-To: <1454442102-1229-4-git-send-email-shilpa.bhat@linux.vnet.ibm.com> References: <1454442102-1229-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com> <1454442102-1229-4-git-send-email-shilpa.bhat@linux.vnet.ibm.com> X-Mailer: Evolution 3.16.5-1ubuntu3.1 Mime-Version: 1.0 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, 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 On Wed, 2016-02-03 at 01:11 +0530, Shilpasri G Bhat wrote: > cpu_to_chip_id() does a DT walk through to find out the chip id by > taking a contended device tree lock. This adds an unnecessary overhead > in a hot path. So instead of calling cpu_to_chip_id() everytime cache > the chip ids for all cores in the array 'core_to_chip_map' and use it > in the hotpath. > > Reported-by: Anton Blanchard > Signed-off-by: Shilpasri G Bhat > Reviewed-by: Gautham R. Shenoy > Acked-by: Viresh Kumar > --- > No changes from v7. How about this instead? It removes the linear lookup and seems a lot less complex. Mikey --- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c index 547890f..d63d2cb 100644 --- a/drivers/cpufreq/powernv-cpufreq.c +++ b/drivers/cpufreq/powernv-cpufreq.c @@ -52,6 +52,7 @@ static struct chip { } *chips; static int nr_chips; +static DEFINE_PER_CPU(unsigned int, chip_id); /* * Note: The set of pstates consists of contiguous integers, the @@ -317,9 +318,7 @@ static void powernv_cpufreq_throttle_check(void *data) pmsr = get_pmspr(SPRN_PMSR); - for (i = 0; i < nr_chips; i++) - if (chips[i].id == cpu_to_chip_id(cpu)) - break; + i = this_cpu_read(chip_id); /* Check for Pmax Capping */ pmsr_pmax = (s8)PMSR_MAX(pmsr); @@ -560,6 +559,7 @@ static int init_chip_info(void) for_each_possible_cpu(cpu) { unsigned int id = cpu_to_chip_id(cpu); + per_cpu(chip_id, cpu) = nr_chips; if (prev_chip_id != id) { prev_chip_id = id; chip[nr_chips++] = id;