Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1318378
| From | Johannes Weiner <hannes@cmpxchg.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 3/5] mm: workingset: separate shadow unpacking and refault calculation |
| Date | 2016-01-26 22:10 +0100 |
| Message-ID | <qVj2a-1Dd-27@gated-at.bofh.it> (permalink) |
| References | <qVj2a-1Dd-17@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Per-cgroup thrash detection will need to derive a live memcg from the
eviction cookie, and doing that inside unpack_shadow() will get nasty
with the reference handling spread over two functions.
In preparation, make unpack_shadow() clearly about extracting static
data, and let workingset_refault() do all the higher-level handling.
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
mm/workingset.c | 56 ++++++++++++++++++++++++++++----------------------------
1 file changed, 28 insertions(+), 28 deletions(-)
diff --git a/mm/workingset.c b/mm/workingset.c
index 3ef92f6e41fe..f874b2c663e3 100644
--- a/mm/workingset.c
+++ b/mm/workingset.c
@@ -165,13 +165,10 @@ static void *pack_shadow(unsigned long eviction, struct zone *zone)
return (void *)(eviction | RADIX_TREE_EXCEPTIONAL_ENTRY);
}
-static void unpack_shadow(void *shadow,
- struct zone **zone,
- unsigned long *distance)
+static void unpack_shadow(void *shadow, struct zone **zonep,
+ unsigned long *evictionp)
{
unsigned long entry = (unsigned long)shadow;
- unsigned long eviction;
- unsigned long refault;
int zid, nid;
entry >>= RADIX_TREE_EXCEPTIONAL_SHIFT;
@@ -179,29 +176,9 @@ static void unpack_shadow(void *shadow,
entry >>= ZONES_SHIFT;
nid = entry & ((1UL << NODES_SHIFT) - 1);
entry >>= NODES_SHIFT;
- eviction = entry;
-
- *zone = NODE_DATA(nid)->node_zones + zid;
- refault = atomic_long_read(&(*zone)->inactive_age);
-
- /*
- * The unsigned subtraction here gives an accurate distance
- * across inactive_age overflows in most cases.
- *
- * There is a special case: usually, shadow entries have a
- * short lifetime and are either refaulted or reclaimed along
- * with the inode before they get too old. But it is not
- * impossible for the inactive_age to lap a shadow entry in
- * the field, which can then can result in a false small
- * refault distance, leading to a false activation should this
- * old entry actually refault again. However, earlier kernels
- * used to deactivate unconditionally with *every* reclaim
- * invocation for the longest time, so the occasional
- * inappropriate activation leading to pressure on the active
- * list is not a problem.
- */
- *distance = (refault - eviction) & EVICTION_MASK;
+ *zonep = NODE_DATA(nid)->node_zones + zid;
+ *evictionp = entry;
}
/**
@@ -233,9 +210,32 @@ void *workingset_eviction(struct address_space *mapping, struct page *page)
bool workingset_refault(void *shadow)
{
unsigned long refault_distance;
+ unsigned long eviction;
+ unsigned long refault;
struct zone *zone;
- unpack_shadow(shadow, &zone, &refault_distance);
+ unpack_shadow(shadow, &zone, &eviction);
+
+ refault = atomic_long_read(&zone->inactive_age);
+
+ /*
+ * The unsigned subtraction here gives an accurate distance
+ * across inactive_age overflows in most cases.
+ *
+ * There is a special case: usually, shadow entries have a
+ * short lifetime and are either refaulted or reclaimed along
+ * with the inode before they get too old. But it is not
+ * impossible for the inactive_age to lap a shadow entry in
+ * the field, which can then can result in a false small
+ * refault distance, leading to a false activation should this
+ * old entry actually refault again. However, earlier kernels
+ * used to deactivate unconditionally with *every* reclaim
+ * invocation for the longest time, so the occasional
+ * inappropriate activation leading to pressure on the active
+ * list is not a problem.
+ */
+ refault_distance = (refault - eviction) & EVICTION_MASK;
+
inc_zone_state(zone, WORKINGSET_REFAULT);
if (refault_distance <= zone_page_state(zone, NR_ACTIVE_FILE)) {
--
2.7.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/5] mm: workingset: per-cgroup thrash detection Johannes Weiner <hannes@cmpxchg.org> - 2016-01-26 22:10 +0100
[PATCH 2/5] mm: workingset: #define radix entry eviction mask Johannes Weiner <hannes@cmpxchg.org> - 2016-01-26 22:10 +0100
Re: [PATCH 2/5] mm: workingset: #define radix entry eviction mask Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-01-27 15:40 +0100
[PATCH 3/5] mm: workingset: separate shadow unpacking and refault calculation Johannes Weiner <hannes@cmpxchg.org> - 2016-01-26 22:10 +0100
Re: [PATCH 3/5] mm: workingset: separate shadow unpacking and refault calculation Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-01-27 15:40 +0100
[PATCH 4/5] mm: workingset: eviction buckets for bigmem/lowbit machines Johannes Weiner <hannes@cmpxchg.org> - 2016-01-26 22:10 +0100
Re: [PATCH 4/5] mm: workingset: eviction buckets for bigmem/lowbit machines Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-01-27 15:50 +0100
[PATCH 1/5] mm: memcontrol: generalize locking for the page->mem_cgroup binding Johannes Weiner <hannes@cmpxchg.org> - 2016-01-26 22:10 +0100
Re: [PATCH 1/5] mm: memcontrol: generalize locking for the page->mem_cgroup binding Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-01-27 15:40 +0100
[PATCH 5/5] mm: workingset: per-cgroup cache thrash detection Johannes Weiner <hannes@cmpxchg.org> - 2016-01-26 22:10 +0100
Re: [PATCH 5/5] mm: workingset: per-cgroup cache thrash detection Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-01-27 16:00 +0100
csiph-web