Re: [PATCH 1/4] zswap bugfix: memory leaks when re-swapon

2013-08-25 Thread Weijie Yang
2013/8/23 Seth Jennings : > On Fri, Aug 23, 2013 at 07:03:37PM +0800, Weijie Yang wrote: >> zswap_tree is not freed when swapoff, and it got re-kzalloc in swapon, >> memory leak occurs. >> Add check statement in zswap_frontswap_init so that zswap_tree is >> inited

Re: [PATCH v2 1/4] mm/zswap: bugfix: memory leak when re-swapon

2013-09-16 Thread Weijie Yang
First, I apologize for my delay reply and appreciate the review from you and Bob Liu. On Tue, Sep 10, 2013 at 1:03 AM, Seth Jennings wrote: > On Fri, Sep 06, 2013 at 01:16:45PM +0800, Weijie Yang wrote: >> zswap_tree is not freed when swapoff, and it got re-kmalloc in swapon, >>

Re: [PATCH v2 4/4] mm/zswap: use GFP_NOIO instead of GFP_KERNEL

2013-09-16 Thread Weijie Yang
On Tue, Sep 10, 2013 at 12:47 AM, Seth Jennings wrote: > On Fri, Sep 06, 2013 at 01:16:45PM +0800, Weijie Yang wrote: >> To avoid zswap store and reclaim functions called recursively, >> use GFP_NOIO instead of GFP_KERNEL >> >> Signed-off-by: Weijie Yang > > I a

[PATCH v2 0/4] mm/zswap bugfix: memory leaks and other problems

2013-09-05 Thread Weijie Yang
This patch series fix a few bugs in zswap based on Linux-3.11. v1 --> v2 - free memory in zswap_frontswap_invalidate_area (in patch 1) - fix whitespace corruption (line wrapping) Corresponding mail thread: https://lkml.org/lkml/2013/8/18/59 These issues fixed/optimized are: 1.

[PATCH v2 4/4] mm/zswap: use GFP_NOIO instead of GFP_KERNEL

2013-09-05 Thread Weijie Yang
To avoid zswap store and reclaim functions called recursively, use GFP_NOIO instead of GFP_KERNEL Signed-off-by: Weijie Yang --- mm/zswap.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index cc40e6a..3d05ed8 100644 --- a/mm/zswap.c +++ b

[PATCH v2 3/4] mm/zswap: avoid unnecessary page scanning

2013-09-05 Thread Weijie Yang
add SetPageReclaim before __swap_writepage so that page can be moved to the tail of the inactive list, which can avoid unnecessary page scanning as this page was reclaimed by swap subsystem before. Signed-off-by: Weijie Yang --- mm/zswap.c |3 +++ 1 file changed, 3 insertions(+) diff --git

[PATCH v2 2/4] mm/zswap: bugfix: memory leak when invalidate and reclaim occur concurrently

2013-09-05 Thread Weijie Yang
: - check the refcount in fail path, free memory if it is not referenced. - use ZSWAP_SWAPCACHE_FAIL instead of ZSWAP_SWAPCACHE_NOMEM as the fail path can be not only caused by nomem but also by invalidate. Signed-off-by: Weijie Yang --- mm/zswap.c | 21 + 1 file changed, 13

[PATCH v2 1/4] mm/zswap: bugfix: memory leak when re-swapon

2013-09-05 Thread Weijie Yang
zswap_tree is not freed when swapoff, and it got re-kmalloc in swapon, so memory-leak occurs. Modify: free memory of zswap_tree in zswap_frontswap_invalidate_area(). Signed-off-by: Weijie Yang --- mm/zswap.c |4 1 file changed, 4 insertions(+) diff --git a/mm/zswap.c b/mm/zswap.c

Re: [PATCH] frontswap: enable call to invalidate area on swapoff

2013-10-10 Thread Weijie Yang
Thanks, Seth On Thu, Oct 10, 2013 at 10:26 AM, Seth Jennings wrote: > On Thu, Oct 10, 2013 at 09:29:07AM +0800, Bob Liu wrote: >> On 10/09/2013 10:40 PM, Seth Jennings wrote: >> > >> > The reason we never noticed this for zswap is that zswap has no >> > dynamically allocated per-type resources.

Re: [BUG REPORT] ZSWAP: theoretical race condition issues

2013-09-25 Thread Weijie Yang
On Wed, Sep 25, 2013 at 6:02 PM, Bob Liu wrote: > On Wed, Sep 25, 2013 at 5:33 PM, Weijie Yang wrote: >> On Wed, Sep 25, 2013 at 4:31 PM, Bob Liu wrote: >>> On Wed, Sep 25, 2013 at 4:09 PM, Weijie Yang >>> wrote: >>>> I think I find a new issue, for

RE: [PATCH v3 2/3] mm/zswap: bugfix: memory leak when invalidate and reclaim occur concurrently

2013-09-25 Thread Weijie Yang
On Tue, Sep 24, 2013 at 9:03 AM, Minchan Kim wrote: > On Mon, Sep 23, 2013 at 04:21:49PM +0800, Weijie Yang wrote: > > > > Modify: > > - check the refcount in fail path, free memory if it is not referenced. > > Hmm, I don't like this because zswap refcount routi

Re: [BUG REPORT] ZSWAP: theoretical race condition issues

2013-09-26 Thread Weijie Yang
On Thu, Sep 26, 2013 at 1:58 PM, Minchan Kim wrote: > Hello Weigie, > > On Wed, Sep 25, 2013 at 05:33:43PM +0800, Weijie Yang wrote: >> On Wed, Sep 25, 2013 at 4:31 PM, Bob Liu wrote: >> > On Wed, Sep 25, 2013 at 4:09 PM, Weijie Yang >> > wrote: >> >&

