From patchwork Sat Jan 4 20:59:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 234446 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1776C33C8C for ; Sat, 4 Jan 2020 20:59:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B7CFF24653 for ; Sat, 4 Jan 2020 20:59:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578171578; bh=HuPWhhHrqeSWiUh121GEnd8YYpBsCHJV6q9ZOlF5gqI=; h=Date:From:To:Subject:List-ID:From; b=PAEIfacB0aNmXqwX5xZ51jhktz072Bdcz/hz8aXdVBfOWaSjTny733h/p8O7tlVOW zZI98Wq8bFVAnqItFJXyCzv5f82SU8nPUXH/yv2kc1+5RxYLu8F762yfltkH5Zhj7k 2o4aYhmv9ug9LEsWDN6WuRV8rdypBB8YfBkjcpk8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726240AbgADU7i (ORCPT ); Sat, 4 Jan 2020 15:59:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:36374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726135AbgADU7h (ORCPT ); Sat, 4 Jan 2020 15:59:37 -0500 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3636824654; Sat, 4 Jan 2020 20:59:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578171577; bh=HuPWhhHrqeSWiUh121GEnd8YYpBsCHJV6q9ZOlF5gqI=; h=Date:From:To:Subject:From; b=I0Hh+tJhU3x3XdeoiQDMD4PF6NJzu/VzscqM5bvQTtml7ryeAGycUcc6l2LFUYCGW MmdI2r6wip6dQ1DAvz91ely/3TPQ7KkiNzf0KyNfK28rleZfNFDrz5iSu/AK/AfDN8 Fg7I2zSRyCDwecmTHgsVvsXClx0L5SAupxomena4= Date: Sat, 04 Jan 2020 12:59:36 -0800 From: akpm@linux-foundation.org To: akpm@linux-foundation.org, chanho.min@lge.com, jjinsuk.choi@lge.com, linux-mm@kvack.org, minchan@kernel.org, mm-commits@vger.kernel.org, sergey.senozhatsky@gmail.com, stable@vger.kernel.org, torvalds@linux-foundation.org Subject: [patch 02/17] mm/zsmalloc.c: fix the migrated zspage statistics. Message-ID: <20200104205936.KQJRwCAg-%akpm@linux-foundation.org> User-Agent: s-nail v14.8.16 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Chanho Min Subject: mm/zsmalloc.c: fix the migrated zspage statistics. When zspage is migrated to the other zone, the zone page state should be updated as well, otherwise the NR_ZSPAGE for each zone shows wrong counts including proc/zoneinfo in practice. Link: http://lkml.kernel.org/r/1575434841-48009-1-git-send-email-chanho.min@lge.com Fixes: 91537fee0013 ("mm: add NR_ZSMALLOC to vmstat") Signed-off-by: Chanho Min Signed-off-by: Jinsuk Choi Reviewed-by: Sergey Senozhatsky Acked-by: Minchan Kim Cc: [4.9+] Signed-off-by: Andrew Morton --- mm/zsmalloc.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/mm/zsmalloc.c~mm-zsmallocc-fix-the-migrated-zspage-statistics +++ a/mm/zsmalloc.c @@ -2069,6 +2069,11 @@ static int zs_page_migrate(struct addres zs_pool_dec_isolated(pool); } + if (page_zone(newpage) != page_zone(page)) { + dec_zone_page_state(page, NR_ZSPAGES); + inc_zone_page_state(newpage, NR_ZSPAGES); + } + reset_page(page); put_page(page); page = newpage; From patchwork Sat Jan 4 20:59:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 234445 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 539EEC32771 for ; Sat, 4 Jan 2020 20:59:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2246224653 for ; Sat, 4 Jan 2020 20:59:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578171588; bh=/ZlR/E1jn0C9hBj0oLMKeaDnKIQNPLBFqwsD/W5qyKg=; h=Date:From:To:Subject:List-ID:From; b=lZu/bLAK4roOlYucbhWdxcoLhQ8JJuBVWSSKbBpgd2U6/tD7KfUVFAL4ljORDkLZ0 55G+sg45mgLeNf8k/CdZYH6Nox3iiSlAAfK1xybX4piVTPw5vnkbwbCoAy7GyXJAY6 j5aMbmCvIzn0UrSEQW67nOFbWgkSIVfok1SsLEmg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726281AbgADU7r (ORCPT ); Sat, 4 Jan 2020 15:59:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:36630 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726135AbgADU7r (ORCPT ); Sat, 4 Jan 2020 15:59:47 -0500 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B56C624650; Sat, 4 Jan 2020 20:59:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578171587; bh=/ZlR/E1jn0C9hBj0oLMKeaDnKIQNPLBFqwsD/W5qyKg=; h=Date:From:To:Subject:From; b=gqYps4jMlTQf2fLQpruLOM4N9yDRoYs89ER1PLGSjqV3S/PxlayZqrik5M0oSZaU/ qPGMU8gyVB5JO7M9Sq1SvPEf4mlkwRr+Myfh278K997+BblSINZXy2GjcXPG8xCgNh zL/PxnlpE4fpmmQ3AvqwfFmvc12HxgpdhhBTbv0k= Date: Sat, 04 Jan 2020 12:59:46 -0800 From: akpm@linux-foundation.org To: akpm@linux-foundation.org, cl@linux.com, fabecassis@nvidia.com, jhubbard@nvidia.com, linux-mm@kvack.org, mgorman@techsingularity.net, mhocko@suse.com, mm-commits@vger.kernel.org, stable@vger.kernel.org, torvalds@linux-foundation.org, vbabka@suse.cz, yang.shi@linux.alibaba.com Subject: [patch 05/17] mm: move_pages: return valid node id in status if the page is already on the target node Message-ID: <20200104205946.bXLvlabMj%akpm@linux-foundation.org> User-Agent: s-nail v14.8.16 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Yang Shi Subject: mm: move_pages: return valid node id in status if the page is already on the target node Felix Abecassis reports move_pages() would return random status if the pages are already on the target node by the below test program: ---8<--- int main(void) { const long node_id = 1; const long page_size = sysconf(_SC_PAGESIZE); const int64_t num_pages = 8; unsigned long nodemask = 1 << node_id; long ret = set_mempolicy(MPOL_BIND, &nodemask, sizeof(nodemask)); if (ret < 0) return (EXIT_FAILURE); void **pages = malloc(sizeof(void*) * num_pages); for (int i = 0; i < num_pages; ++i) { pages[i] = mmap(NULL, page_size, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_POPULATE | MAP_ANONYMOUS, -1, 0); if (pages[i] == MAP_FAILED) return (EXIT_FAILURE); } ret = set_mempolicy(MPOL_DEFAULT, NULL, 0); if (ret < 0) return (EXIT_FAILURE); int *nodes = malloc(sizeof(int) * num_pages); int *status = malloc(sizeof(int) * num_pages); for (int i = 0; i < num_pages; ++i) { nodes[i] = node_id; status[i] = 0xd0; /* simulate garbage values */ } ret = move_pages(0, num_pages, pages, nodes, status, MPOL_MF_MOVE); printf("move_pages: %ld ", ret); for (int i = 0; i < num_pages; ++i) printf("status[%d] = %d ", i, status[i]); } ---8<--- Then running the program would return nonsense status values: $ ./move_pages_bug move_pages: 0 status[0] = 208 status[1] = 208 status[2] = 208 status[3] = 208 status[4] = 208 status[5] = 208 status[6] = 208 status[7] = 208 This is because the status is not set if the page is already on the target node, but move_pages() should return valid status as long as it succeeds. The valid status may be errno or node id. We can't simply initialize status array to zero since the pages may be not on node 0. Fix it by updating status with node id which the page is already on. Link: http://lkml.kernel.org/r/1575584353-125392-1-git-send-email-yang.shi@linux.alibaba.com Fixes: a49bd4d71637 ("mm, numa: rework do_pages_move") Signed-off-by: Yang Shi Reported-by: Felix Abecassis Tested-by: Felix Abecassis Suggested-by: Michal Hocko Reviewed-by: John Hubbard Acked-by: Christoph Lameter Acked-by: Michal Hocko Reviewed-by: Vlastimil Babka Cc: Mel Gorman Cc: [4.17+] Signed-off-by: Andrew Morton --- mm/migrate.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) --- a/mm/migrate.c~mm-move_pages-return-valid-node-id-in-status-if-the-page-is-already-on-the-target-node +++ a/mm/migrate.c @@ -1512,9 +1512,11 @@ static int do_move_pages_to_node(struct /* * Resolves the given address to a struct page, isolates it from the LRU and * puts it to the given pagelist. - * Returns -errno if the page cannot be found/isolated or 0 when it has been - * queued or the page doesn't need to be migrated because it is already on - * the target node + * Returns: + * errno - if the page cannot be found/isolated + * 0 - when it doesn't have to be migrated because it is already on the + * target node + * 1 - when it has been queued */ static int add_page_for_migration(struct mm_struct *mm, unsigned long addr, int node, struct list_head *pagelist, bool migrate_all) @@ -1553,7 +1555,7 @@ static int add_page_for_migration(struct if (PageHuge(page)) { if (PageHead(page)) { isolate_huge_page(page, pagelist); - err = 0; + err = 1; } } else { struct page *head; @@ -1563,7 +1565,7 @@ static int add_page_for_migration(struct if (err) goto out_putpage; - err = 0; + err = 1; list_add_tail(&head->lru, pagelist); mod_node_page_state(page_pgdat(head), NR_ISOLATED_ANON + page_is_file_cache(head), @@ -1640,8 +1642,17 @@ static int do_pages_move(struct mm_struc */ err = add_page_for_migration(mm, addr, current_node, &pagelist, flags & MPOL_MF_MOVE_ALL); - if (!err) + + if (!err) { + /* The page is already on the target node */ + err = store_status(status, i, current_node, 1); + if (err) + goto out_flush; continue; + } else if (err > 0) { + /* The page is successfully queued for migration */ + continue; + } err = store_status(status, i, err, 1); if (err) From patchwork Sat Jan 4 21:00:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 234444 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEAD5C32771 for ; Sat, 4 Jan 2020 21:00:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 91E982465B for ; Sat, 4 Jan 2020 21:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578171624; bh=kAG1O0HrRbdy20jw2FS2bWl+gBNoBZv5eHHwCjoTSzI=; h=Date:From:To:Subject:List-ID:From; b=hUiSiL+oWrgzwAY9aaPzDaixJiHnWfrxuEGpb1ekDk0f6rFsdf0Vvfm/patRWw9x1 5R4qQ+O9szZ/h/jVKKgxLTSxCyFqPl3/bfNDR0n565525d0WsJHjxwXJN2o6JTsvTj vMHXN5StilOZtkNsO6kDhyNsyKmQpn199KuK2hVE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726167AbgADVAY (ORCPT ); Sat, 4 Jan 2020 16:00:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:37802 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726135AbgADVAY (ORCPT ); Sat, 4 Jan 2020 16:00:24 -0500 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 43FED24655; Sat, 4 Jan 2020 21:00:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578171623; bh=kAG1O0HrRbdy20jw2FS2bWl+gBNoBZv5eHHwCjoTSzI=; h=Date:From:To:Subject:From; b=olySzKfK0vDJAKFVIiZAIXzTNg/A3qCZbedr3sPyuYAu5zw+uQushoDFEMgDSDCiG kLOdsgezAbWxcqWX3+316/Z+wFzf1QwKRMWmIITwSRtNz6NE7ZsUTBjGOssNyIGy0R iKr7y0UKpA7AD/IaoK6s3/qlb97oTSU3LVd727LI= Date: Sat, 04 Jan 2020 13:00:22 -0800 From: akpm@linux-foundation.org To: akpm@linux-foundation.org, gechangwei@live.cn, ghe@suse.com, jlbec@evilplan.org, joseph.qi@linux.alibaba.com, junxiao.bi@oracle.com, linux-mm@kvack.org, mark@fasheh.com, mm-commits@vger.kernel.org, piaojun@huawei.com, stable@vger.kernel.org, torvalds@linux-foundation.org Subject: [patch 16/17] ocfs2: fix the crash due to call ocfs2_get_dlm_debug once less Message-ID: <20200104210022.j1pTeIiNp%akpm@linux-foundation.org> User-Agent: s-nail v14.8.16 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Gang He Subject: ocfs2: fix the crash due to call ocfs2_get_dlm_debug once less Because ocfs2_get_dlm_debug() function is called once less here, ocfs2 file system will trigger the system crash, usually after ocfs2 file system is unmounted. This system crash is caused by a generic memory corruption, these crash backtraces are not always the same, for exapmle, [ 4106.597432] ocfs2: Unmounting device (253,16) on (node 172167785) [ 4116.230719] general protection fault: 0000 [#1] SMP PTI [ 4116.230731] CPU: 3 PID: 14107 Comm: fence_legacy Kdump: [ 4116.230737] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996) [ 4116.230772] RIP: 0010:__kmalloc+0xa5/0x2a0 [ 4116.230778] Code: 00 00 4d 8b 07 65 4d 8b [ 4116.230785] RSP: 0018:ffffaa1fc094bbe8 EFLAGS: 00010286 [ 4116.230790] RAX: 0000000000000000 RBX: d310a8800d7a3faf RCX: 0000000000000000 [ 4116.230794] RDX: 0000000000000000 RSI: 0000000000000dc0 RDI: ffff96e68fc036c0 [ 4116.230798] RBP: d310a8800d7a3faf R08: ffff96e6ffdb10a0 R09: 00000000752e7079 [ 4116.230802] R10: 000000000001c513 R11: 0000000004091041 R12: 0000000000000dc0 [ 4116.230806] R13: 0000000000000039 R14: ffff96e68fc036c0 R15: ffff96e68fc036c0 [ 4116.230811] FS: 00007f699dfba540(0000) GS:ffff96e6ffd80000(0000) knlGS:00000 [ 4116.230815] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 4116.230819] CR2: 000055f3a9d9b768 CR3: 000000002cd1c000 CR4: 00000000000006e0 [ 4116.230833] Call Trace: [ 4116.230898] ? ext4_htree_store_dirent+0x35/0x100 [ext4] [ 4116.230924] ext4_htree_store_dirent+0x35/0x100 [ext4] [ 4116.230957] htree_dirblock_to_tree+0xea/0x290 [ext4] [ 4116.230989] ext4_htree_fill_tree+0x1c1/0x2d0 [ext4] [ 4116.231027] ext4_readdir+0x67c/0x9d0 [ext4] [ 4116.231040] iterate_dir+0x8d/0x1a0 [ 4116.231056] __x64_sys_getdents+0xab/0x130 [ 4116.231063] ? iterate_dir+0x1a0/0x1a0 [ 4116.231076] ? do_syscall_64+0x60/0x1f0 [ 4116.231080] ? __ia32_sys_getdents+0x130/0x130 [ 4116.231086] do_syscall_64+0x60/0x1f0 [ 4116.231151] entry_SYSCALL_64_after_hwframe+0x49/0xbe [ 4116.231168] RIP: 0033:0x7f699d33a9fb This regression problem was introduced by commit e581595ea29c ("ocfs: no need to check return value of debugfs_create functions"). Link: http://lkml.kernel.org/r/20191225061501.13587-1-ghe@suse.com Fixes: e581595ea29c ("ocfs: no need to check return value of debugfs_create functions") Signed-off-by: Gang He Acked-by: Joseph Qi Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Changwei Ge Cc: Gang He Cc: Jun Piao Cc: [5.3+] Signed-off-by: Andrew Morton --- fs/ocfs2/dlmglue.c | 1 + 1 file changed, 1 insertion(+) --- a/fs/ocfs2/dlmglue.c~ocfs2-fix-the-crash-due-to-call-ocfs2_get_dlm_debug-once-less +++ a/fs/ocfs2/dlmglue.c @@ -3282,6 +3282,7 @@ static void ocfs2_dlm_init_debug(struct debugfs_create_u32("locking_filter", 0600, osb->osb_debug_root, &dlm_debug->d_filter_secs); + ocfs2_get_dlm_debug(dlm_debug); } static void ocfs2_dlm_shutdown_debug(struct ocfs2_super *osb)