Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp282737ybh; Wed, 22 Jul 2020 00:00:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfUR8TyULTpRWnRtjJL4iZRbuVaOvig5/CVj+pLknuBhYYVNQBZZqKFDezwVUQPuY/HBwp X-Received: by 2002:aa7:d04a:: with SMTP id n10mr30215228edo.132.1595401254479; Wed, 22 Jul 2020 00:00:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595401254; cv=none; d=google.com; s=arc-20160816; b=vmmbMnqCrMmwczesh4kwfKWuatjJO5us1cavnU772zPBkQILp3D+BBgz9BTespz+Yo 9Ee1IpVgKofeAWANFJqE/Y/xidwcUw5ogq2bxxPUcpjvRNyaeKmIQONeBwHSiTUNJs7a eMyfQSdRVP40Os0cGjgPuLqkONhailV3P9DPD8OGGj5kN+ZO0msYfqPHitoqiYkoD0vu Ny84KKpOtRKweIynFEzV4N+q5ax7mA9aK84XLAtt+iX84MfRIvtWYX6QjLvmcMOC0d+G 3YVKd0rtQ6E31xGT1I3q29f2ErX/iqWiMegO6CMctfWH0+/O/dhKx3RJd218NArSjknb sGiQ== 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=Vhk6V3jn2SD6HOWWfLf7ZdSPpAFqjBcped5IQRzC7tk=; b=rkFFSUtXMy6rzANRvP6cgQYHZ/ljXiBYQ9WrMvnAUqHwVcarxXXiEAcZocPIQXzX2q GHdpIMePpnx+TMMd5DQ22IOwMSgGHq+VPGPcomTk3pycSiIpwWDu+y51srxN+sdiTQZl 52H4euhC25bxs0xvrxecx5iXnAImFraLhypRnpCXm6JkBjfkwdQEaQ4whOCBGhrr82h4 ZvMElmW3JAxd3ZN+xATNd3sfUNebWyo5RvgtnyHGrZAG67ODkKS5cWQ75Pvy4MsbvkNY CSINCWAwE1m6MiFiJKW7Xg1IaOtAuHmpHr0RVrtp1ndr023dXJfKwxZ6ARi19ACcYkyn yjuA== 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 gz11si13667768ejb.409.2020.07.22.00.00.30; Wed, 22 Jul 2020 00:00:54 -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 S1730616AbgGVG6I (ORCPT + 99 others); Wed, 22 Jul 2020 02:58:08 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:54072 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730346AbgGVG6H (ORCPT ); Wed, 22 Jul 2020 02:58:07 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06M5Wcq8132660; Wed, 22 Jul 2020 02:57:58 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 32dn0ywp1k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 Jul 2020 02:57:58 -0400 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 06M6slhU154451; Wed, 22 Jul 2020 02:57:58 -0400 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 32dn0ywp0w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 Jul 2020 02:57:57 -0400 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 06M6psUe017812; Wed, 22 Jul 2020 06:57:55 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma06ams.nl.ibm.com with ESMTP id 32brbh4mhw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 Jul 2020 06:57:55 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 06M6vp9N29360618 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 Jul 2020 06:57:51 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E2093AE058; Wed, 22 Jul 2020 06:57:50 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 797FAAE045; Wed, 22 Jul 2020 06:57:48 +0000 (GMT) Received: from linux.vnet.ibm.com (unknown [9.126.150.29]) by d06av26.portsmouth.uk.ibm.com (Postfix) with SMTP; Wed, 22 Jul 2020 06:57:48 +0000 (GMT) Date: Wed, 22 Jul 2020 12:27:47 +0530 From: Srikar Dronamraju To: Gautham R Shenoy Cc: Michael Ellerman , linuxppc-dev , LKML , Ingo Molnar , Peter Zijlstra , Valentin Schneider , Nick Piggin , Oliver OHalloran , Nathan Lynch , Michael Neuling , Anton Blanchard , Vaidyanathan Srinivasan , Jordan Niethe Subject: Re: [PATCH v2 05/10] powerpc/smp: Dont assume l2-cache to be superset of sibling Message-ID: <20200722065747.GB9290@linux.vnet.ibm.com> Reply-To: Srikar Dronamraju References: <20200721113814.32284-1-srikar@linux.vnet.ibm.com> <20200721113814.32284-6-srikar@linux.vnet.ibm.com> <20200722062114.GD31038@in.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20200722062114.GD31038@in.ibm.com> User-Agent: Mutt/1.10.1 (2018-07-13) 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 mlxscore=0 clxscore=1015 priorityscore=1501 adultscore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 phishscore=0 malwarescore=0 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 * Gautham R Shenoy [2020-07-22 11:51:14]: > Hi Srikar, > > > 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. > Right. > > > 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)); Note: Above, we are explicitly setting the cpu_core_mask. > > > > 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... This is not just an optimization. The hunk removed would only work if cpu_l2_cache_mask is bigger than cpu_sibling_mask. (this was the previous assumption that we want to break) If the cpu_sibling_mask is bigger than cpu_l2_cache_mask and pkg_id is -1, then setting only cpu_l2_cache_mask in cpu_core_mask will result in a broken topology. > > > + 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 ? > > As noted above, we are setting before. So we don't missing the cpu and hence have not different from before. > -- > Thanks and Regards > gautham. -- Thanks and Regards Srikar Dronamraju