Re: [BUG REPORT] ZSWAP: theoretical race condition issues

2013-09-26 Thread Weijie Yang
On Thu, Sep 26, 2013 at 3:57 PM, Minchan Kim wrote: > On Thu, Sep 26, 2013 at 03:26:33PM +0800, Weijie Yang wrote: >> On Thu, Sep 26, 2013 at 1:58 PM, Minchan Kim wrote: >> > Hello Weigie, >> > >> > On Wed, Sep 25, 2013 at 05:33:43PM +0800, Weijie Yang wrote

[PATCH] fs/debugfs: add declaration for no CONFIG_DEBUG_FS

2013-09-27 Thread Weijie Yang
Two function declarations are absence if not define CONFIG_DEBUG_FS in include/linux/debugfs.h Signed-off-by: Weijie Yang --- include/linux/debugfs.h | 12 1 file changed, 12 insertions(+) diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h index 263489d..4d0b4d1

Re: [PATCH v2 3/4] mm/zswap: avoid unnecessary page scanning

2013-09-22 Thread Weijie Yang
On Mon, Sep 23, 2013 at 10:06 AM, Bob Liu wrote: > > On 09/10/2013 12:29 AM, Seth Jennings wrote: >> On Fri, Sep 06, 2013 at 01:16:45PM +0800, Weijie Yang wrote: >>> add SetPageReclaim before __swap_writepage so that page can be moved to the >>> tail of the

[PATCH v3 0/3] mm/zswap bugfix: memory leaks and other problems

2013-09-23 Thread Weijie Yang
This patch series fix a few bugs in mm/zswap based on Linux-3.11. v2 --> v3 - keep GFP_KERNEL flag v1 --> v2 - free memory in zswap_frontswap_invalidate_area(in patch 1) - fix whitespace corruption (line wrapping) Corresponding mail thread: https://lkml.org/lkml/2

[PATCH v3 3/3] mm/zswap: avoid unnecessary page scanning

2013-09-23 Thread Weijie Yang
add SetPageReclaim before __swap_writepage so that page can be moved to the tail of the inactive list, which can avoid unnecessary page scanning as this page was reclaimed by swap subsystem before. Signed-off-by: Weijie Yang Reviewed-by: Bob Liu Cc: Minchan Kim Cc: sta...@vger.kernel.org Acked

[PATCH v3 2/3] mm/zswap: bugfix: memory leak when invalidate and reclaim occur concurrently

2013-09-23 Thread Weijie Yang
: - check the refcount in fail path, free memory if it is not referenced. - use ZSWAP_SWAPCACHE_FAIL instead of ZSWAP_SWAPCACHE_NOMEM as the fail path can be not only caused by nomem but also by invalidate. Signed-off-by: Weijie Yang Reviewed-by: Bob Liu Cc: Minchan Kim Cc: sta

[PATCH v3 1/3] mm/zswap: bugfix: memory leak when re-swapon

2013-09-23 Thread Weijie Yang
zswap_tree is not freed when swapoff, and it got re-kmalloc in swapon, so memory-leak occurs. Modify: free memory of zswap_tree in zswap_frontswap_invalidate_area(). Signed-off-by: Weijie Yang Reviewed-by: Bob Liu Cc: Minchan Kim Cc: sta...@vger.kernel.org Acked-by: Seth Jennings --- mm

Re: [PATCH v3 0/3] mm/zswap bugfix: memory leaks and other problems

2013-09-25 Thread Weijie Yang
On Tue, Sep 24, 2013 at 9:11 AM, Minchan Kim wrote: > On Mon, Sep 23, 2013 at 04:19:36PM +0800, Weijie Yang wrote: >> This patch series fix a few bugs in mm/zswap based on Linux-3.11. >> >> v2 --> v3 >> - keep GFP_KERNEL flag > > Why do you drop this? &g

Re: [BUG REPORT] ZSWAP: theoretical race condition issues

