Received: by 10.223.176.5 with SMTP id f5csp1220376wra; Fri, 2 Feb 2018 13:23:10 -0800 (PST) X-Google-Smtp-Source: AH8x226ZjC8973S9UZPLcXwwPSAjakfDojZt14fEg/8FBUUY791gIvTWn3dOvRTzwQvPkD8XZk0q X-Received: by 10.98.213.130 with SMTP id d124mr41308153pfg.112.1517606590594; Fri, 02 Feb 2018 13:23:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517606590; cv=none; d=google.com; s=arc-20160816; b=LzhHeYXIaPxHIwoIPwbqZY/qLjo/ef5Qteu38wNRR9iOvUTD11gxryluheOxZ938Vq F0tBNxEGT2MxHLIo+VA1mjoPAEGXvGSRe7a93OOBnQe1ifPUMEMrMMNm2/NfDRQj1Zmy C/v5YtHNu4b4ukyKFFE7yUADTUP/DXEPZNsKz9oO+0X48CxAsz0QjfnKiOvGi0uHOV9K zb5LP6cjy0XzMKDn51NKWhNn8lYVKrjI2dtzg2BXTvzQ4iTd8zeh3iL3mjiCZJ1DW/9F N+hBVgDBoUOEPSoPyEh16y5WJOERnOvU5uhBl3SwVDwLOhuqVHDH8pW/syuyRFFvl6Rd 5kRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature:arc-authentication-results; bh=OEtpRUsKjxwIxDSqtXNYBm8HjI1HcsX50FjFIVVze0I=; b=Cg7pER0ATNV7EU/VvgFqhYTo/PxNmSC3ve4OdoNtzl8dFzazxn7cBihmS1rc/+LIw7 ramixDCGE+FS7DxVK2+ldDRWYsCwOhQGSrW+cFU+C1/V9mwMsbohJ91kqMyP4HapHazT MnvXP6TGQmJ42kjtBtu1hj2B4+lNesCqIAWQH8/3StOiJCm8x2X22r7oP16mZhtq7U0K 0WBuKrDcJY75VUB5v4ij1C77gQFQrkcR3ZEPIUE4arY/x54c4jJot4rehW1O/V8PjBh0 C3Ul6bXbOdxdcS+00vZGneLmWy5K51WjCUAP5UawNAU+6YdKZDgM8qMJmxXtXA0BOcpU mzGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=JO9gtniP; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 92-v6si510578pli.180.2018.02.02.13.22.54; Fri, 02 Feb 2018 13:23:10 -0800 (PST) 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; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=JO9gtniP; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752685AbeBBUwC (ORCPT + 99 others); Fri, 2 Feb 2018 15:52:02 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:45662 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751557AbeBBUvz (ORCPT ); Fri, 2 Feb 2018 15:51:55 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w12KpcxQ127121; Fri, 2 Feb 2018 20:51:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=OEtpRUsKjxwIxDSqtXNYBm8HjI1HcsX50FjFIVVze0I=; b=JO9gtniPW/X0k8vxHvB5V8LujKobVEsZC3R8gcNGWMVYqUYeQjtnsizyzzymNcP2YDWB qQRrEIAe+oks1l5vLbxq1YWDCXE+iB/7AhpLy0+NYD9WPAemjQfFB1DrJ0sQyxbkxudB jXZGUu0ttOKFaj8HeeX82ZrxONTRV50Sd/pITzXZ1EX5hBh84Yqzcs6ldZ7M5KdHhQPO 8ws/9oFA2OqJy74RV42QpHNls5ZcjhwIDiQTOwUc+w+tnLcltiQylGo4HDC5NWrh7VIA WeTQzpLN27tOI5C3U9fDDQ6/41nsaTOYTCKSx0Hfrrzwzh+6Q0TQeBjue7OtilS81dNm 9A== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2fvxstg4x8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 02 Feb 2018 20:51:38 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w12KpYSM008500 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 2 Feb 2018 20:51:34 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w12KpXIK008372; Fri, 2 Feb 2018 20:51:34 GMT Received: from [10.39.253.191] (/10.39.253.191) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 02 Feb 2018 12:51:32 -0800 Subject: Re: [RESEND RFC PATCH V3] sched: Improve scalability of select_idle_sibling using SMT balance To: Peter Zijlstra Cc: subhra mazumdar , linux-kernel@vger.kernel.org, mingo@redhat.com, dhaval.giani@oracle.com References: <20180129233102.19018-1-subhra.mazumdar@oracle.com> <20180201123335.GV2249@hirez.programming.kicks-ass.net> <911d42cf-54c7-4776-c13e-7c11f8ebfd31@oracle.com> <20180202171708.GN2269@hirez.programming.kicks-ass.net> <0b3ee72d-0316-e11d-dee4-0d35375eed1d@oracle.com> <20180202195839.GQ2269@hirez.programming.kicks-ass.net> From: Steven Sistare Organization: Oracle Corporation Message-ID: Date: Fri, 2 Feb 2018 15:51:25 -0500 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180202195839.GQ2269@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8793 signatures=668661 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=647 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802020251 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/2/2018 2:58 PM, Peter Zijlstra wrote: > On Fri, Feb 02, 2018 at 12:36:47PM -0500, Steven Sistare wrote: >> On 2/2/2018 12:17 PM, Peter Zijlstra wrote: >>> On Fri, Feb 02, 2018 at 11:53:40AM -0500, Steven Sistare wrote: >>>>>> +static int select_idle_smt(struct task_struct *p, struct sched_group *sg) >>>>>> { >>>>>> + int i, rand_index, rand_cpu; >>>>>> + int this_cpu = smp_processor_id(); >>>>>> >>>>>> + rand_index = CPU_PSEUDO_RANDOM(this_cpu) % sg->group_weight; >>>>>> + rand_cpu = sg->cp_array[rand_index]; >>>>> >>>>> Right, so yuck.. I know why you need that, but that extra array and >>>>> dereference is the reason I never went there. >>>>> >>>>> How much difference does it really make vs the 'normal' wrapping search >>>>> from last CPU ? >>>>> >>>>> This really should be a separate patch with separate performance numbers >>>>> on. >>>> >>>> For the benefit of other readers, if we always search and choose starting from >>>> the first CPU in a core, then later searches will often need to traverse the first >>>> N busy CPU's to find the first idle CPU. Choosing a random starting point avoids >>>> such bias. It is probably a win for processors with 4 to 8 CPUs per core, and >>>> a slight but hopefully negligible loss for 2 CPUs per core, and I agree we need >>>> to see performance data for this as a separate patch to decide. We have SPARC >>>> systems with 8 CPUs per core. >>> >>> Which is why the current code already doesn't start from the first cpu >>> in the mask. We start at whatever CPU the task ran last on, which is >>> effectively 'random' if the system is busy. >>> >>> So how is a per-cpu rotor better than that? >> >> The current code is: >> for_each_cpu(cpu, cpu_smt_mask(target)) { >> >> For an 8-cpu/core processor, 8 values of target map to the same cpu_smt_mask. >> 8 different tasks will traverse the mask in the same order. > > Ooh, the SMT loop.. yes that can be improved. But look at the other > ones, they do: > > for_each_cpu_wrap(cpu, sched_domain_span(), target) > > so we look for an idle cpu in the LLC domain, and start iteration at > @target, which will (on average) be different for different CPUs, and > thus hopefully find different idle CPUs. > > You could simple change the SMT loop to something like: > > for_each_cpu_wrap(cpu, cpu_smt_mask(target), target) > > and see what that does. Good idea - Steve