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=-1.0 required=3.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 3978AC433DF for ; Thu, 25 Jun 2020 12:42:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F3830206BE for ; Thu, 25 Jun 2020 12:42:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F3830206BE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 96F7F6B007E; Thu, 25 Jun 2020 08:42:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8F7DD6B0080; Thu, 25 Jun 2020 08:42:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7BF136B0081; Thu, 25 Jun 2020 08:42:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0054.hostedemail.com [216.40.44.54]) by kanga.kvack.org (Postfix) with ESMTP id 5FC5C6B007E for ; Thu, 25 Jun 2020 08:42:38 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 0DC98180AD81D for ; Thu, 25 Jun 2020 12:42:38 +0000 (UTC) X-FDA: 76967697996.13.train12_0f12cda26e4c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id DD57318140B60 for ; Thu, 25 Jun 2020 12:42:37 +0000 (UTC) X-HE-Tag: train12_0f12cda26e4c X-Filterd-Recvd-Size: 5313 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Thu, 25 Jun 2020 12:42:37 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id o8so5406917wmh.4 for ; Thu, 25 Jun 2020 05:42:37 -0700 (PDT) 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=zqYYU+XzLTo4RZ3+vh2KfRtchjL+OjYySOUllgC9oo8=; b=CxzIgv8NlquPdLP8hMqa/G2DX44KhyoSJDX2ZfYrgpi+zkP6Lz1T/3PVF0q0Rh/Uti Gz5h8tmTNImc6uLY85A29rpS4E7Hs6FkbV9DIRaMQcZsOvHvJB/y/En8jTRpd94PVYXz XrNv0hmRco8NSnNfbqqFv7vLcpDUYLtPkdcpTyVoMfrUy9w9358KIJLDEVTKprIBFu27 y75hRo/tF/CSBnHCHRdv27FxH2PiRWqruvzZbNchI9o8ohQdsxK2NZU4aWqgEA84A9YN A8F9Q9LGI2CJ97yb2IuXbsN272gQ+AoKou8GB7XgDzv/AWilWjG57GeByMpdkPLZNgEj uzdQ== X-Gm-Message-State: AOAM530Uc/QfZ62e/Wdwrhe2Ya4MWHkhKBwMyzabmNNymF6vmdUK6gKT YSS/ivu0AEMzXIDFaSTxIK4= X-Google-Smtp-Source: ABdhPJwrxoXQ+HCO1VVYYUvEmwFEOPYklBv2D67vfvs9fNB1wlADT0sE5tlgxNrUNZ128ZofveX60g== X-Received: by 2002:a1c:80c8:: with SMTP id b191mr3021699wmd.37.1593088956395; Thu, 25 Jun 2020 05:42:36 -0700 (PDT) Received: from localhost (ip-37-188-168-3.eurotel.cz. [37.188.168.3]) by smtp.gmail.com with ESMTPSA id t5sm11739610wmj.37.2020.06.25.05.42.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 05:42:35 -0700 (PDT) Date: Thu, 25 Jun 2020 14:42:34 +0200 From: Michal Hocko To: Matthew Wilcox Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, dm-devel@redhat.com, Mikulas Patocka , Jens Axboe , NeilBrown Subject: Re: [PATCH 1/6] mm: Replace PF_MEMALLOC_NOIO with memalloc_noio Message-ID: <20200625124234.GM1320@dhcp22.suse.cz> References: <20200625113122.7540-1-willy@infradead.org> <20200625113122.7540-2-willy@infradead.org> <20200625122239.GJ1320@dhcp22.suse.cz> <20200625123418.GB7703@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200625123418.GB7703@casper.infradead.org> X-Rspamd-Queue-Id: DD57318140B60 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 Thu 25-06-20 13:34:18, Matthew Wilcox wrote: > On Thu, Jun 25, 2020 at 02:22:39PM +0200, Michal Hocko wrote: > > On Thu 25-06-20 12:31:17, Matthew Wilcox wrote: > > > We're short on PF_* flags, so make memalloc_noio its own bit where we > > > have plenty of space. > > > > I do not mind moving that outside of the PF_* space. Unless I > > misremember all flags in this space were intented to be set only on the > > current which rules out any RMW races and therefore they can be > > lockless. I am not sure this holds for the bitfield you are adding this > > to. At least in_memstall seem to be set on external task as well. But > > this would require double checking. Maybe that is not really intended or > > just a bug. > > I was going from the comment: > > /* Unserialized, strictly 'current' */ > (which you can't see from the context of the diff, but is above the block) > > The situation with ->flags is a little more ambiguous: > > /* > * Only the _current_ task can read/write to tsk->flags, but other > * tasks can access tsk->flags in readonly mode for example > * with tsk_used_math (like during threaded core dumping). > * There is however an exception to this rule during ptrace > * or during fork: the ptracer task is allowed to write to the > * child->flags of its traced child (same goes for fork, the parent > * can write to the child->flags), because we're guaranteed the > * child is not running and in turn not changing child->flags > * at the same time the parent does it. > */ OK, I have obviously missed that. > but it wasn't unsafe to use the PF_ flags in the way that you were. > It's just crowded. > > If in_memstall is set on other tasks, then it should be moved to the > PFA flags, which there are plenty of. > > But a quick grep shows it only being read on other tasks and always > set on current: > > kernel/sched/psi.c: *flags = current->in_memstall; > kernel/sched/psi.c: * in_memstall setting & accounting needs to be atomic wrt > kernel/sched/psi.c: current->in_memstall = 1; > kernel/sched/psi.c: * in_memstall clearing & accounting needs to be atomic wrt > kernel/sched/psi.c: current->in_memstall = 0; > kernel/sched/psi.c: if (task->in_memstall) Have a look at cgroup_move_task. So I believe this is something to be fixed but independent on your change. Feel free to add Acked-by: Michal Hocko > kernel/sched/stats.h: if (p->in_memstall) > kernel/sched/stats.h: if (p->in_memstall) > kernel/sched/stats.h: if (unlikely(p->in_iowait || p->in_memstall)) { > kernel/sched/stats.h: if (p->in_memstall) > kernel/sched/stats.h: if (unlikely(rq->curr->in_memstall)) > > so I think everything is fine. -- Michal Hocko SUSE Labs