2013-09-25 Thread Weijie Yang
I think I find a new issue, for integrity of this mail thread, I reply to this mail. It is a concurrence issue either, when duplicate store and reclaim concurrentlly. zswap entry x with offset A is already stored in zswap backend. Consider the following scenario: thread 0: reclaim entry x (get r

Re: [BUG REPORT] ZSWAP: theoretical race condition issues

2013-09-25 Thread Weijie Yang
On Wed, Sep 25, 2013 at 4:31 PM, Bob Liu wrote: > On Wed, Sep 25, 2013 at 4:09 PM, Weijie Yang wrote: >> I think I find a new issue, for integrity of this mail thread, I reply >> to this mail. >> >> It is a concurrence issue either, when duplicate store and reclaim &g

[BUG REPORT] ZSWAP: theoretical race condition issues

2013-08-18 Thread Weijie Yang
I found a few bugs in zswap when I review Linux-3.11-rc5, and I have also some questions about it, described as following: BUG: 1. A race condition when reclaim a page when a handle alloced from zbud, zbud considers this handle is used validly by upper(zswap) and can be a candidate for reclaim. Bu

Re: [BUG REPORT] ZSWAP: theoretical race condition issues

2013-08-20 Thread Weijie Yang
2013/8/19 Minchan Kim : > On Mon, Aug 19, 2013 at 10:17:38AM +0800, Bob Liu wrote: >> Hi Weijie, >> >> On 08/19/2013 12:14 AM, Weijie Yang wrote: >> > I found a few bugs in zswap when I review Linux-3.11-rc5, and I have >> > also some questions about it

[PATCH 0/4] zswap bugfix: memory leaks and other problem

2013-08-23 Thread Weijie Yang
This patch series fix a few bugs in zswap based on Linux-3.11-rc6. Corresponding mail thread see: lkml.org/lkml/2013/8/18/59 . These issues fixed are: 1. memory leaks when re-swapon 2. potential problem which store and reclaim functions is called recursively 3. memory leaks when invalidate and r

[PATCH 1/4] zswap bugfix: memory leaks when re-swapon

2013-08-23 Thread Weijie Yang
zswap_tree is not freed when swapoff, and it got re-kzalloc in swapon, memory leak occurs. Add check statement in zswap_frontswap_init so that zswap_tree is inited only once. --- mm/zswap.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index

[PATCH 2/4] zswap: use GFP_NOIO instead of GFP_KERNEL

2013-08-23 Thread Weijie Yang
avoid zswap store and reclaim functions called recursively. --- mm/zswap.c |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index 1cf1c07..5f97f4f 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -427,7 +427,7 @@ static int zswap_get_swap_cache_page

[PATCH 3/4] zswap bugfix: memory leaks when invalidate and reclaim occur simultaneously

2013-08-23 Thread Weijie Yang
Consider the following scenario: thread 1: zswap reclaim entry x (get the refcount, but not call zswap_get_swap_cache_page yet) thread 0: zswap_frontswap_invalidate_page entry x (finished, entry x and its zbud is not freed as its refcount != 0) now, the swap_map[x] = 0 thread 1: zswap_get_swap_cach

[PATCH 4/4] zswap: avoid unnecessary page scanning

2013-08-23 Thread Weijie Yang
add SetPageReclaim before __swap_writepage, so that page can be moved to the tail of the inactive list, which will avoid unnecessary page scanning as this page was reclaimed by swap subsystem before. --- mm/zswap.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/mm/zswa

[PATCH 0/4] zswap bugfix: memory leaks and other problem

2013-08-23 Thread Weijie Yang
This patch series fix a few bugs in zswap based on Linux-3.11-rc6. Corresponding mail thread see: lkml.org/lkml/2013/8/18/59 . These issues fixed are: 1. memory leaks when re-swapon 2. potential problem which store and reclaim functions is called recursively 3. memory leaks when invalidate and

[PATCH] mm: page_alloc: place zone id check before VM_BUG_ON_PAGE check

2014-12-08 Thread Weijie Yang
uddy) is truehold zone_2 lock page_order(buddy) == order is true alloc buddy trigger VM_BUG_ON_PAGE(page_count(buddy) != 0) This patch fixes this issue by placing the zone id check before the VM_BUG_ON_PAGE check. Signed-off-by: Weijie Yang --- mm/page_alloc.

[PATCH 1/3] mm: page_isolation: remove redundant moving for isolated buddy pages

2014-12-08 Thread Weijie Yang
_list[MIGRATE_ISOLATE]. This patch removes the unnecessary freepage_migratetype check and the redundant page moving. Signed-off-by: Weijie Yang --- mm/page_isolation.c | 17 + 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/mm/page_isolation.c b/mm/page_isolation.c

[PATCH 2/3] mm: page_isolation: remove unnecessary freepage_migratetype check for unused page

2014-12-08 Thread Weijie Yang
ion behavior by rechecking migratetype) patch series have ensure this. So the freepage_migratetype check for page_count==0 page in __test_page_isolated_in_pageblock() is meaningless. This patch removes the unnecessary freepage_migratetype check. Signed-off-by: Weijie Yang --- mm/page_isolation.c |

[PATCH 3/3] mm: page_alloc: remove redundant set_freepage_migratetype() calls

2014-12-08 Thread Weijie Yang
s. 2. Use it in page alloc path to update NR_FREE_CMA_PAGES statistics. This patch aims at the scenario 1 and removes two redundant set_freepage_migratetype() calls, which will make sense in the hot path. Signed-off-by: Weijie Yang --- mm/page_alloc.c |2 -- 1 file changed, 2 deletions(-)

Re: [PATCH] mm: page_alloc: place zone id check before VM_BUG_ON_PAGE check

2014-12-10 Thread Weijie Yang
On Tue, Dec 9, 2014 at 5:59 PM, Mel Gorman wrote: > On Tue, Dec 09, 2014 at 03:40:35PM +0800, Weijie Yang wrote: >> If the free page and its buddy has different zone id, the current >> zone->lock cann't prevent buddy page getting allocated, this could >> trigger

Re: [PATCH 2/3] mm: page_isolation: remove unnecessary freepage_migratetype check for unused page

2014-12-10 Thread Weijie Yang
On Tue, Dec 9, 2014 at 5:24 PM, Vlastimil Babka wrote: > On 12/09/2014 08:51 AM, Weijie Yang wrote: >> >> when we test the pages in a range is free or not, there is a little >> chance we encounter some page which is not in buddy but page_count is 0. >> That means tha

Re: [PATCH 3/3] mm: page_alloc: remove redundant set_freepage_migratetype() calls

2014-12-10 Thread Weijie Yang
On Tue, Dec 9, 2014 at 5:49 PM, Vlastimil Babka wrote: > On 12/09/2014 08:51 AM, Weijie Yang wrote: >> >> The freepage_migratetype is a temporary cached value which represents >> the free page's pageblock migratetype. Now we use it in two scenarios: >> >&g

Re: [RFC PATCH] mm: mincore: use PAGE_SIZE instead of PAGE_CACHE_SIZE

2014-12-10 Thread Weijie Yang
ping. Any comments? On Wed, Nov 12, 2014 at 5:50 PM, Weijie Yang wrote: > This is a RFC patch, because current PAGE_SIZE is equal to PAGE_CACHE_SIZE, > there isn't any difference and issue when running. > > However, the current code mixes these two aligned_size inconsistently,

