[PATCH v1 0/2] mm: cma: introduce a non-blocking version of cma_release()

2020-10-22 Thread Roman Gushchin
of making cma_release() non-blocking, for performance reasons rfc: https://lkml.org/lkml/2020/10/16/1050 Roman Gushchin (2): mm: cma: introduce cma_release_nowait() mm: hugetlb: don't drop hugetlb_lock around cma_release() call include/linux/cma.h | 2 + mm/cma.c| 93

[PATCH v1 1/2] mm: cma: introduce cma_release_nowait()

2020-10-22 Thread Roman Gushchin
that subsequent cma_alloc() call will pass, cma_alloc() flushes the cma_release_wq workqueue. To avoid a performance regression in the case when only cma_release() is used, gate it by a per-cma area flag, which is set by the first call of cma_release_nowait(). Signed-off-by: Roman Gushchin

Re: [PATCH v4] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-22 Thread Roman Gushchin
02cc0a000 CR4: > > 06f0 > > [9.845319] Call Trace: > > [9.845429] __memcg_kmem_uncharge (mm/memcontrol.c:3022) > > [9.845582] drain_obj_stock (./include/linux/rcupdate.h:689 > > mm/memcontrol.c:3114) > > [9.845684] drain_local_stock (mm/memcontrol

Re: [PATCH rfc 0/2] mm: cma: make cma_release() non-blocking

2020-10-22 Thread Roman Gushchin
On Thu, Oct 22, 2020 at 09:42:11AM -0700, Mike Kravetz wrote: > On 10/21/20 7:33 PM, Roman Gushchin wrote: > > On Wed, Oct 21, 2020 at 05:15:53PM -0700, Mike Kravetz wrote: > >> On 10/16/20 3:52 PM, Roman Gushchin wrote: > >>> This small patchset makes cma_release

Re: [PATCH rfc 0/2] mm: cma: make cma_release() non-blocking

2020-10-21 Thread Roman Gushchin
On Thu, Oct 22, 2020 at 09:54:53AM +0800, Xiaqing (A) wrote: > > > On 2020/10/17 6:52, Roman Gushchin wrote: > > > This small patchset makes cma_release() non-blocking and simplifies > > the code in hugetlbfs, where previously we had to temporarily drop > > huget

Re: [PATCH rfc 0/2] mm: cma: make cma_release() non-blocking

2020-10-21 Thread Roman Gushchin
On Wed, Oct 21, 2020 at 05:15:53PM -0700, Mike Kravetz wrote: > On 10/16/20 3:52 PM, Roman Gushchin wrote: > > This small patchset makes cma_release() non-blocking and simplifies > > the code in hugetlbfs, where previously we had to temporarily drop > > hugetlb_lock around t

Re: [PATCH v3] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-21 Thread Roman Gushchin
On Tue, Oct 20, 2020 at 09:56:51AM -0700, Shakeel Butt wrote: > On Tue, Oct 20, 2020 at 6:49 AM Richard Palethorpe > wrote: > > > > Hello, > > > > Richard Palethorpe writes: > > > > > Hello Shakeel, > > > > > > Shakeel Butt writes: > > >>> > > >>> V3: Handle common case where use_hierarchy=1

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-21 Thread Roman Gushchin
On Tue, Oct 20, 2020 at 02:18:22PM -0400, Johannes Weiner wrote: > On Tue, Oct 20, 2020 at 10:07:17AM -0700, Roman Gushchin wrote: > > If we want these counter to function properly, then we should go into the > > opposite > > direction and remove the special handling of t

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-20 Thread Roman Gushchin
On Tue, Oct 20, 2020 at 09:55:38AM -0700, Shakeel Butt wrote: > On Mon, Oct 19, 2020 at 3:28 PM Roman Gushchin wrote: > > > > On Fri, Oct 16, 2020 at 07:15:02PM +0200, Michal Koutny wrote: > > > On Fri, Oct 16, 2020 at 10:53:08AM -0400, Johannes Weiner > >

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-20 Thread Roman Gushchin
On Tue, Oct 20, 2020 at 06:27:14PM +0200, Michal Koutny wrote: > Hi. > > On Mon, Oct 19, 2020 at 03:28:45PM -0700, Roman Gushchin wrote: > > Currently the root memory cgroup is never charged directly, but > > if an ancestor cgroup is charged, the charge is propagated u

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-19 Thread Roman Gushchin
good way to estimate the memory cgroup overhead. How about the patch below, which consistently avoids charging the root memory cgroup? It seems like it doesn't add too many checks. Thanks! -- >From f50ea74d8f118b9121da3754acdde630ddc060a7 Mon Sep 17 00:00:00 2001 From: Roman Gushchin Date

[PATCH rfc 2/2] mm: hugetlb: don't drop hugetlb_lock around cma_release() call

2020-10-16 Thread Roman Gushchin
cma_release() now is a non-blocking function, so there is no more need to drop hugetlb_lock to call it. Signed-off-by: Roman Gushchin --- mm/hugetlb.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index fe76f8fd5a73..c8c892b1cabc 100644 --- a/mm/hugetlb.c

[PATCH rfc 1/2] mm: cma: make cma_release() non-blocking

2020-10-16 Thread Roman Gushchin
-allocations are usually not that frequent, a single global workqueue is used. Signed-off-by: Roman Gushchin --- mm/cma.c | 51 +-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/mm/cma.c b/mm/cma.c index 7f415d7cda9f..523cd9356bc7 100644

[PATCH rfc 0/2] mm: cma: make cma_release() non-blocking

2020-10-16 Thread Roman Gushchin
functions in the kernel: most of them are non-blocking. Roman Gushchin (2): mm: cma: make cma_release() non-blocking mm: hugetlb: don't drop hugetlb_lock around cma_release() call mm/cma.c | 51 +-- mm/hugetlb.c | 6 -- 2 files changed, 49

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-16 Thread Roman Gushchin
On Fri, Oct 16, 2020 at 10:53:08AM -0400, Johannes Weiner wrote: > On Fri, Oct 16, 2020 at 11:47:02AM +0200, Michal Koutný wrote: > > Hello. > > > > On Wed, Oct 14, 2020 at 08:07:49PM +0100, Richard Palethorpe > > wrote: > > > SLAB objects which outlive their memcg are moved to their parent > >

Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-14 Thread Roman Gushchin
.h:2122 > kernel/rcu/tree_plugin.h:2157 kernel/rcu/tree.c:2661) > ... > Reported-By: l...@lists.linux.it > Signed-off-by: Richard Palethorpe > Cc: Johannes Weiner > Cc: Roman Gushchin > Cc: Andrew Morton > Cc: Shakeel Butt > Cc: Christoph Lameter > Cc: Michal Hocko > Cc: Tejun Heo > Cc: Vlastimil Babka > Cc: linux...@kvack.org > Cc: linux-kernel@vger.kernel.org > Fixes: bf4f059954dc ("mm: memcg/slab: obj_cgroup API") Acked-by: Roman Gushchin Thanks!

