Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1104742imm; Mon, 21 May 2018 21:35:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZra5xB3TGi5oR3xsTupm8FbZiHBJWjV8PSEEoup/Ynesyhr5XC7mnOfqy7hn0lFl6W50vOK X-Received: by 2002:a62:e107:: with SMTP id q7-v6mr22539536pfh.226.1526963708433; Mon, 21 May 2018 21:35:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526963708; cv=none; d=google.com; s=arc-20160816; b=eA7XkPc2jaURowcbwWd93wvZ8aS950ISibUxT1eRaSBS9NmcMMjEZFNayDJAVWhTGB 2j7/Eyf9RxK+uNwzPMClqME98l+leVaMjKPJNv/Isd196OgpqNQDgoqQVwhWNgR0224z OulCRnO5Uf477g6G3inkiGfJLpuNji5RmL4Rja9KoD4MoF39J3tEQ25KcgVhYEMsyMef kBktXAdaj/q43WN4AUYHnPeuW2RQP9bDp0H7DcOCg5uN7h0sSKsRhkqAr4u8psLFQKSJ 9C9OAZI4eobDJVQCDN/eYC2geqYlbvSwXeraKF353MiPqMIwSx4HNUZA2j/isH0FXGXH jIpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:subject:cc:to :from:date:arc-authentication-results; bh=0Equfp2aUGjfr7C6xqoOVFxZs6hiEm2waMhV6/+gJHI=; b=iV8RnxCzOgTD5hHyHxWsabDOat0byqoUEX4HNfxlFgoHz4PE+JbLOjj7K2e/XupySv cOk5Ypx86Aoi9h/dLSbQjpM+gesNUy6maPbP8xn/LF/wZrBMFK9UHpt18+7NfddI0ZGj LTF/XlkYKfx1d2qQB3YdUYuf/aVF2QYvkxPIR532q9JsMEn1xIexD2KD2JWqlzhoAdxZ DE6Sdg52Econ4JKjbPEbvtPmH6/LSCr05BR936oqg5h4LdENB6E4E4oupyGNZOPbWPrR 0EU6OFyLmiwDhGGihN2Gf82xVxfe851TuA+kqi1lsoPDncWcTv76h41Ak10dXcXA3nm8 YKGA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u69-v6si6271167pgc.435.2018.05.21.21.34.53; Mon, 21 May 2018 21:35:08 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751205AbeEVEej (ORCPT + 99 others); Tue, 22 May 2018 00:34:39 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:59554 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750733AbeEVEei (ORCPT ); Tue, 22 May 2018 00:34:38 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4M4YQ6K119669 for ; Tue, 22 May 2018 00:34:37 -0400 Received: from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158]) by mx0b-001b2d01.pphosted.com with ESMTP id 2j49f6w8yu-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 22 May 2018 00:34:37 -0400 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 21 May 2018 22:34:36 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 21 May 2018 22:34:33 -0600 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4M4YWOI7995834; Mon, 21 May 2018 21:34:32 -0700 Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A10511360C8; Mon, 21 May 2018 22:34:32 -0600 (MDT) Received: from sofia.ibm.com (unknown [9.124.35.22]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP id 58FA01360C9; Mon, 21 May 2018 22:34:32 -0600 (MDT) Received: by sofia.ibm.com (Postfix, from userid 1000) id 6B0072E2D6F; Tue, 22 May 2018 10:04:30 +0530 (IST) Date: Tue, 22 May 2018 10:04:30 +0530 From: Gautham R Shenoy To: Michael Ellerman Cc: "Gautham R. Shenoy" , Benjamin Herrenschmidt , Michael Neuling , Vaidyanathan Srinivasan , Akshay Adiga , Shilpasri G Bhat , Balbir Singh , "Oliver O'Halloran" , Nicholas Piggin , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] powerpc: Detect the presence of big-core with interleaved threads Reply-To: ego@linux.vnet.ibm.com References: <1526037444-22876-1-git-send-email-ego@linux.vnet.ibm.com> <1526037444-22876-2-git-send-email-ego@linux.vnet.ibm.com> <87h8n5xfot.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87h8n5xfot.fsf@concordia.ellerman.id.au> User-Agent: Mutt/1.5.23 (2014-03-12) X-TM-AS-GCONF: 00 x-cbid: 18052204-0024-0000-0000-000018745FA4 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009064; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000261; SDB=6.01035844; UDB=6.00529854; IPR=6.00814972; MB=3.00021230; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-22 04:34:35 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18052204-0025-0000-0000-000050179DAF Message-Id: <20180522043430.GB5213@in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-22_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805220053 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Michael, On Fri, May 18, 2018 at 11:21:22PM +1000, Michael Ellerman wrote: > "Gautham R. Shenoy" writes: > > > diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c > > index 0af5c11..884dff2 100644 > > --- a/arch/powerpc/kernel/setup-common.c > > +++ b/arch/powerpc/kernel/setup-common.c > > @@ -436,8 +438,56 @@ static void __init cpu_init_thread_core_maps(int tpc) > > printk(KERN_DEBUG " (thread shift is %d)\n", threads_shift); > > } > > > > - > > u32 *cpu_to_phys_id = NULL; > > +/* > > + * check_for_interleaved_big_core - Checks if the core represented by > > + * dn is a big-core whose threads are interleavings of the > > + * threads of the component small cores. > > + * > > + * @dn: device node corresponding to the core. > > + * > > + * Returns true if the core is a interleaved big-core. > > + * Returns false otherwise. > > + */ > > +static inline bool check_for_interleaved_big_core(struct device_node *dn) > > +{ > > + int len, nr_groups, threads_per_group; > > + const __be32 *thread_groups; > > + __be32 *thread_list, *first_cpu_idx; > > + int cur_cpu, next_cpu, i, j; > > + > > + thread_groups = of_get_property(dn, "ibm,thread-groups", &len); > > + if (!thread_groups) > > + return false; > > There are better device tree APIs than bare of_get_property() these > days, can you try to use those? Ok, I will use them. > > > + nr_groups = be32_to_cpu(*(thread_groups + 1)); > > + if (nr_groups <= 1) > > + return false; > > eg. this would be of_property_read_u32_index() > Ok. > > @@ -565,7 +615,16 @@ void __init smp_setup_cpu_maps(void) > > vdso_data->processorCount = num_present_cpus(); > > #endif /* CONFIG_PPC64 */ > > > > - /* Initialize CPU <=> thread mapping/ > > + dn = of_find_node_by_type(NULL, "cpu"); > > + if (dn) { > > + if (check_for_interleaved_big_core(dn)) { > > + has_interleaved_big_core = true; > > + pr_info("Detected interleaved big-cores\n"); > > + } > > + of_node_put(dn); > > + } > > This is a bit untidy, given how unlikely it is that you would have no > CPUs :) This can actually go into the earlier loop where we initialize the smp_processor_ids(). I have fixed it in the next iteration. > > You should be able to do the lookup of the property and the setting of > has_interleaved_big_core all inside > check_for_interleaved_big_core(). Yes, that's what I am doing in the next iteration. > > cheers >