Received: by 10.192.165.148 with SMTP id m20csp5332538imm; Wed, 9 May 2018 03:22:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqKHU/sqOmf8P0PoJhWmpJa3uQY5NiGlplaeNkPp8m0r5fal9zh+vts+emJrbQyxIiYWVxQ X-Received: by 2002:a17:902:125:: with SMTP id 34-v6mr46087044plb.42.1525861322377; Wed, 09 May 2018 03:22:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525861322; cv=none; d=google.com; s=arc-20160816; b=B1xoG2DsBGzis+Qur+5hpW5cUzlyw0RWZCNBWeBZpAr0/NlCZ8exoRxhl3RUgJLYHz FlMnhXr0CRpxEdaUiQjj36cvUJSts485+d7qho0lontJUADJiMBPjkVuViseskArnQmp DvobpKGjOnB687NuHbjWulb0eVhy/K2EBqqALtOn03qcJZkbo0H1EJLs/wVz6hIkqb4I M4mETSW0rvP7M0L9x5N4slbWcTK/9XLiggHjAgxdR28ZXLzTTBUccR5zQoSMRjGTrXYB 6lfe5TSiM2sF74NUdEJh5/wzCRlAQ7Tr3Yy29I1AKpJ8a/Ue4+jjxKyeY4favMeCfRVm QQHA== 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=yXw5wGWgNbTksMl0p2Ca+JTi6iz3wulrrSaIORPjtJs=; b=dBONZSmwdxARk44sgSPKHYG28dJkEMKWmf0nzGi247yYiwdrZrql50R7cuap+4zM9t NuyRi7GPgfFvcix38XACx3gHXcPIZrCZVs9TEaWSxYrqx+x9U9ORLcAkR5mWkKIiyc0+ AUTILdFoBacaQ/88ah4yl68JehAkP9jHVb6QIByzkzpgrwxbsygbIE1ORMqgHFzoXcud qXc2vorI2/agMgYtcmHq5SV3VScW2Tk59+mFGb08wz9l2fjsmaW5hsDVoLWYzi22W18/ fdGRMDFvo5+3RIumNHSVyt2qDGZRm8bndnY+W0piJvjQ7xuwQtiaW3+dNZDRc7+9S6LX zWeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=kw/E4VsO; 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 h193-v6si20973908pgc.57.2018.05.09.03.21.47; Wed, 09 May 2018 03:22:02 -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=bombadil.20170209 header.b=kw/E4VsO; 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 S934200AbeEIKVT (ORCPT + 99 others); Wed, 9 May 2018 06:21:19 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:38552 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933819AbeEIKVR (ORCPT ); Wed, 9 May 2018 06:21:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=yXw5wGWgNbTksMl0p2Ca+JTi6iz3wulrrSaIORPjtJs=; b=kw/E4VsO00CgF0l0htO+1Kgny LyDqanH2BH2E5/FQ1HgbGjhtj1KeSaDCvbrQ2uAZFYY52p5SLR82qgfXdnlcfWsENErL22rqQ+cGo byWptRBo6mQD55S12K48lUm9FMc5kb7TSksNbpMsIEz1NkJ50Suz4EamUGpJZQXzGFQB4bktXuUMJ L34LYoF0JaCZ5Jt0KqilPoP8NRZs+gv4jDdzhB1yoVbYnBTTb3wWBkg8Ms+T1ZKpJsRLRoOh/gSKf E6Q/FadzCB0RiKz3xIGK1VD/q9Kfc74iy8xCwK+s23HS++jHpLesLl/7D+qRXUy6bdoWwicr73MAX R52q8kpzg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fGMDX-0001X0-03; Wed, 09 May 2018 10:21:03 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 023832029FA13; Wed, 9 May 2018 12:21:00 +0200 (CEST) Date: Wed, 9 May 2018 12:21:00 +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: <20180509102100.GN12217@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: > +/** > + * 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; > + > + *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. > + */ > + local_irq_disable(); > + rq = this_rq(); > + raw_spin_lock(&rq->lock); > + rq_pin_lock(rq, &rf); Given that churn in sched.h, you seen rq_lock() and friends. Either write this like: local_irq_disable(); rq = this_rq(); rq_lock(rq, &rf); Or instroduce "rq = this_rq_lock_irq()", which we could also use in do_sched_yield(). > + update_rq_clock(rq); > + > + current->flags |= PF_MEMSTALL; > + psi_task_change(current, rq_clock(rq), 0, TSK_MEMSTALL); > + > + rq_unpin_lock(rq, &rf); > + raw_spin_unlock(&rq->lock); > + local_irq_enable(); That's called rq_unlock_irq(). > +} > + > +/** > + * psi_memstall_leave - mark the end of an memory stall section > + * @flags: flags to handle nested memdelay sections > + * > + * Marks the calling task as no longer stalled due to lack of memory. > + */ > +void psi_memstall_leave(unsigned long *flags) > +{ > + struct rq_flags rf; > + struct rq *rq; > + > + if (*flags) > + return; > + /* > + * PF_MEMSTALL clearing & accounting needs to be atomic wrt > + * changes to the task's scheduling state, otherwise we could > + * race with CPU migration. > + */ > + local_irq_disable(); > + rq = this_rq(); > + raw_spin_lock(&rq->lock); > + rq_pin_lock(rq, &rf); > + > + update_rq_clock(rq); > + > + current->flags &= ~PF_MEMSTALL; > + psi_task_change(current, rq_clock(rq), TSK_MEMSTALL, 0); > + > + rq_unpin_lock(rq, &rf); > + raw_spin_unlock(&rq->lock); > + local_irq_enable(); > +} Idem.