From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62B7AC27C44 for ; Fri, 31 May 2024 10:03:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F1A826B009B; Fri, 31 May 2024 06:03:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EC9FA6B009C; Fri, 31 May 2024 06:03:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D91216B009D; Fri, 31 May 2024 06:03:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id BB5146B009B for ; Fri, 31 May 2024 06:03:15 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 68E2B40EC8 for ; Fri, 31 May 2024 10:03:15 +0000 (UTC) X-FDA: 82178253150.17.4B32418 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 783361A0020 for ; Fri, 31 May 2024 10:03:13 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Uilp6Lze; spf=pass (imf19.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717149793; a=rsa-sha256; cv=none; b=oOxfl9LItR+77mOdntCmdFnuQe68ZR0IshCkm/wBxJm1KL+6sZkIY/r+7g2iaoaJinwqry GPpQ5QGEiGJABSJJMupkWhvSGfnk/N54bapiKRS9ps2eRfYYSrcLrJ8zOuNNGp9suFumd/ B4+xAQ5A7ee+iQv1DBqNbmpDqs79xYg= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Uilp6Lze; spf=pass (imf19.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717149793; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Zc7MonfzRyeQDwj3Ud3usru80cZaxIT/UX2rYkzrde4=; b=Ht69knUilg6w8EME3gNhfKTxViLtta/KKbSpihluDeDc7QDWKUTob6n9+Z4A4MhL1CmOCd rsiyxqhokg5TdpUxOGP8P+nzRS/ri1igoXr39fRIgm2ROosFNx2tmI9V9qHeh1LNSlnFiN SJY2aM4DHRBsn/xdOvfWkIjDnPQMjXI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717149792; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Zc7MonfzRyeQDwj3Ud3usru80cZaxIT/UX2rYkzrde4=; b=Uilp6LzejXB9tiGmOE+dT7nnMTe5/eprXaZQWNvVOQD29Iky8wC3bmDsDaHK8GmuT6gI/a BKs3Xi9tim2/eVFUd0alb+1XztR3lRsva1an464zpqfZ6nAUe7H14kQmPNgc32dvgXxlol SdIS6UiTHQA7IM2JgECMpsn61MkZiO8= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-687-qV7CmnWQOEOsxg0EZQL2qw-1; Fri, 31 May 2024 06:03:06 -0400 X-MC-Unique: qV7CmnWQOEOsxg0EZQL2qw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9D9E33806701; Fri, 31 May 2024 10:03:05 +0000 (UTC) Received: from localhost (unknown [10.72.116.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 04FB4C15BB1; Fri, 31 May 2024 10:03:03 +0000 (UTC) Date: Fri, 31 May 2024 18:03:00 +0800 From: Baoquan He To: Uladzislau Rezki Cc: "zhaoyang.huang" , Andrew Morton , Christoph Hellwig , Lorenzo Stoakes , Thomas Gleixner , hailong liu , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zhaoyang Huang , steve.kang@unisoc.com Subject: Re: [PATCHv3] mm: fix incorrect vbq reference in purge_fragmented_block Message-ID: References: <20240531030520.1615833-1-zhaoyang.huang@unisoc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Rspamd-Queue-Id: 783361A0020 X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: eqwmnegjx1q1gx6xff1a3bo37u45xbup X-HE-Tag: 1717149793-421043 X-HE-Meta: U2FsdGVkX1/xdtatYZiWWgcB3YsUhXQnt6FkMExJBbITyUtP0FtMAXr1HUGJZdFort8BAm9L+UFHPXVgGXD2qO5VKj58LY9toZs8taYJfV7eVaLL0sEznRMaYLylNL35YcwXjcq0gZgaWwJ+dRXFAfzW8n6ncOolvk1u+XHN5jrT1Eld69iVi+pSNR+5TJSbMyraQT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EQYQkxHc6WghFEJxMk63mOuTyDTqkQ/Y0Fm/kaM7r33i3R1rTJNQADskjioQMZqlfqxBlzpJBUU95tqkgsxdnQ== 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: List-Subscribe: List-Unsubscribe: On 05/31/24 at 10:04am, Uladzislau Rezki wrote: > On Fri, May 31, 2024 at 11:05:20AM +0800, zhaoyang.huang wrote: > > From: Zhaoyang Huang > > > > vmalloc area runs out in our ARM64 system during an erofs test as > > vm_map_ram failed[1]. By following the debug log, we find that > > vm_map_ram()->vb_alloc() will allocate new vb->va which corresponding > > to 4MB vmalloc area as list_for_each_entry_rcu returns immediately > > when vbq->free->next points to vbq->free. That is to say, 65536 times > > of page fault after the list's broken will run out of the whole > > vmalloc area. This should be introduced by one vbq->free->next point to > > vbq->free which makes list_for_each_entry_rcu can not iterate the list > > and find the BUG. > > > > [1] > > PID: 1 TASK: ffffff80802b4e00 CPU: 6 COMMAND: "init" > > #0 [ffffffc08006afe0] __switch_to at ffffffc08111d5cc > > #1 [ffffffc08006b040] __schedule at ffffffc08111dde0 > > #2 [ffffffc08006b0a0] schedule at ffffffc08111e294 > > #3 [ffffffc08006b0d0] schedule_preempt_disabled at ffffffc08111e3f0 > > #4 [ffffffc08006b140] __mutex_lock at ffffffc08112068c > > #5 [ffffffc08006b180] __mutex_lock_slowpath at ffffffc08111f8f8 > > #6 [ffffffc08006b1a0] mutex_lock at ffffffc08111f834 > > #7 [ffffffc08006b1d0] reclaim_and_purge_vmap_areas at ffffffc0803ebc3c > > #8 [ffffffc08006b290] alloc_vmap_area at ffffffc0803e83fc > > #9 [ffffffc08006b300] vm_map_ram at ffffffc0803e78c0 > > > > Fixes: fc1e0d980037 ("mm/vmalloc: prevent stale TLBs in fully utilized blocks") > > > > Suggested-by: Hailong.Liu > > Signed-off-by: Zhaoyang Huang > > > Is a problem related to run out of vmalloc space _only_ or it is a problem > with broken list? From the commit message it is hard to follow the reason. The broken list caused the vmalloc space run out. I think we should fix the broken list. Wondering if the issue can be always reproduced, or rarely seen. We should try making a patch to fix the list breakage unless it's not feasible. I will have a look at this. > > Could you please post a full trace or panic? > > > --- > > v2: introduce cpu in vmap_block to record the right CPU number > > v3: use get_cpu/put_cpu to prevent schedule between core > > --- > > --- > > mm/vmalloc.c | 12 ++++++++---- > > 1 file changed, 8 insertions(+), 4 deletions(-) > > > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > > index 22aa63f4ef63..ecdb75d10949 100644 > > --- a/mm/vmalloc.c > > +++ b/mm/vmalloc.c > > @@ -2458,6 +2458,7 @@ struct vmap_block { > > struct list_head free_list; > > struct rcu_head rcu_head; > > struct list_head purge; > > + unsigned int cpu; > > }; > > > > /* Queue of free and dirty vmap blocks, for allocation and flushing purposes */ > > @@ -2586,10 +2587,12 @@ static void *new_vmap_block(unsigned int order, gfp_t gfp_mask) > > return ERR_PTR(err); > > } > > > > + vb->cpu = get_cpu(); > > vbq = raw_cpu_ptr(&vmap_block_queue); > > spin_lock(&vbq->lock); > > list_add_tail_rcu(&vb->free_list, &vbq->free); > > spin_unlock(&vbq->lock); > > + put_cpu(); > > > Why do you need get_cpu() here? Can you go with raw_smp_processor_id() > and then access the per-cpu "vmap_block_queue"? get_cpu() disables > preemption and then a spin-lock is take within this critical section. > From the first glance PREEMPT_RT is broken in this case. > > I am on a vacation, responds can be with delays. > > -- > Uladzislau Rezki >