Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp51806imu; Tue, 27 Nov 2018 08:56:21 -0800 (PST) X-Google-Smtp-Source: AFSGD/VwkruQD/N5gYHeT6XI9ai36+HFRpySooeipil7VbtMrhc1GrFDmZFUowQnab6sMDtHsR+K X-Received: by 2002:a63:d450:: with SMTP id i16mr29285373pgj.246.1543337781039; Tue, 27 Nov 2018 08:56:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543337781; cv=none; d=google.com; s=arc-20160816; b=qQnyCKRPDTC4aA4jidYga/wpwQiT6SZEH7nOhp7mJ+q9U/+WD5Q3xa+qA0T2AZ5uaC 9s4CZN7vCZBup5GyfJliIOTBh8BOGiU/1Aa6qIygTJFov55pNjvfyMYW817/KP63IniU 1S3+5tIC1Ermvpa0F90ssJbFwv/YdeZZEjZAwh8XVm8MR6hmR63BCX3xwWoOgMCHMXaI p10GsjLc6laSyhm3znnX1fBnUqZaU6mtFiaEmphEoI7hFBuKb7ez8+VyWoe0neZiE7xO YFbM6NDgkMjUCNc52r88iJgdRQShIJVKeJjXzBe8R5n7mwaQbil+qaSdnVC60r928I6o kwIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=DOFhC4xf3dILnVmSMTvFksDMfcI8cd5oCAq/Eq05nFI=; b=rgBfYYOlvI6xmnsBlzNq4ZC6ayCAvdQRz60xFFnk/Nyu+t1vF3hQGYlOZJy+OzKO2E AQXyumWg205Cvuh5ytdDNo9wmEwIsgu5mHNRQEVCkM/LxMpUwDsHncvsZ35hwc3lWVor CZqPRamJVraU6RLtFywUbrfqNBml8CtG3QbasYOY+9Ho0/l5eyARkJwusGUJxFbx/Kie aEJbmtBFtj3txjmU66KtWG6GMI3XDGGwaNJf0IcqP6L2dczspHhb+viUN1S4LgT4uHw+ XCHDiM2m5ymX9Dt7aTKhBJYHQ73FaGUh0nBrdTftt5oZbFm650qR03UvoJkmbYa2k6CC GzuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=YecWw6vn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n12si4253636pgb.563.2018.11.27.08.56.01; Tue, 27 Nov 2018 08:56:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=YecWw6vn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731597AbeK1DwE (ORCPT + 99 others); Tue, 27 Nov 2018 22:52:04 -0500 Received: from mail-yw1-f65.google.com ([209.85.161.65]:41231 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731584AbeK1DwD (ORCPT ); Tue, 27 Nov 2018 22:52:03 -0500 Received: by mail-yw1-f65.google.com with SMTP id f65so9411092ywc.8 for ; Tue, 27 Nov 2018 08:53:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=DOFhC4xf3dILnVmSMTvFksDMfcI8cd5oCAq/Eq05nFI=; b=YecWw6vn6Ajh8o4B5VNfhEgUnqSTAHFG+Que8uj6MvQHogsBqANxjHCKq+46kNWHln Su/AU13hjOXPMPu2tfTQcYwwOI7MfFWG2nd6TLrMIzXaXLKk5RPJQBJQnGA9RdmA3HQK B2QXzlvELBywWttLJ+oKu3a1SjKDj/fqU0rA61tT1vxDBOFvv8ys21AUCTkYa8j0UPAz 2Rc9YY7rg2J6abZXB9Q2UfgjpCMdcqiORkRAkjZ2YOdbEasP1iGFt39weFH+jpw8Z/+u MTz1Sa2TvdUnhuhUdnyPD78bPxm77rucuvdF7MJQXKtmZSXeewrXU4TNLDYxSUkqM3P/ paLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=DOFhC4xf3dILnVmSMTvFksDMfcI8cd5oCAq/Eq05nFI=; b=ohnUhMDOvgvjcp2X+Y+f8NIhu6k8CWyi5YRIdvfHQ3qwJxsYKAosSuSs3z+6Qgq5R/ 3z8G7CcK81tsQGEe15IR4KP4CBVZOPBtafiQ3+CZggr37tFuHDIRYPdADaxyfv3xKzkz VyLSXHBdOjMgKfaLHyRJPygVC6MTH2LBGAI6zr71dh1MCvrv/EZo7YTSw6EiwYZCtc7G 5qAAt6xXceESd665G9WVus/GpplRV3PWNYu/iR2VV2kEyNrOj0gtcktx5wiTQKA/ED58 q1NUcaiXtaXvLePtbLwxg+3qzvvxHCm8HYN7sc2ZEq6dNECVlHPvmvpF1nMnahKRSv6v +N8Q== X-Gm-Message-State: AA+aEWbpzS3yG0hCOyrkGinEo7bv8xCFUsrh5VnUCNZg0aCUxcNYei5r pZNKHmC/zQeMuETXf35eifAKwA== X-Received: by 2002:a81:7a0e:: with SMTP id v14mr14883516ywc.115.1543337611759; Tue, 27 Nov 2018 08:53:31 -0800 (PST) Received: from localhost ([2620:10d:c091:200::5:9b77]) by smtp.gmail.com with ESMTPSA id w1sm1608087ywd.49.2018.11.27.08.53.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Nov 2018 08:53:30 -0800 (PST) Date: Tue, 27 Nov 2018 11:53:29 -0500 From: Johannes Weiner To: Mel Gorman Cc: Tejun Heo , Peter Zijlstra , linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Subject: Re: Hackbench pipes regression bisected to PSI Message-ID: <20181127165329.GA29728@cmpxchg.org> References: <20181126133420.GN23260@techsingularity.net> <20181126160724.GA21268@cmpxchg.org> <20181126165446.GQ23260@techsingularity.net> <20181126173218.GA22640@cmpxchg.org> <20181126232926.GS23260@techsingularity.net> <20181127164617.GA29488@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181127164617.GA29488@cmpxchg.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 27, 2018 at 11:46:17AM -0500, Johannes Weiner wrote: > From 347b69a52d1ec7e71df1108cbc5703d6dd0616ba Mon Sep 17 00:00:00 2001 > From: Johannes Weiner > Date: Mon, 26 Nov 2018 09:39:23 -0500 > Subject: [PATCH] psi: make disabling/enabling easier for vendor kernels > > Mel Gorman reports a hackbench regression with psi that would prohibit > shipping the suse kernel with it default-enabled, but he'd still like > users to be able to opt in at little to no cost to others. > > With the current combination of CONFIG_PSI and the psi_disabled bool > set from the commandline, this is a challenge. Do the following things > to make it easier: > > 1. Add a config option CONFIG_PSI_DEFAULT_ENABLED that allows distros This should be: CONFIG_PSI_DEFAULT_DISABLED Refreshed the patch. --- From dc1511101b4c6aa3f7cfb91d8634a682fe7c147e Mon Sep 17 00:00:00 2001 From: Johannes Weiner Date: Mon, 26 Nov 2018 09:39:23 -0500 Subject: [PATCH] psi: make disabling/enabling easier for vendor kernels Mel Gorman reports a hackbench regression with psi that would prohibit shipping the suse kernel with it default-enabled, but he'd still like users to be able to opt in at little to no cost to others. With the current combination of CONFIG_PSI and the psi_disabled bool set from the commandline, this is a challenge. Do the following things to make it easier: 1. Add a config option CONFIG_PSI_DEFAULT_DISABLED that allows distros to enable CONFIG_PSI in their kernel but leave the feature disabled unless a user requests it at boot-time. To avoid double negatives, rename psi_disabled= to psi=. 2. Make psi_disabled a static branch to eliminate any branch costs when the feature is disabled. In terms of numbers before and after this patch, Mel says: : The following is a comparision using CONFIG_PSI=n as a baseline against : your patch and a vanilla kernel : : 4.20.0-rc4 4.20.0-rc4 4.20.0-rc4 : kconfigdisable-v1r1 vanilla psidisable-v1r1 : Amean 1 1.3100 ( 0.00%) 1.3923 ( -6.28%) 1.3427 ( -2.49%) : Amean 3 3.8860 ( 0.00%) 4.1230 * -6.10%* 3.8860 ( -0.00%) : Amean 5 6.8847 ( 0.00%) 8.0390 * -16.77%* 6.7727 ( 1.63%) : Amean 7 9.9310 ( 0.00%) 10.8367 * -9.12%* 9.9910 ( -0.60%) : Amean 12 16.6577 ( 0.00%) 18.2363 * -9.48%* 17.1083 ( -2.71%) : Amean 18 26.5133 ( 0.00%) 27.8833 * -5.17%* 25.7663 ( 2.82%) : Amean 24 34.3003 ( 0.00%) 34.6830 ( -1.12%) 32.0450 ( 6.58%) : Amean 30 40.0063 ( 0.00%) 40.5800 ( -1.43%) 41.5087 ( -3.76%) : Amean 32 40.1407 ( 0.00%) 41.2273 ( -2.71%) 39.9417 ( 0.50%) : : It's showing that the vanilla kernel takes a hit (as the bisection : indicated it would) and that disabling PSI by default is reasonably : close in terms of performance for this particular workload on this : particular machine so; Tested-by: Mel Gorman Reported-by: Mel Gorman Signed-off-by: Johannes Weiner --- .../admin-guide/kernel-parameters.txt | 4 +++ include/linux/psi.h | 3 +- init/Kconfig | 9 ++++++ kernel/sched/psi.c | 30 +++++++++++++------ kernel/sched/stats.h | 8 ++--- 5 files changed, 40 insertions(+), 14 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 19f4423e70d9..8760a343c6d8 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -3504,6 +3504,10 @@ before loading. See Documentation/blockdev/ramdisk.txt. + psi= [KNL] Enable or disable pressure stall information + tracking. + Format: + psmouse.proto= [HW,MOUSE] Highest PS2 mouse protocol extension to probe for; one of (bare|imps|exps|lifebook|any). psmouse.rate= [HW,MOUSE] Set desired mouse report rate, in reports diff --git a/include/linux/psi.h b/include/linux/psi.h index 8e0725aac0aa..7006008d5b72 100644 --- a/include/linux/psi.h +++ b/include/linux/psi.h @@ -1,6 +1,7 @@ #ifndef _LINUX_PSI_H #define _LINUX_PSI_H +#include #include #include @@ -9,7 +10,7 @@ struct css_set; #ifdef CONFIG_PSI -extern bool psi_disabled; +extern struct static_key_false psi_disabled; void psi_init(void); diff --git a/init/Kconfig b/init/Kconfig index a4112e95724a..cf5b5a0dcbc2 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -509,6 +509,15 @@ config PSI Say N if unsure. +config PSI_DEFAULT_DISABLED + bool "Require boot parameter to enable pressure stall information tracking" + default n + depends on PSI + help + If set, pressure stall information tracking will be disabled + per default but can be enabled through passing psi_enable=1 + on the kernel commandline during boot. + endmenu # "CPU/Task time and stats accounting" config CPU_ISOLATION diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index 3d7355d7c3e3..fe24de3fbc93 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -136,8 +136,18 @@ static int psi_bug __read_mostly; -bool psi_disabled __read_mostly; -core_param(psi_disabled, psi_disabled, bool, 0644); +DEFINE_STATIC_KEY_FALSE(psi_disabled); + +#ifdef CONFIG_PSI_DEFAULT_DISABLED +bool psi_enable; +#else +bool psi_enable = true; +#endif +static int __init setup_psi(char *str) +{ + return kstrtobool(str, &psi_enable) == 0; +} +__setup("psi=", setup_psi); /* Running averages - we need to be higher-res than loadavg */ #define PSI_FREQ (2*HZ+1) /* 2 sec intervals */ @@ -169,8 +179,10 @@ static void group_init(struct psi_group *group) void __init psi_init(void) { - if (psi_disabled) + if (!psi_enable) { + static_branch_enable(&psi_disabled); return; + } psi_period = jiffies_to_nsecs(PSI_FREQ); group_init(&psi_system); @@ -549,7 +561,7 @@ void psi_memstall_enter(unsigned long *flags) struct rq_flags rf; struct rq *rq; - if (psi_disabled) + if (static_branch_likely(&psi_disabled)) return; *flags = current->flags & PF_MEMSTALL; @@ -579,7 +591,7 @@ void psi_memstall_leave(unsigned long *flags) struct rq_flags rf; struct rq *rq; - if (psi_disabled) + if (static_branch_likely(&psi_disabled)) return; if (*flags) @@ -600,7 +612,7 @@ void psi_memstall_leave(unsigned long *flags) #ifdef CONFIG_CGROUPS int psi_cgroup_alloc(struct cgroup *cgroup) { - if (psi_disabled) + if (static_branch_likely(&psi_disabled)) return 0; cgroup->psi.pcpu = alloc_percpu(struct psi_group_cpu); @@ -612,7 +624,7 @@ int psi_cgroup_alloc(struct cgroup *cgroup) void psi_cgroup_free(struct cgroup *cgroup) { - if (psi_disabled) + if (static_branch_likely(&psi_disabled)) return; cancel_delayed_work_sync(&cgroup->psi.clock_work); @@ -637,7 +649,7 @@ void cgroup_move_task(struct task_struct *task, struct css_set *to) struct rq_flags rf; struct rq *rq; - if (psi_disabled) { + if (static_branch_likely(&psi_disabled)) { /* * Lame to do this here, but the scheduler cannot be locked * from the outside, so we move cgroups from inside sched/. @@ -673,7 +685,7 @@ int psi_show(struct seq_file *m, struct psi_group *group, enum psi_res res) { int full; - if (psi_disabled) + if (static_branch_likely(&psi_disabled)) return -EOPNOTSUPP; update_stats(group); diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h index 4904c4677000..aa0de240fb41 100644 --- a/kernel/sched/stats.h +++ b/kernel/sched/stats.h @@ -66,7 +66,7 @@ static inline void psi_enqueue(struct task_struct *p, bool wakeup) { int clear = 0, set = TSK_RUNNING; - if (psi_disabled) + if (static_branch_likely(&psi_disabled)) return; if (!wakeup || p->sched_psi_wake_requeue) { @@ -86,7 +86,7 @@ static inline void psi_dequeue(struct task_struct *p, bool sleep) { int clear = TSK_RUNNING, set = 0; - if (psi_disabled) + if (static_branch_likely(&psi_disabled)) return; if (!sleep) { @@ -102,7 +102,7 @@ static inline void psi_dequeue(struct task_struct *p, bool sleep) static inline void psi_ttwu_dequeue(struct task_struct *p) { - if (psi_disabled) + if (static_branch_likely(&psi_disabled)) return; /* * Is the task being migrated during a wakeup? Make sure to @@ -128,7 +128,7 @@ static inline void psi_ttwu_dequeue(struct task_struct *p) static inline void psi_task_tick(struct rq *rq) { - if (psi_disabled) + if (static_branch_likely(&psi_disabled)) return; if (unlikely(rq->curr->flags & PF_MEMSTALL)) -- 2.19.1