Received: by 10.223.176.5 with SMTP id f5csp1015928wra; Fri, 2 Feb 2018 09:45:17 -0800 (PST) X-Google-Smtp-Source: AH8x225FlSfoYmujYwetjzCbXwroS+TpBGQBAliBsq2SDwspRSC7gVSP7YtsSeOOePTMinc05u06 X-Received: by 2002:a17:902:203:: with SMTP id 3-v6mr36976479plc.413.1517593517843; Fri, 02 Feb 2018 09:45:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517593517; cv=none; d=google.com; s=arc-20160816; b=UxOFS4hJRg2hhD/0zFi/mheo3E2IAbSFO5WW6F9D2VeHsEksgiHvGupeWceFJMnvHY +7TJLYWak29YU5LFJ5oez+5/Se4LP+kHY2916R91zfn6vn+bl2E3dN/Q6eANaMU/jlY9 2jcFXaIkxiVwwKL/jjMqZyb2G8qTF3i8B4ovcXOhjsr9MDH3uGitrjTjMbVZGktIPc1N 1IA/9ceN+RyUFjAB/NjiG6Mzvr/RV5uJwpjZmb/clvvn3i1wldw+Vyqo8q01IDiPeJmv QuNy2aIJgn34BL/Kr14rAv8c6xF4AYcew3mJaaCRfqBxvcr2rizQlMsqSTG23oEzgz54 orYA== 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:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:dkim-signature:arc-authentication-results; bh=kBM7O8EOs65W6qyHqcoa1TjSJb9cKpFt6HMCHii4Ab8=; b=ksKSkujCNN00SUVyjbLQKP0x/cAkeZzYXMfFgbuiFqnr6eFtJZ8CG99bdwTfq5g9oQ zXJob5VjMqowRzRoY+HI6ATh08Vo4IxGMDCGJ/wtCi3f5+d1KcoJk3BPF/We5F3VDmUy 4U15kBSkQW2gh8zbhKgEoTBrDdLLiF5GtO7GTvP3EpLUYR7yYgC9DHEyNX/W/T88vLQE QPYd8wdlAxYUu2c5uEzdarBcD3dw/BVzfUD6ur9LamfGH4eZPRY1NTXqbraAtI+Ooul6 4dRdGGyJsWq4gFusf6xSYVch3lcqX4ucOtd1x0OJREnM8WVNAZJ/raPxYih+PfkOqIRp KwUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=lXJwY6mu; 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 h5si1733380pgr.501.2018.02.02.09.45.02; Fri, 02 Feb 2018 09:45:17 -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=lXJwY6mu; 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 S1752836AbeBBRnx (ORCPT + 99 others); Fri, 2 Feb 2018 12:43:53 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:51010 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753497AbeBBRmX (ORCPT ); Fri, 2 Feb 2018 12:42:23 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w12Hg5Xv146257; Fri, 2 Feb 2018 17:42:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : references : cc : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=kBM7O8EOs65W6qyHqcoa1TjSJb9cKpFt6HMCHii4Ab8=; b=lXJwY6muU4uqCLMKVV0cHZDtz11WHJNZyPQMPjzIv8gX9U2tns4NMd+l30O6TzzRQXMy sUkcV/DRYLms8B3PeUSyf44YdHv5z3mbNnEnMffUTMUKTEz671hdHGWJjXyfhNx0ka4e EOjLtuiWv7Qw4Q/2lP0wj/rZqi5WrP5BqfZhK+LM6pmh/0u8u84NexzvNvVzB6Lolf94 D+kZ235O6CqJm0IMjNEtB6EXT5bgsAQ1rvpz3VH3iClfzikDCN2hYccnoDSYIqPJF1f+ CFm7t6Unm5rOGMtVtPWgqdyGSRq1E8eJHmzGlAuTB7giEG+YIK6y+8U0Y8hCjLUsQy5H 6A== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2130.oracle.com with ESMTP id 2fvv5803nj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 02 Feb 2018 17:42:06 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w12HboAe016233 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 2 Feb 2018 17:37:50 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w12Hbn4M020561; Fri, 2 Feb 2018 17:37:50 GMT Received: from Subhras-MacBook-Pro.local (/76.102.103.135) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 02 Feb 2018 09:37:49 -0800 Subject: Re: [RESEND RFC PATCH V3] sched: Improve scalability of select_idle_sibling using SMT balance To: Peter Zijlstra , Steven Sistare 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> Cc: linux-kernel@vger.kernel.org, mingo@redhat.com, dhaval.giani@oracle.com From: Subhra Mazumdar Message-ID: <93db4b69-5ec6-732f-558e-5e64d9ba0cf9@oracle.com> Date: Fri, 2 Feb 2018 09:37:02 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20180202171708.GN2269@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=windows-1252; format=flowed 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=923 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802020216 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/2/18 9:17 AM, 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? In the scheme of SMT balance, if the idle cpu search is done _not_ in the last run core, then we need a random cpu to start from. If the idle cpu search is done in the last run core we can start the search from last run cpu. Since we need the random index for the first case I just did it for both. Thanks, Subhra