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, 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 4F6B9C11D30 for ; Mon, 24 Feb 2020 16:25:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9796E20880 for ; Mon, 24 Feb 2020 16:25:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="1N5AkiHK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9796E20880 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 27BEE6B0005; Mon, 24 Feb 2020 11:25:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 22C106B0006; Mon, 24 Feb 2020 11:25:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 11B096B0007; Mon, 24 Feb 2020 11:25:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0154.hostedemail.com [216.40.44.154]) by kanga.kvack.org (Postfix) with ESMTP id EF2116B0005 for ; Mon, 24 Feb 2020 11:25:19 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C1834824556B for ; Mon, 24 Feb 2020 16:25:19 +0000 (UTC) X-FDA: 76525545558.07.rat92_4b859217a520e X-HE-Tag: rat92_4b859217a520e X-Filterd-Recvd-Size: 5704 Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Mon, 24 Feb 2020 16:25:18 +0000 (UTC) Received: by mail-qk1-f195.google.com with SMTP id b5so2048582qkh.8 for ; Mon, 24 Feb 2020 08:25:18 -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; bh=pUMUmLOvkv6pPNlHDF8kM42BV4WHL66yxh+KM5/nX8I=; b=1N5AkiHKfhDXsBrzKCV3BoRiUdQG0XqvYla3VfjZtARWF5rQ7Ppy1AOTWMmueU1io0 cbT3C6pXQ6ErXcSI9u7bv3tKP8Fk7N7KUbhYWYs9up2eJ7/PEY+xYU83+EjNJQLxt+Ft NgnhabZuJKO1X0jCWGuJuKKjfi7PhyrxpSjbFdvjyWNXDGuwxbCWKYHjHgKMFZMEyraO 4b15lebYS60PtKpJofVESrCGeTPGFGCiuNBHiQKqnNGp8UhRnbWspymfBmOwQaLWQ+jH clF2NukP3JGV8bkO93HLdEIZA6YKUGRXaNVy9Yte2Teor4ddInPH/kVH1RwdE7eSUfni TQDg== 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; bh=pUMUmLOvkv6pPNlHDF8kM42BV4WHL66yxh+KM5/nX8I=; b=DBDxJ944hlVsv5mq0IGCul0YMNQTTSKXLchVBKqE6iL4tO9XI9ITvp42s/Vl3piWT4 hk3ikXo0CxUfGu654cJL+E4OypcS6ZBAlOIHMJPR++4WFal2Wtxh84M0Wqr23i6lOWZQ iC+c94K0iUk9xyvapv/KZ70+Xzeo/MbyghaRj5Pzf6hGWv+zWZ4d1+6ZxRq36UU2VmRA Ss9TBNenl6vOqJPWc/ngVHqymtpVMsuezPqeoLbIGwUAonkKLa0eWsr1rVtYs4H+DO8T cdmgIrNH325+Qcl3bPt0Xf/SJhOSmTl+yxv0PylveOuHlyHMhTf/ebwUTGiuVIJe3cjP u03Q== X-Gm-Message-State: APjAAAWKmyadrDZ2PuMqpsB8y6xHpm852ZoO85oTk4/GqiqKbrayYVZZ jOTlis0+FlL8XEs9uCIVon5vOw== X-Google-Smtp-Source: APXvYqy0yCGZ2oK3HLCnMmkgHwIorn7PRWYW/CQHk0T5DcddYYXAXfBFQUJ+b4qHx25IUcIBwhArbw== X-Received: by 2002:a05:620a:1130:: with SMTP id p16mr52503069qkk.415.1582561517856; Mon, 24 Feb 2020 08:25:17 -0800 (PST) Received: from localhost ([2620:10d:c091:500::1:e64b]) by smtp.gmail.com with ESMTPSA id z13sm6257299qtu.53.2020.02.24.08.25.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2020 08:25:17 -0800 (PST) Date: Mon, 24 Feb 2020 11:25:16 -0500 From: Johannes Weiner To: Yafang Shao Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] psi: move PF_MEMSTALL into psi specific psi_flags Message-ID: <20200224162516.GA1674@cmpxchg.org> References: <20200222144647.10120-1-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200222144647.10120-1-laoar.shao@gmail.com> 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: 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. 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: > @@ -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