[PATCH] zram: clear disk io accounting when reset zram device

2015-05-28 Thread Weijie Yang
This patch clears zram disk io accounting when reset the zram device, if don't do this, the residual io accounting stat will affect the diskstat in the next zram active cycle. Signed-off-by: Weijie Yang --- drivers/block/zram/zram_drv.c |2 ++ 1 file changed, 2 insertions(+) diff --

[PATCH] cma: allow concurrent cma pages allocation for multi-cma areas

2015-06-05 Thread Weijie Yang
cma_mutex and uses per-cma area alloc_lock, this allows concurrent cma pages allocation for different cma areas while protects access to the same pageblocks. Signed-off-by: Weijie Yang --- mm/cma.c |6 +++--- mm/cma.h |1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mm

[PATCH 1/2] mm/vmscan: restore sc->gfp_mask after promoting it to __GFP_HIGHMEM

2014-02-12 Thread Weijie Yang
uch as vmpressure_prio(), shrink_slab(). Signed-off-by: Weijie Yang --- mm/vmscan.c |8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) mode change 100644 => 100755 mm/vmscan.c diff --git a/mm/vmscan.c b/mm/vmscan.c old mode 100644 new mode 100755 index a9c74b4..35879f0 --- a/mm

[PATCH 2/2] mm/vmscan: not check compaction_ready on promoted zones

2014-02-12 Thread Weijie Yang
retry allocation is waste of time and could cause a loop in __alloc_pages_slowpath(). This patch do not check compaction_ready() on promoted zones to avoid the above situation, only set aborted_reclaim if the caller intended zone is ready to compaction. Signed-off-by: Weijie Yang --- mm/vmscan.c

[PATCH] staging: android: lowmemorykiller: set TIF_MEMDIE before send kill sig

2014-02-12 Thread Weijie Yang
Set TIF_MEMDIE tsk_thread flag before send kill signal to the selected thread. This is to fit a usual code sequence and avoid potential race issue. Signed-off-by: Weijie Yang --- drivers/staging/android/lowmemorykiller.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change

Re: [PATCH] mm: swap: Use swapfiles in priority order

2014-02-13 Thread Weijie Yang
On Thu, Feb 13, 2014 at 6:42 PM, Mel Gorman wrote: > According to the swapon documentation > > Swap pages are allocated from areas in priority order, > highest priority first. For areas with different priorities, a > higher-priority area is exhausted before using a l

Re: [PATCH v2] mm/zswap: Check all pool pages instead of one pool pages

2014-01-24 Thread Weijie Yang
o swap A and B with >>> >>> > >> > different priority >>> >>> > >> > and A already has charged 19% long time ago and let's assume >>> >>> > >> > that A swap is >>> >>> > >> &

[PATCH 0/8] mm/swap: fix some rare issues in swap subsystem

2014-01-27 Thread Weijie Yang
This patch series focus on some tiny and rare issues in swap subsystem. These issues happen rarely, so it is just for the correctness of the code. It firstly add some comments to try to make swap flag/lock usage in swapfile.c more clear and readable, and fix some rare issues in swap subsystem that

[PATCH 1/8] mm/swap: add some comments for swap flag/lock usage

2014-01-27 Thread Weijie Yang
The swap flag/lock usage in swapfile.c is lack of clarity and readability, some comments are not correct in other files. Add some comments to try to make it more clear and readable. Signed-off-by: Weijie Yang --- include/linux/blkdev.h |4 ++- mm/rmap.c |2 +- mm

[PATCH 8/8] mm/frontswap: add missing handle on a dup-store failure

2014-01-27 Thread Weijie Yang
If a frontswap dup-store failed, it should invalidate the old page in backend and return failure. This patch add this missing handle. According to the comments of __frontswap_store(), it should have been there. Reported-by: changkun.li Signed-off-by: Weijie Yang --- mm/frontswap.c |4

[PATCH 7/8] mm/swap: check swapfile blocksize greater than PAGE_SIZE

2014-01-27 Thread Weijie Yang
If S_ISREG swapfile's blocksize > PAGE_SIZE, it is not suitable to be a swapfile, because swap slot is fixed to PAGE_SIZE. This patch check this situation and return -EINVAL if it happens. Signed-off-by: Weijie Yang --- mm/page_io.c |2 ++ 1 file changed, 2 insertions(+) diff --

[PATCH 6/8] mm/swap: remove swap_lock to simplify si_swapinfo()

2014-01-27 Thread Weijie Yang
econd period, so it is good to performance. Signed-off-by: Weijie Yang --- mm/swapfile.c | 15 ++- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 3023172..7332c3d 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -2637,19 +2637,8 @

[PATCH 5/8] mm/swap: drop useless and bug frontswap_shrink codes

2014-01-27 Thread Weijie Yang
implement its own shrinker if there is a real-world need. Signed-off-by: Weijie Yang --- include/linux/frontswap.h |2 - include/linux/swapfile.h |3 -- mm/frontswap.c| 116 - mm/swapfile.c | 19 ++-- 4 files

[PATCH 4/8] mm/swap: fix race among frontswap_register_ops, swapoff and swapon

2014-01-27 Thread Weijie Yang
ops for detail. This patch is just for a rare scenario, aim to correct of code. Signed-off-by: Weijie Yang --- include/linux/swapfile.h |1 + mm/frontswap.c |7 --- mm/swapfile.c| 20 +++- 3 files changed, 20 insertions(+), 8 deletions(-) d

[PATCH 3/8] mm/swap: prevent concurrent swapon on the same S_ISBLK blockdev