Re: [PATCH] mm: memcontrol: Remove unused mod_memcg_obj_state()

2020-10-13 Thread Roman Gushchin
the mod_objcg_state() > from int to enum node_stat_item. > > Signed-off-by: Muchun Song Acked-by: Roman Gushchin Thanks!

Re: [PATCH FIX v0] mm: memcg/slab: Uncharge during kmem_cache_free_bulk()

2020-10-12 Thread Roman Gushchin
On Mon, Oct 12, 2020 at 09:03:26AM +0530, Bharata B Rao wrote: > On Fri, Oct 09, 2020 at 11:45:51AM -0700, Roman Gushchin wrote: > > On Fri, Oct 09, 2020 at 11:34:23AM +0530, Bharata B Rao wrote: > > > > Hi Bharata, > > > > > Object cgroup chargin

Re: [kbuild-all] Re: [PATCH] mm: memcg/slab: fix slab statistics in !SMP configuration

2020-10-12 Thread Roman Gushchin
On Tue, Oct 13, 2020 at 07:05:50AM +0800, Philip Li wrote: > On Fri, Oct 02, 2020 at 10:55:06AM -0700, Roman Gushchin wrote: > > On Fri, Oct 02, 2020 at 01:34:06PM +0800, Philip Li wrote: > > > On Thu, Oct 01, 2020 at 05:55:59PM -0700, Roman Gushchin wrote: > > > >

Re: [PATCH FIX v0] mm: memcg/slab: Uncharge during kmem_cache_free_bulk()

2020-10-09 Thread Roman Gushchin
On Fri, Oct 09, 2020 at 11:34:23AM +0530, Bharata B Rao wrote: Hi Bharata, > Object cgroup charging is done for all the objects during > allocation, but during freeing, uncharging ends up happening > for only one object in the case of bulk allocation/freeing. Yes, it's definitely a problem.

Re: [RFC PATCH v2 00/30] 1GB PUD THP support on x86_64

2020-10-05 Thread Roman Gushchin
On Mon, Oct 05, 2020 at 08:33:44PM +0200, David Hildenbrand wrote: > On 05.10.20 20:25, Roman Gushchin wrote: > > On Mon, Oct 05, 2020 at 07:27:47PM +0200, David Hildenbrand wrote: > >> On 05.10.20 19:16, Roman Gushchin wrote: > >>> On Mon, Oct 05, 2020 at

Re: [RFC PATCH v2 00/30] 1GB PUD THP support on x86_64

2020-10-05 Thread Roman Gushchin
On Mon, Oct 05, 2020 at 07:27:47PM +0200, David Hildenbrand wrote: > On 05.10.20 19:16, Roman Gushchin wrote: > > On Mon, Oct 05, 2020 at 11:03:56AM -0400, Zi Yan wrote: > >> On 2 Oct 2020, at 4:30, David Hildenbrand wrote: > >> > >>> On 02.10.20 10:10, Mic

Re: [RFC PATCH v2 00/30] 1GB PUD THP support on x86_64

2020-10-05 Thread Roman Gushchin
On Mon, Oct 05, 2020 at 11:03:56AM -0400, Zi Yan wrote: > On 2 Oct 2020, at 4:30, David Hildenbrand wrote: > > > On 02.10.20 10:10, Michal Hocko wrote: > >> On Fri 02-10-20 09:50:02, David Hildenbrand wrote: > >> - huge page sizes controllable by the userspace? > > > > It might be

Re: [RFC PATCH v2 00/30] 1GB PUD THP support on x86_64

2020-10-05 Thread Roman Gushchin
On Mon, Oct 05, 2020 at 04:55:53PM +0100, Matthew Wilcox wrote: > On Mon, Oct 05, 2020 at 11:03:56AM -0400, Zi Yan wrote: > > On 2 Oct 2020, at 4:30, David Hildenbrand wrote: > > > Yes, I think one important feature would be that we don't end up placing > > > a gigantic page where only a handful

Re: [kbuild-all] Re: [PATCH] mm: memcg/slab: fix slab statistics in !SMP configuration

2020-10-02 Thread Roman Gushchin
On Fri, Oct 02, 2020 at 01:34:06PM +0800, Philip Li wrote: > On Thu, Oct 01, 2020 at 05:55:59PM -0700, Roman Gushchin wrote: > > On Fri, Oct 02, 2020 at 08:08:40AM +0800, kbuild test robot wrote: > > > Hi Roman, > > > > > > Thank you for the patch! Yet some

