Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934565AbdCWNK3 (ORCPT ); Thu, 23 Mar 2017 09:10:29 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:59689 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932941AbdCWNK2 (ORCPT ); Thu, 23 Mar 2017 09:10:28 -0400 X-IMSS-HAND-OFF-DIRECTIVE: 127.0.0.1:10026 Date: Thu, 23 Mar 2017 18:39:47 +0530 From: Gautham R Shenoy To: Madhavan Srinivasan Cc: mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Hemant Kumar , "Gautham R . Shenoy" , Balbir Singh , Benjamin Herrenschmidt , Paul Mackerras , Anton Blanchard , Sukadev Bhattiprolu , Michael Neuling , Stewart Smith , Daniel Axtens , Stephane Eranian , Anju T Sudhakar Subject: Re: [PATCH v5 08/13] powerpc/perf: PMU functions for Core IMC and hotplugging Reply-To: ego@linux.vnet.ibm.com References: <1489649707-8021-1-git-send-email-maddy@linux.vnet.ibm.com> <1489649707-8021-9-git-send-email-maddy@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1489649707-8021-9-git-send-email-maddy@linux.vnet.ibm.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-TM-AS-GCONF: 00 x-cbid: 17032313-2213-0000-0000-0000016F5C2F X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006834; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000206; SDB=6.00837791; UDB=6.00411906; IPR=6.00615554; BA=6.00005233; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014775; XFM=3.00000013; UTC=2017-03-23 13:10:04 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17032313-2214-0000-0000-000054E88E03 Message-Id: <20170323130947.GB4897@in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-03-23_12:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703230118 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2145 Lines: 93 Hi Maddy, Hemant, Anju, On Thu, Mar 16, 2017 at 01:05:02PM +0530, Madhavan Srinivasan wrote: [..snip..] > + > +static void core_imc_change_cpu_context(int old_cpu, int new_cpu) > +{ > + if (!core_imc_pmu) > + return; > + perf_pmu_migrate_context(&core_imc_pmu->pmu, old_cpu, new_cpu); > +} > + > + > +static int ppc_core_imc_cpu_online(unsigned int cpu) > +{ > + int ret; > + > + /* If a cpu for this core is already set, then, don't do anything */ > + ret = cpumask_any_and(&core_imc_cpumask, > + cpu_sibling_mask(cpu)); > + if (ret < nr_cpu_ids) > + return 0; > + > + /* Else, set the cpu in the mask, and change the context */ > + cpumask_set_cpu(cpu, &core_imc_cpumask); > + core_imc_change_cpu_context(-1, cpu); So, in the core case, we are ok as long as any cpu in the core is present in the imc_cpumask. It need not have to be the smallest online cpu in the core. Can the same logic be applied to the earlier nest case ? We can have a single function for cpu_offline and cpu_online which implements these checks and sets the cpu bit if required. ppc_entity_imc_cpu_offline(unsigned int cpu, cpumask_t entity_imc_mask, entity_imc_change_cpu_context_fn) { . . . } static ppc_nest_imc_cpu_offline(unsigned int cpu) { return ppc_entity_imc_cpu_offline(cpu, nest_imc_mask, nest_imc_change_cpu_context); } And similar ones for core imc and thread imc. Does this sound reasonable ? > + return 0; > +} > + > +static int ppc_core_imc_cpu_offline(unsigned int cpu) > +{ > + int target; > + unsigned int ncpu; > + > + /* > + * clear this cpu out of the mask, if not present in the mask, > + * don't bother doing anything. > + */ > + if (!cpumask_test_and_clear_cpu(cpu, &core_imc_cpumask)) > + return 0; > + > + /* Find any online cpu in that core except the current "cpu" */ > + ncpu = cpumask_any_but(cpu_sibling_mask(cpu), cpu); > + > + if (ncpu < nr_cpu_ids) { > + target = ncpu; > + cpumask_set_cpu(target, &core_imc_cpumask); > + } else > + target = -1; > + > + /* migrate the context */ > + core_imc_change_cpu_context(cpu, target); > + > + return 0; > +} > + -- Thanks and Regards gautham.