Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp485773imm; Wed, 18 Jul 2018 05:47:36 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfnhFgoFqxnNHO9x2aNo4SYXoSIIHV+gNHpRM1a+3svbqbJH0Mk3IONNgeSdufmcJpoWs8P X-Received: by 2002:a63:c44a:: with SMTP id m10-v6mr5710745pgg.416.1531918056582; Wed, 18 Jul 2018 05:47:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531918056; cv=none; d=google.com; s=arc-20160816; b=HB0m8tefGS0kuqqcUmROFzHqAw6XvidmjBnTrcDk2ZwyZnFcLcyazNG4BarNk1yR1J PvbD9lJsEnxWoSdf1UrtGMLHtB+Nk/01JdCNBL8zk8Gcx2rLY/Q7yhlKt5YQoCoIv4px cc98rmuJ2KDZMKP8NoQbPFa2xrSwec5iAyVn+SdKMVEUs5gG6H0zElmqa9KYWi77OehR hwHt7asDa07f1z1IUTDTX5M8cqWC4yQ0T2oSWOX98+qmKwN0FAaxZx1QRdZpQjNWl0Xx buT9DL5sCmS8w3byvVYZvYoAYc1zJFW56FBYbg+tXdzuWUsYKXt88nBUIPUUhyWUrM+Y HSjQ== 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=G1CeSVNRSs9e+uLfff8rjLTQr0i13eyHf/GBu+Hp1rg=; b=CVK29HrcjTwE1+U9Pc2EzRBqeStHM2Zo8Kdhm3qKEAQKD03UodMTUf50s+hxhrduWo 9E2+q02Nsy3vMJzD0loQvbEWWjgVhcIpk8mzH1y6JuAf2RBSTiYpVZlUkyHhbD07HxlP rxfNr67LUXGMKXmwMU21WEPIZmU69xecveILxaaDbmETwT5jzyZkCwWNuJVoLUGkbbUQ Chkshk67r7/+u4wlS/qFsZe8R+5tZ58Tulxq2RN2vqGyCwDZVMnMW87fOu7qtG/imLag YzYcocHCxHk/hYPwuDV41WbMp9TwcHnS5RVf7V28uTmr4X+GhOPPwrXSfe+/97PdbhYt cXOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=TlKvUjn1; 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 z13-v6si3443838pgc.409.2018.07.18.05.47.22; Wed, 18 Jul 2018 05:47:36 -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=TlKvUjn1; 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 S1730755AbeGRNY2 (ORCPT + 99 others); Wed, 18 Jul 2018 09:24:28 -0400 Received: from merlin.infradead.org ([205.233.59.134]:40706 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729650AbeGRNY1 (ORCPT ); Wed, 18 Jul 2018 09:24:27 -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=G1CeSVNRSs9e+uLfff8rjLTQr0i13eyHf/GBu+Hp1rg=; b=TlKvUjn1O2j9/9jkG36/vJFJ7 3auHwldptvotgxfSvP16t8FJDRBijLbCwIIYiwOXKzYdc8kayKPCjFBJCcbo4Ye1bpH8LljqpYr9Y IOn3sAxGaJdxT7N9ZAMx8cF66ySuPjNES7SapNySqf13fHAKp5GW0Dc9VAgk+W9Ss7kX1/GqWFHqQ cbwGGPZkv64Bo3PUw+PkIOrZ/4Z3gOeSRhgiJ0NBqUgWoFq56bZye/zGyl+h4T4nRd8hwcnOA+aaE dSLDgGdRKaG6eeT8XRPLAxodJ7aZn4iiDeb323ltaW5wZdOapR+NfP8RpxI0YXQqwTbI8NgOtmuc+ FbrHP83eA==; 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 1fflqe-0004mL-Ov; Wed, 18 Jul 2018 12:46:29 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 2E0D120275F38; Wed, 18 Jul 2018 14:46:27 +0200 (CEST) Date: Wed, 18 Jul 2018 14:46:27 +0200 From: Peter Zijlstra To: Johannes Weiner Cc: Ingo Molnar , Andrew Morton , Linus Torvalds , Tejun Heo , Suren Baghdasaryan , Vinayak Menon , Christopher Lameter , Mike Galbraith , Shakeel Butt , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH 08/10] psi: pressure stall information for CPU, memory, and IO Message-ID: <20180718124627.GD2476@hirez.programming.kicks-ass.net> References: <20180712172942.10094-1-hannes@cmpxchg.org> <20180712172942.10094-9-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180712172942.10094-9-hannes@cmpxchg.org> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 12, 2018 at 01:29:40PM -0400, Johannes Weiner wrote: > +static inline void psi_enqueue(struct task_struct *p, u64 now, bool wakeup) > +{ > + int clear = 0, set = TSK_RUNNING; > + > + if (psi_disabled) > + return; > + > + if (!wakeup || p->sched_psi_wake_requeue) { > + if (p->flags & PF_MEMSTALL) > + set |= TSK_MEMSTALL; > + if (p->sched_psi_wake_requeue) > + 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, bool sleep) > +{ > + int clear = TSK_RUNNING, set = 0; > + > + if (psi_disabled) > + return; > + > + if (!sleep) { > + if (p->flags & PF_MEMSTALL) > + clear |= TSK_MEMSTALL; > + } else { > + if (p->in_iowait) > + set |= TSK_IOWAIT; > + } > + > + psi_task_change(p, now, clear, set); > +} > +/** > + * psi_memstall_enter - mark the beginning of a memory stall section > + * @flags: flags to handle nested sections > + * > + * Marks the calling task as being stalled due to a lack of memory, > + * such as waiting for a refault or performing reclaim. > + */ > +void psi_memstall_enter(unsigned long *flags) > +{ > + struct rq_flags rf; > + struct rq *rq; > + > + if (psi_disabled) > + return; > + > + *flags = current->flags & PF_MEMSTALL; > + if (*flags) > + return; > + /* > + * PF_MEMSTALL setting & accounting needs to be atomic wrt > + * changes to the task's scheduling state, otherwise we can > + * race with CPU migration. > + */ > + rq = this_rq_lock_irq(&rf); > + > + update_rq_clock(rq); > + > + current->flags |= PF_MEMSTALL; > + psi_task_change(current, rq_clock(rq), 0, TSK_MEMSTALL); > + > + rq_unlock_irq(rq, &rf); > +} I'm confused by this whole MEMSTALL thing... I thought the idea was to account the time we were _blocked_ because of memstall, but you seem to count the time we're _running_ with PF_MEMSTALL. And esp. the wait_on_page_bit_common caller seems performance sensitive, and the above function is quite expensive.