Re: Linux 5.9-rc7 / VmallocTotal wrongly reported | Patch OK

2020-10-02 Thread Roman Gushchin
On Fri, Oct 02, 2020 at 09:01:14AM +0200, Bastian Bittorf wrote: > On Thu, Oct 01, 2020 at 01:39:31PM -0700, Roman Gushchin wrote: > > > # Processor type and features > > > # > > > # CONFIG_ZONE_DMA is not set > > > # CONFIG_SMP is not set > > > &

[PATCH v5 1/4] mm: memcontrol: use helpers to read page's memcg data

2020-10-02 Thread Roman Gushchin
ULL. page_memcg() contains a VM_BUG_ON_PAGE() check for the page not being a slab page. To make sure nobody uses a direct access, struct page's mem_cgroup/obj_cgroups is converted to unsigned long memcg_data. Signed-off-by: Roman Gushchin Acked-by: Johannes Weiner --- fs/buffer.c |

[PATCH v5 4/4] mm: convert page kmemcg type to a page memcg flag

2020-10-02 Thread Roman Gushchin
MemcgKmem() and an open-coded OR operation setting the memcg pointer with the MEMCG_DATA_KMEM bit. __ClearPageKmemcg() can be simple deleted, as the whole memcg_data is zeroed at once. As a bonus, on !CONFIG_MEMCG build the PageMemcgKmem() check will be compiled out. Signed-off-by: Roman Gushchin Acked-by:

[PATCH v5 2/4] mm: memcontrol/slab: use helpers to access slab page's memcg_data

2020-10-02 Thread Roman Gushchin
, struct obj_cgroup **objcgs); They are similar to the corresponding API for generic pages, except that the setter can return false, indicating that the value has been already set from a different thread. Signed-off-by: Roman Gushchin Acked-by: Johannes Weiner --- include/linux/memcontrol.h

[PATCH v5 3/4] mm: introduce page memcg flags

2020-10-02 Thread Roman Gushchin
ght be added later. Signed-off-by: Roman Gushchin Reviewed-by: Shakeel Butt --- include/linux/memcontrol.h | 32 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index c7ac0a5b8989..99a4841d658b 100

[PATCH v5 0/4] mm: allow mapping accounted kernel pages to userspace

2020-10-02 Thread Roman Gushchin
xed comments, by Shakeel - added some VM_BUG_ON() checks - fixed the debug output format of page->memcg_data Roman Gushchin (4): mm: memcontrol: use helpers to read page's memcg data mm: memcontrol/slab: use helpers to access slab page's memcg_data mm: introduce page memcg flags mm: convert p

Re: [PATCH] mm: memcg/slab: fix slab statistics in !SMP configuration

2020-10-01 Thread Roman Gushchin
troller patches. Thanks! > > url: > https://github.com/0day-ci/linux/commits/Roman-Gushchin/mm-memcg-slab-fix-slab-statistics-in-SMP-configuration/20201002-044114 > base: git://git.cmpxchg.org/linux-mmotm.git master > config: i386-randconfig-s002-20200930 (attached as .con

Re: [PATCH v4 1/4] mm: memcontrol: use helpers to access page's memcg data

2020-10-01 Thread Roman Gushchin
On Thu, Oct 01, 2020 at 02:59:50PM -0400, Johannes Weiner wrote: > On Thu, Oct 01, 2020 at 11:27:39AM -0700, Roman Gushchin wrote: > > On Thu, Oct 01, 2020 at 09:46:38AM -0400, Johannes Weiner wrote: > > > On Wed, Sep 30, 2020 at 05:27:07PM -0700, Ro

Re: Linux 5.9-rc7 / VmallocTotal wrongly reported

2020-10-01 Thread Roman Gushchin
On Thu, Oct 01, 2020 at 12:58:36PM -0700, Linus Torvalds wrote: > On Thu, Oct 1, 2020 at 12:56 PM Roman Gushchin wrote: > > > > Bastian, can you, please, share your config? > > Bastian actually did that in the original email, but that was only > sent to me and Andrew

Re: Linux 5.9-rc7 / VmallocTotal wrongly reported

2020-10-01 Thread Roman Gushchin
On Thu, Oct 01, 2020 at 12:19:57PM -0700, Linus Torvalds wrote: > Adding Vlastimil, Roman and the kernel mailing list to the cc. > > Vlastimil, Roman - this looks like a slab regression. And while others > have touched slab in this merge window, you guys did so more than > most.. Comments? Thank

Re: [PATCH v4 4/4] mm: convert page kmemcg type to a page memcg flag

