e code. Thanks Mike and Oscar.
- Remap the tail vmemmap page with PAGE_KERNEL_RO instead of PAGE_KERNEL.
Thanks Matthew.
- Add some overhead analysis in the cover letter.
- Use vmemap pmd table lock instead of a hugetlb specific global lock.
Changelog in v1 -> v2:
- Fix do not call d
On Wed, Apr 14, 2021 at 6:15 PM Michal Hocko wrote:
>
> On Wed 14-04-21 18:04:35, Muchun Song wrote:
> > On Wed, Apr 14, 2021 at 5:24 PM Michal Hocko wrote:
> > >
> > > On Tue 13-04-21 14:51:48, Muchun Song wrote:
> > > > When mm is NULL, we do not nee
On Wed, Apr 14, 2021 at 5:24 PM Michal Hocko wrote:
>
> On Tue 13-04-21 14:51:48, Muchun Song wrote:
> > When mm is NULL, we do not need to hold rcu lock and call css_tryget for
> > the root memcg. And we also do not need to check !mm in every loop of
> > while. So
On Wed, Apr 14, 2021 at 5:44 PM Michal Hocko wrote:
>
> On Tue 13-04-21 14:51:50, Muchun Song wrote:
> > We already have a helper lruvec_memcg() to get the memcg from lruvec, we
> > do not need to do it ourselves in the lruvec_holds_page_lru_lock(). So use
> > lruvec
The css_set_lock is used to guard the list of inherited objcgs. So there
is no need to uncharge kernel memory under css_set_lock. Just move it
out of the lock.
Signed-off-by: Muchun Song
---
mm/memcontrol.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/memcontrol.c b
f
reclaim stack") replace pagevecs by lists of pages_to_free. So we do
not need noinline_for_stack, just remove it (let the compiler decide
whether to inline).
Signed-off-by: Muchun Song
Acked-by: Johannes Weiner
Acked-by: Roman Gushchin
Reviewed-by: Shakeel Butt
---
mm/vmscan.c | 6 +++--
RITE_ONCE().
Signed-off-by: Muchun Song
Acked-by: Johannes Weiner
---
mm/memcontrol.c | 20 ++--
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 1f807448233e..42d8c0f4ab1d 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
parameter. Just remove it to simplify the code.
Signed-off-by: Muchun Song
Acked-by: Johannes Weiner
---
include/linux/memcontrol.h | 10 +-
mm/compaction.c| 2 +-
mm/memcontrol.c| 9 +++--
mm/swap.c | 2 +-
mm/workingset.c| 2 +-
5
When mm is NULL, we do not need to hold rcu lock and call css_tryget for
the root memcg. And we also do not need to check !mm in every loop of
while. So bail out early when !mm.
Signed-off-by: Muchun Song
Acked-by: Johannes Weiner
Reviewed-by: Shakeel Butt
---
mm/memcontrol.c | 21
ll trigger? So it is better to fix it.
Signed-off-by: Muchun Song
Acked-by: Johannes Weiner
Reviewed-by: Shakeel Butt
---
mm/memcontrol.c | 8 +---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 64ada9e650a5..f229de925aa5 10064
"memcg = page_memcg(page) ? : root_mem_cgroup". And use lruvec_pgdat
to simplify the code. We can have a single definition for this function
that works for !CONFIG_MEMCG, CONFIG_MEMCG + mem_cgroup_disabled() and
CONFIG_MEMCG.
Signed-off-by: Muchun Song
Acked-by: Johannes Weiner
---
inc
This patch series is part of [1] patch series. Because those patches are
code cleanup or simplification. I gather those patches into a separate
series to make it easier to review.
[1]
https://lore.kernel.org/linux-mm/20210409122959.82264-1-songmuc...@bytedance.com/
Muchun Song (7):
mm
On Mon, Apr 12, 2021 at 6:42 PM Christian Borntraeger
wrote:
>
> FWIW, I was away the last week, and I checked yesterdays next (e99d8a849517)
> regression runs.
> I still do see errors in our CI system:
>
> [ 2263.021681] [ cut here ]
> [ 2263.021697] percpu ref (obj_cgrou
On Sat, Apr 10, 2021 at 12:56 AM Johannes Weiner wrote:
>
> On Fri, Apr 09, 2021 at 08:29:47PM +0800, Muchun Song wrote:
> > Because memory allocations pinning memcgs for a long time - it exists
> > at a larger scale and is causing recurring problems in the real world:
> >
On Sat, Apr 10, 2021 at 12:00 AM Johannes Weiner wrote:
>
> On Fri, Apr 09, 2021 at 08:29:45PM +0800, Muchun Song wrote:
> > We already have a helper lruvec_memcg() to get the memcg from lruvec, we
> > do not need to do it ourselves in the lruvec_holds_page_lru_lock(). So us
On Sat, Apr 10, 2021 at 2:31 AM Johannes Weiner wrote:
>
> On Fri, Apr 09, 2021 at 08:29:50PM +0800, Muchun Song wrote:
> > The noinline_for_stack is introduced by commit 666356297ec4 ("vmscan:
> > set up pagevec as late as possible in shrink_inactive_list()"), its
, removing an atomic operation would be
an optimization. Also this change would not dirty cacheline for a
page which isn't on the LRU.
Signed-off-by: Muchun Song
---
mm/compaction.c | 1 +
mm/memcontrol.c | 31 +++
mm/swap.c | 41 +++--
Now the lock_page_memcg() does not lock a page and memcg binding, it
actually lock a page and objcg binding. So rename lock_page_memcg()
to lock_page_objcg().
This is just code cleanup without any functionality changes.
Signed-off-by: Muchun Song
---
Documentation/admin-guide/cgroup-v1
preparation for reparenting the LRU pages.
Signed-off-by: Muchun Song
---
fs/buffer.c| 3 ++-
fs/fs-writeback.c | 23 +++--
include/linux/memcontrol.h | 34 ---
mm/memcontrol.c| 51
We need to make sure that the page is deleted from or added to the
correct lruvec list. So add a VM_BUG_ON_PAGE() to catch invalid
users.
Signed-off-by: Muchun Song
---
include/linux/mm_inline.h | 6 ++
mm/vmscan.c | 1 -
2 files changed, 6 insertions(+), 1 deletion(-)
diff
ks safe when the LRU pages reparented.
Signed-off-by: Muchun Song
---
include/linux/memcontrol.h | 11 +++
mm/memcontrol.c| 49 --
2 files changed, 58 insertions(+), 2 deletions(-)
diff --git a/include/linux/memcontrol.h b/include/
stability:
- css_set_lock
- cgroup_mutex
- the lruvec lock
- the split queue lock (only THP page)
If the caller only want to ensure that the page counters of memcg are
updated correctly, ensure that the binding stability of page and objcg
is sufficient.
Signed-off-by: Muchun Song
---
incl
Similar to lruvec lock, we use the same approach to make the lock safe
when the LRU pages reparented.
Signed-off-by: Muchun Song
---
mm/huge_memory.c | 23 +++
1 file changed, 23 insertions(+)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 275dbfc8b2ae..aa5d7b72d5fc
like
lruvec lock did) to make thp deferred split queue lock safe when
the LRU pages reparented.
Signed-off-by: Muchun Song
---
mm/huge_memory.c | 96 +++-
1 file changed, 74 insertions(+), 22 deletions(-)
diff --git a/mm/huge_memory.c b/mm
the correct lruvec lock.
Signed-off-by: Muchun Song
---
mm/vmscan.c | 46 +++---
1 file changed, 23 insertions(+), 23 deletions(-)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index e40b21298d77..4431007825ad 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2013,23
f
reclaim stack") replace pagevecs by lists of pages_to_free. So we do
not need noinline_for_stack, just remove it (let the compiler decide
whether to inline).
Signed-off-by: Muchun Song
---
mm/vmscan.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mm/vmscan.c
cannot
be changed when we hold the lruvec lock.
Since lruvec_memcg(lruvec) is always equal to page_memcg(page) after
we hold the lruvec lock, lruvec_memcg_debug() check is pointless. So
remove it.
This is a preparation for reparenting the LRU pages.
Signed-off-by: Muchun Song
-
whether we need to reacquire the new
lruvec lock. So compact_lock_irqsave() is not suitable for us.
Similar to lock_page_lruvec_irqsave(), introduce
compact_lock_page_lruvec_irqsave() to acquire the lruvec lock in
the compaction routine.
Signed-off-by: Muchun Song
---
mm/compac
llocate an object cgroup for the root_mem_cgroup and introduce
root_obj_cgroup to cache its value just like root_mem_cgroup.
Signed-off-by: Muchun Song
---
include/linux/memcontrol.h | 4 ++-
mm/memcontrol.c| 71 +-
2 files changed, 60
RITE_ONCE().
Signed-off-by: Muchun Song
---
mm/memcontrol.c | 20 +++-
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 1f807448233e..90c1ac58c64c 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -261,7 +261,6 @@ st
"memcg = page_memcg(page) ? : root_mem_cgroup". And use lruvec_pgdat
to simplify the code. We can have a single definition for this function
that works for !CONFIG_MEMCG, CONFIG_MEMCG + mem_cgroup_disabled() and
CONFIG_MEMCG.
Signed-off-by: Muchun Song
---
include/linux/memcont
parameter. Just remove it to simplify the code.
Signed-off-by: Muchun Song
Acked-by: Johannes Weiner
---
include/linux/memcontrol.h | 10 +-
mm/compaction.c| 2 +-
mm/memcontrol.c| 9 +++--
mm/swap.c | 2 +-
mm/workingset.c| 2 +-
5
When mm is NULL, we do not need to hold rcu lock and call css_tryget for
the root memcg. And we also do not need to check !mm in every loop of
while. So bail out early when !mm.
Signed-off-by: Muchun Song
Acked-by: Johannes Weiner
---
mm/memcontrol.c | 21 ++---
1 file changed
ll trigger? So it is better to fix it.
Signed-off-by: Muchun Song
Acked-by: Johannes Weiner
---
mm/memcontrol.c | 8 +---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 64ada9e650a5..f229de925aa5 100644
--- a/mm/memcontrol.c
+++ b/mm/me
he objcg direction.
Any comments are welcome. Thanks.
Changlogs in RFC v2:
1. Collect Acked-by tags by Johannes. Thanks.
2. Rework lruvec_holds_page_lru_lock() suggested by Johannes. Thanks.
3. Fix move_pages_to_lru().
Muchun Song (18):
mm: memcontrol: fix page charging in page replacemen
On Sat, Apr 3, 2021 at 12:21 AM Johannes Weiner wrote:
>
> On Tue, Mar 30, 2021 at 06:15:20PM +0800, Muchun Song wrote:
> > We already have a helper lruvec_memcg() to get the memcg from lruvec, we
> > do not need to do it ourselves in the lruvec_holds_page_lru_lock(). So us
On Sat, Apr 3, 2021 at 4:56 AM Mike Kravetz wrote:
>
> On 4/2/21 5:47 AM, Muchun Song wrote:
> > On Wed, Mar 31, 2021 at 11:42 AM Mike Kravetz
> > wrote:
> >>
> >> Commit c77c0a8ac4c5 ("mm/hugetlb: defer freeing of huge pages if in
> >> no
ff-by: Dan Schatzberg
> Acked-by: Johannes Weiner
> Acked-by: Tejun Heo
> Acked-by: Chris Down
> Reviewed-by: Shakeel Butt
Reviewed-by: Muchun Song
Thanks.
s://lore.kernel.org/linux-mm/00000000f1c03b05bc43a...@google.com/
>
> Signed-off-by: Mike Kravetz
> Acked-by: Michal Hocko
> Reviewed-by: Muchun Song
Hi Mike,
Today I pulled the newest code (next-20210401). I found that
alloc_and_dissolve_huge_page is not updated. In th
the result of a code review.
Fixes: 682aa8e1a6a1 ("writeback: implement unlocked_inode_to_wb transaction and
use it for stat updates")
Signed-off-by: Muchun Song
Acked-by: Michal Hocko
---
Changelog in v3:
1. Do not change GFP_ATOMIC.
2. Update commit log.
Thanks for Michal
> On Tue, Mar 30, 2021 at 11:58:31AM -0700, Roman Gushchin wrote:
> > > > > On Tue, Mar 30, 2021 at 11:34:11AM -0700, Shakeel Butt wrote:
> > > > > > On Tue, Mar 30, 2021 at 3:20 AM Muchun Song
> > > > > > wrote:
> > > > >
On Fri, Apr 2, 2021 at 1:15 AM Shakeel Butt wrote:
>
> On Thu, Apr 1, 2021 at 9:08 AM Muchun Song wrote:
> >
> [...]
> > > The zombie issue is a pretty urgent concern that has caused several
> > > production emergencies now. It needs a fix sooner rather than l
; > On Tue, Mar 30, 2021 at 11:34:11AM -0700, Shakeel Butt wrote:
> > > > > On Tue, Mar 30, 2021 at 3:20 AM Muchun Song
> > > > > wrote:
> > > > > >
> > > > > > Since the following patchsets
On Thu, Apr 1, 2021 at 10:37 PM Michal Hocko wrote:
>
> On Thu 01-04-21 21:59:13, Muchun Song wrote:
> > On Thu, Apr 1, 2021 at 6:26 PM Michal Hocko wrote:
> [...]
> > > Even if the css ref count is not really necessary it shouldn't cause any
> > > harm and
On Thu, Apr 1, 2021 at 6:26 PM Michal Hocko wrote:
>
> On Thu 01-04-21 17:33:43, Muchun Song wrote:
> > The caller of wb_get_create() should pin the memcg, because
> > wb_get_create() relies on this guarantee. The rcu read lock
> > only can guarantee that the memcg css
t;)
Signed-off-by: Muchun Song
---
Changelog in v2:
1. Replace GFP_ATOMIC with GFP_NOIO suggested by Matthew.
fs/fs-writeback.c | 11 ---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index e91980f49388..df7f89f8f771 100644
--- a/fs/fs-w
On Fri, Mar 26, 2021 at 9:22 AM Alistair Popple wrote:
>
> request_free_mem_region() is used to find an empty range of physical
> addresses for hotplugging ZONE_DEVICE memory. It does this by iterating
> over the range of possible addresses using region_intersects() to see if
> the range is free.
Christian Borntraeger reported a warning about "percpu ref
(obj_cgroup_release) <= 0 (-1) after switching to atomic".
Because we forgot to obtain the reference to the objcg and
wrongly obtain the reference of memcg.
Reported-by: Christian Borntraeger
Signed-off-by: Muchun Song
On Wed, Mar 31, 2021 at 2:22 PM Christian Borntraeger
wrote:
>
>
>
> On 30.03.21 18:25, Muchun Song wrote:
> > On Tue, Mar 30, 2021 at 11:10 PM Christian Borntraeger
> > wrote:
> >>
> >>
> >> On 30.03.21 15:49, Muchun Song wrote:
> >
On Tue, Mar 30, 2021 at 7:34 PM Matthew Wilcox wrote:
>
> On Tue, Mar 30, 2021 at 05:29:33PM +0800, Muchun Song wrote:
> > +++ b/fs/fs-writeback.c
> > @@ -506,8 +506,10 @@ static void inode_switch_wbs(struct inode *inode, int
> > new_wb_id)
> >
On Wed, Mar 31, 2021 at 2:22 PM Christian Borntraeger
wrote:
>
>
>
> On 30.03.21 18:25, Muchun Song wrote:
> > On Tue, Mar 30, 2021 at 11:10 PM Christian Borntraeger
> > wrote:
> >>
> >>
> >> On 30.03.21 15:49, Muchun Song wrote:
> >
On Tue, Mar 30, 2021 at 11:10 PM Christian Borntraeger
wrote:
>
>
> On 30.03.21 15:49, Muchun Song wrote:
> > On Tue, Mar 30, 2021 at 9:27 PM Christian Borntraeger
> > wrote:
> >>
> >> So bisect shows this for belows warning:
> >
> > Thanks
8f019a
> Author: Muchun Song
> Date: Mon Mar 29 11:12:06 2021 +1100
>
> mm: memcontrol: use obj_cgroup APIs to charge kmem pages
>
> Since Roman's series "The new cgroup slab memory controller" applied.
> All
> slab objects are charged via the
We need to make sure that the page is deleted from or added to the
correct lruvec list. So add a VM_BUG_ON_PAGE() to catch invalid
users.
Signed-off-by: Muchun Song
---
include/linux/mm_inline.h | 6 ++
mm/vmscan.c | 3 ++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff
Now the lock_page_memcg() does not lock a page and memcg binding, it
actually lock a page and objcg binding. So rename lock_page_memcg()
to lock_page_objcg().
This is just code cleanup without any functionality changes.
Signed-off-by: Muchun Song
---
Documentation/admin-guide/cgroup-v1
stability:
- css_set_lock
- cgroup_mutex
- the lruvec lock
- the split queue lock (only THP page)
If the caller only want to ensure that the page counters of memcg are
updated correctly, ensure that the binding stability of page and objcg
is sufficient.
Signed-off-by: Muchun Song
---
incl
ks safe when the LRU pages reparented.
Signed-off-by: Muchun Song
---
include/linux/memcontrol.h | 11 +++
mm/memcontrol.c| 49 --
2 files changed, 58 insertions(+), 2 deletions(-)
diff --git a/include/linux/memcontrol.h b/include/
preparation for reparenting the LRU pages.
Signed-off-by: Muchun Song
---
fs/buffer.c| 3 ++-
fs/fs-writeback.c | 23 +++--
include/linux/memcontrol.h | 34 ---
mm/memcontrol.c| 50
Similar to lruvec lock, we use the same approach to make the lock safe
when the LRU pages reparented.
Signed-off-by: Muchun Song
---
mm/huge_memory.c | 26 ++
1 file changed, 26 insertions(+)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 186dc11e8992
like
lruvec lock did) to make thp deferred split queue lock safe when
the LRU pages reparented.
Signed-off-by: Muchun Song
---
mm/huge_memory.c | 97 +++-
1 file changed, 75 insertions(+), 22 deletions(-)
diff --git a/mm/huge_memory.c b/mm
cannot
be changed when we hold the lruvec lock.
Since lruvec_memcg(lruvec) is always equal to page_memcg(page) after
we hold the lruvec lock, lruvec_memcg_debug() check is pointless. So
remove it.
This is a preparation for reparenting the LRU pages.
Signed-off-by: Muchun Song
-
whether we need to reacquire the new
lruvec lock. So compact_lock_irqsave() is not suitable for us.
Similar to lock_page_lruvec_irqsave(), introduce
compact_lock_page_lruvec_irqsave() to acquire the lruvec lock in
the compaction routine.
Signed-off-by: Muchun Song
---
mm/compac
llocate an object cgroup for the root_mem_cgroup and introduce
root_obj_cgroup to cache its value just like root_mem_cgroup.
Signed-off-by: Muchun Song
---
include/linux/memcontrol.h | 4 ++-
mm/memcontrol.c| 71 +-
2 files changed, 60
We already have a helper lruvec_memcg() to get the memcg from lruvec, we
do not need to do it ourselves in the lruvec_holds_page_lru_lock(). So use
lruvec_memcg() instead.
Signed-off-by: Muchun Song
---
include/linux/memcontrol.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff
RITE_ONCE().
Signed-off-by: Muchun Song
---
mm/memcontrol.c | 20 +++-
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 405c9642aac0..fdabe12e9df0 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -261,7 +261,6 @@ st
parameter. Just remove it to simplify the code.
Signed-off-by: Muchun Song
---
include/linux/memcontrol.h | 10 +-
mm/compaction.c| 2 +-
mm/memcontrol.c| 9 +++--
mm/page-writeback.c| 2 +-
mm/swap.c | 2 +-
mm/workingset.c
ll trigger? So it is better to fix it.
Signed-off-by: Muchun Song
---
mm/memcontrol.c | 8 +---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 249bf6b4d94c..d0c4f6e91e17 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -6936,9 +6936,
When mm is NULL, we do not need to hold rcu lock and call css_tryget for
the root memcg. And we also do not need to check !mm in every loop of
while. So bail out early when !mm.
Signed-off-by: Muchun Song
---
mm/memcontrol.c | 21 ++---
1 file changed, 10 insertions(+), 11
he objcg direction.
Muchun Song (15):
mm: memcontrol: fix page charging in page replacement
mm: memcontrol: bail out early when !mm in get_mem_cgroup_from_mm
mm: memcontrol: remove the pgdata parameter of mem_cgroup_page_lruvec
mm: memcontrol: use lruvec_memcg in lruvec_holds_page_lru_loc
calling
wb_get_create(). This is not a problem I encountered in the
real world. Just the result of a code review.
Fixes: 682aa8e1a6a1 ("writeback: implement unlocked_inode_to_wb transaction and
use it for stat updates")
Signed-off-by: Muchun Song
---
fs/fs-writeback.c | 4 +++-
1 file
On Tue, Mar 30, 2021 at 4:18 PM Michal Hocko wrote:
>
> On Tue 30-03-21 16:08:36, Muchun Song wrote:
> > On Tue, Mar 30, 2021 at 4:01 PM Michal Hocko wrote:
> > >
> > > On Mon 29-03-21 16:23:55, Mike Kravetz wrote:
> > > > Ideally, cma_release could be
On Tue, Mar 30, 2021 at 4:01 PM Michal Hocko wrote:
>
> On Mon 29-03-21 16:23:55, Mike Kravetz wrote:
> > Ideally, cma_release could be called from any context. However, that is
> > not possible because a mutex is used to protect the per-area bitmap.
> > Change the bitmap to an irq safe spinlock.
ght forward accounting effectively
> reverting the commit.
>
> Signed-off-by: Mike Kravetz
Reviewed-by: Muchun Song
Some nits below.
> ---
> mm/hugetlb.c | 95 +---
> 1 file changed, 53 insertions(+), 42 deletions(-)
>
&g
; allow one hugetlb page adjustment at a time. This will synchronize
> modifications to the next_nid_to_alloc variable.
>
> Signed-off-by: Mike Kravetz
Thanks Mike.
Reviewed-by: Muchun Song
> Acked-by: Michal Hocko
> Reviewed-by: Oscar Salvador
> Reviewed-by: Miaohe Lin
> ---
Mike Kravetz
> Acked-by: Michal Hocko
> Reviewed-by: Muchun Song
> ---
> mm/hugetlb.c | 32 +++-
> 1 file changed, 27 insertions(+), 5 deletions(-)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 16beae49..dec7bd0dc63d 100644
> --- a/mm/hu
On Tue, Mar 30, 2021 at 10:03 AM Wan Jiabing wrote:
>
> struct mem_cgroup is declared twice. One has been declared
> at forward struct declaration. Remove the duplicate.
>
> Signed-off-by: Wan Jiabing
Reviewed-by: Muchun Song
Thanks.
> ---
> include/linux/memcontr
On Mon, Mar 29, 2021 at 10:49 PM Dan Schatzberg
wrote:
>
> set_active_memcg() worked for kernel allocations but was silently
> ignored for user pages.
>
> This patch establishes a precedence order for who gets charged:
>
> 1. If there is a memcg associated with the page already, that memcg is
>
On Thu, Mar 25, 2021 at 8:29 AM Mike Kravetz wrote:
>
> After making hugetlb lock irq safe and separating some functionality
> done under the lock, add some lockdep_assert_held to help verify
> locking.
>
> Signed-off-by: Mike Kravetz
Reviewed-by: Muchun Song
Thanks.
>
ck calls to spin_*lock_irq* calls.
> - Make subpool lock irq safe in a similar manner.
> - Revert the !in_task check and workqueue handoff.
>
> [1] https://lore.kernel.org/linux-mm/f1c03b05bc43a...@google.com/
>
> Signed-off-by: Mike Kravetz
The changes are straightfor
allow loops which decrease
> the huge page pool to drop the hugetlb_lock with each page to reduce
> long hold times.
>
> The ugly unlock/lock cycle in free_pool_huge_page will be removed in
> a subsequent patch which restructures free_pool_huge_page.
>
> Signed-off-by: Mike Kr
ne and separating functionality is in preparation for
> restructuring code to reduce lock hold times.
>
> Signed-off-by: Mike Kravetz
Reviewed-by: Muchun Song
Thanks for your effort on this.
> ---
> mm/hugetlb.c | 70 +---
>
On Wed, Mar 24, 2021 at 4:33 PM Michal Hocko wrote:
>
> On Wed 24-03-21 12:11:35, Muchun Song wrote:
> > On Tue, Mar 23, 2021 at 11:04 PM Muchun Song
> > wrote:
> > >
> > > The pages aren't accounted at the root level, so we cannot uncharge the
> >
On Tue, Mar 23, 2021 at 11:04 PM Muchun Song wrote:
>
> The pages aren't accounted at the root level, so we cannot uncharge the
> page to the memsw counter for the root memcg. Fix this.
>
> Fixes: 1f47b61fb407 ("mm: memcontrol: fix swap counter leak on swapout from
&g
The pages aren't accounted at the root level, so we cannot uncharge the
page to the memsw counter for the root memcg. Fix this.
Fixes: 1f47b61fb407 ("mm: memcontrol: fix swap counter leak on swapout from
offline cgroup")
Signed-off-by: Muchun Song
---
mm/memcontrol.c | 3 ++-
1
On Mon, Mar 22, 2021 at 10:46 PM Johannes Weiner wrote:
>
> On Sat, Mar 20, 2021 at 12:38:14AM +0800, Muchun Song wrote:
> > The rcu_read_lock/unlock only can guarantee that the memcg will not be
> > freed, but it cannot guarantee the success of css_get (which is in the
>
The page only can be marked as kmem when CONFIG_MEMCG_KMEM is enabled.
So move PageMemcgKmem() to the scope of the CONFIG_MEMCG_KMEM.
As a bonus, on !CONFIG_MEMCG_KMEM build some code can be compiled out.
Signed-off-by: Muchun Song
Acked-by: Roman Gushchin
Reviewed-by: Shakeel Butt
Acked-by
up. We can use the __page_objcg() to get the object
cgroup associated with a kmem page. Or we can use page_memcg()
to get the memory cgroup associated with a kmem page, but caller must
ensure that the returned memcg won't be released (e.g. acquire the
rcu_read_lock or css_set_lock).
Signed-off-b
Just like assignment to ug->memcg, we only need to update ug->dummy_page
if memcg changed. So move it to there. This is a very small optimization.
Signed-off-by: Muchun Song
Acked-by: Johannes Weiner
Reviewed-by: Shakeel Butt
---
mm/memcontrol.c | 2 +-
1 file changed, 1 insertion
without any functionality changes.
Signed-off-by: Muchun Song
---
mm/memcontrol.c | 63 +++--
1 file changed, 25 insertions(+), 38 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 962499542531..249bf6b4d94c 100644
--- a/mm
whether the value of page->memcg_data is 0. So just
directly access page->memcg_data here.
Signed-off-by: Muchun Song
Acked-by: Johannes Weiner
Reviewed-by: Shakeel Butt
---
mm/page_alloc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_a
objcg stock. And obj_cgroup_{un}charge_pages() are
introduced to charge in units of page level.
In the later patch, we also can reuse those two helpers to charge or
uncharge a number of kernel pages to a object cgroup. This is just
a code movement without any functional changes.
Signed-off-by: Muchun
ix this by holding a reference to the memcg which is passed to the
__memcg_kmem_uncharge() before calling __memcg_kmem_uncharge().
Fixes: 3de7d4f25a74 ("mm: memcg/slab: optimize objcg stock draining")
Signed-off-by: Muchun Song
---
mm/memcontrol.c | 10 +-
1 file changed, 9 inse
ohannes and Shakeel).
3. Reduce the CC list to mm/memcg folks (Thanks to Johannes).
4. Introduce remote objcg charging APIs instead of convert "remote memcg
charging APIs" to "remote objcg charging APIs".
Muchun Song (7):
mm: memcontrol: slab: fix obtain a reference to
On Fri, Mar 19, 2021 at 9:59 PM Shakeel Butt wrote:
>
> On Thu, Mar 18, 2021 at 9:05 PM Muchun Song wrote:
> >
> > On Fri, Mar 19, 2021 at 11:40 AM Shakeel Butt wrote:
> > >
> > > On Thu, Mar 18, 2021 at 4:08 AM Muchun Song
> > > wrote:
>
On Fri, Mar 19, 2021 at 4:59 PM Oscar Salvador wrote:
>
> On Mon, Mar 15, 2021 at 05:20:14PM +0800, Muchun Song wrote:
> > --- a/arch/x86/mm/init_64.c
> > +++ b/arch/x86/mm/init_64.c
> > @@ -34,6 +34,7 @@
> > #include
> > #include
> > #include
>
On Fri, Mar 19, 2021 at 11:40 AM Shakeel Butt wrote:
>
> On Thu, Mar 18, 2021 at 4:08 AM Muchun Song wrote:
> >
> [...]
> >
> > +static inline struct mem_cgroup *get_obj_cgroup_memcg(struct obj_cgroup
> > *objcg)
>
> I would prefer get_mem_cgroup_from
up. We can use the __page_objcg() to get the object
cgroup associated with a kmem page. Or we can use page_memcg()
to get the memory cgroup associated with a kmem page, but caller must
ensure that the returned memcg won't be released (e.g. acquire the
rcu_read_lock or css_set_lock).
Signe
Just like assignment to ug->memcg, we only need to update ug->dummy_page
if memcg changed. So move it to there. This is a very small optimization.
Signed-off-by: Muchun Song
---
mm/memcontrol.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/memcontrol.c b/mm/memcon
The page only can be marked as kmem when CONFIG_MEMCG_KMEM is enabled.
So move PageMemcgKmem() to the scope of the CONFIG_MEMCG_KMEM.
As a bonus, on !CONFIG_MEMCG_KMEM build some code can be compiled out.
Signed-off-by: Muchun Song
Acked-by: Roman Gushchin
Reviewed-by: Shakeel Butt
Acked-by
whether the value of page->memcg_data is 0. So just
directly access page->memcg_data here.
Signed-off-by: Muchun Song
---
mm/page_alloc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index f10966e3b4a5..e5454b85a106 100644
--
101 - 200 of 1001 matches
Mail list logo