From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCF6FC4BA10 for ; Wed, 26 Feb 2020 14:23:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8674D24680 for ; Wed, 26 Feb 2020 14:23:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iOnngqoO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8674D24680 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2CA076B0003; Wed, 26 Feb 2020 09:23:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 27ADD6B0005; Wed, 26 Feb 2020 09:23:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1911F6B0006; Wed, 26 Feb 2020 09:23:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0228.hostedemail.com [216.40.44.228]) by kanga.kvack.org (Postfix) with ESMTP id 0198F6B0003 for ; Wed, 26 Feb 2020 09:23:53 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B7EA2181AC9CC for ; Wed, 26 Feb 2020 14:23:53 +0000 (UTC) X-FDA: 76532497146.17.pump17_4dc03068122e X-HE-Tag: pump17_4dc03068122e X-Filterd-Recvd-Size: 6158 Received: from mail-io1-f66.google.com (mail-io1-f66.google.com [209.85.166.66]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Wed, 26 Feb 2020 14:23:53 +0000 (UTC) Received: by mail-io1-f66.google.com with SMTP id e7so3463838ioe.13 for ; Wed, 26 Feb 2020 06:23:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BeNWEAdLUwurTRAu4WEqbTLswFUOMRIguNpdcSr0Tds=; b=iOnngqoOYmXsacqkDSMrBkMWzxQgRV/ODDWvY2p3gD7nr+4Xfw3hmFjUut/UqTxMTD rXQiXTadY/RG9GpL90SZZ+qY8nj3wgqwNuQAYLyLxX3wYPp7SyAg6Rni9lq3sEQt9e0p 3JIGJ1Sm4aEWANsOV88sIh5OEKrbphs4WmD3n3fhWYQGGV/rNiB3w1SB03PR3gQX9J3C 5N7TgwZFIBnJMpNgIjmYbtMuxfRLutuWOlq4+GFav1qAgAXmCPUkd1z0nRXTw8GHl24B 5UP2FGnQ4X0jFOpw2zDIOPvWMqtNor21vVnBGAjBTP26aQGKkYxoCcvvfFrS0xuV9Xqv Iwlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BeNWEAdLUwurTRAu4WEqbTLswFUOMRIguNpdcSr0Tds=; b=ckBQoienlTv4/eKbs8truEvviQ0Eyf2JL8CCke1REdWdwEosl9wd6k4gkOGfE9tA+L 5jqSARWddyeDtZVHfZNDQBVN55Ekj0TleGaCOG1njQP2sFNH+5/NKDEjunylHORW7VZr SphUlj3m4HFLYosXqurc4he9yZ13P6o/H3CsSXiC1a9vJBGCjF1o/O+5gpFDLOcCVgdT 9AbgcyXQ+XoTzbxkRHAO8KkNYHgxP5tvNjcyLWhpBuq83Kn5C3t/T8z/cet8ux/IGXwO oWNQmc6Yx4GNncMvhsOqMYynv7iD3qEWE1y7WrjJ1fu24SMYxZP/PpbjztnQOrgmkNCv gPQQ== X-Gm-Message-State: APjAAAWe6eMwK+hLSwnBmchzFx59wKagDtmzEgg8U7423cKorw/KCwQR 9DvLrbJnPX4T1funZH+/0PVYEXalvGngtCR4J/s= X-Google-Smtp-Source: APXvYqzSiNs5ZunngLzbnJNQm/953PyIVPIh6ZpAYW26lLSU4xUyryuSUjFFWvkyh4um9jwgaLrnQ2UPO/sUFkYEEOA= X-Received: by 2002:a02:b615:: with SMTP id h21mr4543900jam.109.1582727032643; Wed, 26 Feb 2020 06:23:52 -0800 (PST) MIME-Version: 1.0 References: <20200222144647.10120-1-laoar.shao@gmail.com> <20200224162516.GA1674@cmpxchg.org> In-Reply-To: <20200224162516.GA1674@cmpxchg.org> From: Yafang Shao Date: Wed, 26 Feb 2020 22:23:16 +0800 Message-ID: Subject: Re: [PATCH] psi: move PF_MEMSTALL into psi specific psi_flags To: Johannes Weiner Cc: mingo@redhat.com, Peter Zijlstra , juri.lelli@redhat.com, Vincent Guittot , dietmar.eggemann@arm.com, Steven Rostedt , Benjamin Segall , mgorman@suse.de, Andrew Morton , Linux MM , LKML Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Feb 25, 2020 at 12:25 AM Johannes Weiner wrote: > > Hello Yafang, > > On Sat, Feb 22, 2020 at 09:46:47AM -0500, Yafang Shao wrote: > > The task->flags is a 32-bits flag, in which 31 bits have already been > > consumed. So it is hardly to introduce other new per process flag. > > As there's a psi specific flag psi_flags, we'd better move the psi specific > > per process flag PF_MEMSTALL into it. > > Currently, psi_flags is used only for debugging: > > if (((task->psi_flags & set) || > (task->psi_flags & clear) != clear) && > !psi_bug) { > printk_deferred(KERN_ERR "psi: inconsistent task state! task=%d:%s cpu=%d psi_flags=%x clear=%x set=%x\n", > task->pid, task->comm, cpu, > task->psi_flags, clear, set); > psi_bug = 1; > } > > task->psi_flags &= ~clear; > task->psi_flags |= set; > > While this has caught a few bugs while the code was new, I'm planning > on moving it to a CONFIG option that is only enabled in debug builds. > Got it. Many thanks for you explanation. > If you need the room in task->flags, can you please make the memstall > state a single bit in task_struct instead? AFAICS there is still space > in this section: > > /* Force alignment to the next boundary: */ > unsigned :0; > > /* Unserialized, strictly 'current' */ > > ... > > #ifdef CONFIG_PSI > unsigned in_memstall:1; > #endif > > It would also avoid the mixed-bit masking headache: > Seems that's a better solution. I will update with it. Thanks for your suggestion. > > @@ -17,11 +17,21 @@ enum psi_task_count { > > NR_PSI_TASK_COUNTS = 3, > > }; > > > > -/* Task state bitmasks */ > > +/* > > + * Task state bitmasks: > > + * These flags are stored in the lower PSI_TSK_BITS bits of > > + * task->psi_flags, and the higher bits are set with per process flag which > > + * persists across sleeps. > > + */ > > +#define PSI_TSK_STATE_BITS 16 > > +#define PSI_TSK_STATE_MASK ((1 << PSI_TSK_STATE_BITS) - 1) > > #define TSK_IOWAIT (1 << NR_IOWAIT) > > #define TSK_MEMSTALL (1 << NR_MEMSTALL) > > #define TSK_RUNNING (1 << NR_RUNNING) > > > > +/* Stalled due to lack of memory, that's per process flag. */ > > +#define PSI_PF_MEMSTALL (1 << PSI_TSK_STATE_BITS) > > + > > /* Resources that workloads could be stalled on */ > > enum psi_res { > > PSI_IO, > > diff --git a/include/linux/sched.h b/include/linux/sched.h > > index f314790cb527..2d4c04d35d9b 100644 > > --- a/include/linux/sched.h > > +++ b/include/linux/sched.h > > @@ -1025,7 +1025,11 @@ struct task_struct { > > > > struct task_io_accounting ioac; > > #ifdef CONFIG_PSI > > - /* Pressure stall state */ > > + /* > > + * Pressure stall state: > > + * Bits 0 ~ PSI_TSK_STATE_BITS-1: PSI task states > > + * Bits PSI_TSK_STATE_BITS ~ 31: Per process flags > > + */ > > unsigned int psi_flags; > > #endif > > #ifdef CONFIG_TASK_XACCT > > Thanks -- Yafang Shao DiDi