2020-10-01 Thread Roman Gushchin
On Thu, Oct 01, 2020 at 07:00:36PM +0200, Michal Koutny wrote: > Hi. > > On Wed, Sep 30, 2020 at 05:27:10PM -0700, Roman Gushchin wrote: > > @@ -369,8 +371,12 @@ enum page_memcg_data_flags { > > */ > > static inline struct mem_cgroup *page_memcg(struct page *page) &

Re: [PATCH v4 1/4] mm: memcontrol: use helpers to access page's memcg data

2020-10-01 Thread Roman Gushchin
On Thu, Oct 01, 2020 at 09:46:38AM -0400, Johannes Weiner wrote: > On Wed, Sep 30, 2020 at 05:27:07PM -0700, Roman Gushchin wrote: > > +/* > > + * set_page_memcg - associate a page with a memory cgroup > > + * @page: a pointer to the page struct > > + * @memcg: a p

[PATCH v4 1/4] mm: memcontrol: use helpers to access page's memcg data

2020-09-30 Thread Roman Gushchin
verted to unsigned long memcg_data. Only new helpers and a couple of slab-accounting related functions access this field directly. Signed-off-by: Roman Gushchin Acked-by: Johannes Weiner --- fs/buffer.c | 2 +- fs/iomap/buffered-io.c | 2 +- include/linux/memcon

[PATCH v4 0/4] mm: allow mapping accounted kernel pages to userspace

2020-09-30 Thread Roman Gushchin
fixed a bug in page_obj_cgroups_check() - moved some definitions between patches, by Shakeel - dropped the memcg flags mutual exclusion requirement, by Shakeel v1: - added and fixed comments, by Shakeel - added some VM_BUG_ON() checks - fixed the debug output format of page->mem

[PATCH v4 2/4] mm: memcontrol/slab: use helpers to access slab page's memcg_data

2020-09-30 Thread Roman Gushchin
, struct obj_cgroup **objcgs); They are similar to the corresponding API for generic pages, except that the setter can return false, indicating that the value has been already set from a different thread. Signed-off-by: Roman Gushchin Acked-by: Johannes Weiner --- include/linux/memcontrol.h

[PATCH v4 3/4] mm: introduce page memcg flags

2020-09-30 Thread Roman Gushchin
ght be added later. Signed-off-by: Roman Gushchin Reviewed-by: Shakeel Butt --- include/linux/memcontrol.h | 35 --- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 7e3da7cdc1ba..5e05599e1

[PATCH v4 4/4] mm: convert page kmemcg type to a page memcg flag

2020-09-30 Thread Roman Gushchin
MemcgKmem() and an open-coded OR operation setting the memcg pointer with the MEMCG_DATA_KMEM bit. __ClearPageKmemcg() can be simple deleted, as the whole memcg_data is zeroed at once. As a bonus, on !CONFIG_MEMCG build the PageMemcgKmem() check will be compiled out. Signed-off-by: Roman Gushchin --- incl

Re: [PATCH v3 3/4] mm: introduce page memcg flags

2020-09-30 Thread Roman Gushchin
On Wed, Sep 30, 2020 at 04:35:37PM -0700, Shakeel Butt wrote: > On Tue, Sep 29, 2020 at 4:59 PM Roman Gushchin wrote: > > > > The lowest bit in page->memcg_data is used to distinguish between > > struct memory_cgroup pointer and a pointer to a objcgs array. > >

[PATCH v3 4/4] mm: convert page kmemcg type to a page memcg flag

2020-09-29 Thread Roman Gushchin
MemcgKmem() and __SetPageMemcgKmem(). __ClearPageKmemcg() can be simple deleted because clear_page_mem_cgroup() already does the job. As a bonus, on !CONFIG_MEMCG build the PageMemcgKmem() check will be compiled out. Signed-off-by: Roman Gushchin --- include/linux/memcontr

[PATCH v3 1/4] mm: memcontrol: use helpers to access page's memcg data

2020-09-29 Thread Roman Gushchin
y uses a direct access, struct page's mem_cgroup/obj_cgroups is converted to unsigned long memcg_data. Only new helpers and a couple of slab-accounting related functions access this field directly. Signed-off-by: Roman Gushchin --- fs/buffer.c | 2 +- fs/iomap/buffere

[PATCH v3 0/4] mm: allow mapping accounted kernel pages to userspace

2020-09-29 Thread Roman Gushchin
- moved some definitions between patches, by Shakeel - dropped the memcg flags mutual exclusion requirement, by Shakeel v1: - added and fixed comments, by Shakeel - added some VM_BUG_ON() checks - fixed the debug output format of page->memcg_data Roman Gushchin (4): mm: memcontr

[PATCH v3 2/4] mm: memcontrol/slab: use helpers to access slab page's memcg_data

2020-09-29 Thread Roman Gushchin
page *page, struct obj_cgroup **objcgs); void clear_page_objcgs(struct page *page); They are similar to the corresponding API for generic pages, except that the setter can return false, indicating that the value has been already set from a different thread. Signed-off-by: Roman Gushchin

[PATCH v3 3/4] mm: introduce page memcg flags

2020-09-29 Thread Roman Gushchin
ght be added later. Signed-off-by: Roman Gushchin --- include/linux/memcontrol.h | 35 --- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index d4d15c04bbaf..35f846c6b89b 100644 --- a/include/li

Re: REGRESSION: 37f4a24c2469: blk-mq: centralise related handling into blk_mq_get_driver_tag

2020-09-26 Thread Roman Gushchin
> > static void drain_cpu_caches(struct kmem_cache *cachep) > > @@ -3402,9 +3406,9 @@ static void cache_flusharray(struct kmem_cache > > *cachep, struct array_cache *ac) > > } > > #endif > > spin_unlock(>list_lock); > > - slabs_destroy(cachep, ); > > ac->avail -= batchcount; > > memmove(ac->entry, &(ac->entry[batchcount]), sizeof(void *)*ac->avail); > > + slabs_destroy(cachep, ); > > } > > The issue can't be reproduced after applying this patch: > > Tested-by: Ming Lei Perfect, thank you very much for the confirmation! Shakeel, can you, please, resend the patch with the proper fixes tag and the updated commit log? Please, feel free to add Reviewed-by: Roman Gushchin . Thank you! Roman

Re: REGRESSION: 37f4a24c2469: blk-mq: centralise related handling into blk_mq_get_driver_tag

2020-09-25 Thread Roman Gushchin
On Fri, Sep 25, 2020 at 12:19:02PM -0700, Shakeel Butt wrote: > On Fri, Sep 25, 2020 at 10:58 AM Shakeel Butt > wrote: > > > [snip] > > > > I don't think you can ignore the flushing. The __free_once() in > > ___cache_free() assumes there is a space available. > > > > BTW do_drain() also have the

Re: REGRESSION: 37f4a24c2469: blk-mq: centralise related handling into blk_mq_get_driver_tag

2020-09-25 Thread Roman Gushchin
On Fri, Sep 25, 2020 at 10:35:03AM -0700, Shakeel Butt wrote: > On Fri, Sep 25, 2020 at 10:22 AM Shakeel Butt wrote: > > > > On Fri, Sep 25, 2020 at 10:17 AM Linus Torvalds > > wrote: > > > > > > On Fri, Sep 25, 2020 at 9:19 AM Ming Lei wrote: > > > > > > > > git bisect shows the first bad

Re: REGRESSION: 37f4a24c2469: blk-mq: centralise related handling into blk_mq_get_driver_tag

2020-09-25 Thread Roman Gushchin
On Fri, Sep 25, 2020 at 09:47:43AM -0700, Shakeel Butt wrote: > On Fri, Sep 25, 2020 at 9:32 AM Shakeel Butt wrote: > > > > On Fri, Sep 25, 2020 at 9:19 AM Ming Lei wrote: > > > > > > On Fri, Sep 25, 2020 at 03:31:45PM +0800, Ming Lei wrote: > > > > On Thu, Sep 24, 2020 at 09:13:11PM -0400,

Re: [PATCH v1 4/4] mm: convert page kmemcg type to a page memcg flag

2020-09-24 Thread Roman Gushchin
On Thu, Sep 24, 2020 at 04:14:17PM -0400, Johannes Weiner wrote: > On Tue, Sep 22, 2020 at 01:37:00PM -0700, Roman Gushchin wrote: > > PageKmemcg flag is currently defined as a page type (like buddy, > > offline, table and guard). Semantically it means that the page > > was

Re: [PATCH v1 3/4] mm: introduce page memcg flags

2020-09-24 Thread Roman Gushchin
On Thu, Sep 24, 2020 at 04:01:22PM -0400, Johannes Weiner wrote: > On Tue, Sep 22, 2020 at 01:36:59PM -0700, Roman Gushchin wrote: > > The lowest bit in page->memcg_data is used to distinguish between > > struct memory_cgroup pointer and a pointer to a objcgs arr

Re: [PATCH v1 2/4] mm: memcontrol/slab: use helpers to access slab page's memcg_data

2020-09-24 Thread Roman Gushchin
On Thu, Sep 24, 2020 at 03:53:56PM -0400, Johannes Weiner wrote: > On Tue, Sep 22, 2020 at 01:36:58PM -0700, Roman Gushchin wrote: > > To gather all direct accesses to struct page's memcg_data field > > in one place, let's introduce 4 new helper functions to use in > > the

Re: [PATCH v1 1/4] mm: memcontrol: use helpers to access page's memcg data

2020-09-24 Thread Roman Gushchin
On Thu, Sep 24, 2020 at 03:45:08PM -0400, Johannes Weiner wrote: > On Tue, Sep 22, 2020 at 01:36:57PM -0700, Roman Gushchin wrote: > > Currently there are many open-coded reads and writes of the > > page->mem_cgroup pointer, as well as a couple of read helpers, > &g

[PATCH v2 0/4] mm: allow mapping accounted kernel pages to userspace

2020-09-24 Thread Roman Gushchin
1: - added and fixed comments, by Shakeel - added some VM_BUG_ON() checks - fixed the debug output format of page->memcg_data Roman Gushchin (4): mm: memcontrol: use helpers to access page's memcg data mm: memcontrol/slab: use helpers to access slab page's memcg_data mm: introduce p

[PATCH v2 3/4] mm: introduce page memcg flags

2020-09-24 Thread Roman Gushchin
ses with test_bit()/__set_bit(). Additional flags might be added later. Signed-off-by: Roman Gushchin --- include/linux/memcontrol.h | 34 +++--- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h in

[PATCH v2 2/4] mm: memcontrol/slab: use helpers to access slab page's memcg_data

2020-09-24 Thread Roman Gushchin
-by: Roman Gushchin Reviewed-by: Shakeel Butt --- include/linux/memcontrol.h | 80 ++ mm/memcontrol.c| 4 +- mm/slab.h | 27 ++--- 3 files changed, 85 insertions(+), 26 deletions(-) diff --git a/include/linux/memcontrol.h b/include

[PATCH v2 4/4] mm: convert page kmemcg type to a page memcg flag

2020-09-24 Thread Roman Gushchin
MemcgKmem() and SetPageMemcgKmem(). __ClearPageKmemcg() can be simple deleted because clear_page_mem_cgroup() already does the job. As a bonus, on !CONFIG_MEMCG build the PageMemcgKmem() check will be compiled out. Signed-off-by: Roman Gushchin Reviewed-by: Shakeel Butt --- include/linux/memcontr

[PATCH v2 1/4] mm: memcontrol: use helpers to access page's memcg data

2020-09-24 Thread Roman Gushchin
cg_rcu() has a single call site in a small rcu-read-lock section, so it's just not worth it to have a separate helper. So it's replaced with page_mem_cgroup() too. Signed-off-by: Roman Gushchin Reviewed-by: Shakeel Butt --- fs/buffer.c | 2 +- fs/iomap/buffere

Re: [PATCH v1 3/4] mm: introduce page memcg flags

2020-09-24 Thread Roman Gushchin
On Thu, Sep 24, 2020 at 12:03:35AM -0700, Shakeel Butt wrote: > On Tue, Sep 22, 2020 at 1:38 PM Roman Gushchin wrote: > > > > The lowest bit in page->memcg_data is used to distinguish between > > struct memory_cgroup pointer and a pointer to a objcgs array. > >

[PATCH v1 0/4] mm: allow mapping accounted kernel pages to userspace

2020-09-22 Thread Roman Gushchin
and removes a couple of obsolete functions. As the result the code became more robust with fewer open-coded bits tricks. v1: - added and fixed comments, by Shakeel - added some VM_BUG_ON() checks - fixed the debug output format of page->memcg_data Roman Gushchin (4): mm: memcontr

[PATCH v1 3/4] mm: introduce page memcg flags

2020-09-22 Thread Roman Gushchin
ses with test_bit()/__set_bit(). Few additional flags might be added later. Flags are intended to be mutually exclusive. Signed-off-by: Roman Gushchin --- include/linux/memcontrol.h | 29 +++-- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/include/li

[PATCH v1 1/4] mm: memcontrol: use helpers to access page's memcg data

2020-09-22 Thread Roman Gushchin
cg_rcu() has a single call site in a small rcu-read-lock section, so it's just not worth it to have a separate helper. So it's replaced with page_mem_cgroup() too. Signed-off-by: Roman Gushchin Reviewed-by: Shakeel Butt --- fs/buffer.c | 2 +- fs/iomap/buffere

[PATCH v1 2/4] mm: memcontrol/slab: use helpers to access slab page's memcg_data

2020-09-22 Thread Roman Gushchin
-by: Roman Gushchin Reviewed-by: Shakeel Butt --- include/linux/memcontrol.h | 80 ++ mm/memcontrol.c| 4 +- mm/slab.h | 27 ++--- 3 files changed, 85 insertions(+), 26 deletions(-) diff --git a/include/linux/memcontrol.h b/include

[PATCH v1 4/4] mm: convert page kmemcg type to a page memcg flag

2020-09-22 Thread Roman Gushchin
MemcgKmem() and SetPageMemcgKmem(). __ClearPageKmemcg() can be simple deleted because clear_page_mem_cgroup() already does the job. As a bonus, on !CONFIG_MEMCG build the PageMemcgKmem() check will be compiled out. Signed-off-by: Roman Gushchin --- include/linux/memcontr

Re: [PATCH rfc 3/5] mm: memcontrol/slab: use helpers to access slab page's memcg_data

2020-09-17 Thread Roman Gushchin
On Wed, Sep 16, 2020 at 06:12:37PM -0700, Shakeel Butt wrote: > On Thu, Sep 10, 2020 at 1:27 PM Roman Gushchin wrote: > > > > To gather all direct accesses to struct page's memcg_data field > > in one place, let's introduce 4 new helper functions to use in > &g

Re: [External] Re: [PATCH] mm: memcontrol: Add the missing numa stat of anon and file for cgroup v2

2020-09-11 Thread Roman Gushchin
On Fri, Sep 11, 2020 at 11:51:42AM +0800, Muchun Song wrote: > On Fri, Sep 11, 2020 at 12:02 AM Shakeel Butt wrote: > > > > On Thu, Sep 10, 2020 at 1:46 AM Muchun Song > > wrote: > > > > > > In the cgroup v1, we have a numa_stat interface. This is useful for > > > providing visibility into the

Re: [PATCH rfc 0/5] mm: allow mapping accounted kernel pages to userspace

2020-09-11 Thread Roman Gushchin
On Fri, Sep 11, 2020 at 10:34:57AM -0700, Shakeel Butt wrote: > On Fri, Sep 11, 2020 at 10:34 AM Shakeel Butt wrote: > > > > On Thu, Sep 10, 2020 at 1:27 PM Roman Gushchin wrote: > > > > > > Currently a non-slab kernel page which has been charged to a me

Re: [PATCH] mm: memcg/slab: fix racy access to page->mem_cgroup in mem_cgroup_from_obj()

2020-09-11 Thread Roman Gushchin
On Fri, Sep 11, 2020 at 09:21:49AM -0700, Shakeel Butt wrote: > On Thu, Sep 10, 2020 at 3:43 PM Roman Gushchin wrote: > > > > Forgot to cc stable@, an updated version is below. > > > > Thanks! > > > > -- > > > > From fe61af45ae570b143ca783b

Re: [PATCH] mm: memcg/slab: fix racy access to page->mem_cgroup in mem_cgroup_from_obj()

2020-09-10 Thread Roman Gushchin
Forgot to cc stable@, an updated version is below. Thanks! -- >From fe61af45ae570b143ca783ba4d013a0a2b923a15 Mon Sep 17 00:00:00 2001 From: Roman Gushchin Date: Wed, 9 Sep 2020 12:19:37 -0700 Subject: [PATCH] mm: memcg/slab: fix racy access to page->mem_cgroup in mem_cgroup_fr

[PATCH rfc 2/5] mm: memcontrol: use helpers to access page's memcg data

2020-09-10 Thread Roman Gushchin
cg_rcu() has a single call site in a small rcu-read-lock section, so it's just not worth it to have a separate helper. So it's replaced with page_mem_cgroup() too. Signed-off-by: Roman Gushchin --- include/linux/memcontrol.h | 72 +--- include/linux/mm.h

[PATCH rfc 5/5] mm: convert page kmemcg type to a page memcg flag

2020-09-10 Thread Roman Gushchin
MemcgKmem() and SetPageMemcgKmem(). __ClearPageKmemcg() can be simple deleted because clear_page_mem_cgroup() already does the job. As a bonus, on !CONFIG_MEMCG build the PageMemcgKmem() check will be compiled out. Signed-off-by: Roman Gushchin --- include/linux/memcontr

[PATCH rfc 4/5] mm: introduce page memcg flags

2020-09-10 Thread Roman Gushchin
ses with test_bit()/__set_bit(). Few additional flags might be added later. Flags are intended to be mutually exclusive. Signed-off-by: Roman Gushchin --- include/linux/memcontrol.h | 34 +++--- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/include/li

[PATCH rfc 1/5] mm: memcg/slab: fix racy access to page->mem_cgroup in mem_cgroup_from_obj()

2020-09-10 Thread Roman Gushchin
a slab object and page->mem_cgroup is NULL, it means that the object is not accounted, so the function must return NULL. I've discovered the race looking at the code, so far I haven't seen it in the wild. Fixes: 10befea91b61 ("mm: memcg/slab: use a single set of kmem_caches for all allocations&q

[PATCH rfc 0/5] mm: allow mapping accounted kernel pages to userspace

2020-09-10 Thread Roman Gushchin
and removes a couple of obsolete functions. As the result the code became more robust with fewer open-coded bits tricks. The first patch in the series is a bugfix, which I already sent separately. Including it in rfc to make the whole series compile. Roman Gushchin (5): mm: memcg/slab: fix

[PATCH rfc 3/5] mm: memcontrol/slab: use helpers to access slab page's memcg_data

2020-09-10 Thread Roman Gushchin
-by: Roman Gushchin --- include/linux/memcontrol.h | 48 ++ mm/memcontrol.c| 4 ++-- mm/slab.h | 27 +++-- 3 files changed, 53 insertions(+), 26 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux

[PATCH] mm: memcg/slab: fix racy access to page->mem_cgroup in mem_cgroup_from_obj()

2020-09-09 Thread Roman Gushchin
a slab object and page->mem_cgroup is NULL, it means that the object is not accounted, so the function must return NULL. I've discovered the race looking at the code, so far I haven't seen it in the wild. Fixes: 10befea91b61 ("mm: memcg/slab: use a single set of kmem_caches for all allocations&q

Re: [PATCH] mm: workingset: ignore slab memory size when calculating shadows pressure

2020-09-09 Thread Roman Gushchin
On Wed, Sep 09, 2020 at 10:55:34AM -0400, Johannes Weiner wrote: > On Thu, Sep 03, 2020 at 04:00:55PM -0700, Roman Gushchin wrote: > > In the memcg case count_shadow_nodes() sums the number of pages in lru > > lists and the amount of slab memory (reclaimable and non-reclaimable) &g

Re: [RFC PATCH 00/16] 1GB THP support on x86_64

2020-09-08 Thread Roman Gushchin
On Tue, Sep 08, 2020 at 11:09:25AM -0400, Zi Yan wrote: > On 7 Sep 2020, at 3:20, Michal Hocko wrote: > > > On Fri 04-09-20 14:10:45, Roman Gushchin wrote: > >> On Fri, Sep 04, 2020 at 09:42:07AM +0200, Michal Hocko wrote: > > [...] > >>> An explicit op

Re: [PATCH] mm: memcg: yield cpu when we fail to charge pages

2020-09-08 Thread Roman Gushchin
ort comment here? Something like "give oom_reaper a chance on a non-SMP system"? > /* >* keep retrying as long as the memcg oom killer is able to make >* a forward progress or bypass the charge if the oom killer > -- > 2.17.1 > The patch makes total sense to me. Please, feel free to add Acked-by: Roman Gushchin after adding a comment. Thank you!

Re: [RFC PATCH 00/16] 1GB THP support on x86_64

2020-09-04 Thread Roman Gushchin
On Fri, Sep 04, 2020 at 09:42:07AM +0200, Michal Hocko wrote: > On Thu 03-09-20 09:25:27, Roman Gushchin wrote: > > On Thu, Sep 03, 2020 at 09:32:54AM +0200, Michal Hocko wrote: > > > On Wed 02-09-20 14:06:12, Zi Yan wrote: > > > > From: Z

Re: [PATCH] mm: workingset: ignore slab memory size when calculating shadows pressure

2020-09-03 Thread Roman Gushchin
On Thu, Sep 03, 2020 at 09:10:59PM -0700, Andrew Morton wrote: > On Thu, 3 Sep 2020 16:00:55 -0700 Roman Gushchin wrote: > > > In the memcg case count_shadow_nodes() sums the number of pages in lru > > lists and the amount of slab memory (reclaimable and non-reclaimable)

[PATCH] mm: workingset: ignore slab memory size when calculating shadows pressure

2020-09-03 Thread Roman Gushchin
adow_nodes(). Signed-off-by: Roman Gushchin Cc: Johannes Weiner Cc: Michal Hocko Cc: Shakeel Butt --- mm/workingset.c | 4 1 file changed, 4 deletions(-) diff --git a/mm/workingset.c b/mm/workingset.c index 92e66113a577..50d53f3699e4 100644 --- a/mm/workingset.c +++ b/mm/workingset.c

Re: [RFC PATCH] cma: make number of CMA areas dynamic, remove CONFIG_CMA_AREAS

2020-09-03 Thread Roman Gushchin
is likely to grow. Instead of > using a static array for cma areas, use a simple linked list. These > areas are used before normal memory allocators, so use the memblock > allocator. > > Signed-off-by: Mike Kravetz Sounds like a good idea! That 7 always confused me. Acked-by: Roman G

Re: [RFC PATCH 00/16] 1GB THP support on x86_64

2020-09-03 Thread Roman Gushchin
On Thu, Sep 03, 2020 at 05:23:00PM +0300, Kirill A. Shutemov wrote: > On Wed, Sep 02, 2020 at 02:06:12PM -0400, Zi Yan wrote: > > From: Zi Yan > > > > Hi all, > > > > This patchset adds support for 1GB THP on x86_64. It is on top of > > v5.9-rc2-mmots-2020-08-25-21-13. > > > > 1GB THP is more

Re: [RFC PATCH 00/16] 1GB THP support on x86_64

2020-09-03 Thread Roman Gushchin
On Thu, Sep 03, 2020 at 09:32:54AM +0200, Michal Hocko wrote: > On Wed 02-09-20 14:06:12, Zi Yan wrote: > > From: Zi Yan > > > > Hi all, > > > > This patchset adds support for 1GB THP on x86_64. It is on top of > > v5.9-rc2-mmots-2020-08-25-21-13. > > > > 1GB THP is more flexible for reducing

[PATCH v1 3/4] mm: kmem: prepare remote memcg charging infra for interrupt contexts

2020-08-27 Thread Roman Gushchin
to get it depending on the current context. Signed-off-by: Roman Gushchin Reviewed-by: Shakeel Butt --- include/linux/sched/mm.h | 13 +-- mm/memcontrol.c | 48 2 files changed, 45 insertions(+), 16 deletions(-) diff --git a/include/linux/sched/

[PATCH v1 2/4] mm: kmem: remove redundant checks from get_obj_cgroup_from_current()

2020-08-27 Thread Roman Gushchin
There are checks for current->mm and current->active_memcg in get_obj_cgroup_from_current(), but these checks are redundant: memcg_kmem_bypass() called just above performs same checks. Signed-off-by: Roman Gushchin Reviewed-by: Shakeel Butt --- mm/memcontrol.c | 3 --- 1 file chan

[PATCH v1 4/4] mm: kmem: enable kernel memcg accounting from interrupt contexts

2020-08-27 Thread Roman Gushchin
of the memory pressure and an inability to put the workload under the limit will eventually trigger the OOM. To use active_memcg() helper, memcg_kmem_bypass() is moved back to memcontrol.c. Signed-off-by: Roman Gushchin Reviewed-by: Shakeel Butt --- include/linux/memcontrol.h | 12 mm

[PATCH v1 1/4] mm: kmem: move memcg_kmem_bypass() calls to get_mem/obj_cgroup_from_current()

2020-08-27 Thread Roman Gushchin
Currently memcg_kmem_bypass() is called before obtaining the current memory/obj cgroup using get_mem/obj_cgroup_from_current(). Moving memcg_kmem_bypass() into get_mem/obj_cgroup_from_current() reduces the number of call sites and allows further code simplifications. Signed-off-by: Roman Gushchin

[PATCH v1 0/4] mm: kmem: kernel memory accounting in an interrupt context

2020-08-27 Thread Roman Gushchin
for it. The bpf memory accounting will likely be the first user of it: a typical example is a bpf program parsing an incoming network packet, which allocates an entry in hashmap map to store some information. v1: - fixed a typo, by Shakeel rfc: https://lkml.org/lkml/2020/8/27/1155 Roman Gushchin (4

Re: [PATCH RFC 3/4] mm: kmem: prepare remote memcg charging infra for interrupt contexts

2020-08-27 Thread Roman Gushchin
On Thu, Aug 27, 2020 at 02:58:50PM -0700, Shakeel Butt wrote: > On Thu, Aug 27, 2020 at 10:52 AM Roman Gushchin wrote: > > > > Remote memcg charging API uses current->active_memcg to store the > > currently active memory cgroup, which overwrites the memory cgroup &g

[PATCH RFC 3/4] mm: kmem: prepare remote memcg charging infra for interrupt contexts

2020-08-27 Thread Roman Gushchin
to get it depending on the current context. Signed-off-by: Roman Gushchin --- include/linux/sched/mm.h | 13 +-- mm/memcontrol.c | 48 2 files changed, 45 insertions(+), 16 deletions(-) diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h

[PATCH RFC 2/4] mm: kmem: remove redundant checks from get_obj_cgroup_from_current()

2020-08-27 Thread Roman Gushchin
There are checks for current->mm and current->active_memcg in get_obj_cgroup_from_current(), but these checks are redundant: memcg_kmem_bypass() called just above performs same checks. Signed-off-by: Roman Gushchin --- mm/memcontrol.c | 3 --- 1 file changed, 3 deletions(-) diff --gi

[PATCH RFC 4/4] mm: kmem: enable kernel memcg accounting from interrupt contexts

2020-08-27 Thread Roman Gushchin
of the memory pressure and an inability to put the workload under the limit will eventually trigger the OOM. To use active_memcg() helper, memcg_kmem_bypass() is moved back to memcontrol.c. Signed-off-by: Roman Gushchin --- include/linux/memcontrol.h | 12 mm/memcontrol.c| 13

[PATCH RFC 0/4] mm: kmem: kernel memory accounting in an interrupt context

2020-08-27 Thread Roman Gushchin
for it. The bpf memory accounting will likely be the first user of it: a typical example is a bpf program parsing an incoming network packet, which allocates an entry in hashmap map to store some information. Roman Gushchin (4): mm: kmem: move memcg_kmem_bypass() calls to get_mem

[PATCH RFC 1/4] mm: kmem: move memcg_kmem_bypass() calls to get_mem/obj_cgroup_from_current()

2020-08-27 Thread Roman Gushchin
Currently memcg_kmem_bypass() is called before obtaining the current memory/obj cgroup using get_mem/obj_cgroup_from_current(). Moving memcg_kmem_bypass() into get_mem/obj_cgroup_from_current() reduces the number of call sites and allows further code simplifications. Signed-off-by: Roman Gushchin

Re: [PATCH bpf-next v4 03/30] bpf: memcg-based memory accounting for bpf maps

2020-08-25 Thread Roman Gushchin
On Tue, Aug 25, 2020 at 04:27:09PM -0700, Shakeel Butt wrote: > On Fri, Aug 21, 2020 at 8:01 AM Roman Gushchin wrote: > > > > This patch enables memcg-based memory accounting for memory allocated > > by __bpf_map_area_alloc(), which is used by most map types for

<    1   2   3   4   5   6   7   8   9   10   >