Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2713546ybd; Thu, 27 Jun 2019 18:10:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqxuLUIKf4GJxJSMccjx3iJvni/KrU2IfSb2gDtXXoPOLmnZMyLH2/UT1MUTLAjDhVDJrWZI X-Received: by 2002:a17:902:2983:: with SMTP id h3mr8226843plb.45.1561684241888; Thu, 27 Jun 2019 18:10:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561684241; cv=none; d=google.com; s=arc-20160816; b=EI9zL8jUzJpAszohsVKmYUwGnPDtpAk+1SRwWSTZ7eOB4mXmPICO4q4qbVSapfaMW9 M/unz/LDom9/rMnHgP0AtyF5tEsmfANxtEVJErtHpTzRzEbY/aHOSCI2hXQPOQTFi3Ug lvQfGuT/1RGipJrR6pYYaZHupOE3aTtTUIOVlJOVAJCoT4sIcBVIUhQ6RiDfTo8xPYJn QiEPNFeKXFhrg/4Dw0n9lPZfihC9JCWBx64Uy3HMayzngvagRKizbjhZwSDpzMh+QOb7 ldt+2diPx2xSkaugmkjgwoLLMGx4Byqzuhu8YNhh920nYdmNq+IgtQAAFE34NLtl+VKr xheQ== 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; bh=1S4dAP87l582dcEyjKUD0+mpbepPHEjIXouA5/ouMM4=; b=dHs/FdiMwH4P7UjO4EsxPwLT28e/bOltejiSXYu3aqNAKRxSyO4JetSMOjhjiNJtfY ujin5pmdiYMiKON1Tw/VrnMrtSug6UNouY6Ulyo8eBu5wWuxQrbHhVPhlmlogy6m0nV4 nuPjWKZq0yrjI425s7QEvdNHUwDapYMHfPfsa4+/GDZ0yMiu5MFVelxNFLGxJAjsvDfU AmQQglG3c5IArWHYluywf2tXs2sCW2qtPovYjdsR7J5Wvq3s+LNadlxyOtxrE5tr0oRF tNasC42kkOBlJuTUkc8CnUj1GZmYFiVBXVrlMXCvyQqIKcv5o0VcoViCP0kydxz5wDY6 EEoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=J4DAc2GS; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x9si498294plo.98.2019.06.27.18.10.25; Thu, 27 Jun 2019 18:10:41 -0700 (PDT) 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=@kernel.org header.s=default header.b=J4DAc2GS; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726691AbfF1BKS (ORCPT + 99 others); Thu, 27 Jun 2019 21:10:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:46514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726595AbfF1BKS (ORCPT ); Thu, 27 Jun 2019 21:10:18 -0400 Received: from localhost (lfbn-ncy-1-174-150.w83-194.abo.wanadoo.fr [83.194.254.150]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D5D90208CB; Fri, 28 Jun 2019 01:10:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561684217; bh=yzoO61EJmprVWNY3EpL3GXI+joDNjs4U10vKsbjnU54=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=J4DAc2GS3ltAyGnSJz8KKcoypxlm0zXtV8PZB8uJEmQnyghsKWeED0zUoAfSMzoDJ DuYlTiFcwxXIiBb+vuD+HIEZiXLmpZi5D3ZmcMriTX/hUU7aa2nnD/hKhlbI+OCapN 2Lp28nmbcieceEy6Ow52Y+n5cu3oTFJwr6bK2gXY= Date: Fri, 28 Jun 2019 03:10:13 +0200 From: Frederic Weisbecker To: Wanpeng Li Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Ingo Molnar , Thomas Gleixner Subject: Re: [PATCH v2] sched/nohz: Optimize get_nohz_timer_target() Message-ID: <20190628011012.GA19488@lerouge> References: <1561682593-12071-1-git-send-email-wanpengli@tencent.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1561682593-12071-1-git-send-email-wanpengli@tencent.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 28, 2019 at 08:43:12AM +0800, Wanpeng Li wrote: > From: Wanpeng Li > > On a machine, cpu 0 is used for housekeeping, the other 39 cpus in the > same socket are in nohz_full mode. We can observe huge time burn in the > loop for seaching nearest busy housekeeper cpu by ftrace. > > 2) | get_nohz_timer_target() { > 2) 0.240 us | housekeeping_test_cpu(); > 2) 0.458 us | housekeeping_test_cpu(); > > ... > > 2) 0.292 us | housekeeping_test_cpu(); > 2) 0.240 us | housekeeping_test_cpu(); > 2) 0.227 us | housekeeping_any_cpu(); > 2) + 43.460 us | } > > This patch optimizes the searching logic by finding a nearest housekeeper > cpu in the housekeeping cpumask, it can minimize the worst searching time > from ~44us to < 10us in my testing. In addition, the last iterated busy > housekeeper can become a random candidate while current CPU is a better > fallback if it is a housekeeper. > > Cc: Ingo Molnar > Cc: Peter Zijlstra > Cc: Frederic Weisbecker > Cc: Thomas Gleixner > Signed-off-by: Wanpeng Li Reviewed-by: Frederic Weisbecker Thanks!