Hi Julia, There were lkp logs reporting that before, but I have no idea why it is reported. z_pagemap_global_lock is taken iff (pages = z_pagemap_global), and it is unlocked at > 3883a79a Gao Xiang 2018-07-26 987 if (pages == z_pagemap_global) > 3883a79a Gao Xiang 2018-07-26 988 mutex_unlock(&z_pagemap_global_lock); It is designed on purpose for now. actually erofs is actually running on our commerical products but I haven't observed lock leaking. hmmmm... If I am wrong, please point out thanks... Thanks, Gao Xiang On 2018/9/11 21:40, Julia Lawall wrote: > I don't know if there is a problem here. Please check the lines mentiond > below, ie lines 839 and 1003. > > julia > > ---------- Forwarded message ---------- > Date: Tue, 11 Sep 2018 17:17:15 +0800 > From: kbuild test robot <lkp@xxxxxxxxx> > To: kbuild@xxxxxx > Cc: Julia Lawall <julia.lawall@xxxxxxx> > Subject: [staging:staging-next 118/220] > drivers/staging/erofs/unzip_vle.c:1003:1-7: preceding lock on line 839 > > CC: kbuild-all@xxxxxx > CC: devel@xxxxxxxxxxxxxxxxxxxx > TO: Gao Xiang <gaoxiang25@xxxxxxxxxx> > CC: "Greg Kroah-Hartman" <gregkh@xxxxxxxxxxxxxxxxxxx> > CC: Chao Yu <yuchao0@xxxxxxxxxx>, Chao Yu <chao@xxxxxxxxxx> > > Hi Gao, > > First bad commit (maybe != root cause): > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git staging-next > head: 7aaaabd50d785e30b290054b3a1b115393927da3 > commit: aca19723604c232ffc6376c1c6cd9c8a12158dcc [118/220] Revert "staging: erofs: disable compiling temporarile" > :::::: branch date: 17 hours ago > :::::: commit date: 25 hours ago > >>> drivers/staging/erofs/unzip_vle.c:1003:1-7: preceding lock on line 839 > > # https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/commit/?id=aca19723604c232ffc6376c1c6cd9c8a12158dcc > git remote add staging https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git > git remote update staging > git checkout aca19723604c232ffc6376c1c6cd9c8a12158dcc > vim +1003 drivers/staging/erofs/unzip_vle.c > > 3883a79a Gao Xiang 2018-07-26 787 > 3883a79a Gao Xiang 2018-07-26 788 static int z_erofs_vle_unzip(struct super_block *sb, > 3883a79a Gao Xiang 2018-07-26 789 struct z_erofs_vle_workgroup *grp, > 3883a79a Gao Xiang 2018-07-26 790 struct list_head *page_pool) > 3883a79a Gao Xiang 2018-07-26 791 { > 3883a79a Gao Xiang 2018-07-26 792 struct erofs_sb_info *const sbi = EROFS_SB(sb); > 105d4ad8 Gao Xiang 2018-07-26 793 #ifdef EROFS_FS_HAS_MANAGED_CACHE > 105d4ad8 Gao Xiang 2018-07-26 794 struct address_space *const mngda = sbi->managed_cache->i_mapping; > 105d4ad8 Gao Xiang 2018-07-26 795 #endif > 3883a79a Gao Xiang 2018-07-26 796 const unsigned clusterpages = erofs_clusterpages(sbi); > 3883a79a Gao Xiang 2018-07-26 797 > 3883a79a Gao Xiang 2018-07-26 798 struct z_erofs_pagevec_ctor ctor; > 3883a79a Gao Xiang 2018-07-26 799 unsigned nr_pages; > 3883a79a Gao Xiang 2018-07-26 800 #ifndef CONFIG_EROFS_FS_ZIP_MULTIREF > 3883a79a Gao Xiang 2018-07-26 801 unsigned sparsemem_pages = 0; > 3883a79a Gao Xiang 2018-07-26 802 #endif > 3883a79a Gao Xiang 2018-07-26 803 struct page *pages_onstack[Z_EROFS_VLE_VMAP_ONSTACK_PAGES]; > 3883a79a Gao Xiang 2018-07-26 804 struct page **pages, **compressed_pages, *page; > 3883a79a Gao Xiang 2018-07-26 805 unsigned i, llen; > 3883a79a Gao Xiang 2018-07-26 806 > 3883a79a Gao Xiang 2018-07-26 807 enum z_erofs_page_type page_type; > 3883a79a Gao Xiang 2018-07-26 808 bool overlapped; > 3883a79a Gao Xiang 2018-07-26 809 struct z_erofs_vle_work *work; > 3883a79a Gao Xiang 2018-07-26 810 void *vout; > 3883a79a Gao Xiang 2018-07-26 811 int err; > 3883a79a Gao Xiang 2018-07-26 812 > 3883a79a Gao Xiang 2018-07-26 813 might_sleep(); > 3883a79a Gao Xiang 2018-07-26 814 #ifndef CONFIG_EROFS_FS_ZIP_MULTIREF > 3883a79a Gao Xiang 2018-07-26 815 work = z_erofs_vle_grab_primary_work(grp); > 3883a79a Gao Xiang 2018-07-26 816 #else > 3883a79a Gao Xiang 2018-07-26 817 BUG(); > 3883a79a Gao Xiang 2018-07-26 818 #endif > 3883a79a Gao Xiang 2018-07-26 819 BUG_ON(!READ_ONCE(work->nr_pages)); > 3883a79a Gao Xiang 2018-07-26 820 > 3883a79a Gao Xiang 2018-07-26 821 mutex_lock(&work->lock); > 3883a79a Gao Xiang 2018-07-26 822 nr_pages = work->nr_pages; > 3883a79a Gao Xiang 2018-07-26 823 > 3883a79a Gao Xiang 2018-07-26 824 if (likely(nr_pages <= Z_EROFS_VLE_VMAP_ONSTACK_PAGES)) > 3883a79a Gao Xiang 2018-07-26 825 pages = pages_onstack; > 3883a79a Gao Xiang 2018-07-26 826 else if (nr_pages <= Z_EROFS_VLE_VMAP_GLOBAL_PAGES && > 3883a79a Gao Xiang 2018-07-26 827 mutex_trylock(&z_pagemap_global_lock)) > 3883a79a Gao Xiang 2018-07-26 828 pages = z_pagemap_global; > 3883a79a Gao Xiang 2018-07-26 829 else { > 3883a79a Gao Xiang 2018-07-26 830 repeat: > 3883a79a Gao Xiang 2018-07-26 831 pages = kvmalloc_array(nr_pages, > 3883a79a Gao Xiang 2018-07-26 832 sizeof(struct page *), GFP_KERNEL); > 3883a79a Gao Xiang 2018-07-26 833 > 3883a79a Gao Xiang 2018-07-26 834 /* fallback to global pagemap for the lowmem scenario */ > 3883a79a Gao Xiang 2018-07-26 835 if (unlikely(pages == NULL)) { > 3883a79a Gao Xiang 2018-07-26 836 if (nr_pages > Z_EROFS_VLE_VMAP_GLOBAL_PAGES) > 3883a79a Gao Xiang 2018-07-26 837 goto repeat; > 3883a79a Gao Xiang 2018-07-26 838 else { > 3883a79a Gao Xiang 2018-07-26 @839 mutex_lock(&z_pagemap_global_lock); > 3883a79a Gao Xiang 2018-07-26 840 pages = z_pagemap_global; > 3883a79a Gao Xiang 2018-07-26 841 } > 3883a79a Gao Xiang 2018-07-26 842 } > 3883a79a Gao Xiang 2018-07-26 843 } > 3883a79a Gao Xiang 2018-07-26 844 > 3883a79a Gao Xiang 2018-07-26 845 for (i = 0; i < nr_pages; ++i) > 3883a79a Gao Xiang 2018-07-26 846 pages[i] = NULL; > 3883a79a Gao Xiang 2018-07-26 847 > 3883a79a Gao Xiang 2018-07-26 848 z_erofs_pagevec_ctor_init(&ctor, > 3883a79a Gao Xiang 2018-07-26 849 Z_EROFS_VLE_INLINE_PAGEVECS, work->pagevec, 0); > 3883a79a Gao Xiang 2018-07-26 850 > 3883a79a Gao Xiang 2018-07-26 851 for (i = 0; i < work->vcnt; ++i) { > 3883a79a Gao Xiang 2018-07-26 852 unsigned pagenr; > 3883a79a Gao Xiang 2018-07-26 853 > 3883a79a Gao Xiang 2018-07-26 854 page = z_erofs_pagevec_ctor_dequeue(&ctor, &page_type); > 3883a79a Gao Xiang 2018-07-26 855 > 3883a79a Gao Xiang 2018-07-26 856 /* all pages in pagevec ought to be valid */ > 3883a79a Gao Xiang 2018-07-26 857 DBG_BUGON(page == NULL); > 3883a79a Gao Xiang 2018-07-26 858 DBG_BUGON(page->mapping == NULL); > 3883a79a Gao Xiang 2018-07-26 859 > 3883a79a Gao Xiang 2018-07-26 860 if (z_erofs_gather_if_stagingpage(page_pool, page)) > 3883a79a Gao Xiang 2018-07-26 861 continue; > 3883a79a Gao Xiang 2018-07-26 862 > 3883a79a Gao Xiang 2018-07-26 863 if (page_type == Z_EROFS_VLE_PAGE_TYPE_HEAD) > 3883a79a Gao Xiang 2018-07-26 864 pagenr = 0; > 3883a79a Gao Xiang 2018-07-26 865 else > 3883a79a Gao Xiang 2018-07-26 866 pagenr = z_erofs_onlinepage_index(page); > 3883a79a Gao Xiang 2018-07-26 867 > 3883a79a Gao Xiang 2018-07-26 868 BUG_ON(pagenr >= nr_pages); > 3883a79a Gao Xiang 2018-07-26 869 > 3883a79a Gao Xiang 2018-07-26 870 #ifndef CONFIG_EROFS_FS_ZIP_MULTIREF > 3883a79a Gao Xiang 2018-07-26 871 BUG_ON(pages[pagenr] != NULL); > 3883a79a Gao Xiang 2018-07-26 872 ++sparsemem_pages; > 3883a79a Gao Xiang 2018-07-26 873 #endif > 3883a79a Gao Xiang 2018-07-26 874 pages[pagenr] = page; > 3883a79a Gao Xiang 2018-07-26 875 } > 3883a79a Gao Xiang 2018-07-26 876 > 3883a79a Gao Xiang 2018-07-26 877 z_erofs_pagevec_ctor_exit(&ctor, true); > 3883a79a Gao Xiang 2018-07-26 878 > 3883a79a Gao Xiang 2018-07-26 879 overlapped = false; > 3883a79a Gao Xiang 2018-07-26 880 compressed_pages = grp->compressed_pages; > 3883a79a Gao Xiang 2018-07-26 881 > 3883a79a Gao Xiang 2018-07-26 882 for (i = 0; i < clusterpages; ++i) { > 3883a79a Gao Xiang 2018-07-26 883 unsigned pagenr; > 3883a79a Gao Xiang 2018-07-26 884 > 3883a79a Gao Xiang 2018-07-26 885 page = compressed_pages[i]; > 3883a79a Gao Xiang 2018-07-26 886 > 3883a79a Gao Xiang 2018-07-26 887 /* all compressed pages ought to be valid */ > 3883a79a Gao Xiang 2018-07-26 888 DBG_BUGON(page == NULL); > 3883a79a Gao Xiang 2018-07-26 889 DBG_BUGON(page->mapping == NULL); > 3883a79a Gao Xiang 2018-07-26 890 > 3883a79a Gao Xiang 2018-07-26 891 if (z_erofs_is_stagingpage(page)) > 3883a79a Gao Xiang 2018-07-26 892 continue; > 105d4ad8 Gao Xiang 2018-07-26 893 #ifdef EROFS_FS_HAS_MANAGED_CACHE > 105d4ad8 Gao Xiang 2018-07-26 894 else if (page->mapping == mngda) { > 105d4ad8 Gao Xiang 2018-07-26 895 BUG_ON(PageLocked(page)); > 105d4ad8 Gao Xiang 2018-07-26 896 BUG_ON(!PageUptodate(page)); > 105d4ad8 Gao Xiang 2018-07-26 897 continue; > 105d4ad8 Gao Xiang 2018-07-26 898 } > 105d4ad8 Gao Xiang 2018-07-26 899 #endif > 3883a79a Gao Xiang 2018-07-26 900 > 3883a79a Gao Xiang 2018-07-26 901 /* only non-head page could be reused as a compressed page */ > 3883a79a Gao Xiang 2018-07-26 902 pagenr = z_erofs_onlinepage_index(page); > 3883a79a Gao Xiang 2018-07-26 903 > 3883a79a Gao Xiang 2018-07-26 904 BUG_ON(pagenr >= nr_pages); > 3883a79a Gao Xiang 2018-07-26 905 #ifndef CONFIG_EROFS_FS_ZIP_MULTIREF > 3883a79a Gao Xiang 2018-07-26 906 BUG_ON(pages[pagenr] != NULL); > 3883a79a Gao Xiang 2018-07-26 907 ++sparsemem_pages; > 3883a79a Gao Xiang 2018-07-26 908 #endif > 3883a79a Gao Xiang 2018-07-26 909 pages[pagenr] = page; > 3883a79a Gao Xiang 2018-07-26 910 > 3883a79a Gao Xiang 2018-07-26 911 overlapped = true; > 3883a79a Gao Xiang 2018-07-26 912 } > 3883a79a Gao Xiang 2018-07-26 913 > 3883a79a Gao Xiang 2018-07-26 914 llen = (nr_pages << PAGE_SHIFT) - work->pageofs; > 3883a79a Gao Xiang 2018-07-26 915 > 3883a79a Gao Xiang 2018-07-26 916 if (z_erofs_vle_workgrp_fmt(grp) == Z_EROFS_VLE_WORKGRP_FMT_PLAIN) { > 3883a79a Gao Xiang 2018-07-26 917 /* FIXME! this should be fixed in the future */ > 3883a79a Gao Xiang 2018-07-26 918 BUG_ON(grp->llen != llen); > 3883a79a Gao Xiang 2018-07-26 919 > 3883a79a Gao Xiang 2018-07-26 920 err = z_erofs_vle_plain_copy(compressed_pages, clusterpages, > 3883a79a Gao Xiang 2018-07-26 921 pages, nr_pages, work->pageofs); > 3883a79a Gao Xiang 2018-07-26 922 goto out; > 3883a79a Gao Xiang 2018-07-26 923 } > 3883a79a Gao Xiang 2018-07-26 924 > 3883a79a Gao Xiang 2018-07-26 925 if (llen > grp->llen) > 3883a79a Gao Xiang 2018-07-26 926 llen = grp->llen; > 3883a79a Gao Xiang 2018-07-26 927 > 3883a79a Gao Xiang 2018-07-26 928 err = z_erofs_vle_unzip_fast_percpu(compressed_pages, > 3883a79a Gao Xiang 2018-07-26 929 clusterpages, pages, llen, work->pageofs, > 3883a79a Gao Xiang 2018-07-26 930 z_erofs_onlinepage_endio); > 3883a79a Gao Xiang 2018-07-26 931 if (err != -ENOTSUPP) > 3883a79a Gao Xiang 2018-07-26 932 goto out_percpu; > 3883a79a Gao Xiang 2018-07-26 933 > 3883a79a Gao Xiang 2018-07-26 934 #ifndef CONFIG_EROFS_FS_ZIP_MULTIREF > 3883a79a Gao Xiang 2018-07-26 935 if (sparsemem_pages >= nr_pages) { > 3883a79a Gao Xiang 2018-07-26 936 BUG_ON(sparsemem_pages > nr_pages); > 3883a79a Gao Xiang 2018-07-26 937 goto skip_allocpage; > 3883a79a Gao Xiang 2018-07-26 938 } > 3883a79a Gao Xiang 2018-07-26 939 #endif > 3883a79a Gao Xiang 2018-07-26 940 > 3883a79a Gao Xiang 2018-07-26 941 for (i = 0; i < nr_pages; ++i) { > 3883a79a Gao Xiang 2018-07-26 942 if (pages[i] != NULL) > 3883a79a Gao Xiang 2018-07-26 943 continue; > 3883a79a Gao Xiang 2018-07-26 944 > 3883a79a Gao Xiang 2018-07-26 945 pages[i] = __stagingpage_alloc(page_pool, GFP_NOFS); > 3883a79a Gao Xiang 2018-07-26 946 } > 3883a79a Gao Xiang 2018-07-26 947 > 3883a79a Gao Xiang 2018-07-26 948 #ifndef CONFIG_EROFS_FS_ZIP_MULTIREF > 3883a79a Gao Xiang 2018-07-26 949 skip_allocpage: > 3883a79a Gao Xiang 2018-07-26 950 #endif > 3883a79a Gao Xiang 2018-07-26 951 vout = erofs_vmap(pages, nr_pages); > 3883a79a Gao Xiang 2018-07-26 952 > 3883a79a Gao Xiang 2018-07-26 953 err = z_erofs_vle_unzip_vmap(compressed_pages, > 3883a79a Gao Xiang 2018-07-26 954 clusterpages, vout, llen, work->pageofs, overlapped); > 3883a79a Gao Xiang 2018-07-26 955 > 3883a79a Gao Xiang 2018-07-26 956 erofs_vunmap(vout, nr_pages); > 3883a79a Gao Xiang 2018-07-26 957 > 3883a79a Gao Xiang 2018-07-26 958 out: > 3883a79a Gao Xiang 2018-07-26 959 for (i = 0; i < nr_pages; ++i) { > 3883a79a Gao Xiang 2018-07-26 960 page = pages[i]; > 3883a79a Gao Xiang 2018-07-26 961 DBG_BUGON(page->mapping == NULL); > 3883a79a Gao Xiang 2018-07-26 962 > 3883a79a Gao Xiang 2018-07-26 963 /* recycle all individual staging pages */ > 3883a79a Gao Xiang 2018-07-26 964 if (z_erofs_gather_if_stagingpage(page_pool, page)) > 3883a79a Gao Xiang 2018-07-26 965 continue; > 3883a79a Gao Xiang 2018-07-26 966 > 3883a79a Gao Xiang 2018-07-26 967 if (unlikely(err < 0)) > 3883a79a Gao Xiang 2018-07-26 968 SetPageError(page); > 3883a79a Gao Xiang 2018-07-26 969 > 3883a79a Gao Xiang 2018-07-26 970 z_erofs_onlinepage_endio(page); > 3883a79a Gao Xiang 2018-07-26 971 } > 3883a79a Gao Xiang 2018-07-26 972 > 3883a79a Gao Xiang 2018-07-26 973 out_percpu: > 3883a79a Gao Xiang 2018-07-26 974 for (i = 0; i < clusterpages; ++i) { > 3883a79a Gao Xiang 2018-07-26 975 page = compressed_pages[i]; > 3883a79a Gao Xiang 2018-07-26 976 > 105d4ad8 Gao Xiang 2018-07-26 977 #ifdef EROFS_FS_HAS_MANAGED_CACHE > 105d4ad8 Gao Xiang 2018-07-26 978 if (page->mapping == mngda) > 105d4ad8 Gao Xiang 2018-07-26 979 continue; > 105d4ad8 Gao Xiang 2018-07-26 980 #endif > 3883a79a Gao Xiang 2018-07-26 981 /* recycle all individual staging pages */ > 3883a79a Gao Xiang 2018-07-26 982 (void)z_erofs_gather_if_stagingpage(page_pool, page); > 3883a79a Gao Xiang 2018-07-26 983 > 3883a79a Gao Xiang 2018-07-26 984 WRITE_ONCE(compressed_pages[i], NULL); > 3883a79a Gao Xiang 2018-07-26 985 } > 3883a79a Gao Xiang 2018-07-26 986 > 3883a79a Gao Xiang 2018-07-26 987 if (pages == z_pagemap_global) > 3883a79a Gao Xiang 2018-07-26 988 mutex_unlock(&z_pagemap_global_lock); > 3883a79a Gao Xiang 2018-07-26 989 else if (unlikely(pages != pages_onstack)) > 3883a79a Gao Xiang 2018-07-26 990 kvfree(pages); > 3883a79a Gao Xiang 2018-07-26 991 > 3883a79a Gao Xiang 2018-07-26 992 work->nr_pages = 0; > 3883a79a Gao Xiang 2018-07-26 993 work->vcnt = 0; > 3883a79a Gao Xiang 2018-07-26 994 > 3883a79a Gao Xiang 2018-07-26 995 /* all work locks MUST be taken before the following line */ > 3883a79a Gao Xiang 2018-07-26 996 > 3883a79a Gao Xiang 2018-07-26 997 WRITE_ONCE(grp->next, Z_EROFS_VLE_WORKGRP_NIL); > 3883a79a Gao Xiang 2018-07-26 998 > 3883a79a Gao Xiang 2018-07-26 999 /* all work locks SHOULD be released right now */ > 3883a79a Gao Xiang 2018-07-26 1000 mutex_unlock(&work->lock); > 3883a79a Gao Xiang 2018-07-26 1001 > 3883a79a Gao Xiang 2018-07-26 1002 z_erofs_vle_work_release(work); > 3883a79a Gao Xiang 2018-07-26 @1003 return err; > 3883a79a Gao Xiang 2018-07-26 1004 } > 3883a79a Gao Xiang 2018-07-26 1005 > > :::::: The code at line 1003 was first introduced by commit > :::::: 3883a79abd02272222a214a5f84395d41eecdc84 staging: erofs: introduce VLE decompression support > > :::::: TO: Gao Xiang <gaoxiang25@xxxxxxxxxx> > :::::: CC: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> > > --- > 0-DAY kernel test infrastructure Open Source Technology Center > https://lists.01.org/pipermail/kbuild-all Intel Corporation > _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel