Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp500486ybg; Thu, 19 Mar 2020 03:48:04 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv0TYYyTn3sjaZs5L0P8Bkwez3/TX+iwb9YBCgZszvPfJw16++Mq9JCKEJ7ieameBLEXwKe X-Received: by 2002:a05:6830:1e96:: with SMTP id n22mr1687471otr.189.1584614884778; Thu, 19 Mar 2020 03:48:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584614884; cv=none; d=google.com; s=arc-20160816; b=rUVCn5Y8Z19wlzV7+nApCoPNA9ZqHATUBC0A3vHLVPuBzMubSg67wY+IPiX7ES55bN WGQG+bZWX4V/8sBwwx/9yxhDE4AGcnCXUlf/g8W0Bek4OSAWhl8cKghDi4xPXAAqSgiK rhHl6jGLbQcyk4xg3Fpr3Bxoy+v7v/zIAv11LcLYZsirugG8RsFti24pphNefhqVmkum sYiT2bSpxidK+QKa+mvLIynCmsXC28tcBhXxPTK9Lm+LYs9jmbm9W1/KUctagbjtQYwk LSaX+XjMOXgRGdS35Xu8S81bs7NASxlXLWpMclioMCaY7TAK8FPxA0ywJ6pAelSeaYgm mcuA== 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:references:cc:to:subject:from; bh=nbVhC/1d7avA6Cu40bT1AK3tLx+aZtylOKfvBW7ctww=; b=vE4tFTm6juAzu0PnLWlGka0Y1EGfZ9ce2KpYfJAFXJEmFPp+DI+nBixDYaca97kXQH RPdkRghUxbflFG/aQBAHhx1UBwkKNCsAduXVJOTEB7oopb4IDM0jYlpv71iz3VRB2930 Gunjb2RjIdVoBC6eacTpkMG/wcBAIRR/a6OHYwvB8laKSKDUitAu5S38Ozj7ofX/KmaX 020munREJXkoR96VhgWyvIjwHZk/Cvg4cMVWFxnG+LCb9rdgRSBg4N3XhI2gOPeDQ1zT TkDBO5oG9oBOK1tS9gND3rnXazlidsHsXJ+J4Lx3PWHEjNpRUyC0WOiJeoS9vG/nA55C zgEQ== ARC-Authentication-Results: i=1; mx.google.com; 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 t19si911557oif.250.2020.03.19.03.47.51; Thu, 19 Mar 2020 03:48:04 -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; 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 S1726911AbgCSKqY (ORCPT + 99 others); Thu, 19 Mar 2020 06:46:24 -0400 Received: from foss.arm.com ([217.140.110.172]:33214 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725768AbgCSKqY (ORCPT ); Thu, 19 Mar 2020 06:46:24 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9B09B31B; Thu, 19 Mar 2020 03:46:23 -0700 (PDT) Received: from [192.168.1.19] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9C05B3F305; Thu, 19 Mar 2020 03:46:22 -0700 (PDT) From: Dietmar Eggemann Subject: Re: [PATCH v2 9/9] sched/topology: Define and use shortcut pointers for wakeup sd_flag scan To: Valentin Schneider , linux-kernel@vger.kernel.org Cc: mingo@kernel.org, peterz@infradead.org, vincent.guittot@linaro.org References: <20200311181601.18314-1-valentin.schneider@arm.com> <20200311181601.18314-10-valentin.schneider@arm.com> Message-ID: <53763a32-0ce5-e267-9d5d-99e65c921d08@arm.com> Date: Thu, 19 Mar 2020 11:46:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200311181601.18314-10-valentin.schneider@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11.03.20 19:16, Valentin Schneider wrote: > Reworking select_task_rq_fair()'s domain walk exposed that !want_affine > wakeups only look for highest sched_domain with the required sd_flag > set. This is something we can cache at sched domain build time to slightly > optimize select_task_rq_fair(). Note that this isn't a "free" optimization: > it costs us 3 pointers per CPU. > > Add cached per-CPU pointers for the highest domains with SD_BALANCE_WAKE, > SD_BALANCE_EXEC and SD_BALANCE_FORK. Use them in select_task_rq_fair(). > > Signed-off-by: Valentin Schneider > --- > kernel/sched/fair.c | 25 +++++++++++++------------ > kernel/sched/sched.h | 3 +++ > kernel/sched/topology.c | 12 ++++++++++++ > 3 files changed, 28 insertions(+), 12 deletions(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index a6fca6817e92..40fb97062157 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -6595,17 +6595,6 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags) > int want_affine = 0; > int sd_flag; > > - switch (wake_flags & (WF_TTWU | WF_FORK | WF_EXEC)) { > - case WF_TTWU: > - sd_flag = SD_BALANCE_WAKE; > - break; > - case WF_FORK: > - sd_flag = SD_BALANCE_FORK; > - break; > - default: > - sd_flag = SD_BALANCE_EXEC; > - } > - > if (wake_flags & WF_TTWU) { > record_wakee(p); > > @@ -6621,7 +6610,19 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags) > > rcu_read_lock(); > > - sd = highest_flag_domain(cpu, sd_flag); > + switch (wake_flags & (WF_TTWU | WF_FORK | WF_EXEC)) { > + case WF_TTWU: > + sd_flag = SD_BALANCE_WAKE; > + sd = rcu_dereference(per_cpu(sd_balance_wake, cpu)); IMHO, since we hard-code 0*SD_BALANCE_WAKE in sd_init(), sd would always be NULL, so !want_affine (i.e. wake_wide()) would still go sis(). SD_BALANCE_WAKE is no a topology related sd_flag so it can't be set from outside. Since the sd->flags sysctl is now read-only, wouldn't this case be redundant? [...]