Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1270833ybz; Wed, 29 Apr 2020 18:33:56 -0700 (PDT) X-Google-Smtp-Source: APiQypJg+wBJ/QQrBHZYqDx+/lcOoZ64rbBPw4k/9/P9jQJVGBd+eCAi8r7TqoLlw6Ol7gxxp5hJ X-Received: by 2002:a17:907:447f:: with SMTP id oo23mr528830ejb.274.1588210436309; Wed, 29 Apr 2020 18:33:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588210436; cv=none; d=google.com; s=arc-20160816; b=eLXOg1rNl2XBKe2h/nn5HL1DVs+286zJQPJ4YmmdP7sA1wJCDBnxTqZxL2/B9asar3 BRue7+xsj9vVB7gFIE3tQpwezqlpbaXlrKensQDbS9cTh3Y8gn01PFR598B6u7VkSmxv E+WNpZH/7kCsEySClxRXasTx3pVPtmD2Mwk35iEIReq0LyNnqeFAlyuGIuAw0KlQBo02 8QRhG7kEBhLMZi1xv2blqD/dLj7xSxFqX9vJ1xNMfPvCGVVZ83I5x/+J5RGXnrYhllAs 97we5lnV3Y59vN2noy5AQItMXgc6DPO9euMV/4A/t+Jc6l4el1z+xPZsGhyYarUPEaTT a6sQ== 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:user-agent:date :mime-version:organization:references:in-reply-to:cc:to:from:subject :message-id:dkim-signature; bh=dn/lWgNDUyOjkAW0d+CfM2/g1REm4TptTiXnq8Nxe00=; b=TJQSducQknTFAHb5E6h/M+lfKPLUaWGg6cX4FJHKAatKzcGixlGL6v7nVdPyXq5YyW QSVh1mHwBv6aKFasIKQ3ZL7v9kJNH2huaJxIJa1NJ+fob24utPEf/rfsSXYVp5y2CmJZ rZaA846rl86aFGEmg57whUU1xPvHF9+0WyOx09W8Z0zl2Lt3XclJgo72VDEYJ2mFiUCZ a8KBn2Gs/Hdpgvuu7r27fs1MzFA6+u0dyk5BbMntq886ne89Im/oaMUfiF1ojepnn0kc o3w1bxUjXDh5/axxVLhBTBRjKXWw98SU72vUc493gxQ8FwsuCThI108Ysb6Y3yqRuiUH Intg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=a5t2x5SQ; 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 oy6si4826277ejb.383.2020.04.29.18.33.33; Wed, 29 Apr 2020 18:33:56 -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=a5t2x5SQ; 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 S1726583AbgD3BcE (ORCPT + 99 others); Wed, 29 Apr 2020 21:32:04 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:43967 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726476AbgD3BcC (ORCPT ); Wed, 29 Apr 2020 21:32:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588210320; 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=dn/lWgNDUyOjkAW0d+CfM2/g1REm4TptTiXnq8Nxe00=; b=a5t2x5SQWs6kd1slZGVzEDZCQj1U8znW6DovxB/v+uAYqnBKoMJa4v04zeSh2I2zN1T9PZ gqSpjnEfN4BzKl2MXtJAA/Pwks2HXD4WRnhergqlz2/blPjGgbPJTZt/ixjhG9CUXVZhrd jonRlpzM1y20c1casqapgvATmpkHP20= 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-43-YRv229c6PBSsndGaIbz2-A-1; Wed, 29 Apr 2020 21:31:54 -0400 X-MC-Unique: YRv229c6PBSsndGaIbz2-A-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 55701108BD0F; Thu, 30 Apr 2020 01:31:52 +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 D17DE5C1D0; Thu, 30 Apr 2020 01:31:50 +0000 (UTC) Message-ID: <0945b70535f11c9abd45d3a3da2e984c4b1d832b.camel@redhat.com> Subject: Re: [RFC PATCH 1/3] sched/fair: Call newidle_balance() from finish_task_switch() From: Scott Wood To: Peter Zijlstra Cc: Valentin Schneider , Steven Rostedt , Ingo Molnar , Vincent Guittot , Dietmar Eggemann , Rik van Riel , Mel Gorman , linux-kernel@vger.kernel.org, linux-rt-users In-Reply-To: <20200429090533.GH13592@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> <20200428230204.GE16027@hirez.programming.kicks-ass.net> <89043649a64fc97dd90eb25c85bcc8f65483cf4f.camel@redhat.com> <20200429090533.GH13592@hirez.programming.kicks-ass.net> Organization: Red Hat Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Wed, 29 Apr 2020 20:31:39 -0500 User-Agent: Evolution 3.30.5 (3.30.5-1.fc29) Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 11:05 +0200, Peter Zijlstra wrote: > On Tue, Apr 28, 2020 at 06:20:32PM -0500, Scott Wood wrote: > > On Wed, 2020-04-29 at 01:02 +0200, Peter Zijlstra wrote: > > > On Tue, Apr 28, 2020 at 05:55:03PM -0500, Scott Wood wrote: > > > > On Wed, 2020-04-29 at 00:09 +0200, Peter Zijlstra wrote: > > > > > 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 > > > > > > BH? softirqs you mean? Pray tell more. > > > > In https://lore.kernel.org/lkml/5122CD9C.9070702@oracle.com/ the need to > > keep softirqs disabled during rebalance was brought up, but simply > > wrapping > > the lock dropping in local_bh_enable()/local_bh_disable() meant that > > local_bh_enable() would be called with interrupts disabled, which isn't > > allowed. > > That thread, nor your explanation make any sense -- why do we care about > softirqs?, I was trusting Steve's claim that that was the issue (it seemed plausible given that system-wide rebalancing is done from a softirq). If things have changed since then, great. If that was never the issue, then there's the question of what caused the bug Sasha saw. > nor do I see how placing it in finish_task_switch() helps > with any of this. It lets us do the local_bh_enable() after IRQs are enabled, since we don't enter with any existing atomic context. Though I suppose we could instead do another lock drop at the end of newidle_balance() just to enable softirqs. > > > > 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. > > > > > > You're not reading it right. > > > > Could you elaborate? > > If you were to do a queue_balance_callback() from somewhere in the > pick_next_task() machinery, then the balance_callback() at the end of > __schedule() would run it, and it'd be gone. How would > rt_mutex_setprio() / __sched_setscheduler() be affected? The rq lock is dropped between queue_balance_callback() and the balance_callback() at the end of __schedule(). What stops setprio/setscheduler on another cpu from doing the callback at that point? -Scott