Re: [PATCH] zswap: only save zswap header if zpool is shrinkable

2018-01-10 Thread Yu Zhao
On Wed, Jan 10, 2018 at 03:06:47PM -0500, Dan Streetman wrote: > On Tue, Jan 9, 2018 at 5:47 PM, Yu Zhao wrote: > > On Tue, Jan 09, 2018 at 01:25:18PM -0500, Dan Streetman wrote: > >> On Mon, Jan 8, 2018 at 5:51 PM, Yu Zhao wrote: > >> > We waste sizeof(swp_entry_

[PATCH v2] zswap: only save zswap header when necessary

2018-01-10 Thread Yu Zhao
We waste sizeof(swp_entry_t) for zswap header when using zsmalloc as zpool driver because zsmalloc doesn't support eviction. Add zpool_evictable() to detect if zpool is potentially evictable, and use it in zswap to avoid waste memory for zswap header. Signed-off-by: Yu Zhao --- include/

[PATCH v3] zswap: only save zswap header when necessary

2018-01-10 Thread Yu Zhao
We waste sizeof(swp_entry_t) for zswap header when using zsmalloc as zpool driver because zsmalloc doesn't support eviction. Add zpool_evictable() to detect if zpool is potentially evictable, and use it in zswap to avoid waste memory for zswap header. Signed-off-by: Yu Zhao --- include/

Re: [PATCH v2] zswap: only save zswap header when necessary

2018-01-10 Thread Yu Zhao
On Wed, Jan 10, 2018 at 02:47:41PM -0800, Yu Zhao wrote: > We waste sizeof(swp_entry_t) for zswap header when using zsmalloc > as zpool driver because zsmalloc doesn't support eviction. > > Add zpool_evictable() to detect if zpool is potentially evictable, > and use it in

[PATCH v4] memcg: refactor mem_cgroup_resize_limit()

2018-01-08 Thread Yu Zhao
mem_cgroup_resize_limit() and mem_cgroup_resize_memsw_limit() have identical logics. Refactor code so we don't need to keep two pieces of code that does same thing. Signed-off-by: Yu Zhao Acked-by: Vladimir Davydov Acked-by: Michal Hocko --- mm/memcontrol.c

[PATCH] zswap: only save zswap header if zpool is shrinkable

2018-01-08 Thread Yu Zhao
We waste sizeof(swp_entry_t) for zswap header when using zsmalloc as zpool driver because zsmalloc doesn't support eviction. Add zpool_shrinkable() to detect if zpool is shrinkable, and use it in zswap to avoid waste memory for zswap header. Signed-off-by: Yu Zhao --- include/linux/zp

[PATCH] mm: don't expose page to fast gup before it's ready

2018-01-08 Thread Yu Zhao
renced() Fix the problem by delaying set_pte_at() until page is ready. Signed-off-by: Yu Zhao --- mm/memory.c | 2 +- mm/swapfile.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index ca5674cbaff2..b8be1a4adf93 100644 --- a/mm/memory.c +++

Re: [PATCH] mm: don't expose page to fast gup before it's ready

2018-01-09 Thread Yu Zhao
On Tue, Jan 09, 2018 at 09:46:22AM +0100, Michal Hocko wrote: > On Mon 08-01-18 14:56:32, Yu Zhao wrote: > > We don't want to expose page before it's properly setup. During > > page setup, we may call page_add_new_anon_rmap() which uses non- > > atomic bit op. If p

Re: [PATCH] zswap: only save zswap header if zpool is shrinkable

2018-01-09 Thread Yu Zhao
On Tue, Jan 09, 2018 at 01:48:17PM +0900, Sergey Senozhatsky wrote: > On (01/08/18 14:51), Yu Zhao wrote: > [..] > > int zpool_shrink(struct zpool *zpool, unsigned int pages, > > unsigned int *reclaimed) > > { > > - return zpool->driver->

Re: [PATCH] zswap: only save zswap header if zpool is shrinkable

2018-01-09 Thread Yu Zhao
On Tue, Jan 09, 2018 at 01:25:18PM -0500, Dan Streetman wrote: > On Mon, Jan 8, 2018 at 5:51 PM, Yu Zhao wrote: > > We waste sizeof(swp_entry_t) for zswap header when using zsmalloc > > as zpool driver because zsmalloc doesn't support eviction. > > > > Add zpool_sh

Re: [PATCH] mmc: add quirk for O2 Micro dev 0x8620 rev 0x01

2018-09-26 Thread Yu Zhao
On Thu, Sep 27, 2018 at 01:48:58AM +0200, Ulf Hansson wrote: > On 23 September 2018 at 22:39, Yu Zhao wrote: > > This device reports SDHCI_CLOCK_INT_STABLE even though it's not > > ready to take SDHCI_CLOCK_CARD_EN. The symptom is that reading > > SDHCI_CLOCK_CONTRO

[PATCH] cfg80211: fix use-after-free in reg_process_hint()

2018-09-27 Thread Yu Zhao
0xdc/0x470 reg_process_hint+0x31e/0x8aa [cfg80211] reg_todo+0x204/0x5b9 [cfg80211] process_one_work+0x55f/0x8d0 worker_thread+0x5dd/0x841 kthread+0x270/0x285 ret_from_fork+0x22/0x40 Signed-off-by: Yu Zhao --- net/wireless/reg.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ne

Re: [PATCH v2] mm: fix swap offset when replacing shmem page

2018-11-19 Thread Yu Zhao
On Mon, Nov 19, 2018 at 02:11:27PM -0800, Hugh Dickins wrote: > On Sun, 18 Nov 2018, Yu Zhao wrote: > > > We used to have a single swap address space with swp_entry_t.val > > as its radix tree index. This is not the case anymore. Now Each > > swp_type() has its own addr

[PATCH v3] mm: use swp_offset as key in shmem_replace_page()

2018-11-21 Thread Yu Zhao
We changed key of swap cache tree from swp_entry_t.val to swp_offset. Need to do so in shmem_replace_page() as well. Fixes: f6ab1f7f6b2d ("mm, swap: use offset of swap entry as key of swap cache") Cc: sta...@vger.kernel.org # v4.9+ Signed-off-by: Yu Zhao --- mm/shmem.c | 6

[PATCH] mm: remove pte_lock_deinit()

2018-11-28 Thread Yu Zhao
Pagetable page doesn't touch page->mapping or have any used field that overlaps with it. No need to clear mapping in dtor. In fact, doing so might mask problems that otherwise would be detected by bad_page(). Signed-off-by: Yu Zhao --- include/linux/mm.h | 11 ++- 1 file ch

[PATCH] mm: fix swap offset when replacing shmem page

2018-11-18 Thread Yu Zhao
We used to have a single swap address space with swp_entry_t.val as its radix tree index. This is not the case anymore. Now Each swp_type() has its own address space and should use swp_offset() as radix tree index. Signed-off-by: Yu Zhao --- mm/shmem.c | 11 +++ 1 file changed, 7

[PATCH v2] mm: fix swap offset when replacing shmem page

2018-11-18 Thread Yu Zhao
We used to have a single swap address space with swp_entry_t.val as its radix tree index. This is not the case anymore. Now Each swp_type() has its own address space and should use swp_offset() as radix tree index. Signed-off-by: Yu Zhao --- mm/shmem.c | 11 +++ 1 file changed, 7

[PATCH 1/2] ASoC: use DMA addr rather than CPU pa for acp_audio_dma

2018-12-04 Thread Yu Zhao
7;s most likely different from CPU physical address when AMD IOMMU is not in passthrough mode. Signed-off-by: Yu Zhao --- sound/soc/amd/acp-pcm-dma.c | 15 +-- sound/soc/amd/acp.h | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/sound/soc/amd/acp-pcm-dma.c b/so

[PATCH 2/2] ASoC: use dma_ops of parent device for acp_audio_dma

2018-12-04 Thread Yu Zhao
les null struct device or uses the default dma_ops if struct device doesn't have it set. Signed-off-by: Yu Zhao --- sound/soc/amd/acp-pcm-dma.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index fd3db4

[PATCH v2] iommu: fix amd_iommu=force_isolation

2018-12-06 Thread Yu Zhao
This option does not override iommu=pt Fixes: aafd8ba0ca74 ("iommu/amd: Implement add_device and remove_device") Signed-off-by: Yu Zhao --- drivers/iommu/amd_iommu.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/amd_iommu.c b/drivers/io

[PATCH 1/3] drm/amd: fix race in page flip job

2018-12-20 Thread Yu Zhao
e job will eventually times out. Reverse the order of calling page_flip and setting pflip_status to fix the race. Signed-off-by: Yu Zhao --- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display

[PATCH 3/3] drm/amd: validate user GEM object size

2018-12-20 Thread Yu Zhao
path because individual driver might have different requirement. Signed-off-by: Yu Zhao --- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 8 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c index

[PATCH 2/3] drm/amd: validate user pitch alignment

2018-12-20 Thread Yu Zhao
memory will cause memory corruption. Signed-off-by: Yu Zhao --- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c index e309d26170db..755daa332f8a

Re: [PATCH 2/3] drm/amd: validate user pitch alignment

2018-12-21 Thread Yu Zhao
On Fri, Dec 21, 2018 at 10:07:26AM +0100, Michel Dänzer wrote: > On 2018-12-21 4:10 a.m., Yu Zhao wrote: > > Userspace may request pitch alignment that is not supported by GPU. > > Some requests 32, but GPU ignores it and uses default 64 when cpp is > > 4. If GEM object is a

[PATCH v2 1/2] drm/amd: validate user pitch alignment

2018-12-21 Thread Yu Zhao
memory will cause memory corruption. Signed-off-by: Yu Zhao --- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c index 686a26de50f9..883a4df2386d

[PATCH v2 2/2] drm/amd: validate user GEM object size

2018-12-21 Thread Yu Zhao
path because individual driver might have different requirement. Signed-off-by: Yu Zhao --- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 8 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c index

[PATCH v3 1/2] drm/amd: validate user pitch alignment

2018-12-22 Thread Yu Zhao
memory will cause memory corruption. Cc: sta...@vger.kernel.org # v4.2+ Signed-off-by: Yu Zhao --- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c

[PATCH v3 2/2] drm/amd: validate user GEM object size

2018-12-22 Thread Yu Zhao
path because individual driver might have different requirement. Cc: sta...@vger.kernel.org # v4.2+ Signed-off-by: Yu Zhao --- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 8 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd

Re: [PATCH 2/3] drm/amd: validate user pitch alignment

2018-12-23 Thread Yu Zhao
On Fri, Dec 21, 2018 at 10:07:26AM +0100, Michel Dänzer wrote: > On 2018-12-21 4:10 a.m., Yu Zhao wrote: > > Userspace may request pitch alignment that is not supported by GPU. > > Some requests 32, but GPU ignores it and uses default 64 when cpp is > > 4. If GEM object is a

[PATCH v4 2/2] drm/amd: validate user GEM object size

2018-12-23 Thread Yu Zhao
path because individual driver might have different requirement. Cc: sta...@vger.kernel.org # v4.2+ Signed-off-by: Yu Zhao --- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 8 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd

[PATCH v4 1/2] drm/amd: validate user pitch alignment

2018-12-23 Thread Yu Zhao
memory will cause memory corruption. Cc: sta...@vger.kernel.org # v4.2+ Signed-off-by: Yu Zhao --- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c

Re: [PATCH v5 1/2] drm/amd: validate user pitch alignment

2019-01-06 Thread Yu Zhao
On Thu, Jan 03, 2019 at 05:33:19PM +0100, Michel Dänzer wrote: > On 2018-12-30 2:00 a.m., Yu Zhao wrote: > > Userspace may request pitch alignment that is not supported by GPU. > > Some requests 32, but GPU ignores it and uses default 64 when cpp is > > 4. If GEM object is a

[PATCH v6 2/2] drm/amd: validate user GEM object size

2019-01-07 Thread Yu Zhao
because individual driver might have different requirement. Cc: sta...@vger.kernel.org # v4.2+ Signed-off-by: Yu Zhao --- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 8 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu

[PATCH v6 1/2] drm/amd: validate user pitch alignment

2019-01-07 Thread Yu Zhao
Userspace may request pitch alignment that is not supported by GPU. Some requests 32, but GPU ignores it and uses default 64 when cpp is 4. If GEM object is allocated based on the smaller alignment, GPU DMA will go out of bound. Cc: sta...@vger.kernel.org # v4.2+ Signed-off-by: Yu Zhao

[PATCH v5 2/2] drm/amd: validate user GEM object size

2018-12-29 Thread Yu Zhao
because individual driver might have different requirement. Cc: sta...@vger.kernel.org # v4.2+ Signed-off-by: Yu Zhao --- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 8 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu

[PATCH v5 1/2] drm/amd: validate user pitch alignment

2018-12-29 Thread Yu Zhao
Userspace may request pitch alignment that is not supported by GPU. Some requests 32, but GPU ignores it and uses default 64 when cpp is 4. If GEM object is allocated based on the smaller alignment, GPU DMA will go out of bound. Cc: sta...@vger.kernel.org # v4.2+ Signed-off-by: Yu Zhao

[PATCH] mm: detect numbers of vmstat keys/values mismatch

2018-10-15 Thread Yu Zhao
ct such mismatch and hopefully prevent it from happening again. Signed-off-by: Yu Zhao --- include/linux/vmstat.h | 4 mm/vmstat.c| 18 -- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index f25cef

Re: [PATCH] mm: detect numbers of vmstat keys/values mismatch

2018-10-15 Thread Yu Zhao
On Mon, Oct 15, 2018 at 08:41:52PM +0200, Jann Horn wrote: > On Mon, Oct 15, 2018 at 8:38 PM Yu Zhao wrote: > > There were mismatches between number of vmstat keys and number of > > vmstat values. They were fixed recently by: > > commit 58bc4c34d249 ("mm/vmstat.c

Re: [PATCH v3 6/7] KVM: arm64: Participate in bitmap-based PTE aging

2024-04-01 Thread Yu Zhao
gt; When mkold == true, only age the pages that need aging according to the > passed-in bitmap. > > Suggested-by: Yu Zhao Thanks but I did not suggest this. What I have in v2 is RCU based. I hope Oliver or someone else can help make that work. Otherwise we can just drop this for now and r

Re: [PATCH v3 5/7] KVM: x86: Participate in bitmap-based PTE aging

2024-04-20 Thread Yu Zhao
On Fri, Apr 19, 2024 at 3:48 PM James Houghton wrote: > > On Fri, Apr 19, 2024 at 2:07 PM David Matlack wrote: > > > > On 2024-04-19 01:47 PM, James Houghton wrote: > > > On Thu, Apr 11, 2024 at 10:28 AM David Matlack > > > wrote: > > > > On 2024-04-11 10:08 AM, David Matlack wrote: > > > > boo

Re: [PATCH v4] vmscan: add trace events for lru_gen

2023-10-01 Thread Yu Zhao
On Sun, Oct 1, 2023 at 5:41 PM Jaewon Kim wrote: > > Hello Yu Zhao > > Could you give me your comment? I am waiting for your opinion on the > reuse method. I'm planning to resend it as a complete patch with it. > Thank you. Acked-by: Yu Zhao

Re: [PATCH 2/2] mm: multi-gen lru: fix stat count

2023-10-18 Thread Yu Zhao
On Wed, Oct 18, 2023 at 2:22 AM Huan Yang wrote: > > For multi-gen lru reclaim in evict_folios, like shrink_inactive_list, > gather folios which isolate to reclaim, and invoke shirnk_folio_list. > > But, when complete shrink, it not gather shrink reclaim stat into sc, > we can't get info like nr_d

Re: [PATCH 1/2] tracing: mm: multigen-lru: fix mglru trace

2023-10-18 Thread Yu Zhao
On Wed, Oct 18, 2023 at 2:22 AM Huan Yang wrote: > > This patch add two reclaim stat: > nr_promote: nr_pages shrink before promote by folio_update_gen. > nr_demote: nr_pages NUMA demotion passed. The above isn't specific to MLGRU, so they should be in a separate patchset. > And then, use correct

Re: [PATCH 2/2] mm: multi-gen lru: fix stat count

2023-10-18 Thread Yu Zhao
On Wed, Oct 18, 2023 at 8:17 PM Huan Yang wrote: > > Hi Yu Zhao, > > Thanks for your reply. > > 在 2023/10/19 0:21, Yu Zhao 写道: > > On Wed, Oct 18, 2023 at 2:22 AM Huan Yang wrote: > >> For multi-gen lru reclaim in evict_folios, like shrink_inactive_list, &g

Re: [PATCH -next v4 2/2] mm: vmscan: add new event to trace shrink lru

2023-12-20 Thread Yu Zhao
On Tue, Dec 19, 2023 at 6:22 PM Bixuan Cui wrote: > > From: cuibixuan > > Add a new event to calculate the shrink_inactive_list()/shrink_active_list() > execution time. > > Example of output: > kswapd0-103 [007] . 1098.353020: > mm_vmscan_lru_shrink_active_start: nid=0 >

Re: [PATCH v2] nvdimm: Support sizeof(struct page) > MAX_STRUCT_PAGE_SIZE

2023-01-25 Thread Yu Zhao
e9f05dc66f9 ("libnvdimm/pfn_dev: increase MAX_STRUCT_PAGE_SIZE") > Cc: > Cc: Alexander Potapenko > Cc: Marco Elver > Reported-by: Jeff Moyer Thanks -- that BUILD_BUG_ON() has been a nuisance for some of my debug configs. Acked-by: Yu Zhao

Re: [PATCH v4] vmscan: add trace events for lru_gen

2023-09-25 Thread Yu Zhao
On Mon, Sep 25, 2023 at 10:20 PM Jaewon Kim wrote: > > As the legacy lru provides, the lru_gen needs some trace events for > debugging. > > This commit introduces 2 trace events. > trace_mm_vmscan_lru_gen_scan > trace_mm_vmscan_lru_gen_evict > > Each event is similar to the following legacy ev

Re: [PATCH v2 03/10] mm: don't pass "enum lru_list" to lru list addition functions

2021-02-23 Thread Yu Zhao
On Tue, Feb 23, 2021 at 02:50:11PM -0800, Andrew Morton wrote: > On Tue, 26 Jan 2021 15:14:38 -0700 Yu Zhao wrote: > > > On Tue, Jan 26, 2021 at 10:01:11PM +, Matthew Wilcox wrote: > > > On Fri, Jan 22, 2021 at 03:05:53PM -0700, Yu Zhao wrote: > > > > +++ b/m

Re: [PATCH v2 03/10] mm: don't pass "enum lru_list" to lru list addition functions

2021-02-24 Thread Yu Zhao
On Wed, Feb 24, 2021 at 04:06:45PM +0800, Alex Shi wrote: > > > 在 2021/2/24 下午1:29, Yu Zhao 写道: > > On Tue, Feb 23, 2021 at 02:50:11PM -0800, Andrew Morton wrote: > >> On Tue, 26 Jan 2021 15:14:38 -0700 Yu Zhao wrote: > >> > >>> On Tue, Jan 26, 2

[PATCH] mm: test page->flags directly in page_lru()

2021-02-24 Thread Yu Zhao
scripts/bloat-o-meter results before and after the entire series: Glang: add/remove: 0/1 grow/shrink: 7/10 up/down: 191/-1189 (-998) GCC: add/remove: 0/1 grow/shrink: 9/9 up/down: 1010/-783 (227) Signed-off-by: Yu Zhao --- include/linux/mm_inline.h | 21 +++-- 1 file changed, 7 in

Re: [PATCH] mm: test page->flags directly in page_lru()

2021-02-24 Thread Yu Zhao
On Wed, Feb 24, 2021 at 05:15:58AM -0800, Andrew Morton wrote: > On Wed, 24 Feb 2021 01:48:07 -0700 Yu Zhao wrote: > > > Currently page_lru() uses Page{Active,Unevictable} to determine which > > lru list a page belongs to. Page{Active,Unevictable} contain > > compo

Re: [PATCH] mm: test page->flags directly in page_lru()

2021-02-24 Thread Yu Zhao
On Wed, Feb 24, 2021 at 09:56:39PM +, Matthew Wilcox wrote: > On Wed, Feb 24, 2021 at 05:15:58AM -0800, Andrew Morton wrote: > > Here's what the preprocessor produces for an allmodconfig version of > > PageActive(): > > > > static inline __attribute__((__gnu_inline__)) __attribute__((__unused_

Re: [PATCH] mm: test page->flags directly in page_lru()

2021-02-24 Thread Yu Zhao
On Wed, Feb 24, 2021 at 10:48:46PM +, Matthew Wilcox wrote: > On Wed, Feb 24, 2021 at 03:34:16PM -0700, Yu Zhao wrote: > > > If only somebody were working on a patch series to get rid of > > > all those calls to compound_head()! Some reviews on > > > ht

Re: [PATCH] mm: test page->flags directly in page_lru()

2021-02-24 Thread Yu Zhao
On Thu, Feb 25, 2021 at 03:55:53AM +, Matthew Wilcox wrote: > On Wed, Feb 24, 2021 at 04:50:39PM -0700, Yu Zhao wrote: > > On Wed, Feb 24, 2021 at 10:48:46PM +, Matthew Wilcox wrote: > > > On Wed, Feb 24, 2021 at 03:34:16PM -0700, Yu Zhao wrote: > > > > > I

Re: [page-reclaim] Augmented Page Reclaim

2021-02-09 Thread Yu Zhao
On Tue, Feb 09, 2021 at 01:32:58PM -0800, Jesse Barnes wrote: > > == > > Augmented Page Reclaim > > == > > We would like to share a work with you and see if there is enough > > interest to warrant a run for the mainline. This work is a part of > > result from

Re: Augmented Page Reclaim

2021-02-02 Thread Yu Zhao
On Tue, Feb 02, 2021 at 01:57:15AM -0700, Yu Zhao wrote: > > > Versatility > > === > > Userspace can trigger aging and eviction independently via the > > ``debugfs`` interface [note]_ for working set estimation, proactive > > 1. `Long-term SLOs for re

Augmented Page Reclaim

2021-02-02 Thread Yu Zhao
== Augmented Page Reclaim == We would like to share a work with you and see if there is enough interest to warrant a run for the mainline. This work is a part of result from a decade of research and experimentation in memory overcommit at Google: an augmented

[PATCH v2 1/3] mm: bypass compound_head() for PF_NO_TAIL when enforce=1

2021-02-26 Thread Yu Zhao
evidence such "correction" is beneficial. bloat-o-meter result: add/remove: 0/0 grow/shrink: 4/62 up/down: 309/-2851 (-2542) Signed-off-by: Yu Zhao --- include/linux/page-flags.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/page-flags.h b/includ

[PATCH v2 0/3] trim the uses of compound_head()

2021-02-26 Thread Yu Zhao
-hanging fruit, this v2 removes compound_head() completely from Page{Active,Unevictable}. bloat-o-meter result before and after the series: add/remove: 0/0 grow/shrink: 6/92 up/down: 697/-7656 (-6959) Yu Zhao (3): mm: bypass compound_head() for PF_NO_TAIL when enforce=1 mm: use PF_NO_TA

[PATCH v2 2/3] mm: use PF_NO_TAIL for PG_lru

2021-02-26 Thread Yu Zhao
helpful -- even if a piece of buggy code has gotten away with compound_page(tail)->flags, it will run into trouble with lru list addition and deletion because they use tail->lru rather than compound_page(tail)->lru. bloat-o-meter result: add/remove: 0/0 grow/shrink: 0/11 up/down

[PATCH v2 3/3] mm: use PF_ONLY_HEAD for PG_active and PG_unevictable

2021-02-26 Thread Yu Zhao
All places but one test, set or clear PG_active and PG_unevictable on small or head pages. Use compound_head() explicitly for that singleton so the rest can rid of redundant compound_head(). bloat-o-meter result: add/remove: 0/0 grow/shrink: 3/38 up/down: 388/-4270 (-3882) Signed-off-by: Yu

Re: [PATCH v2 0/3] trim the uses of compound_head()

2021-02-26 Thread Yu Zhao
On Fri, Feb 26, 2021 at 11:52:03AM +0100, Vlastimil Babka wrote: > On 2/26/21 10:17 AM, Yu Zhao wrote: > > Patch series "mm: lru related cleanups" starting at commit 42895ea73bcd > > ("mm/vmscan.c: use add_page_to_lru_list()") bloated vmlinux by 1777 > &

Re: [PATCH v2 3/3] mm: use PF_ONLY_HEAD for PG_active and PG_unevictable

2021-02-26 Thread Yu Zhao
On Fri, Feb 26, 2021 at 12:13:14PM +, Matthew Wilcox wrote: > On Fri, Feb 26, 2021 at 02:17:18AM -0700, Yu Zhao wrote: > > All places but one test, set or clear PG_active and PG_unevictable on > > small or head pages. Use compound_head() explicitly for that singleton > > s

Re: [PATCH v2 2/3] mm: use PF_NO_TAIL for PG_lru

2021-02-26 Thread Yu Zhao
On Fri, Feb 26, 2021 at 02:17:17AM -0700, Yu Zhao wrote: > Trying to set or clear PG_lru on tail pages has been considered buggy. > Enforce this rule by changing the policy for PG_lru from PF_HEAD to > PF_NO_TAIL. This means setting or clearing PG_lru on tail pages won't >

[PATCH 1/3] mm: don't call activate_page() on new ksm pages

2020-08-11 Thread Yu Zhao
lru_cache_add_active_or_unevictable() already adds new ksm pages to active lru. Calling activate_page() isn't really necessary in this case. Signed-off-by: Yu Zhao --- mm/swapfile.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/swapfile.c b/mm/swapf

[PATCH 2/3] mm: remove superfluous __ClearPageActive()

2020-08-11 Thread Yu Zhao
ive(), but it's irrelevant to LRU pages. Signed-off-by: Yu Zhao --- mm/memremap.c | 2 -- mm/swap.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/mm/memremap.c b/mm/memremap.c index 03e38b7a38f1..3a06eb91cb59 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -

[PATCH 3/3] mm: remove superfluous __ClearPageWaiters()

2020-08-11 Thread Yu Zhao
clearing to PAGE_FLAGS_CHECK_AT_PREP is more appropriate. Signed-off-by: Yu Zhao --- include/linux/page-flags.h | 2 +- mm/filemap.c | 2 ++ mm/memremap.c | 2 -- mm/swap.c | 3 --- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/include

Re: [PATCH v2 3/3] mm: remove superfluous __ClearPageWaiters()

2020-08-19 Thread Yu Zhao
On Wed, Aug 19, 2020 at 04:06:32PM -0700, Yang Shi wrote: > On Tue, Aug 18, 2020 at 11:47 AM Yu Zhao wrote: > > > > Presumably __ClearPageWaiters() was added to follow the previously > > removed __ClearPageActive() pattern. > > > > Only flags that are in PAG

Re: [PATCH v2 3/3] mm: remove superfluous __ClearPageWaiters()

2020-08-20 Thread Yu Zhao
On Thu, Aug 20, 2020 at 08:18:27AM +0200, Michal Hocko wrote: > On Tue 18-08-20 12:47:04, Yu Zhao wrote: > > Presumably __ClearPageWaiters() was added to follow the previously > > removed __ClearPageActive() pattern. > > I do not think so. Please have a look at 6

[PATCH v2 1/3] mm: remove activate_page() from unuse_pte()

2020-08-18 Thread Yu Zhao
mmit, we called lru_cache_add_active_or_unevictable() to add new ksm pages to active lruvec. Therefore, activate_page() wasn't necessary for them in the first place. Signed-off-by: Yu Zhao --- include/linux/swap.h | 1 - mm/swap.c| 4 ++-- mm/swapfile.c| 5 - 3 files c

[PATCH v2 2/3] mm: remove superfluous __ClearPageActive()

2020-08-18 Thread Yu Zhao
ive(), but it's irrelevant to LRU pages. Signed-off-by: Yu Zhao --- mm/memremap.c | 2 -- mm/swap.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/mm/memremap.c b/mm/memremap.c index 03e38b7a38f1..3a06eb91cb59 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -451,8 +451,6 @@ void free

[PATCH v2 3/3] mm: remove superfluous __ClearPageWaiters()

2020-08-18 Thread Yu Zhao
clearing to PAGE_FLAGS_CHECK_AT_PREP is more appropriate. Signed-off-by: Yu Zhao --- include/linux/page-flags.h | 2 +- mm/filemap.c | 2 ++ mm/memremap.c | 2 -- mm/swap.c | 3 --- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/include

Re: [PATCH v2 3/6] tlb: mmu_gather: Introduce tlb_gather_mmu_fullmm()

2020-12-10 Thread Yu Zhao
gt; + WARN_ON(!(start | (end + 1))); /* Use _fullmm() instead */ > + __tlb_gather_mmu(tlb, mm, start, end); > +} > + > +void tlb_gather_mmu_fullmm(struct mmu_gather *tlb, struct mm_struct *mm) > +{ > + __tlb_gather_mmu(tlb, mm, 0, -1); > +} > + IMO, there is no point adding the wrappers given you will remove the WARN_ON in the next patch. But if you prefer, they should be at least moved to the header for inlining. Consider this whole series Reviewed-by: Yu Zhao

Re: [PATCH] mm/userfaultfd: fix memory corruption due to writeprotect

2020-12-21 Thread Yu Zhao
On Mon, Dec 21, 2020 at 10:31:57AM -0800, Nadav Amit wrote: > > On Dec 21, 2020, at 9:27 AM, Peter Xu wrote: > > > > Hi, Nadav, > > > > On Sun, Dec 20, 2020 at 12:06:38AM -0800, Nadav Amit wrote: > > > > [...] > > > >> So to correct myself, I think that what I really encountered was actually >

Re: [PATCH] mm/userfaultfd: fix memory corruption due to writeprotect

2020-12-21 Thread Yu Zhao
On Mon, Dec 21, 2020 at 11:55:02AM -0800, Linus Torvalds wrote: > On Mon, Dec 21, 2020 at 11:16 AM Yu Zhao wrote: > > > > Nadav Amit found memory corruptions when running userfaultfd test above. > > It seems to me the problem is related to commit 09854ba94c6a ("mm: >

Re: [PATCH] mm/userfaultfd: fix memory corruption due to writeprotect

2020-12-21 Thread Yu Zhao
your patch (you might want to update the commit message). Reviewed-by: Yu Zhao While we are all here, there is also clear_soft_dirty() that could use a similar fix...

Re: [PATCH] mm/userfaultfd: fix memory corruption due to writeprotect

2020-12-21 Thread Yu Zhao
On Mon, Dec 21, 2020 at 05:30:41PM -0500, Peter Xu wrote: > On Mon, Dec 21, 2020 at 01:49:55PM -0800, Nadav Amit wrote: > > BTW: In general, I think that you are right, and that changing of PTEs > > should not require taking mmap_lock for write. However, I am not sure > > cow_user_page() is not the

Re: [PATCH] mm/userfaultfd: fix memory corruption due to writeprotect

2020-12-21 Thread Yu Zhao
On Mon, Dec 21, 2020 at 03:33:30PM -0800, Linus Torvalds wrote: > On Mon, Dec 21, 2020 at 3:12 PM Yu Zhao wrote: > > > > I can't say I disagree with you but the man has made the call and I > > think we should just move on. > > "The man" can always be

Re: [PATCH] mm/userfaultfd: fix memory corruption due to writeprotect

2020-12-21 Thread Yu Zhao
On Mon, Dec 21, 2020 at 04:11:01PM -0800, Linus Torvalds wrote: > On Mon, Dec 21, 2020 at 4:00 PM Yu Zhao wrote: > > > > My first instinct is to be conservative and revert 09854ba94c6a ("mm: > > do_wp_page() simplification") so people are less likely to c

Re: [PATCH] mm/userfaultfd: fix memory corruption due to writeprotect

2020-12-22 Thread Yu Zhao
On Tue, Dec 22, 2020 at 04:40:32AM -0800, Nadav Amit wrote: > > On Dec 21, 2020, at 1:24 PM, Yu Zhao wrote: > > > > On Mon, Dec 21, 2020 at 12:26:22PM -0800, Linus Torvalds wrote: > >> On Mon, Dec 21, 2020 at 12:23 PM Nadav Amit wrote: > >>> Using mmap_wr

Re: [PATCH] mm/userfaultfd: fix memory corruption due to writeprotect

2020-12-22 Thread Yu Zhao
On Tue, Dec 22, 2020 at 02:31:52PM -0500, Andrea Arcangeli wrote: > On Mon, Dec 21, 2020 at 07:19:35PM -0800, Andy Lutomirski wrote: > > instance of this (with mmap_sem held for write) in x86: > > mark_screen_rdonly(). Dare I ask how broken this is? We could likely > > That one is buggy despite

Re: [PATCH] mm/userfaultfd: fix memory corruption due to writeprotect

2020-12-22 Thread Yu Zhao
On Tue, Dec 22, 2020 at 05:02:37PM -0500, Andrea Arcangeli wrote: > On Tue, Dec 22, 2020 at 02:14:41PM -0700, Yu Zhao wrote: > > This works but I don't prefer this option because 1) this is new > > way of making pte_wrprotect safe and 2) it's specific to ufd an

Re: [PATCH] mm/userfaultfd: fix memory corruption due to writeprotect

2020-12-22 Thread Yu Zhao
On Tue, Dec 22, 2020 at 04:01:45PM -0800, Linus Torvalds wrote: > On Tue, Dec 22, 2020 at 3:50 PM Linus Torvalds > wrote: > > > > See zap_pte_range() for an example of doing it right, even in the > > presence of complexities (ie that has an example of both flushing the > > TLB, and doing the actua

Re: [PATCH] mm/userfaultfd: fix memory corruption due to writeprotect

2020-12-22 Thread Yu Zhao
On Tue, Dec 22, 2020 at 09:56:11PM -0500, Andrea Arcangeli wrote: > On Tue, Dec 22, 2020 at 04:39:46PM -0700, Yu Zhao wrote: > > We are talking about non-COW anon pages here -- they can't be mapped > > more than once. So why not just identify them by checking > > p

Re: [PATCH] mm/userfaultfd: fix memory corruption due to writeprotect

2020-12-23 Thread Yu Zhao
On Wed, Dec 23, 2020 at 01:44:42AM -0800, Linus Torvalds wrote: > On Tue, Dec 22, 2020 at 4:01 PM Linus Torvalds > wrote: > > > > The more I look at the mprotect code, the less I like it. We seem to > > be much better about the TLB flushes in other places (looking at > > mremap, for example). The

[PATCH 02/11] mm: shuffle lru list addition and deletion functions

2020-12-07 Thread Yu Zhao
These functions will call page_lru() in the following patches. Move them below page_lru() to avoid the forward declaration. Signed-off-by: Yu Zhao --- include/linux/mm_inline.h | 42 +++ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/include

[PATCH 04/11] mm: don't pass "enum lru_list" to trace_mm_lru_insertion()

2020-12-07 Thread Yu Zhao
The parameter is redundant in the sense that it can be extracted from the "struct page" parameter by page_lru() correctly. Signed-off-by: Yu Zhao --- include/trace/events/pagemap.h | 11 --- mm/swap.c | 5 + 2 files changed, 5 insertions(+), 11

[PATCH 03/11] mm: don't pass "enum lru_list" to lru list addition functions

2020-12-07 Thread Yu Zhao
et or cleared before calling these two functions. And they are indeed. Signed-off-by: Yu Zhao --- include/linux/mm_inline.h | 8 ++-- mm/swap.c | 15 +++ mm/vmscan.c | 6 ++ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/include

[PATCH 05/11] mm: don't pass "enum lru_list" to del_page_from_lru_list()

2020-12-07 Thread Yu Zhao
xes them. This patch may have left page_off_lru() seemingly odd, and we'll take care of it in the next patch. Signed-off-by: Yu Zhao --- include/linux/mm_inline.h | 5 +++-- mm/compaction.c | 2 +- mm/mlock.c| 3 +-- mm/swap.c | 26 ++

[PATCH 07/11] mm: VM_BUG_ON lru page flags

2020-12-07 Thread Yu Zhao
Move scattered VM_BUG_ONs to two essential places that cover all lru list additions and deletions. Signed-off-by: Yu Zhao --- include/linux/mm_inline.h | 4 mm/swap.c | 2 -- mm/vmscan.c | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a

[PATCH 11/11] mm: enlarge the "int nr_pages" parameter of update_lru_size()

2020-12-07 Thread Yu Zhao
int -> long) Note that __mod_node_page_state() for the smp case and __mod_zone_page_state() already use long. So this change also fixes the inconsistency. Signed-off-by: Yu Zhao --- include/linux/memcontrol.h | 10 +- include/linux/mm_inline.h | 2 +- include/linux/vmstat.h | 6

[PATCH 10/11] mm: make lruvec_lru_size() static

2020-12-07 Thread Yu Zhao
All other references to the function were removed after commit b910718a948a ("mm: vmscan: detect file thrashing at the reclaim root") Signed-off-by: Yu Zhao --- include/linux/mmzone.h | 2 -- mm/vmscan.c| 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git

[PATCH 08/11] mm: fold page_lru_base_type() into its sole caller

2020-12-07 Thread Yu Zhao
We've removed all other references to this function. Signed-off-by: Yu Zhao --- include/linux/mm_inline.h | 27 ++- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h index 6d907a4dd6ad..7183c7a

[PATCH 01/11] mm: use add_page_to_lru_list()

2020-12-07 Thread Yu Zhao
There is add_page_to_lru_list(), and move_pages_to_lru() should reuse it, not duplicate it. Signed-off-by: Yu Zhao --- mm/vmscan.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 469016222cdb..a174594e40f8 100644 --- a/mm/vmscan.c +++ b

[PATCH 09/11] mm: fold __update_lru_size() into its sole caller

2020-12-07 Thread Yu Zhao
All other references to the function were removed after commit a892cb6b977f ("mm/vmscan.c: use update_lru_size() in update_lru_sizes()") Signed-off-by: Yu Zhao --- include/linux/mm_inline.h | 9 + 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/include/linux/mm_

[PATCH 06/11] mm: add __clear_page_lru_flags() to replace page_off_lru()

2020-12-07 Thread Yu Zhao
change that is meant to help debug. Signed-off-by: Yu Zhao --- include/linux/mm_inline.h | 28 ++-- mm/swap.c | 6 ++ mm/vmscan.c | 3 +-- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/include/linux/mm_inline.h b

[PATCH 00/11] mm: lru related cleanups

2020-12-07 Thread Yu Zhao
;t strictly a clean-up patch, but it seems still relevant to include it here. Yu Zhao (11): mm: use add_page_to_lru_list() mm: shuffle lru list addition and deletion functions mm: don't pass "enum lru_list" to lru list addition functions mm: don't pass "enum lru_

Re: [PATCH] mm/userfaultfd: fix memory corruption due to writeprotect

2021-01-12 Thread Yu Zhao
On Tue, Jan 12, 2021 at 11:15:43AM -0800, Nadav Amit wrote: > > On Jan 12, 2021, at 11:02 AM, Laurent Dufour > > wrote: > > > > Le 12/01/2021 à 17:57, Peter Zijlstra a écrit : > >> On Tue, Jan 12, 2021 at 04:47:17PM +0100, Laurent Dufour wrote: > >>> Le 12/01/2021 à 12:43, Vinayak Menon a écrit

Re: [PATCH] mm/userfaultfd: fix memory corruption due to writeprotect

2021-01-12 Thread Yu Zhao
On Tue, Jan 12, 2021 at 12:38:34PM -0800, Nadav Amit wrote: > > On Jan 12, 2021, at 11:56 AM, Yu Zhao wrote: > > > > On Tue, Jan 12, 2021 at 11:15:43AM -0800, Nadav Amit wrote: > >>> On Jan 12, 2021, at 11:02 AM, Laurent Dufour > >>> wrote: > >&

Re: [PATCH] mm/userfaultfd: fix memory corruption due to writeprotect

2020-12-23 Thread Yu Zhao
On Wed, Dec 23, 2020 at 11:24:16AM -0500, Peter Xu wrote: > On Wed, Dec 23, 2020 at 03:06:30AM -0700, Yu Zhao wrote: > > On Wed, Dec 23, 2020 at 01:44:42AM -0800, Linus Torvalds wrote: > > > On Tue, Dec 22, 2020 at 4:01 PM Linus Torvalds > > > wrote: > > &

  1   2   3   4   >