diff for duplicates of <20130128232145.GA2666@blaptop> diff --git a/a/1.txt b/N1/1.txt index 3672db9..e9cba2c 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -18,3 +18,67 @@ In read path, we called kmap_atomic. How about this? ------------------------- >8 ------------------------------- + +>From 9f8756ae0b0f2819f93cb94dcd38da372843aa12 Mon Sep 17 00:00:00 2001 +From: Minchan Kim <minchan@kernel.org> +Date: Mon, 21 Jan 2013 13:58:52 +0900 +Subject: [RESEND PATCH v5 1/4] zram: Fix deadlock bug in partial read/write + +Now zram allocates new page with GFP_KERNEL in zram I/O path +if IO is partial. Unfortunately, It may cause deadlock with +reclaim path like below. + +write_page from fs +fs_lock +allocation(GFP_KERNEL) +reclaim +pageout + write_page from fs + fs_lock <-- deadlock + +This patch fixes it by using GFP_ATOMIC and GFP_NOIO. +In read path, we called kmap_atomic so that we need GFP_ATOMIC +while we need GFP_NOIO in write path. + +Cc: stable@vger.kernel.org +Cc: Jerome Marchand <jmarchan@redhat.com> +Acked-by: Nitin Gupta <ngupta@vflare.org> +Signed-off-by: Minchan Kim <minchan@kernel.org> +--- +We could use GFP_IO instead of GFP_ATOMIC in zram_bvec_read with +some modification related to buffer allocation in case of partial IO. +But it needs more churn and prevent merge this patch into stable +if we should send this to stable so I'd like to keep it as simple +as possbile. GFP_IO usage could be separate patch after we merge it. +Thanks. + drivers/staging/zram/zram_drv.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c +index 61fb8f1..b285b3a 100644 +--- a/drivers/staging/zram/zram_drv.c ++++ b/drivers/staging/zram/zram_drv.c +@@ -220,7 +220,7 @@ static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec, + user_mem = kmap_atomic(page); + if (is_partial_io(bvec)) + /* Use a temporary buffer to decompress the page */ +- uncmem = kmalloc(PAGE_SIZE, GFP_KERNEL); ++ uncmem = kmalloc(PAGE_SIZE, GFP_ATOMIC); + else + uncmem = user_mem; + +@@ -268,7 +268,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index, + * This is a partial IO. We need to read the full page + * before to write the changes. + */ +- uncmem = kmalloc(PAGE_SIZE, GFP_KERNEL); ++ uncmem = kmalloc(PAGE_SIZE, GFP_NOIO); + if (!uncmem) { + pr_info("Error allocating temp memory!\n"); + ret = -ENOMEM; +-- +1.7.9.5 + +-- +Kind regards, +Minchan Kim diff --git a/a/content_digest b/N1/content_digest index c6ae624..85a07b4 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -34,6 +34,70 @@ "In read path, we called kmap_atomic.\n" "\n" "How about this?\n" - ------------------------- >8 ------------------------------- + "------------------------- >8 -------------------------------\n" + "\n" + ">From 9f8756ae0b0f2819f93cb94dcd38da372843aa12 Mon Sep 17 00:00:00 2001\n" + "From: Minchan Kim <minchan@kernel.org>\n" + "Date: Mon, 21 Jan 2013 13:58:52 +0900\n" + "Subject: [RESEND PATCH v5 1/4] zram: Fix deadlock bug in partial read/write\n" + "\n" + "Now zram allocates new page with GFP_KERNEL in zram I/O path\n" + "if IO is partial. Unfortunately, It may cause deadlock with\n" + "reclaim path like below.\n" + "\n" + "write_page from fs\n" + "fs_lock\n" + "allocation(GFP_KERNEL)\n" + "reclaim\n" + "pageout\n" + "\t\t\t\twrite_page from fs\n" + "\t\t\t\tfs_lock <-- deadlock\n" + "\n" + "This patch fixes it by using GFP_ATOMIC and GFP_NOIO.\n" + "In read path, we called kmap_atomic so that we need GFP_ATOMIC\n" + "while we need GFP_NOIO in write path.\n" + "\n" + "Cc: stable@vger.kernel.org\n" + "Cc: Jerome Marchand <jmarchan@redhat.com>\n" + "Acked-by: Nitin Gupta <ngupta@vflare.org>\n" + "Signed-off-by: Minchan Kim <minchan@kernel.org>\n" + "---\n" + "We could use GFP_IO instead of GFP_ATOMIC in zram_bvec_read with\n" + "some modification related to buffer allocation in case of partial IO.\n" + "But it needs more churn and prevent merge this patch into stable\n" + "if we should send this to stable so I'd like to keep it as simple\n" + "as possbile. GFP_IO usage could be separate patch after we merge it.\n" + "Thanks.\n" + " drivers/staging/zram/zram_drv.c | 4 ++--\n" + " 1 file changed, 2 insertions(+), 2 deletions(-)\n" + "\n" + "diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c\n" + "index 61fb8f1..b285b3a 100644\n" + "--- a/drivers/staging/zram/zram_drv.c\n" + "+++ b/drivers/staging/zram/zram_drv.c\n" + "@@ -220,7 +220,7 @@ static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec,\n" + " \tuser_mem = kmap_atomic(page);\n" + " \tif (is_partial_io(bvec))\n" + " \t\t/* Use a temporary buffer to decompress the page */\n" + "-\t\tuncmem = kmalloc(PAGE_SIZE, GFP_KERNEL);\n" + "+\t\tuncmem = kmalloc(PAGE_SIZE, GFP_ATOMIC);\n" + " \telse\n" + " \t\tuncmem = user_mem;\n" + " \n" + "@@ -268,7 +268,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,\n" + " \t\t * This is a partial IO. We need to read the full page\n" + " \t\t * before to write the changes.\n" + " \t\t */\n" + "-\t\tuncmem = kmalloc(PAGE_SIZE, GFP_KERNEL);\n" + "+\t\tuncmem = kmalloc(PAGE_SIZE, GFP_NOIO);\n" + " \t\tif (!uncmem) {\n" + " \t\t\tpr_info(\"Error allocating temp memory!\\n\");\n" + " \t\t\tret = -ENOMEM;\n" + "-- \n" + "1.7.9.5\n" + "\n" + "-- \n" + "Kind regards,\n" + Minchan Kim -abcec476c66d4b00bf1edfea067395e00e1e5aec1553bd5c84118338d4972412 +ae0176eace6dbd9d20994e613931689c9c1ae57c82959ecc76d36dbe1bfcdfe9
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.