2014-01-27 Thread Weijie Yang
return -EBUSY for one swapon call. As for S_ISREG swapfile, claim_swapfile() already prevent this scenario by holding inode->i_mutex. This patch is just for a rare scenario, aim to correct of code. Signed-off-by: Weijie Yang --- mm/swapfile.c |4 +++- 1 file changed, 3 insertions(+)

[PATCH 2/8] mm/swap: fix race on swap_info reuse between swapoff and swapon

2014-01-27 Thread Weijie Yang
Signed-off-by: Weijie Yang --- mm/swapfile.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 0a623a9..4d24158 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1977,7 +1977,6 @@ SYSCALL_DEFINE1(swapoff, const char __user

[PATCH] mm/swap: fix race on swap_info reuse between swapoff and swapon

2014-01-08 Thread Weijie Yang
- inode->i_flags &= ~S_SWAPFILE This patch clear SWP_USED flag after all its resources freed, so that swapon can reuse this swap_info by alloc_swap_info() safely. Signed-off-by: Weijie Yang --- mm/swapfile.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git

Re: [Patch 3.11.7 1/1]mm: remove and free expired data in time in zswap

2014-01-10 Thread Weijie Yang
Hi, Seth Would you please check this issue? Thanks On Mon, Nov 18, 2013 at 3:06 PM, Weijie Yang wrote: > add cc Seth 's new email address. > > On Fri, Nov 8, 2013 at 6:28 PM, Bob Liu wrote: >> On 11/08/2013 05:50 PM, changkun.li wrote: >>> In zswap, store page

Re: [PATCH] mm/swap: fix race on swap_info reuse between swapoff and swapon

2014-01-12 Thread Weijie Yang
On Sat, Jan 11, 2014 at 9:11 AM, Andrew Morton wrote: > On Thu, 09 Jan 2014 13:39:55 +0800 Weijie Yang > wrote: > >> swapoff clear swap_info's SWP_USED flag prematurely and free its resources >> after that. A concurrent swapon will reuse this swap_info while its pre

Re: [PATCH] mm/swap: fix race on swap_info reuse between swapoff and swapon

2014-01-12 Thread Weijie Yang
On Mon, Jan 13, 2014 at 11:27 AM, Andrew Morton wrote: > On Mon, 13 Jan 2014 11:08:58 +0800 Weijie Yang > wrote: > >> >> --- a/mm/swapfile.c >> >> +++ b/mm/swapfile.c >> >> @@ -1922,7 +1922,6 @@ SYSCALL_DEFINE1(swapoff, const char __user *, >

Re: [PATCH] mm/swap: fix race on swap_info reuse between swapoff and swapon

2014-01-12 Thread Weijie Yang
On Mon, Jan 13, 2014 at 2:27 PM, Mateusz Guzik wrote: > On Mon, Jan 13, 2014 at 11:51:42AM +0800, Weijie Yang wrote: >> On Mon, Jan 13, 2014 at 11:27 AM, Andrew Morton >> wrote: >> > On Mon, 13 Jan 2014 11:08:58 +0800 Weijie Yang >> > wrote: >> > >

Re: [PATCH] mm/zswap: Check all pool pages instead of one pool pages

2014-01-13 Thread Weijie Yang
On Tue, Jan 14, 2014 at 1:42 PM, Bob Liu wrote: > > On 01/14/2014 01:05 PM, Minchan Kim wrote: >> On Tue, Jan 14, 2014 at 01:50:22PM +0900, Minchan Kim wrote: >>> Hello Bob, >>> >>> On Tue, Jan 14, 2014 at 09:19:23AM +0800, Bob Liu wrote: On 01/14/2014 07:35 AM, Minchan Kim wrote: >

Re: [PATCH] swap: fix setting PAGE_SIZE blocksize during swapoff/swapon race

2013-10-17 Thread Weijie Yang
On Wed, Oct 16, 2013 at 1:19 AM, Hugh Dickins wrote: > On Tue, 15 Oct 2013, Krzysztof Kozlowski wrote: >> On Tue, 2013-10-15 at 02:59 -0700, Hugh Dickins wrote: >> > On Mon, 14 Oct 2013, Krzysztof Kozlowski wrote: >> > >> > > Fix race between swapoff and swapon resulting in setting blocksize of >>

Re: [PATCH] swap: fix setting PAGE_SIZE blocksize during swapoff/swapon race

2013-10-17 Thread Weijie Yang
On Thu, Oct 17, 2013 at 11:48 PM, Weijie Yang wrote: > On Wed, Oct 16, 2013 at 1:19 AM, Hugh Dickins wrote: >> On Tue, 15 Oct 2013, Krzysztof Kozlowski wrote: >>> On Tue, 2013-10-15 at 02:59 -0700, Hugh Dickins wrote: >>> > On Mon, 14 Oct 2013, Krzysztof Kozlowski

Re: [PATCH] mm/zswap: don't allow entry eviction if in use by load

2013-11-20 Thread Weijie Yang
Hello Dan On Thu, Nov 21, 2013 at 3:48 AM, Dan Streetman wrote: > The changes in commit 0ab0abcf511545d1fddbe72a36b3ca73388ac937 > introduce a bug in writeback, if an entry is in use by load > it will be evicted anyway, which isn't correct (technically, > the code currently in zbud doesn't actual

Re: [PATCH] mm/zswap: remove unneeded zswap_rb_erase calls

2013-11-20 Thread Weijie Yang
Hello Dan On Thu, Nov 21, 2013 at 3:47 AM, Dan Streetman wrote: > Since zswap_rb_erase was added to the final (when refcount == 0) > zswap_put_entry, there is no need to call zswap_rb_erase before > calling zswap_put_entry. > > Signed-off-by: Dan Streetman > --- > mm/zswap.c | 5 - > 1 file

Re: [PATCH] mm/zswap: change params from hidden to ro

2013-11-20 Thread Weijie Yang
On Thu, Nov 21, 2013 at 1:52 AM, Dan Streetman wrote: > On Wed, Nov 20, 2013 at 12:33 PM, Vladimir Murzin wrote: >> Hi Dan! >> >> On Wed, Nov 20, 2013 at 11:38:42AM -0500, Dan Streetman wrote: >>> The "compressor" and "enabled" params are currently hidden, >>> this changes them to read-only, so u

Re: [PATCH] mm/zswap: reverse zswap_entry tree/refcount relationship

2013-11-22 Thread Weijie Yang
Hello Dan, On Sat, Nov 23, 2013 at 6:10 AM, Dan Streetman wrote: > Currently, zswap_entry_put removes the entry from its tree if > the resulting refcount is 0. Several places in code put an > entry's initial reference, but they also must remove the entry > from its tree first, which makes the tr

Re: [PATCH v3] mm/zswap: change zswap to writethrough cache

2013-11-22 Thread Weijie Yang
Hello Dan, On Sat, Nov 23, 2013 at 6:10 AM, Dan Streetman wrote: > Currently, zswap is writeback cache; stored pages are not sent > to swap disk, and when zswap wants to evict old pages it must > first write them back to swap cache/disk manually. This avoids > swap out disk I/O up front, but onl

Re: [PATCH] frontswap: enable call to invalidate area on swapoff

2013-10-11 Thread Weijie Yang
On Fri, Oct 11, 2013 at 5:25 PM, Krzysztof Kozlowski wrote: > On Fri, 2013-10-11 at 10:23 +0800, Weijie Yang wrote: >> I am sorry to interrupt this topic, but I found an tiny issue near that: >> >> we can not "set_blocksize(bdev, p->old_block_size);" at the end o

Re: [PATCH v3 2/3] mm/zswap: bugfix: memory leak when invalidate and reclaim occur concurrently

2013-10-12 Thread Weijie Yang
On Fri, Oct 11, 2013 at 3:13 PM, Minchan Kim wrote: > On Thu, Sep 26, 2013 at 11:42:17AM +0800, Weijie Yang wrote: >> On Tue, Sep 24, 2013 at 9:03 AM, Minchan Kim wrote: >> > On Mon, Sep 23, 2013 at 04:21:49PM +0800, Weijie Yang wrote: >> > > >> > > Mo

Re: [PATCH v3 2/3] mm/zswap: bugfix: memory leak when invalidate and reclaim occur concurrently

2013-10-12 Thread Weijie Yang
On Sat, Oct 12, 2013 at 10:32 AM, Bob Liu wrote: > On Thu, Sep 26, 2013 at 11:42 AM, Weijie Yang wrote: >> On Tue, Sep 24, 2013 at 9:03 AM, Minchan Kim wrote: >>> On Mon, Sep 23, 2013 at 04:21:49PM +0800, Weijie Yang wrote: >>> > >>> > Modify: >

Re: [PATCH v3 2/3] mm/zswap: bugfix: memory leak when invalidate and reclaim occur concurrently

2013-10-12 Thread Weijie Yang
On Sat, Oct 12, 2013 at 10:50 AM, Bob Liu wrote: > On Fri, Oct 11, 2013 at 3:13 PM, Minchan Kim wrote: >> On Thu, Sep 26, 2013 at 11:42:17AM +0800, Weijie Yang wrote: >>> On Tue, Sep 24, 2013 at 9:03 AM, Minchan Kim wrote: >>> > On Mon, Sep 23, 2013 at 04:21

RE: [PATCH v3 2/3] mm/zswap: bugfix: memory leak when invalidate and reclaim occur concurrently

2013-10-12 Thread Weijie Yang
accepted, I will resent it instead of the previous refactor patch please see below, Request For Comments, Thanks. On Fri, Oct 11, 2013 at 3:13 PM, Minchan Kim wrote: > On Thu, Sep 26, 2013 at 11:42:17AM +0800, Weijie Yang wrote: > > On Tue, Sep 24, 2013 at 9:03 AM, Minchan Kim wrote: > >

Re: [PATCH v3 2/3] mm/zswap: bugfix: memory leak when invalidate and reclaim occur concurrently

2013-10-14 Thread Weijie Yang
more decsription and resend it as a RFC patch. Thanks, On Mon, Oct 14, 2013 at 8:31 AM, Minchan Kim wrote: > Hello, > > On Sat, Oct 12, 2013 at 05:37:55PM +0800, Weijie Yang wrote: >> Hi, all >> >> I thought out a new way to resolve this problem: use CAS instead of refcount

[PATCH 1/2] mm/zswap: bugfix: memory leak when invalidate and reclaim occur concurrently

2013-10-14 Thread Weijie Yang
: - check the refcount in fail path, free memory if it is not referenced. - use ZSWAP_SWAPCACHE_FAIL instead of ZSWAP_SWAPCACHE_NOMEM as the fail path can be not only caused by nomem but also by invalidate. Signed-off-by: Weijie Yang Reviewed-by: Bob Liu Cc: Minchan Kim Cc: Acked-by: Seth

[PATCH 2/2] mm/zswap: refoctor the get/put routines

2013-10-14 Thread Weijie Yang
zswap_entry_find_get(), so that callers can use easily in the following pattern: zswap_entry_find_get .../* do something */ zswap_entry_put - to eliminate compile error, move some functions declaration This patch is based on Minchan Kim 's idea and suggestion. Signed-off-by: Weijie Yang --- mm/zs

Re: [PATCH v6 1/3] Staging: zram: Fix access of NULL pointer

2013-10-28 Thread Weijie Yang
On Mon, Oct 28, 2013 at 8:21 PM, Rashika Kheria wrote: > This patch fixes the bug in reset_store caused by accessing NULL pointer. > Hence, It introduces a check for bdev. It also removes unnecessary check > of bdev for fsync_bdev(). > > Signed-off-by: Rashika Kheria > --- > > This revision fixes

Re: [PATCH v6 1/3] Staging: zram: Fix access of NULL pointer

2013-10-28 Thread Weijie Yang
On Mon, Oct 28, 2013 at 10:33 PM, Rashika Kheria wrote: > > > > On Mon, Oct 28, 2013 at 7:15 PM, Weijie Yang > wrote: >> >> On Mon, Oct 28, 2013 at 8:21 PM, Rashika Kheria >> wrote: >> > This patch fixes the bug in reset_store caused by accessing NULL

Re: [PATCH v8 2/3] Staging: zram: Fix decrement of variable by calling bdput()

2013-10-31 Thread Weijie Yang
Hello, Rashika On Wed, Oct 30, 2013 at 9:10 PM, Rashika Kheria wrote: > As suggested by Jerome Marchand "The code in reset_store get the block device > (bdget_disk()) but it does not put it (bdput()) when it's done using it. > The usage count is therefore incremented but never decremented." > > T

Re: [PATCH] zram: correct offset usage in zram_bio_discard

2014-04-22 Thread Weijie Yang
On Wed, Apr 23, 2014 at 3:55 AM, Andrew Morton wrote: > On Tue, 22 Apr 2014 11:14:02 +0800 Weijie Yang > wrote: > >> we want to skip the logical block which is partially covered by >> the discard bio, so check the remaining size and subtract it if >> there is a ne

Re: [PATCH] zram: correct offset usage in zram_bio_discard

2014-04-22 Thread Weijie Yang
On Wed, Apr 23, 2014 at 11:08 AM, Joonsoo Kim wrote: > On Wed, Apr 23, 2014 at 10:32:30AM +0800, Weijie Yang wrote: >> On Wed, Apr 23, 2014 at 3:55 AM, Andrew Morton >> wrote: >> > On Tue, 22 Apr 2014 11:14:02 +0800 Weijie Yang >> > wrote: >> > >&g

[PATCH RESEND] zram: correct offset usage in zram_bio_discard

2014-04-23 Thread Weijie Yang
blocks. However, with the current offset usage, it will discard the second physical block and free its memory, which will cause filesystem breakdown. This patch corrects the offset usage in zram_bio_discard. Signed-off-by: Weijie Yang Acked-by: Joonsoo Kim --- drivers/block/zram/zram_drv.c

Re: [PATCH RESEND] zram: correct offset usage in zram_bio_discard

2014-04-24 Thread Weijie Yang
On Thu, Apr 24, 2014 at 3:31 PM, Sergey Senozhatsky wrote: > Hello Minchan, > > On (04/24/14 11:06), Minchan Kim wrote: >> Hello, >> >> On Wed, Apr 23, 2014 at 04:41:15PM +0800, Weijie Yang wrote: >> > We want to skip the physical block(PAGE_SIZE) which is p

Re: [PATCH 1/2] swap: change swap_info singly-linked list to list_head

2014-04-24 Thread Weijie Yang
On Fri, Apr 25, 2014 at 2:48 AM, Dan Streetman wrote: > On Wed, Apr 23, 2014 at 6:34 AM, Mel Gorman wrote: >> On Sat, Apr 12, 2014 at 05:00:53PM -0400, Dan Streetman wrote: >>> Replace the singly-linked list tracking active, i.e. swapon'ed, >>> swap_info_struct entries with a doubly-linked list u

Re: [PATCH] Fix the issue that lowmemkiller fell into a cycle that try to kill a task

2014-09-23 Thread Weijie Yang
On Tue, Sep 23, 2014 at 12:48 PM, 朱辉 wrote: > > > On 09/23/14 12:18, Greg KH wrote: >> On Tue, Sep 23, 2014 at 10:57:09AM +0800, Hui Zhu wrote: >>> The cause of this issue is when free memroy size is low and a lot of task is >>> trying to shrink the memory, the task that is killed by lowmemkiller

Re: [PATCH 2/4] mm: zpool: implement zsmalloc shrinking

2014-04-26 Thread Weijie Yang
On Sat, Apr 19, 2014 at 11:52 PM, Dan Streetman wrote: > Add zs_shrink() and helper functions to zsmalloc. Update zsmalloc > zs_create_pool() creation function to include ops param that provides > an evict() function for use during shrinking. Update helper function > fix_fullness_group() to alwa

Re: [PATCH v2] zram: remove global tb_lock with fine grain lock

2014-05-16 Thread Weijie Yang
On Fri, May 16, 2014 at 2:51 PM, Minchan Kim wrote: > Hello Andrew, > > On Thu, May 15, 2014 at 02:38:56PM -0700, Andrew Morton wrote: >> On Thu, 15 May 2014 16:00:47 +0800 Weijie Yang >> wrote: >> >> > Currently, we use a rwlock tb_lock to protect concurren

Re: [PATCH] staging: android: lowmemorykiller: set TIF_MEMDIE before send kill sig

2014-02-13 Thread Weijie Yang
On Thu, Feb 13, 2014 at 4:00 PM, David Rientjes wrote: > On Thu, 13 Feb 2014, Weijie Yang wrote: > >> Set TIF_MEMDIE tsk_thread flag before send kill signal to the >> selected thread. This is to fit a usual code sequence and avoid >> potential race issue. >> >

Re: [PATCH 1/2] mm/vmscan: restore sc->gfp_mask after promoting it to __GFP_HIGHMEM

2014-02-13 Thread Weijie Yang
On Fri, Feb 14, 2014 at 12:10 AM, Rik van Riel wrote: > On 02/12/2014 09:39 PM, Weijie Yang wrote: > >> --- a/mm/vmscan.c >> +++ b/mm/vmscan.c >> @@ -2298,14 +2298,17 @@ static bool shrink_zones(struct zonelist *zonelist, >> struct scan_control *sc) >>

[PATCH RESEND] staging: android: lowmemorykiller: set TIF_MEMDIE before send kill sig

2014-02-13 Thread Weijie Yang
Set TIF_MEMDIE tsk_thread flag before send kill signal to the selected thread. This is to fit a usual code sequence and avoid potential race issue. Signed-off-by: Weijie Yang --- drivers/staging/android/lowmemorykiller.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a

[PATCH V2 1/2] mm/vmscan: restore sc->gfp_mask after promoting it to __GFP_HIGHMEM

2014-02-13 Thread Weijie Yang
uch as vmpressure_prio(), shrink_slab(). Signed-off-by: Weijie Yang --- Changes since v1: - use orig_mask to record the caller's orininal mask and restore it after finishing scan, according to Riel's suggestion. V1: https://lkml.org/lkml/2014/2/12/764 mm/vmscan.c |

[PATCH V2 2/2] mm/vmscan: not check compaction_ready on promoted zones

2014-02-13 Thread Weijie Yang
retry allocation is waste of time and could cause a loop in __alloc_pages_slowpath(). This patch do not check compaction_ready() on promoted zones to avoid the above situation, only set aborted_reclaim if the caller intended zone is ready to compaction. Acked-by: Rik van Riel Signed-off-by: Weijie

Re: [PATCH] mm: swap: Use swapfiles in priority order

2014-02-14 Thread Weijie Yang
On Fri, Feb 14, 2014 at 6:17 PM, Mel Gorman wrote: > On Thu, Feb 13, 2014 at 11:58:05PM +0800, Weijie Yang wrote: >> On Thu, Feb 13, 2014 at 6:42 PM, Mel Gorman wrote: >> > According to the swapon documentation >> > >> > Swap pages are alloc

[RFC PATCH] mm/vmscan: remove two un-needed mem_cgroup_page_lruvec() call

2014-02-15 Thread Weijie Yang
In putback_inactive_pages() and move_active_pages_to_lru(), lruvec is already an input parameter and pages are all from this lruvec, therefore there is no need to call mem_cgroup_page_lruvec() in loop. Signed-off-by: Weijie Yang --- mm/vmscan.c |3 --- 1 file changed, 3 deletions(-) diff

Re: [RFC PATCH] mm/vmscan: remove two un-needed mem_cgroup_page_lruvec() call

2014-02-15 Thread Weijie Yang
On Sun, Feb 16, 2014 at 12:00 PM, Hugh Dickins wrote: > On Sun, 16 Feb 2014, Weijie Yang wrote: > >> In putback_inactive_pages() and move_active_pages_to_lru(), >> lruvec is already an input parameter and pages are all from this lruvec, >> therefore there is no need to cal

[PATCH v2] zram: remove global tb_lock with fine grain lock

2014-05-15 Thread Weijie Yang
lag() to zram_test_zero() - add some comments - change the patch subject Signed-off-by: Weijie Yang --- drivers/block/zram/zram_drv.c | 84 +++-- drivers/block/zram/zram_drv.h | 22 --- 2 files changed, 63 insertions(+), 43 deletions(-) diff

[PATCH] zsmalloc: fixup trivial zs size classes value in comments

2014-05-15 Thread Weijie Yang
According to calculation, ZS_SIZE_CLASSES value is 255 on systems with 4K page size, not 254. The old value may forget count the ZS_MIN_ALLOC_SIZE in. This patch fixup this trivial issue in the comments. Signed-off-by: Weijie Yang --- mm/zsmalloc.c |2 +- 1 file changed, 1 insertion(+), 1

RE: [PATCH] zram: remove global tb_lock by using lock-free CAS

2014-05-09 Thread Weijie Yang
On Thu, May 8, 2014 at 2:24 PM, Minchan Kim wrote: > On Wed, May 07, 2014 at 11:52:59PM +0900, Joonsoo Kim wrote: >> >> Most popular use of zram is the in-memory swap for small embedded system >> >> so I don't want to increase memory footprint without good reason although >> >> it makes synthetic

Re: [PATCH 3/8] mm/swap: prevent concurrent swapon on the same S_ISBLK blockdev

2014-04-17 Thread Weijie Yang
On Tue, Feb 4, 2014 at 12:20 PM, Hugh Dickins wrote: > On Mon, 3 Feb 2014, Andrew Morton wrote: >> On Mon, 27 Jan 2014 18:03:04 +0800 Weijie Yang >> wrote: >> >> > When swapon the same S_ISBLK blockdev concurrent, the allocated two >> > swap_info co

RE: [PATCH 0/4] mm: zpool: add common api for zswap to use zbud/zsmalloc

2014-04-20 Thread Weijie Yang
On Sat, Apr 19, 2014 at 11:52 PM, Dan Streetman wrote: > In order to allow zswap users to choose between zbud and zsmalloc for > the compressed storage pool, this patch set adds a new api "zpool" that > provides an interface to both zbud and zsmalloc. Only a minor change > to zbud's interface w

[PATCH] zram: correct offset usage in zram_bio_discard

2014-04-21 Thread Weijie Yang
we want to skip the logical block which is partially covered by the discard bio, so check the remaining size and subtract it if there is a need to goto the next logical block. This patch corrects the offset usage in zram_bio_discard. Signed-off-by: Weijie Yang --- drivers/block/zram/zram_drv.c

  1   2   >