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 BC66CC27C4F for ; Fri, 21 Jun 2024 09:44:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 49FA06B00CD; Fri, 21 Jun 2024 05:44:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 44FF48D00DB; Fri, 21 Jun 2024 05:44:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F1AF6B00CE; Fri, 21 Jun 2024 05:44:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 074EE8D00DB for ; Fri, 21 Jun 2024 05:44:17 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A9B10C035B for ; Fri, 21 Jun 2024 09:44:17 +0000 (UTC) X-FDA: 82254410154.25.FE76AE7 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) by imf30.hostedemail.com (Postfix) with ESMTP id B846080026 for ; Fri, 21 Jun 2024 09:44:15 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Oim9m24s; spf=pass (imf30.hostedemail.com: domain of urezki@gmail.com designates 209.85.218.48 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718963051; 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=YH8HgTmsyYTHd1UBCvXdgm36Yrr0b+GSZnRwwUHMfH4=; b=HHU2vVYfyRexaaGk30daIomb5/UMyMZfUokobMmS4BZ4y5q7vgwP3tctS51j27vU/udkDL Ikn2neBuDkQItuGg1gcO5ZYXfy2i2NTspLUIanH/kEkfFu/3JeiUDtRt9T6jq6ATRTQzrG Zil60N95Mn8NWkRmfeRzmPJ0oKf1VSk= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Oim9m24s; spf=pass (imf30.hostedemail.com: domain of urezki@gmail.com designates 209.85.218.48 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718963051; a=rsa-sha256; cv=none; b=EjW2QhvsJuTQQmYv0a9KVuNFrZOzQ2u12zOi1tOchbVFkBXmTRjLmwvBaqvV1KX1bpU2ET prMg30YEQiosg32YQ1evezp85aiWWBgA22L6qeDSu6Eu+z7RO0dSVhPgsZlmoozYGcc++O d22Ht9IEAa8C1/bAmQQAX+5HxVeVJwg= Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a6fd7bee2feso7834566b.1 for ; Fri, 21 Jun 2024 02:44:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718963054; x=1719567854; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=YH8HgTmsyYTHd1UBCvXdgm36Yrr0b+GSZnRwwUHMfH4=; b=Oim9m24sgcbPu/CwzAi/I+yfUzF6bFJQEwKeB12rnmypD//4w0hAg1bSUoYxkn+5Pr dcS4AjEHVEa8KlA7ZUE2meE7njRqP1AMBjVVX/9HnTVCKzLo069TVyxNETGN6x1IPfB3 FLpqkCh5LXgtte6D5FskxZmM69efFGQ6cNLSCYmUEzWFyCTpw9LCA/u0hsL9ybyVbpy+ 00sAx61dt0LxlqBqdHajcrMNbP3QE6tuFPfGp+A+wy4b4zKnMTztOBhgABMX/UpU/Yh+ nLOaaVNEebYV/M7Kv6gq86NWiixRoINlmEYEww7pmbfD47vuBQ8ZycbLJSzWS6hLzPVq gyjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718963054; x=1719567854; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YH8HgTmsyYTHd1UBCvXdgm36Yrr0b+GSZnRwwUHMfH4=; b=G6rLxDU+paI1EpixQrzyk8RdHK15HtE3u51AjLKRdTD1vuO5O7gJKLgrhmPaOfgfr+ uRDQ+AwE3lgqQzLllLGdGhJXq6u4m4WLXePBh6ua36bRUN14Vu33ZOkn5Z9Q0jTNMzf3 oXPChe50/dmaJPTAb6nOmgDAqpbM7bVaruIoRWFcFPcl/kvvlA1T4muPKzJHMahtKkxY LYjbQbLQj9osIinYb+1p31XW0xJ17XwHWLH38cuccgpmi0B+IJdVaCv1Es5oWpgKbCwy I+LyOaEWp0mHmdniJIbwgr/aEiAVmziuEBJ9Ppa60Hgs4svoH9hcwD1xAl8gq+oc2XXT +kRw== X-Forwarded-Encrypted: i=1; AJvYcCWa3ozp+Ik7szc81LEa0PiacAGJ1/w5FIqO1gvxRlqZaLhQYax/6YbXYi40aYO18pZxzkI9R5rKwPHNDp7sYtiPPek= X-Gm-Message-State: AOJu0YyGzjxh6XA/GEx2+VcxDVK97bzGtqa8r3Z1DJLf5Bg1V26kgPWv k7521FHKra+m3YIlbEdyucbB06n02Anv9zFG4/06cOWsc21YI+Vr X-Google-Smtp-Source: AGHT+IHFvIYFRPxClWRA8y4JLBhyArN9ZGGm2+KYv28v2EmS+G6m3eLsRivYBY4rUA6LGQZV4cbFow== X-Received: by 2002:a17:907:a602:b0:a6f:5efb:5c8 with SMTP id a640c23a62f3a-a6fab6088e7mr596883766b.9.1718963054027; Fri, 21 Jun 2024 02:44:14 -0700 (PDT) Received: from pc636 (176-227-201-31.ftth.glasoperator.nl. [31.201.227.176]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6fcf48b17esm64261166b.88.2024.06.21.02.44.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 02:44:13 -0700 (PDT) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Fri, 21 Jun 2024 11:44:12 +0200 To: Baoquan He , Nick Bowler Cc: Hailong Liu , Nick Bowler , linux-kernel@vger.kernel.org, Linux regressions mailing list , linux-mm@kvack.org, sparclinux@vger.kernel.org, "Uladzislau Rezki (Sony)" , Andrew Morton Subject: Re: PROBLEM: kernel crashes when running xfsdump since ~6.4 Message-ID: References: <75e17b57-1178-4288-b792-4ae68b19915e@draconx.ca> <00d74f24-c49c-460e-871c-d5af64701306@draconx.ca> <20240621033005.6mccm7waduelb4m5@oppo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: B846080026 X-Stat-Signature: rhy6p41ry9s3g4hxupu8rsh7ehswupw3 X-HE-Tag: 1718963055-151885 X-HE-Meta: U2FsdGVkX1/+m86+eBHzcBjDciUhTJskVrPjEmSVv5mzg3RMrc4I+E1CGI5DVs34aZP/vGpvlD/kqH7BJd/D9wmQ/ULcECFIbVxg3rzIKT9O2m88X3Lq4AtTrtGNtusbQ6PVA3xbUy/dNbjccMouLcJ7CHk9r6Z1SkMl2ZeMXxcUqldxGOZhecw7Jnk6TohErHqoUZN888Zbbdv8GITVkFBwITy55+9KUuHXH7XRR4SBqkOcScZe5y3tEA2fn+/BNoBdHev2OP2zM47oFMUePTBS/yP5yXn0DABmYzoocYmcVyQfZm5SkYWUTmL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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 Fri, Jun 21, 2024 at 03:07:16PM +0800, Baoquan He wrote: > On 06/21/24 at 11:30am, Hailong Liu wrote: > > On Thu, 20. Jun 14:02, Nick Bowler wrote: > > > On 2024-06-20 02:19, Nick Bowler wrote: > > > > After upgrading my sparc to 6.9.5 I noticed that attempting to run > > > > xfsdump instantly (within a couple seconds) and reliably crashes the > > > > kernel. The same problem is also observed on 6.10-rc4. > > > [...] > > > > 062eacf57ad91b5c272f89dc964fd6dd9715ea7d is the first bad commit > > > > commit 062eacf57ad91b5c272f89dc964fd6dd9715ea7d > > > > Author: Uladzislau Rezki (Sony) > > > > Date: Thu Mar 30 21:06:38 2023 +0200 > > > > > > > > mm: vmalloc: remove a global vmap_blocks xarray > > > > > > I think I might see what is happening here. > > > > > > On this machine, there are two CPUs numbered 0 and 2 (there is no CPU1). > > > > > +Baoquan > > Thanks for adding me, Hailong. > > > > > Ahh, I thought you are right. addr_to_vb_xa assume that the CPU numbers are > > contiguous. I don't have knowledge about CPU at all. > > Technically change the implement addr_to_vb_xa() to > > return &per_cpu(vmap_block_queue, raw_smp_processor_id()).vmap_blocks; > > would also work, but it violate the load balance. Wating for > > experts reply. > > Yeah, I think so as you explained. > > > > > > The per-cpu variables in mm/vmalloc.c are initialized like this, in > > > vmalloc_init > > > > > > for_each_possible_cpu(i) { > > > /* ... */ > > > vbq = &per_cpu(vmap_block_queue, i); > > > /* initialize stuff in vbq */ > > > } > > > > > > This loops over the set bits of cpu_possible_mask, bits 0 and 2 are set, > > > so it initializes stuff with i=0 and i=2, skipping i=1 (I added prints to > > > confirm this). > > > > > > Then, in vm_map_ram, with the problematic change it calls the new > > > function addr_to_vb_xa, which does this: > > > > > > int index = (addr / VMAP_BLOCK_SIZE) % num_possible_cpus(); > > > return &per_cpu(vmap_block_queue, index).vmap_blocks; > > > > > > The num_possible_cpus() function counts the number of set bits in > > > cpu_possible_mask, so it returns 2. Thus, index is either 0 or 1, which > > > does not correspond to what was initialized (0 or 2). The crash occurs > > > when the computed index is 1 in this function. In this case, the > > > returned value appears to be garbage (I added prints to confirm this). > > This is a great catch. > Indeed :) > > > > > > If I change addr_to_vb_xa function to this: > > > > > > int index = ((addr / VMAP_BLOCK_SIZE) & 1) << 1; /* 0 or 2 */ > > > return &per_cpu(vmap_block_queue, index).vmap_blocks; > > Yeah, while above change is not generic, e.g if it's CPU0 and CPU3. > I think we should take the max possible CPU number as the hush bucket > size. The vb->va is also got from global free_vmap_area, so no need to > worry about the waste. > Agree. > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index be2dd281ea76..18e87cafbaf2 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -2542,7 +2542,7 @@ static DEFINE_PER_CPU(struct vmap_block_queue, vmap_block_queue); > static struct xarray * > addr_to_vb_xa(unsigned long addr) > { > - int index = (addr / VMAP_BLOCK_SIZE) % num_possible_cpus(); > + int index = (addr / VMAP_BLOCK_SIZE) % nr_cpu_ids; > > return &per_cpu(vmap_block_queue, index).vmap_blocks; > } > The problem i see is about not-initializing of the: for_each_possible_cpu(i) { struct vmap_block_queue *vbq; struct vfree_deferred *p; vbq = &per_cpu(vmap_block_queue, i); spin_lock_init(&vbq->lock); INIT_LIST_HEAD(&vbq->free); p = &per_cpu(vfree_deferred, i); init_llist_head(&p->list); INIT_WORK(&p->wq, delayed_vfree_work); xa_init(&vbq->vmap_blocks); } correctly or fully. It is my bad i did not think that CPUs in a possible mask can be non sequential :-/ nr_cpu_ids - is not the max possible CPU. For example, in Nick case, when he has two CPUs, num_possible_cpus() and nr_cpu_ids are the same. Or i missed something in your patch, Baoquan? -- Uladzislau Rezki