Received: by 10.223.176.5 with SMTP id f5csp1008911wra; Fri, 2 Feb 2018 09:37:22 -0800 (PST) X-Google-Smtp-Source: AH8x226qLejdpwfk9cEgwpKOBEqvi4pXk5MLsnHVoNXAoUusC3ggyY7t9eNfNPymuCiYg2gC9G5l X-Received: by 10.98.61.208 with SMTP id x77mr41664149pfj.2.1517593042589; Fri, 02 Feb 2018 09:37:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517593042; cv=none; d=google.com; s=arc-20160816; b=uAQzRuA/u9l8pkpkc0dY9Uzj9/pt4+hovjb054RI+53iBrct/AC0Aj5/PyriReS3TC uy7EOhrXya0yXlnlF0BbRa3mnVCSbfiEnHK2aKrQEIrzB3N6lCHLWj1nxZ/se0XN6kbX oxOi+nl5DlhlkoL2EWgSIobdAE+uFCtE73HW+CWCdrwMuZCLHLCH4L3wvIJbtmMo+0LQ 4Q3+TM95LYQ7VXJcNaY33BabhmeGNa0zpwJWL2dQa+nPPHeF3EfpfkclNFaCqXnGKEMF 66AgxoFdZFrVheU8YCDIzSPCWSMbXbtiLe9Y91HSW8vPd+mcjSF1PpAR0VKjee9CYLV3 efDQ== 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:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=IbD8ssPpSCY7qAcvXq0eMOQAH5qVvHPgrLZahb7xXCg=; b=Vs/HCPJ/S0E/0ckMfLztRG7GrJcrvUOvYnWH8xeRRnEsaeh2lxA+vJOZoxrJpEe2RZ 4ygQN3C0YWWIZInId6mYUoYwkwtZHoG3gPJBfJazT57j8aSO53XIeHK/DW2EAt0T8K5T jeCsvzOQe3tQKdow/xKgwVCMWLF7LlYoD1WuPgYznG6uMzFVlR54g26ji5McrB+9E4op 6xCf6Sut3x/2QK2lIBBUMHWMFvE3x1EuoukooU3W87mm8VDzMgJSGnLZt8lsbQU1f1HF v6k+agOqkek/7VcCfFXFS3x++q+PrBpLr+NAtrSwgphNjiwLlfkor1Dhho9l5kVQdFJQ AQtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=EHI5XfYU; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2si1308064pgm.215.2018.02.02.09.37.07; Fri, 02 Feb 2018 09:37:22 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=EHI5XfYU; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753058AbeBBRgR (ORCPT + 99 others); Fri, 2 Feb 2018 12:36:17 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:40185 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753667AbeBBRRO (ORCPT ); Fri, 2 Feb 2018 12:17:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=IbD8ssPpSCY7qAcvXq0eMOQAH5qVvHPgrLZahb7xXCg=; b=EHI5XfYUlqY8tMuq00s033TdN X+qsnI4dQ2J81x+lijrIdrmRklYdtwDOApnVHTLxQicrP7VWAqlB8MqWNbCH4RXYzQMYXsmEF/Njz HV5P4ao8hEGi7O9g3P/gwCtdWDKUELlixoOjY/k7VnFI2SxInrtwrFuXLvJmGAwBV2EGaYxT10cuN hIRsKxVMi7whtI8vzJEKfAkKx1ZoSgXAOk3eZIzxAkIxle/B6DscujrrikNIv73sYOIvI3WW3gDlM 7/ir0X8GijwcOXXlkyISX2j5EUeFk/yvmyZQHZ7SHcQnl3tT1dKgNprCrJ3Wz/lAW8fTzhy8+RYIX tqJZBF/mQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1ehexb-0005Cg-E7; Fri, 02 Feb 2018 17:17:11 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 2871C2029F9F9; Fri, 2 Feb 2018 18:17:08 +0100 (CET) Date: Fri, 2 Feb 2018 18:17:08 +0100 From: Peter Zijlstra To: Steven Sistare Cc: subhra mazumdar , linux-kernel@vger.kernel.org, mingo@redhat.com, dhaval.giani@oracle.com Subject: Re: [RESEND RFC PATCH V3] sched: Improve scalability of select_idle_sibling using SMT balance Message-ID: <20180202171708.GN2269@hirez.programming.kicks-ass.net> References: <20180129233102.19018-1-subhra.mazumdar@oracle.com> <20180201123335.GV2249@hirez.programming.kicks-ass.net> <911d42cf-54c7-4776-c13e-7c11f8ebfd31@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <911d42cf-54c7-4776-c13e-7c11f8ebfd31@oracle.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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?