All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] mm: split gfp_mask and mapping flags into separate fields
Date: Mon, 12 Sep 2016 13:48:57 +0200	[thread overview]
Message-ID: <20160912114852.GI14524@dhcp22.suse.cz> (raw)
In-Reply-To: <20160912111608.2588-3-mhocko@kernel.org>

Errr, the gfp_mask move behind private_lock didn't make it into the
commit. Here is the updated patch. Btw. with this patch we can drop
mm-check-that-we-havent-used-more-than-32-bits-in-address_spaceflags.patch
---
>From a8200e0de375886bbb41bbae4df7fa65ec619d05 Mon Sep 17 00:00:00 2001
From: Michal Hocko <mhocko@suse.com>
Date: Mon, 12 Sep 2016 12:50:09 +0200
Subject: [PATCH] mm: split gfp_mask and mapping flags into separate fields

mapping->flags currently encodes two different things into a single
flag. It contains sticky gfp_mask for page cache allocations and AS_
codes used to report errors/enospace and other states which are mapping
specific. Condensing the two semantically unrelated things saves few
bytes but it also complicates other things. For one thing the gfp flags
space is reduced and in fact we are already running out of available
bits. It can be assumed that more gfp flags will be necessary later on.

To not introduce the address_space grow (at least on x86_64) we can
stick it right after private_lock because we have a hole there.

struct address_space {
        struct inode *             host;                 /*     0     8 */
        struct radix_tree_root     page_tree;            /*     8    16 */
        spinlock_t                 tree_lock;            /*    24     4 */
        atomic_t                   i_mmap_writable;      /*    28     4 */
        struct rb_root             i_mmap;               /*    32     8 */
        struct rw_semaphore        i_mmap_rwsem;         /*    40    40 */
        /* --- cacheline 1 boundary (64 bytes) was 16 bytes ago --- */
        long unsigned int          nrpages;              /*    80     8 */
        long unsigned int          nrexceptional;        /*    88     8 */
        long unsigned int          writeback_index;      /*    96     8 */
        const struct address_space_operations  * a_ops;  /*   104     8 */
        long unsigned int          flags;                /*   112     8 */
        spinlock_t                 private_lock;         /*   120     4 */

        /* XXX 4 bytes hole, try to pack */

        /* --- cacheline 2 boundary (128 bytes) --- */
        struct list_head           private_list;         /*   128    16 */
        void *                     private_data;         /*   144     8 */

        /* size: 152, cachelines: 3, members: 14 */
        /* sum members: 148, holes: 1, sum holes: 4 */
        /* last cacheline: 24 bytes */
};

Signed-off-by: Michal Hocko <mhocko@suse.com>
---
 include/linux/fs.h      |  3 ++-
 include/linux/pagemap.h | 20 +++++++++-----------
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index cd8a5e1d5580..34b9d88cb788 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -443,8 +443,9 @@ struct address_space {
 	unsigned long		nrexceptional;
 	pgoff_t			writeback_index;/* writeback starts here */
 	const struct address_space_operations *a_ops;	/* methods */
-	unsigned long		flags;		/* error bits/gfp mask */
+	unsigned long		flags;		/* error bits */
 	spinlock_t		private_lock;	/* for use by the address_space */
+	gfp_t			gfp_mask;	/* implicit gfp mask for allocations */
 	struct list_head	private_list;	/* ditto */
 	void			*private_data;	/* ditto */
 } __attribute__((aligned(sizeof(long))));
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 76f151ab4f62..0385a954465c 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -16,17 +16,16 @@
 #include <linux/hugetlb_inline.h>
 
 /*
- * Bits in mapping->flags.  The lower __GFP_BITS_SHIFT bits are the page
- * allocation mode flags.
+ * Bits in mapping->flags.
  */
 enum mapping_flags {
-	AS_EIO		= __GFP_BITS_SHIFT + 0,	/* IO error on async write */
-	AS_ENOSPC	= __GFP_BITS_SHIFT + 1,	/* ENOSPC on async write */
-	AS_MM_ALL_LOCKS	= __GFP_BITS_SHIFT + 2,	/* under mm_take_all_locks() */
-	AS_UNEVICTABLE	= __GFP_BITS_SHIFT + 3,	/* e.g., ramdisk, SHM_LOCK */
-	AS_EXITING	= __GFP_BITS_SHIFT + 4, /* final truncate in progress */
+	AS_EIO		= 0,	/* IO error on async write */
+	AS_ENOSPC	= 1,	/* ENOSPC on async write */
+	AS_MM_ALL_LOCKS	= 2,	/* under mm_take_all_locks() */
+	AS_UNEVICTABLE	= 3,	/* e.g., ramdisk, SHM_LOCK */
+	AS_EXITING	= 4, 	/* final truncate in progress */
 	/* writeback related tags are not used */
-	AS_NO_WRITEBACK_TAGS = __GFP_BITS_SHIFT + 5,
+	AS_NO_WRITEBACK_TAGS = 5,
 
 	AS_LAST_FLAG,
 };
