Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4662784ybz; Tue, 28 Apr 2020 15:58:26 -0700 (PDT) X-Google-Smtp-Source: APiQypJRlokdHuFaFMPqHy68TBBMPH7q7SiQJys1FdYmhlE744pQ1wh305W8IsNXJzKzdWLXpTi8 X-Received: by 2002:a05:6402:22a6:: with SMTP id cx6mr31642edb.277.1588114706238; Tue, 28 Apr 2020 15:58:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588114706; cv=none; d=google.com; s=arc-20160816; b=iKcY4X4KFpXPKj07wzwQcEgK41b78k/Ig+Xe+6i3wi92jrLK/+vI4BiDPiJAfmOLVi zHA/7BKnM3RGybKkl9WrVUn86wbI3jMQRzn4e5HnGJkXVCFTR9q5TgPCmDyr1pBd8KRv 0GYohcWjvAXAjVcGtUg4eOvkhqqANMgPqa915W3KTFlajlj7KJ0Izjcbt2J2Ud8ui2pK Zg73kA4CgucRuBiRme6V6apNZyXqbXf4Y9dVRPE573MrSpHipCGVTo+4vycJRi5NQ9cx ymQ1VbAJy7jkjbP/K6Gf9zjt8yp1DeVATzK+zRX9WqBpyg/P5hBnvD3fRWfe9Wf3r/QB U6+Q== 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:mime-version :user-agent:organization:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=u7uAqY8p0pjY0KMACKKK3etw1n75eHJHi1TZE1AVD8U=; b=m3V/PdDO3VA8WGo0bo1OSQsP7I3+ojl85BSnsc/DOxamI/KXBQepS/Plqi6yoFTupB TrrNLeXyRQidO6ktX1AKyvlY/bUCvmtqnn6DzfCRv4HwVK5vXT/fIUe8Zxj2tcOEYvwA NzV/QMjmdsXfvYBPcuNT/uQ9e/l2In1Tq5jiYeHRo6LxWxGUYhB9H9c89AKFMv/rCYfr +zuyYtkadVHYzUi8tI4sS0o0yo408zXvMfj/PVPBuWYGQT0qHi9V6TgKgjE1m9/AFf+u HkaNGLWa07IY7lsG9NyIG3L6M+OSPGmx/YttG4RbZ9WL8RIifEyXoT7T/onpOUPcfmKD NLPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=F2bCXtMO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q10si2537473eji.306.2020.04.28.15.57.37; Tue, 28 Apr 2020 15:58:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=F2bCXtMO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726516AbgD1WzM (ORCPT + 99 others); Tue, 28 Apr 2020 18:55:12 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:50706 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726274AbgD1WzM (ORCPT ); Tue, 28 Apr 2020 18:55:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588114511; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u7uAqY8p0pjY0KMACKKK3etw1n75eHJHi1TZE1AVD8U=; b=F2bCXtMO1Exu6EF+xXZtyNfsfHGreF4b55NiZsTM/yNpE2i3zRLl3ptAthlqliSCuR6BWG LWDiERyUyr9KKs9evXPjNCQTixzJVD2Fpq/Mb72cw9FofL4X/nIgy50AeJOl9OGMZXP3wQ sKbJcuf/Pdpzl74R8SnxRfXwmscn/6Q= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-245-bD6M3SYYNKyG_p9xUVnZ5w-1; Tue, 28 Apr 2020 18:55:09 -0400 X-MC-Unique: bD6M3SYYNKyG_p9xUVnZ5w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4C4C5107ACCD; Tue, 28 Apr 2020 22:55:07 +0000 (UTC) Received: from ovpn-112-24.phx2.redhat.com (ovpn-112-24.phx2.redhat.com [10.3.112.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id D4A311002388; Tue, 28 Apr 2020 22:55:03 +0000 (UTC) Message-ID: Subject: Re: [RFC PATCH 1/3] sched/fair: Call newidle_balance() from finish_task_switch() From: Scott Wood To: Peter Zijlstra , Valentin Schneider Cc: Steven Rostedt , Ingo Molnar , Vincent Guittot , Dietmar Eggemann , Rik van Riel , Mel Gorman , linux-kernel@vger.kernel.org, linux-rt-users Date: Tue, 28 Apr 2020 17:55:03 -0500 In-Reply-To: <20200428220917.GB16027@hirez.programming.kicks-ass.net> References: <20200428050242.17717-1-swood@redhat.com> <20200428050242.17717-2-swood@redhat.com> <20200428220917.GB16027@hirez.programming.kicks-ass.net> Organization: Red Hat Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.5 (3.30.5-1.fc29) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2020-04-29 at 00:09 +0200, Peter Zijlstra wrote: > On Tue, Apr 28, 2020 at 10:37:18PM +0100, Valentin Schneider wrote: > > On 28/04/20 06:02, Scott Wood wrote: > > > Thus, newidle_balance() is entered with interrupts enabled, which > > > allows > > > (in the next patch) enabling interrupts when the lock is dropped. > > > > > > Signed-off-by: Scott Wood > > > --- > > > kernel/sched/core.c | 7 ++++--- > > > kernel/sched/fair.c | 45 ++++++++++++++++--------------------------- > > > - > > > kernel/sched/sched.h | 6 ++---- > > > 3 files changed, 22 insertions(+), 36 deletions(-) > > > > > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > > > index 9a2fbf98fd6f..0294beb8d16c 100644 > > > --- a/kernel/sched/core.c > > > +++ b/kernel/sched/core.c > > > @@ -3241,6 +3241,10 @@ static struct rq *finish_task_switch(struct > > > task_struct *prev) > > > } > > > > > > tick_nohz_task_switch(); > > > + > > > + if (is_idle_task(current)) > > > + newidle_balance(); > > > + > > > > This means we must go through a switch_to(idle) before figuring out we > > could've switched to a CFS task, and do it then. I'm curious to see the > > performance impact of that. > > Also, if you move it this late, this is entirely the wrong place. If you > do it after the context switch either use the balance_callback or put it > in the idle path. > > But what Valentin said; this needs a fair bit of support, the whole > reason we've never done this is to avoid that double context switch... > balance_callback() enters with the rq lock held but BH not separately disabled, which interferes with the ability to enable interrupts but not BH. It also gets called from rt_mutex_setprio() and __sched_setscheduler(), and I didn't want the caller of those to be stuck with the latency. -Scott