Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1604935pxb; Thu, 4 Mar 2021 16:07:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJxqU3MHYgQI3XVU7LJtCUiyXjQCDxLW0O6DfDyFwo33oQT7IqNSLGz7TEin8u3eGCCI5l8Q X-Received: by 2002:a02:74a:: with SMTP id f71mr6693731jaf.30.1614902845677; Thu, 04 Mar 2021 16:07:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614902845; cv=none; d=google.com; s=arc-20160816; b=qjdZ/o/wW+KrGg2NqAH13Rz6de3ZaRWkC6Aj3htaEZ8ft/49LWTjiS1IpswqlWXzBE EMvRduRgHlsY73rLFQNRG6rgZn9vXhxwjAm25nqDz/LB1ZcuQrjPy5GPCB4SpPu8PRXy lRKP+4k0zumEs0stal+Djbd194OR9v1VoMk19I896eomwiPMpWmVayBEeAQeX0mMgsB1 KNWXCuTpscBsZ807/Z+e/f26QqcBfePb+eMDyDUExn9AYlQmh9qs/nEDFo2EepRNAb9d GXTRsRnGri2U27hLoOBRijBYMKWxuji2M/tiiCfG50p6sKXanfAFzkjFk34xORzqVvkS 5uZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=aE+hRovfdY2IR6YoPMbaRzy74CcpsGZ94v2nJOzW8Kc=; b=0Je3042aajo3n2ET76rc41UZEcSjoGqQ0vsItuJmr476ym3cP6qBWjCkrkeW7Is+ws sCIYdlZzD0bmYp/O+k2Q5E35jQbwu/asex+NDtr6X9zXMgsLoCI5QXZiC8RUm50HJifo eFPFbsN+ci0P6hDtB/UjoqQQtK9H1m5FWWlPYhCu8H6LyUkjgW80naOelwnxe+n9RH2A mghfXyaGg5y79Zmqk5SQYo154p1TZFwwv1sIjBooj5y9M31E9g1MaklsDXtBtqf1S92H P+LG4UlvohQ70gLcBjQb5uenq7bJ6u3S5HTUM9BgjjdgZSfAZQ3o/J3c8wQmOBKzA48g yxxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=FUehcKmH; dkim=neutral (no key) header.i=@linutronix.de header.b=gLroJmnO; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n16si1003313jat.35.2021.03.04.16.07.12; Thu, 04 Mar 2021 16:07:25 -0800 (PST) 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=@linutronix.de header.s=2020 header.b=FUehcKmH; dkim=neutral (no key) header.i=@linutronix.de header.b=gLroJmnO; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237297AbhCDJKX (ORCPT + 99 others); Thu, 4 Mar 2021 04:10:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232808AbhCDJJy (ORCPT ); Thu, 4 Mar 2021 04:09:54 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 199D0C061756; Thu, 4 Mar 2021 01:09:14 -0800 (PST) Date: Thu, 04 Mar 2021 09:09:11 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1614848952; h=from:from:sender:sender:reply-to: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=aE+hRovfdY2IR6YoPMbaRzy74CcpsGZ94v2nJOzW8Kc=; b=FUehcKmHUwQLvWKeVJNpxwZvrAWy0AP01sXkGpfXtGlpxlW2YNi0ilCnvhP+TTC03hImYd EkmEp63UREvuFAiVC1l1khPZIPlBaURnrxpbmyPgb68MzWrn5jxJZqfrulYvFB8Jng1ToS Z5Qs2M+r8umsH3m7t+haEN7pkEYykiwPTvx6mqspaP/TBiL/W1NO7Fu0CwWLQXLz4+iFX2 t/vAtRfik73Uo1HrsLgEwLNGrBvLs+deeO5W6tzU/TuVwvOmWAopxjDQfVS2T9ETQVeBG4 l+tWQpoV9d6VRA+E0VfXXN6UYiA4hYEIkbTHWmaqA6u727iUrdOTzBfsHiqURg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1614848952; h=from:from:sender:sender:reply-to: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=aE+hRovfdY2IR6YoPMbaRzy74CcpsGZ94v2nJOzW8Kc=; b=gLroJmnOTn708W7G5HTll8PG4WjswGE7/zjTQfeQ+Ci8+GcsHmDHS4G0BkzuY/cF8l3NqP iG9RPgvE/dnJiXDA== From: "tip-bot2 for Johannes Weiner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] psi: Pressure states are unlikely Cc: Johannes Weiner , Chengming Zhou , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20210303034659.91735-4-zhouchengming@bytedance.com> References: <20210303034659.91735-4-zhouchengming@bytedance.com> MIME-Version: 1.0 Message-ID: <161484895180.398.11244199191413169708.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: 24f3cb558f59debe0e9159459bb9627b51b47c17 Gitweb: https://git.kernel.org/tip/24f3cb558f59debe0e9159459bb9627b51b47c17 Author: Johannes Weiner AuthorDate: Wed, 03 Mar 2021 11:46:58 +08:00 Committer: Peter Zijlstra CommitterDate: Thu, 04 Mar 2021 09:56:02 +01:00 psi: Pressure states are unlikely Move the unlikely branches out of line. This eliminates undesirable jumps during wakeup and sleeps for workloads that aren't under any sort of resource pressure. Signed-off-by: Johannes Weiner Signed-off-by: Chengming Zhou Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20210303034659.91735-4-zhouchengming@bytedance.com --- kernel/sched/psi.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index 0fe6ff6..3907a6b 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -219,17 +219,17 @@ static bool test_state(unsigned int *tasks, enum psi_states state) { switch (state) { case PSI_IO_SOME: - return tasks[NR_IOWAIT]; + return unlikely(tasks[NR_IOWAIT]); case PSI_IO_FULL: - return tasks[NR_IOWAIT] && !tasks[NR_RUNNING]; + return unlikely(tasks[NR_IOWAIT] && !tasks[NR_RUNNING]); case PSI_MEM_SOME: - return tasks[NR_MEMSTALL]; + return unlikely(tasks[NR_MEMSTALL]); case PSI_MEM_FULL: - return tasks[NR_MEMSTALL] && !tasks[NR_RUNNING]; + return unlikely(tasks[NR_MEMSTALL] && !tasks[NR_RUNNING]); case PSI_CPU_SOME: - return tasks[NR_RUNNING] > tasks[NR_ONCPU]; + return unlikely(tasks[NR_RUNNING] > tasks[NR_ONCPU]); case PSI_CPU_FULL: - return tasks[NR_RUNNING] && !tasks[NR_ONCPU]; + return unlikely(tasks[NR_RUNNING] && !tasks[NR_ONCPU]); case PSI_NONIDLE: return tasks[NR_IOWAIT] || tasks[NR_MEMSTALL] || tasks[NR_RUNNING]; @@ -729,7 +729,7 @@ static void psi_group_change(struct psi_group *group, int cpu, * task in a cgroup is in_memstall, the corresponding groupc * on that cpu is in PSI_MEM_FULL state. */ - if (groupc->tasks[NR_ONCPU] && cpu_curr(cpu)->in_memstall) + if (unlikely(groupc->tasks[NR_ONCPU] && cpu_curr(cpu)->in_memstall)) state_mask |= (1 << PSI_MEM_FULL); groupc->state_mask = state_mask;