Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp264814ybh; Tue, 21 Jul 2020 23:22:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysHrUxk/ZonwlMGwcAmpFFhTz7dmZEY2aqZgXhJKAAfDe1Bz7VTbn8pweNG+Wl9PTSDIzW X-Received: by 2002:a17:906:d143:: with SMTP id br3mr27949408ejb.268.1595398931385; Tue, 21 Jul 2020 23:22:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595398931; cv=none; d=google.com; s=arc-20160816; b=vszHhkWhPbn3g+EQvspxlFoCXipzoGZt43o38zuLmjDrtoMmURbmwnkvkro0uAs0na WUmRB5MQV1EvjZ/NgtzlAvs4reg/wC1w4j8oE0vaNvr5Seg/eUBRQoyt0xoqmw1o7thD VXlbxn7DknCZGBfH4nAIcs8YUdEPhYED6m8Hv2p4RobeyRxChUmlFR4TNSjKdXkmqTiO Rvu3AAZgbjeCOW882Qw27bSDAJqQxXauYl2u9I7alIV2GezfAI//LlrCh/us4Gle6bzL d+QjlyuCRcPqn5nXkWMtebktrBJUxm54wgOzGf1uwtQpMT23enRBcqYj1OT02lG19W2N kpvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date; bh=1FCwzlxV7xec9j1zWrR6BxhC4eEr/cZKC17JukEB99s=; b=gRbLTw+7JI5Fhx+o4/5ZYP4v91OxnBh2EtjGjjeKEQoCMDBEvwGgGkmDV0ti3kH6WO 78tn8qEo+88ThcVbPFnwEct+0F6XljgrSXP9de7fUUE3qa2LoGQRbjq5gS9/0nOI6ebe U5RerZIuIX0o0C7eZZxBPJbTKJ7muBkaccbHqBsKgCIt5CF05BRsuhfDaqhc2ndYlzfa w4GzDC4ltGJwEOYNCSC6VWpMvHPuyGieeYXZ+SA7o7OmUdwvGaQ5LSyAnaFzjwuAuXNY 21rDjxcPKyhiyv3mbFALyWcY6vh2vjSgNYUsaBv3xfjKz/fG8hDn0qXA/2pUP7sONwOq BIBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id rs25si13359861ejb.536.2020.07.21.23.21.47; Tue, 21 Jul 2020 23:22:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728394AbgGVGVe (ORCPT + 99 others); Wed, 22 Jul 2020 02:21:34 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:24068 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727929AbgGVGVd (ORCPT ); Wed, 22 Jul 2020 02:21:33 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06M61rdi161127; Wed, 22 Jul 2020 02:21:23 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 32e1vrf16h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 Jul 2020 02:21:23 -0400 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 06M6GvGL012016; Wed, 22 Jul 2020 02:21:23 -0400 Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0a-001b2d01.pphosted.com with ESMTP id 32e1vrf16a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 Jul 2020 02:21:23 -0400 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 06M6K4cL030774; Wed, 22 Jul 2020 06:21:22 GMT Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by ppma04dal.us.ibm.com with ESMTP id 32d5dq7qcr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 Jul 2020 06:21:22 +0000 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 06M6LKCD33030484 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 Jul 2020 06:21:20 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E228C6A04F; Wed, 22 Jul 2020 06:21:19 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2FA306A04D; Wed, 22 Jul 2020 06:21:19 +0000 (GMT) Received: from sofia.ibm.com (unknown [9.85.82.72]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 22 Jul 2020 06:21:19 +0000 (GMT) Received: by sofia.ibm.com (Postfix, from userid 1000) id A1BEA2E48D7; Wed, 22 Jul 2020 11:51:14 +0530 (IST) Date: Wed, 22 Jul 2020 11:51:14 +0530 From: Gautham R Shenoy To: Srikar Dronamraju Cc: Michael Ellerman , linuxppc-dev , LKML , Ingo Molnar , Peter Zijlstra , Valentin Schneider , Nick Piggin , Oliver OHalloran , Nathan Lynch , Michael Neuling , Anton Blanchard , Gautham R Shenoy , Vaidyanathan Srinivasan , Jordan Niethe Subject: Re: [PATCH v2 05/10] powerpc/smp: Dont assume l2-cache to be superset of sibling Message-ID: <20200722062114.GD31038@in.ibm.com> Reply-To: ego@linux.vnet.ibm.com References: <20200721113814.32284-1-srikar@linux.vnet.ibm.com> <20200721113814.32284-6-srikar@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200721113814.32284-6-srikar@linux.vnet.ibm.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-22_02:2020-07-22,2020-07-22 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 priorityscore=1501 adultscore=0 mlxscore=0 impostorscore=0 bulkscore=0 phishscore=0 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007220040 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Srikar, On Tue, Jul 21, 2020 at 05:08:09PM +0530, Srikar Dronamraju wrote: > Current code assumes that cpumask of cpus sharing a l2-cache mask will > always be a superset of cpu_sibling_mask. > > Lets stop that assumption. cpu_l2_cache_mask is a superset of > cpu_sibling_mask if and only if shared_caches is set. > > Cc: linuxppc-dev > Cc: LKML > Cc: Michael Ellerman > Cc: Ingo Molnar > Cc: Peter Zijlstra > Cc: Valentin Schneider > Cc: Nick Piggin > Cc: Oliver OHalloran > Cc: Nathan Lynch > Cc: Michael Neuling > Cc: Anton Blanchard > Cc: Gautham R Shenoy > Cc: Vaidyanathan Srinivasan > Cc: Jordan Niethe > Signed-off-by: Srikar Dronamraju > --- > Changelog v1 -> v2: > powerpc/smp: Dont assume l2-cache to be superset of sibling > Set cpumask after verifying l2-cache. (Gautham) > > arch/powerpc/kernel/smp.c | 28 +++++++++++++++------------- > 1 file changed, 15 insertions(+), 13 deletions(-) > > diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c > index 72f16dc0cb26..57468877499a 100644 > --- a/arch/powerpc/kernel/smp.c > +++ b/arch/powerpc/kernel/smp.c > @@ -1196,6 +1196,7 @@ static bool update_mask_by_l2(int cpu, struct cpumask *(*mask_fn)(int)) > if (!l2_cache) > return false; > > + cpumask_set_cpu(cpu, mask_fn(cpu)); Ok, we need to do this because "cpu" is not yet set in the cpu_online_mask. Prior to your patch the "cpu" was getting set in cpu_l2_cache_map(cpu) as a side-effect of the code that is removed in the patch. > for_each_cpu(i, cpu_online_mask) { > /* > * when updating the marks the current CPU has not been marked > @@ -1278,29 +1279,30 @@ static void add_cpu_to_masks(int cpu) > * add it to it's own thread sibling mask. > */ > cpumask_set_cpu(cpu, cpu_sibling_mask(cpu)); > + cpumask_set_cpu(cpu, cpu_core_mask(cpu)); > > for (i = first_thread; i < first_thread + threads_per_core; i++) > if (cpu_online(i)) > set_cpus_related(i, cpu, cpu_sibling_mask); > > add_cpu_to_smallcore_masks(cpu); > - /* > - * Copy the thread sibling mask into the cache sibling mask > - * and mark any CPUs that share an L2 with this CPU. > - */ > - for_each_cpu(i, cpu_sibling_mask(cpu)) > - set_cpus_related(cpu, i, cpu_l2_cache_mask); > update_mask_by_l2(cpu, cpu_l2_cache_mask); > > - /* > - * Copy the cache sibling mask into core sibling mask and mark > - * any CPUs on the same chip as this CPU. > - */ > - for_each_cpu(i, cpu_l2_cache_mask(cpu)) > - set_cpus_related(cpu, i, cpu_core_mask); > + if (pkg_id == -1) { I suppose this "if" condition is an optimization, since if pkg_id != -1, we anyway set these CPUs in the cpu_core_mask below. However... > + struct cpumask *(*mask)(int) = cpu_sibling_mask; > + > + /* > + * Copy the sibling mask into core sibling mask and > + * mark any CPUs on the same chip as this CPU. > + */ > + if (shared_caches) > + mask = cpu_l2_cache_mask; > + > + for_each_cpu(i, mask(cpu)) > + set_cpus_related(cpu, i, cpu_core_mask); > > - if (pkg_id == -1) > return; > + } ... since "cpu" is not yet set in the cpu_online_mask, do we not miss setting "cpu" in the cpu_core_mask(cpu) in the for-loop below ? > > for_each_cpu(i, cpu_online_mask) > if (get_physical_package_id(i) == pkg_id) Before this patch it was unconditionally getting set in cpu_core_mask(cpu) because of the fact that it was set in cpu_l2_cache_mask(cpu) and we were unconditionally setting all the CPUs in cpu_l2_cache_mask(cpu) in cpu_core_mask(cpu). What am I missing ? > -- > 2.17.1 > -- Thanks and Regards gautham.