Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1370244ybt; Thu, 25 Jun 2020 04:34:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRadpKZ9zbKHBSL9LIC/PxuuXVLN87Rk5DGNCz3tNBIG04lZyLKNlk8vqQr8c3BAdWye1P X-Received: by 2002:aa7:d283:: with SMTP id w3mr31910061edq.262.1593084871448; Thu, 25 Jun 2020 04:34:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593084871; cv=none; d=google.com; s=arc-20160816; b=WSXdVLsyGrEaEKrzhwKrS5FNpGXMtzlFClpsxxNX2ZmcPwDJigMFdqWT1grgbKkAON dO8U/bP5lvcMXLBzzHyS8tyV1KGRfLSNmSsZ1k60GPyspXFafCoEe9l51yDOY6L9skEv mIa4hsVVzlrTh5OCMAFjkE6SV8BClPuLlIKrb0+IaDK2EeogqfJ2IRXJIySpKJV3HIWl ZfM4Ed0d4CcAIlcYpPj+feBTZWRj2lr68hNDFO7CHZfNsAhFF9ArvQy3nmkTZedIqRS6 ycS/D29Ucz5NksH4MJmIrmAJCAtkrfYZKJkAFuZkwfEDd88FqMsgDPHXvm/EehnbQMo1 soUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Crp4AhmOUV70+9ieRKgaDTzbnRsfy5cJ4K1WeF+oLJU=; b=mgoSjik3N8dJeNcBwZzbXZwy/r0ltChvvvNUEUn0KwyjMPfDluvYrVbDDC1o/yWYms x7Hjc4V/D9a5aL1pYs3Br0AQSsiYVJ2/uf+ydQhIe/U5U4QL93ojILE2UKH4m3A3etz3 bm8CY8jztSIiUuWPBXHRHFevmQZn9pUPIdRj6M7/eIfWN9YBtX1DTMlyB0XICdmpr7KN RdJuuq8TMfjJf/p6Yv73Vy0oQOa0dkxfD+ajZ8vz8NJ4lVJPoTewme0RZYcZKp24qOd2 2GtlmgxlojmvHq/AbFtAPI94AspQSBOqSg2orueV9J8oIpODejefyKRuC1/DA+x/LTc7 3SxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b="ZyI8Ej/K"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u5si15795987edq.596.2020.06.25.04.34.08; Thu, 25 Jun 2020 04:34:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b="ZyI8Ej/K"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404326AbgFYLcA (ORCPT + 99 others); Thu, 25 Jun 2020 07:32:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404267AbgFYLb6 (ORCPT ); Thu, 25 Jun 2020 07:31:58 -0400 Received: from casper.infradead.org (unknown [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFEFDC0613ED; Thu, 25 Jun 2020 04:31:57 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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