Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp652802pxy; Thu, 22 Apr 2021 10:13:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYRPigdHC97jT73cH8X36SbgBgL2IHBibCl6HS9aBMxC6AUuteko2OQy1Hg9lFTaYT1fH3 X-Received: by 2002:a17:906:134d:: with SMTP id x13mr4511114ejb.61.1619111610959; Thu, 22 Apr 2021 10:13:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619111610; cv=none; d=google.com; s=arc-20160816; b=WYGwQdyEhJKC9ExO8ASVQqlN7qFcIY/3wSMvLJssYubm+kkbYWSPOM1yehU0/s9Fl8 5wXAOi3AgD1QwbAx+W/d61/Lh5EM1SV1KxIu6mMuQ3av9REJE0oY6aOjZESx0gLkmLAu JtUVd98IZO00Ibpowy8tKiEAz2d+lFP4Xh2YrCgnp7Ye+41+EdSRChQcv6CRf/Lp0Q8l komRBg87rMwXmnMPA4r9olo1s+coZhYalqqn8vi6TiY4YbU7N3Zn3DvHbq6sYYJR+Q/j u2Q1ebgxh79jta5EmEnCdbghmKpL6/8L3RysUOCDW+Sbr7Tk4Iabk0ovoc87yvueyqtx 90iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=7k0hnNuOG3QRzXOhhHlFC+IlgbwmTQXTG7uqldPEFX4=; b=DAidzBdVO/YC/s4TYA9T0nygGXlZ5/X7IMSAOF+Dy3pjEkEUA6BCMEYACstLEvb5Xg DZKHngTPRmFomo3B+vL7QpdM1TRsVnGZZZb12FEbOk1ANDqDCg/uX/bBe1323xoSEUdZ GyVu+IwgyqZBV+KGvjBEIUpit35HnJnF9gF+N+V9XpyAAfs5c97qjVdRc1uanDQCoR4u HT/tKwSauaCz38qZkSqkpqV8EXqsJKeBsD+7ZiWv6SIHrasd+r+9bQ1LTaJPuNijH4Nx Wz4DZwm2qP3Y14oWPiUhr3rhYZMnCoVOePf7upG94To4H00sEoaiVGP+8YAiljzdFJLX sLlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UG9HTnyq; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v5si3129428edi.582.2021.04.22.10.13.07; Thu, 22 Apr 2021 10:13:30 -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=@linaro.org header.s=google header.b=UG9HTnyq; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236742AbhDVRKg (ORCPT + 99 others); Thu, 22 Apr 2021 13:10:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236651AbhDVRKe (ORCPT ); Thu, 22 Apr 2021 13:10:34 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83F1DC061756 for ; Thu, 22 Apr 2021 10:09:59 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id t14so16168288lfe.1 for ; Thu, 22 Apr 2021 10:09:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7k0hnNuOG3QRzXOhhHlFC+IlgbwmTQXTG7uqldPEFX4=; b=UG9HTnyqjD2eRDdyDn5/wwES3kEbUb3/iOm5X2ZMSmkYyNJ34qt3Nh03sG97Y3Cpb7 8STzfjT03MF4NWdNt/UclyvnG7v7z+kSGpXFy/2o96xIXRoc/kpiuS4DPf8no64hBnXj /eWS1vm8pfm6M64EHAcNYGWxDUJ9yeFo6zKwtMxKP3Tei9SWn0nQh2j08f9oTOUlsN2H 8AtuEdJroDLuKSpy4JBVB39B/d7mcDcbNHsy5KVNL9xMsVbgmo+ZpNac1QoROLXPC7Cu G7W6QZFFdFn1OiLlm1BYg9IY/oybgyAsJt0vFwkU2vgBMLwUks2ebeMN3PPpt/rlDVrF e6uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7k0hnNuOG3QRzXOhhHlFC+IlgbwmTQXTG7uqldPEFX4=; b=Mb3dkP5Nzrc5I96THeNDHOn23IKd7FE3Del3qfSV3PRDEJlsmeL3Ebwn0ogIuR/z5H p5Yk7bkNb/phelhr4YE2YQrkJWo1YaczQy073LeCUk9nhqiHAihSV8EXx+EATLltSXyX i5VXgoF4YEA2WqAZXFYdmrjqIDo+pf7WTBbIUYndOBmIt5nLSadGcR0E7LfeWLjITYZ8 ES0cvV/ZbRDdLO7G413hstxqDCBk96mUWqvVtliDAwCR9v0X6KIbtUy6hKfaIbgvZT37 lEcbT5Urx7CHSuewXqLvzq7yEXIfEfN9NSoSNVBP2kSjMoM2mSTTji0NzGrEsDQ+9JwQ fItQ== X-Gm-Message-State: AOAM530WgEhv8IPJ9r1RfJxHGMYfe73TV4UWtXuHtB8DmWQn7lm3kl8K s6DrHHbJ9IZtvTronImkMKGRasGcyKs+4XCEsWHBug== X-Received: by 2002:a19:a416:: with SMTP id q22mr3434882lfc.305.1619111397911; Thu, 22 Apr 2021 10:09:57 -0700 (PDT) MIME-Version: 1.0 References: <20210422130236.0bb353df@imladris.surriel.com> In-Reply-To: <20210422130236.0bb353df@imladris.surriel.com> From: Vincent Guittot Date: Thu, 22 Apr 2021 19:09:46 +0200 Message-ID: Subject: Re: [PATCH v4] sched,fair: Skip newidle_balance if a wakeup is pending To: Rik van Riel Cc: linux-kernel , Kernel Team , Valentin Schneider , Peter Zijlstra , Ingo Molnar , Dietmar Eggemann , Mel Gorman Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 22 Apr 2021 at 19:02, Rik van Riel wrote: > > The try_to_wake_up function has an optimization where it can queue > a task for wakeup on its previous CPU, if the task is still in the > middle of going to sleep inside schedule(). > > Once schedule() re-enables IRQs, the task will be woken up with an > IPI, and placed back on the runqueue. > > If we have such a wakeup pending, there is no need to search other > CPUs for runnable tasks. Just skip (or bail out early from) newidle > balancing, and run the just woken up task. > > For a memcache like workload test, this reduces total CPU use by > about 2%, proportionally split between user and system time, > and p99 and p95 application response time by 10% on average. > The schedstats run_delay number shows a similar improvement. > > Signed-off-by: Rik van Riel Reviewed-by: Vincent Guittot > --- > kernel/sched/fair.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 69680158963f..6a18688a37f8 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -10594,6 +10594,14 @@ static int newidle_balance(struct rq *this_rq, struct rq_flags *rf) > u64 curr_cost = 0; > > update_misfit_status(NULL, this_rq); > + > + /* > + * There is a task waiting to run. No need to search for one. > + * Return 0; the task will be enqueued when switching to idle. > + */ > + if (this_rq->ttwu_pending) > + return 0; > + > /* > * We must set idle_stamp _before_ calling idle_balance(), such that we > * measure the duration of idle_balance() as idle time. > @@ -10661,7 +10669,8 @@ static int newidle_balance(struct rq *this_rq, struct rq_flags *rf) > * Stop searching for tasks to pull if there are > * now runnable tasks on this rq. > */ > - if (pulled_task || this_rq->nr_running > 0) > + if (pulled_task || this_rq->nr_running > 0 || > + this_rq->ttwu_pending) > break; > } > rcu_read_unlock(); > -- > 2.25.4 > >