@@ -80,7 +79,7 @@ static inline int mapping_use_writeback_tags(struct address_space *mapping)
 
 static inline gfp_t mapping_gfp_mask(struct address_space * mapping)
 {
-	return (__force gfp_t)mapping->flags & __GFP_BITS_MASK;
+	return mapping->gfp_mask;
 }
 
 /* Restricts the given gfp_mask to what the mapping allows. */
@@ -96,8 +95,7 @@ static inline gfp_t mapping_gfp_constraint(struct address_space *mapping,
  */
 static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask)
 {
-	m->flags = (m->flags & ~(__force unsigned long)__GFP_BITS_MASK) |
-				(__force unsigned long)mask;
+	m->gfp_mask = mask;
 }
 
 void release_pages(struct page **pages, int nr, bool cold);
-- 
2.9.3

-- 
Michal Hocko
SUSE Labs

WARNING: multiple messages have this Message-ID
From: Michal Hocko <mhocko@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] mm: split gfp_mask and mapping flags into separate fields
Date: Mon, 12 Sep 2016 13:48:57 +0200	[thread overview]
Message-ID: <20160912114852.GI14524@dhcp22.suse.cz> (raw)
In-Reply-To: <20160912111608.2588-3-mhocko@kernel.org>

Errr, the gfp_mask move behind private_lock didn't make it into the
commit. Here is the updated patch. Btw. with this patch we can drop
mm-check-that-we-havent-used-more-than-32-bits-in-address_spaceflags.patch
---

  reply	other threads:[~2016-09-12 11:49 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-30 17:28 [PATCH -v2] mm: Don't use radix tree writeback tags for pages in swap cache Huang, Ying
2016-08-30 17:28 ` Huang, Ying
2016-08-30 18:29 ` Rik van Riel
2016-08-31  9:14 ` Mel Gorman
2016-08-31  9:14   ` Mel Gorman
2016-08-31 15:17   ` Huang, Ying
2016-08-31 15:17     ` Huang, Ying
2016-08-31 15:39     ` Mel Gorman
2016-08-31 15:39       ` Mel Gorman
2016-08-31 15:44       ` Huang, Ying
2016-08-31 15:44         ` Huang, Ying
2016-08-31 21:35       ` Andi Kleen
2016-08-31 21:35         ` Andi Kleen
2016-08-31 21:30   ` Andrew Morton
2016-08-31 21:30     ` Andrew Morton
2016-09-01  8:51     ` Mel Gorman
2016-09-01  8:51       ` Mel Gorman
2016-09-01  9:13     ` Michal Hocko
2016-09-01  9:13       ` Michal Hocko
2016-09-12 11:16       ` [PATCH 0/2] do not squash mapping flags and gfp_mask together (was: Re: [PATCH -v2] mm: Don't use radix tree writeback tags for pages in) Michal Hocko
2016-09-12 11:16         ` Michal Hocko
2016-09-12 11:16         ` [PATCH 1/2] fs: use mapping_set_error instead of opencoded set_bit Michal Hocko
2016-09-12 11:16           ` Michal Hocko
2016-09-12 22:11           ` Andrew Morton
2016-09-12 22:11             ` Andrew Morton
2016-09-12 22:18             ` Andrew Morton
2016-09-12 22:18               ` Andrew Morton
2016-09-13  6:53               ` Michal Hocko
2016-09-13  6:53                 ` Michal Hocko
2016-09-13 21:29                 ` Andrew Morton
2016-09-13 21:29                   ` Andrew Morton
2016-09-12 11:16         ` [PATCH 2/2] mm: split gfp_mask and mapping flags into separate fields Michal Hocko
2016-09-12 11:16           ` Michal Hocko
2016-09-12 11:48           ` Michal Hocko [this message]
2016-09-12 11:48             ` Michal Hocko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160912114852.GI14524@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --subject='Re: [PATCH 2/2] mm: split gfp_mask and mapping flags into separate fields' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.