mm/memcg: avoid page count check for zone device
Subsystems (2)
PATCH 1/1 mm/memcg: avoid page count check for zone device
From: Jérôme Glisse <[email protected]>
Fix for 4.14, zone device page always have an elevated refcount of one and thus page count sanity check in uncharge_page() is inappropriate for them.
--- mm/memcontrol.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm/memcontrol.c +2 -1
@@ -5648,7 +5648,8 @@ static void uncharge_batch(const struct uncharge_gather *ug)static void uncharge_page (struct page *page,struct uncharge_gather *ug) {VM_BUG_ON_PAGE (PageLRU (page), page); -VM_BUG_ON_PAGE (!PageHWPoison (page) &&page_count (page), page); +VM_BUG_ON_PAGE (!PageHWPoison (page) && !is_zone_device_page (page) && +page_count (page), page);if (!page->mem_cgroup)return ;
Signature · 1 line
2.13.5
Quoted 6 lines · On Thu 14-09-17 15:00:11, [email protected] wrote:
From: Jérôme Glisse <[email protected]>
Fix for 4.14, zone device page always have an elevated refcount of one and thus page count sanity check in
uncharge_page()is inappropriate for them.
Quoted 6 lines
Signed-off-by Jérôme Glisse <[email protected]>Reported-by Evgeny Baskakov <[email protected]>Cc Andrew Morton <[email protected]>Cc Johannes Weiner <[email protected]>Cc Michal Hocko <[email protected]>Cc Vladimir Davydov <[email protected]>
Side note. Wouldn't it be better to re-organize the check a bit? It is true that this is VM_BUG so it is not usually compiled in but when it preferably checks for unlikely cases first while the ref count will be 0 in the prevailing cases. So can we have
VM_BUG_ON_PAGE(page_count(page) && !is_zone_device_page(page) && !PageHWPoison(page), page);
I would simply fold this nano optimization into the patch as you are touching it already. Not sure it is worth a separate commit.
Quoted 20 lines
--- mm/memcontrol.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)mm/memcontrol.c +2
-1@@ -5648,7 +5648,8 @@ static void uncharge_batch(const struct uncharge_gather *ug)static void uncharge_page (struct page *page,struct uncharge_gather *ug) {VM_BUG_ON_PAGE (PageLRU (page), page); -VM_BUG_ON_PAGE (!PageHWPoison (page) &&page_count (page), page); +VM_BUG_ON_PAGE (!PageHWPoison (page) && !is_zone_device_page (page) && +page_count (page), page);if (!page->mem_cgroup)return ;Signature · 1 line
2.13.5
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 20 lines · Michal Hocko
Quoted 6 lines · On Thu 14-09-17 15:00:11, [email protected] wrote:
From: Jerome Glisse <[email protected]>
Fix for 4.14, zone device page always have an elevated refcount of one and thus page count sanity check in
uncharge_page()is inappropriate for them.Quoted 6 lines
Signed-off-by Jerome Glisse <[email protected]>Reported-by Evgeny Baskakov <[email protected]>Cc Andrew Morton <[email protected]>Cc Johannes Weiner <[email protected]>Cc Michal Hocko <[email protected]>Cc Vladimir Davydov <[email protected]>Acked-by Michal Hocko <[email protected]>Side note. Wouldn't it be better to re-organize the check a bit? It is true that this is
VM_BUGso it is not usually compiled in but when it preferably checks for unlikely cases first while the ref count will be 0 in the prevailing cases. So can we have
Quoted 5 lines
VM_BUG_ON_PAGE(page_count(page) && !is_zone_device_page(page) && !PageHWPoison(page), page);I would simply fold this nano optimization into the patch as you are touching it already. Not sure it is worth a separate commit.
I am traveling sorry for late answer. This nano optimization make sense Andrew do you want me to respin or should we leave it be ? I don't mind either way.
Cheers,
Jerome
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Michal Hocko
maintainerQuoted 24 lines · Jerome Glisse
Quoted 23 lines · Michal Hocko
Quoted 6 lines · On Thu 14-09-17 15:00:11, [email protected] wrote:
From: Jérôme Glisse <[email protected]>
Fix for 4.14, zone device page always have an elevated refcount of one and thus page count sanity check in
uncharge_page()is inappropriate for them.Quoted 6 lines
Signed-off-by Jérôme Glisse <[email protected]>Reported-by Evgeny Baskakov <[email protected]>Cc Andrew Morton <[email protected]>Cc Johannes Weiner <[email protected]>Cc Michal Hocko <[email protected]>Cc Vladimir Davydov <[email protected]>Acked-by Michal Hocko <[email protected]>Side note. Wouldn't it be better to re-organize the check a bit? It is true that this is
VM_BUGso it is not usually compiled in but when it preferably checks for unlikely cases first while the ref count will be 0 in the prevailing cases. So can we haveVM_BUG_ON_PAGE(page_count(page) && !is_zone_device_page(page) && !PageHWPoison(page), page);
Quoted 6 lines
Quoted 2 lines
I would simply fold this nano optimization into the patch as you are touching it already. Not sure it is worth a separate commit.
I am traveling sorry for late answer. This nano optimization make sense Andrew do you want me to respin or should we leave it be ? I don't mind either way.
Andrew, could you fold this into the patch then?
---
Quoted 1 line
From
73b5c07aed76aa68b413e708852da63ed9eb965cMon Sep 17 00:00:00 2001
From: Michal Hocko <[email protected]>
Date: Mon, 18 Sep 2017 08:27:43 +0200
Subject: [PATCH] memcg: nano-optimize VM_BUG_ON in uncharge_page
Even though VM_BUG* is usually not compiled in there are systems which enable CONFIG_DEBUG_VM by default. VM_BUG_ON_PAGE in uncharge_page is not very optimal for the normal case. All pages should have counter==0 so that is the first thing to check. is_zone_device_page is nicely noop if ZONE_DEVICE is not compiled in and finally HW poison pages should be least probable. So reorder the check to bail out as early as possible on normal case.
--- mm/memcontrol.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memcontrol.c +2 -2
@@ -5658,8 +5658,8 @@ static void uncharge_batch(const struct uncharge_gather *ug)static void uncharge_page (struct page *page,struct uncharge_gather *ug) {VM_BUG_ON_PAGE (PageLRU (page), page); -VM_BUG_ON_PAGE (!PageHWPoison (page) && !is_zone_device_page (page) && -page_count (page), page); +VM_BUG_ON_PAGE (page_count (page) && !is_zone_device_page (page) && + !PageHWPoison (page) , page);if (!page->mem_cgroup)return ;
Signature · 5 lines
2.14.1 -- Michal Hocko SUSE Labs