From patchwork Sun Sep 13 11:03:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 11772301 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BA200746 for ; Sun, 13 Sep 2020 11:03:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3CDFD21548 for ; Sun, 13 Sep 2020 11:03:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="nvqgc0X9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3CDFD21548 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 07E8B6B0002; Sun, 13 Sep 2020 07:03:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 055346B0037; Sun, 13 Sep 2020 07:03:50 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E85886B0055; Sun, 13 Sep 2020 07:03:49 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0130.hostedemail.com [216.40.44.130]) by kanga.kvack.org (Postfix) with ESMTP id D24836B0002 for ; Sun, 13 Sep 2020 07:03:49 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 95CB81830EE6F for ; Sun, 13 Sep 2020 11:03:49 +0000 (UTC) X-FDA: 77257752978.13.care92_250feee270ff Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 76AEF182C371E for ; Sun, 13 Sep 2020 11:03:49 +0000 (UTC) X-Spam-Summary: 1,0,0,bcebf84cfc5580d5,d41d8cd98f00b204,aneesh.kumar@linux.ibm.com,,RULES_HIT:41:355:379:541:800:960:966:973:981:988:989:1260:1261:1311:1314:1345:1359:1431:1437:1515:1535:1542:1711:1730:1747:1777:1792:2196:2199:2380:2393:2559:2562:3138:3139:3140:3141:3142:3353:3622:3865:4117:4321:4385:5007:6117:6119:6261:6653:7903:8634:8660:9163:9391:10004:11026:11658:11914:12043:12297:12438:12555:12740:12895:12986:13148:13221:13229:13230:13255:13894:14181:14394:14721:21080:21433:21451:21627:21939:21966:21990:30029:30054:30056:30064,0,RBL:148.163.156.1:@linux.ibm.com:.lbl8.mailshell.net-62.14.0.100 64.201.201.201;04ygjhx3x6t4tc8t8tjedf159uqq1yc6j4nu8nfqxyfwukg9yrdwk94ot8ifofn.spxeop5jnhy9g69c1zb3mdekzpc9fxb1pr1iyy68aogspsz3tktknonjjuxupd4.s-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:32,LUA_SUMMARY:none X-HE-Tag: care92_250feee270ff X-Filterd-Recvd-Size: 6235 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Sun, 13 Sep 2020 11:03:48 +0000 (UTC) Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 08DB1rsU139895; Sun, 13 Sep 2020 07:03:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=/7bWLq/4UR3AFsFsX3toYMdMsUkhqc3jFmuQfJjCf+o=; b=nvqgc0X95S9O9JlOgImajcKvL6AHq0j+6tvywJfGh51oF82cGN5SXv0OQyB5DSRwOr48 K6IXFTcXwDw+SXfb4WKLK5AIQM8z06Se2jvDiBFbAahHXmhVjdYEcpxQWKCAWXfcwcCF AqHdSRA1JOX+Mq5stWQ5+nLNSje1ZlAgA8EsEK5PObwQqqCmSK988DO7IMKScL6gQfNv ayip0W0bs8T7a/cSwSkPJ+DZQJDpxvMJygWE5bZlvoCcmkd7C5Pxo75TT7YCYWZtlG4L fuzjFqrUhGYsU/qjYFyyRZ4HbBQUORHyNyd5s3NINgXqdCIIDretOv7tLn30e9utDXLO Pw== Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 33h8f5hk0e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 13 Sep 2020 07:03:37 -0400 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 08DB25LU011238; Sun, 13 Sep 2020 11:03:36 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma01dal.us.ibm.com with ESMTP id 33gny8jrur-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 13 Sep 2020 11:03:36 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 08DB3Ux021168584 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 13 Sep 2020 11:03:30 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6809BBE04F; Sun, 13 Sep 2020 11:03:35 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9FB03BE053; Sun, 13 Sep 2020 11:03:32 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.199.55.193]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Sun, 13 Sep 2020 11:03:32 +0000 (GMT) From: "Aneesh Kumar K.V" To: linux-mm@kvack.org, akpm@linux-foundation.org Cc: mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org, Anshuman Khandual , "Aneesh Kumar K.V" , kernel test robot Subject: [PATCH] mm/debug_vm_pgtable: Avoid doing memory allocation with pgtable_t mapped. Date: Sun, 13 Sep 2020 16:33:27 +0530 Message-Id: <20200913110327.645310-1-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200902114222.181353-1-aneesh.kumar@linux.ibm.com> References: <20200902114222.181353-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-09-13_01:2020-09-10,2020-09-13 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 adultscore=0 spamscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009130095 X-Rspamd-Queue-Id: 76AEF182C371E X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: With highmem, pte_alloc_map() keep the level4 page table mapped using kmap_atomic(). Avoid doing new memory allocation with page table mapped like above. [ 9.409233] BUG: sleeping function called from invalid context at mm/page_alloc.c:4822 [ 9.410557] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1, name: swapper [ 9.411932] no locks held by swapper/1. [ 9.412595] CPU: 0 PID: 1 Comm: swapper Not tainted 5.9.0-rc3-00323-gc50eb1ed654b5 #2 [ 9.413824] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014 [ 9.415207] Call Trace: [ 9.415651] ? ___might_sleep.cold+0xa7/0xcc [ 9.416367] ? __alloc_pages_nodemask+0x14c/0x5b0 [ 9.417055] ? swap_migration_tests+0x50/0x293 [ 9.417704] ? debug_vm_pgtable+0x4bc/0x708 [ 9.418287] ? swap_migration_tests+0x293/0x293 [ 9.418911] ? do_one_initcall+0x82/0x3cb [ 9.419465] ? parse_args+0x1bd/0x280 [ 9.419983] ? rcu_read_lock_sched_held+0x36/0x60 [ 9.420673] ? trace_initcall_level+0x1f/0xf3 [ 9.421279] ? trace_initcall_level+0xbd/0xf3 [ 9.421881] ? do_basic_setup+0x9d/0xdd [ 9.422410] ? do_basic_setup+0xc3/0xdd [ 9.422938] ? kernel_init_freeable+0x72/0xa3 [ 9.423539] ? rest_init+0x134/0x134 [ 9.424055] ? kernel_init+0x5/0x12c [ 9.424574] ? ret_from_fork+0x19/0x30 Reported-by: kernel test robot Signed-off-by: Aneesh Kumar K.V --- mm/debug_vm_pgtable.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c index d12bde82ae95..612c665a1136 100644 --- a/mm/debug_vm_pgtable.c +++ b/mm/debug_vm_pgtable.c @@ -994,7 +994,13 @@ static int __init debug_vm_pgtable(void) p4dp = p4d_alloc(mm, pgdp, vaddr); pudp = pud_alloc(mm, p4dp, vaddr); pmdp = pmd_alloc(mm, pudp, vaddr); - ptep = pte_alloc_map(mm, pmdp, vaddr); + /* + * Allocate pgtable_t + */ + if (pte_alloc(mm, pmdp)) { + pr_err("pgtable allocation failed\n"); + return 1; + } /* * Save all the page table page addresses as the page table @@ -1048,8 +1054,7 @@ static int __init debug_vm_pgtable(void) * proper page table lock. */ - ptl = pte_lockptr(mm, pmdp); - spin_lock(ptl); + ptep = pte_offset_map_lock(mm, pmdp, vaddr, &ptl); pte_clear_tests(mm, ptep, pte_aligned, vaddr, prot); pte_advanced_tests(mm, vma, ptep, pte_aligned, vaddr, prot); pte_unmap_unlock(ptep, ptl);