Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp404104pxb; Sat, 6 Mar 2021 03:46:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJy7z7UD0hsUW3lvHYto9CIkCNqf8EQm3FgRwbG1iw8RTXP7FBBgGTAiAYsHlg/OzMSLxPoL X-Received: by 2002:a05:6402:3047:: with SMTP id bu7mr13583891edb.227.1615031185044; Sat, 06 Mar 2021 03:46:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615031185; cv=none; d=google.com; s=arc-20160816; b=m+Saw4OrpltO5BMRmBKAFF1WB0dRvGrWQOWKGq2aaykTDRKvo3aaNQHLfH5Vl6NtD5 PdQBZIGsGOOGN9qm8kbhTRb9VP63wnoe1a/9bwqvjo9YWGW/gunR4g7MH6xT2bNc1fcp n2GRFqeDaLLvmJQ4BMIWKydZCJr2Ayqmr3i59IGlFccCjDlZSz4P87+DZ3xNP4CakXyA 1dc9edmUpx5rOJxHXay8LF5cJdNo3Umc5fAzeubidBcxy+qxzTcN6l0giU8wQROvpzvP o2FxIFgZYhig3PF/6MO34Wzu5vn9y7AnlU7/az4aeqkxKBe4ztJbWu4X0V+goQbZJSsQ vKEw== 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=4vvHwa4ijzPORnwg40Q6sbzSiFhrexXoUjLep87zoHA=; b=LafQxVvsBh8saP4uvEJMQjrUZk/tDbHaYhfU9zfM1CxXVPqd1en6S7p8lPi2NqkM5q 3H1KTIZRLVB56BVsA7fyTsi8A20jMzrPcDB9Flr3ugHWD5j8XHa4COoWQrRn1X+bqxLM 2+lYP55UCZnPG6cj7lqRUOppTbV6S9TphswdwL2lgeeTbphLfXvONOkte0q1bJpRswbO rFm3fUPGysWLQn3nr0/pjfEbwZjzGucIQw33r4rV2V7qF/zLUuKLQ+XQEDrYjbPNAnMU n39LjLFFlyRSkqLSTRjLNMR7MkUaAjtl1NEiEHrq0Hun+TFEdgm6teiOLsfMtkxNf9Uc wk/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="S9CWc/53"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=5mC6esdX; 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 cw1si3570364edb.412.2021.03.06.03.46.03; Sat, 06 Mar 2021 03:46: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="S9CWc/53"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=5mC6esdX; 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 S231256AbhCFLmo (ORCPT + 99 others); Sat, 6 Mar 2021 06:42:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230323AbhCFLmV (ORCPT ); Sat, 6 Mar 2021 06:42:21 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A12F7C06175F; Sat, 6 Mar 2021 03:42:20 -0800 (PST) Date: Sat, 06 Mar 2021 11:42:18 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1615030939; 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=4vvHwa4ijzPORnwg40Q6sbzSiFhrexXoUjLep87zoHA=; b=S9CWc/53AmqQYDGnJeJnbfFZH8RhnlFZT7y679hDYmPMDUjK3Hz7Bw0xTzeCh6MNj3Oppx avt65AjMQZYWAjdk7vmnkZJwISUHZjcKCoNHGZNV8l8fnbbQhTbW8E4YTcBJsZ4ha4W8u0 wUIasr/i+r6Fm0eKy8IkWzwuYWLvpFAomDbcsvcTh5hp2Pun0aoyQcxEfodOWKtC3YhAvX XkYM8Zj1fv0ymAXp/2rYsGI9Kr7I8qVT3VQ83RmOwmVZSzvuuSMqr5M7kHjGTHtohr/sOR tM8+Y4/vICuKYf3bLddjJZJw2DwYw/j6hDokHl36DDnAYQcCZZ9y6jzM8mWX6w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1615030939; 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=4vvHwa4ijzPORnwg40Q6sbzSiFhrexXoUjLep87zoHA=; b=5mC6esdXBj4rKimbeTDD8xyI6gpo1GxdxMTyLRQEB+M8NSLVA/+6PPTOMnQW94hN4WhXtw FBeYiLROZYMSEDDQ== 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)" , Ingo Molnar , 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: <161503093847.398.958510579963989988.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: fddc8bab531e217806b84906681324377d741c6c Gitweb: https://git.kernel.org/tip/fddc8bab531e217806b84906681324377d741c6c Author: Johannes Weiner AuthorDate: Wed, 03 Mar 2021 11:46:58 +08:00 Committer: Ingo Molnar CommitterDate: Sat, 06 Mar 2021 12:40:23 +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) Signed-off-by: Ingo Molnar 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;