Received: by 10.192.165.148 with SMTP id m20csp5364670imm; Wed, 9 May 2018 03:59:26 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrRffpukKpG3IOE5IU3aBh3CDl8cvnaTE9P3VH2ecyo3WcCKUdKCd64NCD5dy5pnNYO/AQj X-Received: by 2002:a63:90c4:: with SMTP id a187-v6mr35365204pge.189.1525863566619; Wed, 09 May 2018 03:59:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525863566; cv=none; d=google.com; s=arc-20160816; b=zREOvN9hlP57swk2+49MWHrZAxsZVDYuuhvjvzBGXvbD/AiXApRb14gv7XqhS/XRnU d2qbQ56YrZOdknOAcy3gMnmp0GzkEgi9MqgKcuWz06WECM46orIBsivgZo0jzAptcayU otib+hxKNOF/hLXCoues+obTHuOVDAJguN0E0QJvTDGukxRtoZ5JqewVb/hag8hq+Awg yjQFXE6Xiw7IB3sWt0lQR6O+x9O58RA3iJBBV6dTFwcoJTANTjKBBEcKykEbzF8qeWS9 TokRsPEqL4HTqX6tYHeeierMD7rFPQtasOUfmioDLcwvSjsi1pXLxGUEF+PVsdUnAh5E BqQA== 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:arc-authentication-results; bh=xEvcsgNJX26D71IbUXyuispBBMEfRfB+37tUjDV7HIc=; b=n1S82ZXRzH7Oq7u/a/DI4PW50HAd2nJdbLTo3EJUUQT+UTrK8K6t6g/hxjgRCSnTjJ DcEm2z2Oh1QCYR2gytWIZ+g3gkfGhuf4+oB1bCB20P49uRC8OFfKySPBblZB7dAOd4JM VJ7jlIhkoli2KSeI7Y9DeYypZV5L3Qm+i/tKqgtxEACjDa5aSgchomi7YyplsryMHQ7F eVnAu4MVE4CpB4TDtgHRwmbLJZBQv+l8uISJzUz5II1F/is3Pos97LdEM6vkyeMpN6wg oDzJusFoJ/pbZz6RCR8sItVH5nu00AWva+zkmOm09ppZnvsa1MJw8xBuK8zK7fcRm+ea tQRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=E0hsG871; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u11-v6si25350881plr.165.2018.05.09.03.59.12; Wed, 09 May 2018 03:59:26 -0700 (PDT) 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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=E0hsG871; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756076AbeEIKz3 (ORCPT + 99 others); Wed, 9 May 2018 06:55:29 -0400 Received: from merlin.infradead.org ([205.233.59.134]:52234 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750767AbeEIKz0 (ORCPT ); Wed, 9 May 2018 06:55:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=xEvcsgNJX26D71IbUXyuispBBMEfRfB+37tUjDV7HIc=; b=E0hsG8714gH08sFRHI8NoCKkX 63dxxdppYXJuI+a8Bl/0YXirWdCc3sR0gLTV8iH5AuL04cOX19sIbIGcc2M4OVFESSsTNhX1sMfEv eXbgtHn3EHtUmb8e/D9gn+6wajervjQA8iFfudXs7vTPc8x+QavypDyhPaa2ygBxsTgoR8Jn0k7T3 rjdGsBK1/L4BIcnHGwUzDf6i1f9RQ81VNshidjjV5TsdQa2Qq/Ezguw+Fy7PAgXAPU90PF5xDseKl g46CMQ8jprLaAzFvZK+3NHwVLd0icrhtalf8r2qZpZw/aUoi1CyDvxNBfTnp9Mts+xhmB2DvZJWqB aF7XTiBzQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fGMkV-0007PS-KS; Wed, 09 May 2018 10:55:07 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 887302029FA13; Wed, 9 May 2018 12:55:05 +0200 (CEST) Date: Wed, 9 May 2018 12:55:05 +0200 From: Peter Zijlstra To: Johannes Weiner Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-block@vger.kernel.org, cgroups@vger.kernel.org, Ingo Molnar , Andrew Morton , Tejun Heo , Balbir Singh , Mike Galbraith , Oliver Yang , Shakeel Butt , xxx xxx , Taras Kondratiuk , Daniel Walker , Vinayak Menon , Ruslan Ruslichenko , kernel-team@fb.com Subject: Re: [PATCH 6/7] psi: pressure stall information for CPU, memory, and IO Message-ID: <20180509105505.GQ12217@hirez.programming.kicks-ass.net> References: <20180507210135.1823-1-hannes@cmpxchg.org> <20180507210135.1823-7-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180507210135.1823-7-hannes@cmpxchg.org> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 07, 2018 at 05:01:34PM -0400, Johannes Weiner wrote: > @@ -28,10 +28,14 @@ static inline int sched_info_on(void) > return 1; > #elif defined(CONFIG_TASK_DELAY_ACCT) > extern int delayacct_on; > - return delayacct_on; > -#else > - return 0; > + if (delayacct_on) > + return 1; > +#elif defined(CONFIG_PSI) > + extern int psi_disabled; > + if (!psi_disabled) > + return 1; > #endif > + return 0; > } > diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h > index 8aea199a39b4..cb4a68bcf37a 100644 > --- a/kernel/sched/stats.h > +++ b/kernel/sched/stats.h > @@ -55,12 +55,90 @@ static inline void rq_sched_info_depart (struct rq *rq, unsigned long long delt > # define schedstat_val_or_zero(var) 0 > #endif /* CONFIG_SCHEDSTATS */ > > +#ifdef CONFIG_PSI > +/* > + * PSI tracks state that persists across sleeps, such as iowaits and > + * memory stalls. As a result, it has to distinguish between sleeps, > + * where a task's runnable state changes, and requeues, where a task > + * and its state are being moved between CPUs and runqueues. > + */ > +static inline void psi_enqueue(struct task_struct *p, u64 now) > +{ > + int clear = 0, set = TSK_RUNNING; > + > + if (p->state == TASK_RUNNING || p->sched_psi_wake_requeue) { > + if (p->flags & PF_MEMSTALL) > + set |= TSK_MEMSTALL; > + p->sched_psi_wake_requeue = 0; > + } else { > + if (p->in_iowait) > + clear |= TSK_IOWAIT; > + } > + > + psi_task_change(p, now, clear, set); > +} > +static inline void psi_dequeue(struct task_struct *p, u64 now) > +{ > + int clear = TSK_RUNNING, set = 0; > + > + if (p->state == TASK_RUNNING) { > + if (p->flags & PF_MEMSTALL) > + clear |= TSK_MEMSTALL; > + } else { > + if (p->in_iowait) > + set |= TSK_IOWAIT; > + } > + > + psi_task_change(p, now, clear, set); > +} > +static inline void psi_ttwu_dequeue(struct task_struct *p) > +{ > + /* > + * Is the task being migrated during a wakeup? Make sure to > + * deregister its sleep-persistent psi states from the old > + * queue, and let psi_enqueue() know it has to requeue. > + */ > + if (unlikely(p->in_iowait || (p->flags & PF_MEMSTALL))) { > + struct rq_flags rf; > + struct rq *rq; > + int clear = 0; > + > + if (p->in_iowait) > + clear |= TSK_IOWAIT; > + if (p->flags & PF_MEMSTALL) > + clear |= TSK_MEMSTALL; > + > + rq = __task_rq_lock(p, &rf); > + update_rq_clock(rq); > + psi_task_change(p, rq_clock(rq), clear, 0); > + p->sched_psi_wake_requeue = 1; > + __task_rq_unlock(rq, &rf); > + } > +} That all seems to be missing psi_disabled tests.. Yes I know it's burried down in psi_task_change() somewhere, but that's really (too) late. (also, you seem to be conserving whitespace; typically we have an empty lines between functions)