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=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 8C523C433DF for ; Thu, 25 Jun 2020 11:31:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 459BD20781 for ; Thu, 25 Jun 2020 11:31:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="ZyI8Ej/K" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 459BD20781 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B85C96B000C; Thu, 25 Jun 2020 07:31:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B35CD6B000D; Thu, 25 Jun 2020 07:31:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A4BA66B000E; Thu, 25 Jun 2020 07:31:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0151.hostedemail.com [216.40.44.151]) by kanga.kvack.org (Postfix) with ESMTP id 8DF276B000C for ; Thu, 25 Jun 2020 07:31:45 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 3BD60180AD817 for ; Thu, 25 Jun 2020 11:31:45 +0000 (UTC) X-FDA: 76967519370.10.bike26_1b0bb1726e4c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id 0674916A0DD for ; Thu, 25 Jun 2020 11:31:44 +0000 (UTC) X-HE-Tag: bike26_1b0bb1726e4c X-Filterd-Recvd-Size: 5260 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Thu, 25 Jun 2020 11:31:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=Crp4AhmOUV70+9ieRKgaDTzbnRsfy5cJ4K1WeF+oLJU=; b=ZyI8Ej/KG39B3+hOJXl5accoDV ZwIM8vPmUud8fp963KDNrm5eXW6e1KHx8c2Va/h16g6bjDJtLD12Qe1uh0P/oicdhmwRCHppYRBn6 nvvgIptt7YosCjpWoXpLLZq0Da17Zh4+PigsQDMhDAsc+uIAwq4qB1RTrGvNqVN1gruKDDHNPNQRs jZDziVcrAEx8r7CMsH2j5rkZh3auVhtCWKDNB3clJQD2tVb1tSiT3HTck2SfHMVA9fjg7JEchBB+j IvZs9j4HumOJu63Khhk9EsWu4iucMoT4wHPlgW2f1mLaIvAy9nlWK6765AApD3g0TrdPmxvmUdgvl y9oMaM0w==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1joQ6X-0001za-5V; Thu, 25 Jun 2020 11:31:41 +0000 From: "Matthew Wilcox (Oracle)" To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-xfs@vger.kernel.org, dm-devel@redhat.com, Mikulas Patocka , Jens Axboe , NeilBrown Subject: [PATCH 4/6] mm: Replace PF_MEMALLOC_NOFS with memalloc_nofs Date: Thu, 25 Jun 2020 12:31:20 +0100 Message-Id: <20200625113122.7540-5-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200625113122.7540-1-willy@infradead.org> References: <20200625113122.7540-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 0674916A0DD X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 Content-Transfer-Encoding: quoted-printable 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: 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) --- 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 writeb= ack_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; =20 /* 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; =20 unsigned long atomic_flags; /* Flags requiring atomic access. */ =20 @@ -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 inhe= rit 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= ) =20 /* * 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 &=3D ~(__GFP_IO | __GFP_FS); - else if (current->flags & PF_MEMALLOC_NOFS) + else if (current->memalloc_nofs) flags &=3D ~__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 =3D current->flags & PF_MEMALLOC_NOFS; - current->flags |=3D PF_MEMALLOC_NOFS; + unsigned int flags =3D current->memalloc_nofs; + current->memalloc_nofs =3D 1; return flags; } =20 @@ -269,7 +268,7 @@ static inline unsigned int memalloc_nofs_save(void) */ static inline void memalloc_nofs_restore(unsigned int flags) { - current->flags =3D (current->flags & ~PF_MEMALLOC_NOFS) | flags; + current->memalloc_nofs =3D flags ? 1 : 0; } =20 static inline unsigned int memalloc_noreclaim_save(void) --=20 2.27.0