Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp4844ybm; Tue, 26 May 2020 09:21:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz24IMV+xsaY6LsQS6Wlw1gq4saqhJFkQeDiuYfka9nibyF0KEK4UQGEloer0D41JDI+zwO X-Received: by 2002:a17:906:9249:: with SMTP id c9mr1891529ejx.173.1590510080083; Tue, 26 May 2020 09:21:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590510080; cv=none; d=google.com; s=arc-20160816; b=tyUGkxnOOv2On5uRq6BHrzZDXWpfNL7/KpEK1jYa0eEvuzucEWxR3j14nxPpDZt6hR gEw2dM2NYmAlY4P1LLjXSoMB0gYWW2ModVHfs2ksFpxitl/aLLoBU4tMtWl6GeKrbGQt T0LPCryCT2Z9WG2zi4xSzymZnVJ4G/YS1UjR5OMCLWkuy2zq2rbOa5BVPdNaXOvp04nd ApBtEFE1Ah/5AcQ670eu4Z2tRyb7DWDuDqQRH9K9SVEiV7yGWFSvbJlnis8TxRjZeoTe Fc0SQ5dCIU5IOfmE0GZIrpYnmBmQp+fFuVibg9leJcJ+25O9tFmxNqKJZ1085bAEFk7t KhfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:from:references:cc:to:subject:dkim-signature; bh=iSh71IsMqjVcHLkoit8W8c+kNI1QUMO+CiEGYra3TPc=; b=lyZJvSPVFTk8+VcsJmAecdtEy7rVi90cL/16L/8kqPVlu/UdgHYOrjgFeBlKu1IFOd 0RfeX56Gw+YAX0ubclJhWYULOswb/L32RxG8Vbx7+fb6PnIbRwX+F6JhikRwYT7NoBt7 d83kSz4qHB0QIe4pTc5QqGggQq7W935pQgOvAD0vdpz7stxRJ9dtecARrlxwET6IP1QX Pzp3pDEEL9IxaKMQnXuJDG7QXrXFC+gwmSFv1yrjKCi/14iNSHA00H6tyQhfre1Is1tz vyGQY7C46UA6okJk2kkhLrZ/WiV3TUv+BBj9l8INJtErDf0o6ugKr6KamQ6zwlBUyYav sElQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=u+RDQPE1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r8si191502edi.84.2020.05.26.09.20.56; Tue, 26 May 2020 09:21:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=u+RDQPE1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388061AbgEZQS6 (ORCPT + 99 others); Tue, 26 May 2020 12:18:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728280AbgEZQS5 (ORCPT ); Tue, 26 May 2020 12:18:57 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88019C03E96D for ; Tue, 26 May 2020 09:18:57 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id 23so10371373pfy.8 for ; Tue, 26 May 2020 09:18:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=iSh71IsMqjVcHLkoit8W8c+kNI1QUMO+CiEGYra3TPc=; b=u+RDQPE1BrJiZ0y/2neMhWm2dV7NaP3cvNkfgME6XRBnj8eJ7YKKKlGezZW2eptPVw nKXaVyE/pmMezs+5f10wefnn6McnYQR2RJ8itImtsDIG7LRu9aoQw4qohRv66XPn1Rxq RgKbFNAJ/N7WirvozWWW0JYRQy25n67JZWGTJlyVEIbg2hv5az8XR6N+9fIc1Aqvtm8U XGWfW82cVwcGnHDRytgNNsl5abskbCsNM52ZyvSwo9i2OYUJzEGDEv1oHJjfYqhipO8I a/0OCjSTpQH7yokwGG0whMMzWzyiiRfLI5XM+uovDiy9GLE/TDw1HssAwa4O8tzvi9rd 0VRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=iSh71IsMqjVcHLkoit8W8c+kNI1QUMO+CiEGYra3TPc=; b=Sf8afXKgtnc3flktU2mjk1cJDZ7bf16H2Kwz8di7QX8Ay0TYM5R//06rfgPYOuQFAm sw8eyYAFnAvDaaPOzie7vObqxjIK2n2TJFpaPC7kb/oYT0sQg9fmlx1+YW+oNp3BpAc/ kXlaF8gJhej+HH6f6tB5O7Ec0xh8Oxb3bcmTPdDPZtUE1sqLsfehPKHfTYy/aQAmAs5K OZo+VnjVLott5YMQnvfK6QK7+Vb9vCLtxevBCUTFWZljEJs8tBeH1Jx/n3Ch/L6Hne/C DiZr4wi4dUViZ6ps5XKIZAPi6CNQuiFYbtE/p2FLDte1vyXn8PcAe7e8X58qd6SKA1no Mn2A== X-Gm-Message-State: AOAM530NVoHcysYj6I8+mey6GUTmsoQts6JW2/OjNUCGknBI3/i5cR08 afeMEJBbmvQ2xbIFcyehoXIxxHc6 X-Received: by 2002:a63:5c4c:: with SMTP id n12mr1819826pgm.320.1590509936993; Tue, 26 May 2020 09:18:56 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id q44sm72118pja.29.2020.05.26.09.18.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 26 May 2020 09:18:56 -0700 (PDT) Subject: Re: [PATCH v5 04/18] sparc32: mm: Reduce allocation size for PMD and PTE tables To: Will Deacon , Mike Rapoport Cc: linux-kernel@vger.kernel.org, elver@google.com, tglx@linutronix.de, paulmck@kernel.org, mingo@kernel.org, peterz@infradead.org, "David S. Miller" References: <20200511204150.27858-5-will@kernel.org> <20200517000050.GA87467@roeck-us.net> <20200517000750.GA157503@roeck-us.net> <20200518083715.GA31383@willie-the-truck> <20200520170306.GG1118872@kernel.org> <6034a1b5-d4f6-c836-142c-9b3b06db3246@roeck-us.net> <20200520195110.GH1118872@kernel.org> <20200524123256.GN1118872@kernel.org> <20200526132634.GC27166@willie-the-truck> <20200526140126.GD27166@willie-the-truck> From: Guenter Roeck Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQk3bC90xXMPg+O3R+C/SkwcnUak1UZaeK/SwQbq/t0tkMzYDRxfJ7 nyFiKxUehbNF3r9qlJgPqONwX5vJy4/GvDHdddSCxV41P/ejsZ8PykxyJs98UWhF54tGRWFl 7i1xvaDB9lN5WTLRKSO7wICuLiSz5WZHXMkyF4d+/O5ll7yz/o/JxK5vO/sduYDIlFTvBZDh gzaEtNf5tQjsjG4io8E0Yq0ViobLkS2RTNZT8ICq/Jmvl0SpbHRvYwa2DhNsK0YjHFQBB0FX IdhdUEzNefcNcYvqigJpdICoP2e4yJSyflHFO4dr0OrdnGLe1Zi/8Xo/2+M1dSSEt196rXaC kwu2KgIgmkRBb3cp2vIBBIIowU8W3qC1+w+RdMUrZxKGWJ3juwcgve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YCOrT4jriMFBtKNPtj2EE4DNV4s7k0Zy+6iRQ8G8ng QjsSqYJx8iAR8JRB7Gm2rQOMv8lSRdjva++GT0VLXtHULdlzg8VjDnFZ3lfz5PWEOeIMk7Rj trjv82EZtrhLuLjHRCaG50OOm0hwPSk1J64R8O3HjSLdertmw7eyAYOo4RuWJguYMg5DRnBk WkRwrSuCn7UG+qVWZeKEsFKFOkynOs3pVbcbq1pxbhk3TRWCGRU5JolI4ohy/7JV1TVbjiDI HP/aVnm6NC8of26P40Pg8EdAhajZnHHjA7FrJXsy3cyIGqvg9os4rNkUWmrCfLLsZDHD8FnU mDW4+i+XlNFUPUYMrIKi9joBhu18ssf5i5Q= Message-ID: Date: Tue, 26 May 2020 09:18:54 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200526140126.GD27166@willie-the-truck> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/26/20 7:01 AM, Will Deacon wrote: > On Tue, May 26, 2020 at 02:26:35PM +0100, Will Deacon wrote: >> On Sun, May 24, 2020 at 03:32:56PM +0300, Mike Rapoport wrote: >>> On Thu, May 21, 2020 at 04:02:11PM -0700, Guenter Roeck wrote: >>>> On 5/20/20 12:51 PM, Mike Rapoport wrote: >>>>> On Wed, May 20, 2020 at 12:03:31PM -0700, Guenter Roeck wrote: >>>>>> With above patch applied on top of Ira's patch, I get: >>>>>> >>>>>> BUG: spinlock recursion on CPU#0, S01syslogd/139 >>>>>> lock: 0xf5448350, .magic: dead4ead, .owner: S01syslogd/139, .owner_cpu: 0 >>>>>> CPU: 0 PID: 139 Comm: S01syslogd Not tainted 5.7.0-rc6-next-20200518-00002-gb178d2d56f29-dirty #1 >>>>>> [f0067a64 : >>>>>> do_raw_spin_lock+0xa8/0xd8 ] >>>>>> [f00d5034 : >>>>>> copy_page_range+0x328/0x804 ] >>>>>> [f0025be4 : >>>>>> dup_mm+0x334/0x434 ] >>>>>> [f0027124 : >>>>>> copy_process+0x1224/0x12b0 ] >>>>>> [f0027344 : >>>>>> _do_fork+0x54/0x30c ] >>>>>> [f0027670 : >>>>>> do_fork+0x5c/0x6c ] >>>>>> [f000de44 : >>>>>> sparc_do_fork+0x18/0x38 ] >>>>>> [f000b7f4 : >>>>>> do_syscall+0x34/0x40 ] >>>>>> [5010cd4c : >>>>>> 0x5010cd4c ] >>>>>> >>>>>> Looks like yet another problem. >>>>> >>>>> I've checked the patch above on top of the mmots which already has Ira's >>>>> patches and it booted fine. I've used sparc32_defconfig to build the >>>>> kernel and qemu-system-sparc with default machine and CPU. >>>>> >>>> >>>> Try sparc32_defconfig+SMP. >>> >>> I see a differernt problem, but this could be related: >>> >>> INIT: version 2.86 booting >>> rcu: INFO: rcu_sched detected stalls on CPUs/tasks: >>> (detected by 0, t=5252 jiffies, g=-935, q=3) >>> rcu: All QSes seen, last rcu_sched kthread activity 5252 (-68674--73926), jiffies_till_next_fqs=1, root ->qsmask 0x0 >>> rcu: rcu_sched kthread starved for 5252 jiffies! g-935 f0x2 RCU_GP_WAIT_FQS(5) ->state=0x0 ->cpu=0 >>> rcu: Unless rcu_sched kthread gets sufficient CPU time, OOM is now expected behavior. >>> rcu: RCU grace-period kthread stack dump: >>> rcu_sched R running task 0 10 2 0x00000000 >>> >>> I'm running a bit old debian [1] with qemu-img-sparc. >>> >>> My bisect pointed at commit 8c8f3156dd40 ("sparc32: mm: Reduce >>> allocation size for PMD and PTE tables"). The commit ID is valid for >>> next-20200522. >> >> Can you try the diff below please? > > Actually, that's racy. New version below! > Applied on top of next-20200526, with defconfig+SMP, I still get: BUG: Bad page state in process swapper/0 pfn:0069f many times. Did I have to revert something else ? Sorry, I lost track. Note that "-smp 2" on SS-10 works for me (with the same page state messages). Guenter > Will > > --->8 > > diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c > index c861c0f0df73..068029471aa4 100644 > --- a/arch/sparc/mm/srmmu.c > +++ b/arch/sparc/mm/srmmu.c > @@ -363,11 +363,16 @@ pgtable_t pte_alloc_one(struct mm_struct *mm) > > if ((ptep = pte_alloc_one_kernel(mm)) == 0) > return NULL; > + > page = pfn_to_page(__nocache_pa((unsigned long)ptep) >> PAGE_SHIFT); > - if (!pgtable_pte_page_ctor(page)) { > - __free_page(page); > - return NULL; > + > + spin_lock(&mm->page_table_lock); > + if (page_ref_inc_return(page) == 2 && !pgtable_pte_page_ctor(page)) { > + page_ref_dec(page); > + ptep = NULL; > } > + spin_unlock(&mm->page_table_lock); > + > return ptep; > } > > @@ -376,7 +381,12 @@ void pte_free(struct mm_struct *mm, pgtable_t ptep) > struct page *page; > > page = pfn_to_page(__nocache_pa((unsigned long)ptep) >> PAGE_SHIFT); > - pgtable_pte_page_dtor(page); > + > + spin_lock(&mm->page_table_lock); > + if (page_ref_dec_return(page) == 1) > + pgtable_pte_page_dtor(page); > + spin_unlock(&mm->page_table_lock); > + > srmmu_free_nocache(ptep, SRMMU_PTE_TABLE_SIZE); > } > > diff --git a/mm/Kconfig b/mm/Kconfig > index c1acc34c1c35..97458119cce8 100644 > --- a/mm/Kconfig > +++ b/mm/Kconfig > @@ -192,6 +192,9 @@ config MEMORY_HOTREMOVE > # Default to 4 for wider testing, though 8 might be more appropriate. > # ARM's adjust_pte (unused if VIPT) depends on mm-wide page_table_lock. > # PA-RISC 7xxx's spinlock_t would enlarge struct page from 32 to 44 bytes. > +# SPARC32 allocates multiple pte tables within a single page, and therefore > +# a per-page lock leads to problems when multiple tables need to be locked > +# at the same time (e.g. copy_page_range()). > # DEBUG_SPINLOCK and DEBUG_LOCK_ALLOC spinlock_t also enlarge struct page. > # > config SPLIT_PTLOCK_CPUS > @@ -199,6 +202,7 @@ config SPLIT_PTLOCK_CPUS > default "999999" if !MMU > default "999999" if ARM && !CPU_CACHE_VIPT > default "999999" if PARISC && !PA20 > + default "999999" if SPARC32 > default "4" > > config ARCH_ENABLE_SPLIT_PMD_PTLOCK >