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=-7.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 2A4D1C433DF for ; Thu, 25 Jun 2020 13:35:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E948820781 for ; Thu, 25 Jun 2020 13:35:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E948820781 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 8701F8D0005; Thu, 25 Jun 2020 09:35:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 81F758D0002; Thu, 25 Jun 2020 09:35:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E8568D0005; Thu, 25 Jun 2020 09:35:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0174.hostedemail.com [216.40.44.174]) by kanga.kvack.org (Postfix) with ESMTP id 53CEC8D0002 for ; Thu, 25 Jun 2020 09:35:13 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 07188181AC9B6 for ; Thu, 25 Jun 2020 13:35:13 +0000 (UTC) X-FDA: 76967830506.13.steam16_32142e326e4d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id A3E5318140B82 for ; Thu, 25 Jun 2020 13:35:06 +0000 (UTC) X-HE-Tag: steam16_32142e326e4d X-Filterd-Recvd-Size: 6282 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Thu, 25 Jun 2020 13:35:06 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id z13so5872411wrw.5 for ; Thu, 25 Jun 2020 06:35:06 -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=IgYZrPxHW1Yk3TwSNNUUSYdD36C5CbbVMe0vITplDXw=; b=fLij1Z8VRbw4yk3SYeB7o/RKw4fXOLpxT9t6LJ6qKIPoeB+ZKFakcd88PLWfpBIyw3 TGmRx5pab5ikgh0aHOzGJCDL0JRhmOlVpvAckLXxBG/fOkZ0VS7FqjG/wFm7zYoyrWq4 Q2JtUA9boKfEUYwyujXL4K1ciwc+EaFucftv9mklWvYCQfCYar1rA+2JV8IET8b1WYFn VyQoo2X/6q/8XA8HAokL5t7MBocz5FyeKBMK35PgcTl1HqerqnkeIJiNtUI1kdaT9eWZ uQUUlG0mxXZ61aVJYOF+w2AMs2CR8C2WXvBE9lnbFz4TdlgcewZi4ewRC962E9rWi9wM 6qPg== X-Gm-Message-State: AOAM533GQpbsAFiWPL14RfuZr3dAGLAirhu8mMKrmc+9MvX4og9lJLuq O+v8moxOJ4Lb5akz4p/5wew= X-Google-Smtp-Source: ABdhPJwaddI6ttW180z9XolsU5F/8EUo6u4oLwe5Z7g00mWKYqqFcDJ9Z0yPcz+5CvQGbwEE1bpQkg== X-Received: by 2002:a05:6000:18c:: with SMTP id p12mr39132209wrx.66.1593092105200; Thu, 25 Jun 2020 06:35:05 -0700 (PDT) Received: from localhost (ip-37-188-168-3.eurotel.cz. [37.188.168.3]) by smtp.gmail.com with ESMTPSA id c143sm14010709wmd.1.2020.06.25.06.35.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 06:35:04 -0700 (PDT) Date: Thu, 25 Jun 2020 15:35:03 +0200 From: Michal Hocko To: "Matthew Wilcox (Oracle)" 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 4/6] mm: Replace PF_MEMALLOC_NOFS with memalloc_nofs Message-ID: <20200625133503.GO1320@dhcp22.suse.cz> References: <20200625113122.7540-1-willy@infradead.org> <20200625113122.7540-5-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200625113122.7540-5-willy@infradead.org> X-Rspamd-Queue-Id: A3E5318140B82 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 12:31:20, Matthew Wilcox wrote: > We're short on PF_* flags, so make memalloc_nofs its own bit where we > have plenty of space. > > Signed-off-by: Matthew Wilcox (Oracle) forgot to add Acked-by: Michal Hocko > --- > fs/iomap/buffered-io.c | 2 +- > include/linux/sched.h | 2 +- > include/linux/sched/mm.h | 13 ++++++------- > 3 files changed, 8 insertions(+), 9 deletions(-) > > diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c > index bcfc288dba3f..87d66c13bf5c 100644 > --- a/fs/iomap/buffered-io.c > +++ b/fs/iomap/buffered-io.c > @@ -1502,7 +1502,7 @@ iomap_do_writepage(struct page *page, struct writeback_control *wbc, void *data) > * Given that we do not allow direct reclaim to call us, we should > * never be called in a recursive filesystem reclaim context. > */ > - if (WARN_ON_ONCE(current->flags & PF_MEMALLOC_NOFS)) > + if (WARN_ON_ONCE(current->memalloc_nofs)) > goto redirty; > > /* > diff --git a/include/linux/sched.h b/include/linux/sched.h > index cf18a3d2bc4c..eaf36ae1fde2 100644 > --- a/include/linux/sched.h > +++ b/include/linux/sched.h > @@ -802,6 +802,7 @@ struct task_struct { > unsigned in_memstall:1; > #endif > unsigned memalloc_noio:1; > + unsigned memalloc_nofs:1; > > unsigned long atomic_flags; /* Flags requiring atomic access. */ > > @@ -1505,7 +1506,6 @@ extern struct pid *cad_pid; > #define PF_NOFREEZE 0x00008000 /* This thread should not be frozen */ > #define PF_FROZEN 0x00010000 /* Frozen for system suspend */ > #define PF_KSWAPD 0x00020000 /* I am kswapd */ > -#define PF_MEMALLOC_NOFS 0x00040000 /* All allocation requests will inherit GFP_NOFS */ > #define PF_LOCAL_THROTTLE 0x00100000 /* Throttle writes only against the bdi I write to, > * I am cleaning dirty pages from some other bdi. */ > #define PF_KTHREAD 0x00200000 /* I am a kernel thread */ > diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h > index b0089eadc367..08bc9d0606a8 100644 > --- a/include/linux/sched/mm.h > +++ b/include/linux/sched/mm.h > @@ -175,20 +175,19 @@ static inline bool in_vfork(struct task_struct *tsk) > > /* > * Applies per-task gfp context to the given allocation flags. > - * PF_MEMALLOC_NOFS implies GFP_NOFS > * PF_MEMALLOC_NOCMA implies no allocation from CMA region. > */ > static inline gfp_t current_gfp_context(gfp_t flags) > { > - if (unlikely(current->flags & (PF_MEMALLOC_NOFS | PF_MEMALLOC_NOCMA) || > - current->memalloc_noio)) { > + if (unlikely((current->flags & PF_MEMALLOC_NOCMA) || > + current->memalloc_noio || current->memalloc_nofs)) { > /* > * NOIO implies both NOIO and NOFS and it is a weaker context > * so always make sure it makes precedence > */ > if (current->memalloc_noio) > flags &= ~(__GFP_IO | __GFP_FS); > - else if (current->flags & PF_MEMALLOC_NOFS) > + else if (current->memalloc_nofs) > flags &= ~__GFP_FS; > #ifdef CONFIG_CMA > if (current->flags & PF_MEMALLOC_NOCMA) > @@ -254,8 +253,8 @@ static inline void memalloc_noio_restore(unsigned int flags) > */ > static inline unsigned int memalloc_nofs_save(void) > { > - unsigned int flags = current->flags & PF_MEMALLOC_NOFS; > - current->flags |= PF_MEMALLOC_NOFS; > + unsigned int flags = current->memalloc_nofs; > + current->memalloc_nofs = 1; > return flags; > } > > @@ -269,7 +268,7 @@ static inline unsigned int memalloc_nofs_save(void) > */ > static inline void memalloc_nofs_restore(unsigned int flags) > { > - current->flags = (current->flags & ~PF_MEMALLOC_NOFS) | flags; > + current->memalloc_nofs = flags ? 1 : 0; > } > > static inline unsigned int memalloc_noreclaim_save(void) > -- > 2.27.0 -- Michal Hocko SUSE Labs