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 33C43C2BD09 for ; Mon, 24 Jun 2024 12:20:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B75BA6B03E2; Mon, 24 Jun 2024 08:20:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B267A6B03E3; Mon, 24 Jun 2024 08:20:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C6256B03E5; Mon, 24 Jun 2024 08:20:49 -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 7DF316B03E2 for ; Mon, 24 Jun 2024 08:20:49 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3AA53140E6D for ; Mon, 24 Jun 2024 12:20:49 +0000 (UTC) X-FDA: 82265691018.16.2C8A5F8 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by imf26.hostedemail.com (Postfix) with ESMTP id 3150A140011 for ; Mon, 24 Jun 2024 12:20:46 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=MsCiTRGx; spf=pass (imf26.hostedemail.com: domain of urezki@gmail.com designates 209.85.208.175 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=1719231640; a=rsa-sha256; cv=none; b=eSRDQSbKanKZfSRM5yX6wEGAEeFqSg+uYJV4AAOFE6RDbOeLjjMM8l4g128rRzC8EtMJKp rAI4Uu4TSJWjXB0JY3GQgTnZZA2ZKwyTCzAv79xf4/MIrhyck3tySTSfgXoZo735rHZTWo gDF7cQ0CFO8qMNGVUssj5BoHpwPRsX8= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=MsCiTRGx; spf=pass (imf26.hostedemail.com: domain of urezki@gmail.com designates 209.85.208.175 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=1719231640; 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=TSI4KQV7tp+wxmh1FMoXKiaVJwFpmSl7UPXF+v3NqxA=; b=5855j/ukEOMeeqDRzeTjRf5gzwDs1mxM2+vGZQU1Jasv4ltaXEce535mV29p6huWFQN3vR J+OhxDdereNjYOAsRuzSGrlNoLB/UINlZ//wMCmjDvJBK4qoNJmiyjS8+Pn5c1uS3d+FNz KDJUL2XvyyapSw7dzxLXo47CZfyXPnI= Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2ebe3fb5d4dso37396371fa.0 for ; Mon, 24 Jun 2024 05:20:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719231645; x=1719836445; 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=TSI4KQV7tp+wxmh1FMoXKiaVJwFpmSl7UPXF+v3NqxA=; b=MsCiTRGxPDW2ROjx2HyaeK6Tzjm2jWOJ44DXwmtTnUMJfRKIcikxbJ9HD+oWmf2E65 DkrGIiPRR1Jg1L1pBL9jDaGdnLXgaefHcQ4XURjRefHqx13KFQtiNanY2bUJn6RuZxcg 462XmNvKQ0Oc9UtMPfLxnprOabS8sLCvGY4ZGFjlrM95o9Q4ZN+MkGqlDqBR0WySLIMF lobg/wCHnzT5gfHkfhFow7mDNaMpRg2375KucWgKjSz6j9k21cus6agHlfcnDTIPQJku rDaoPekeX7Zbxi3h1OW3MLibruYJBxrgr3hoKsCbti9EgGT+/+pa0An9EwztIrFQy6LH IYCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719231645; x=1719836445; 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=TSI4KQV7tp+wxmh1FMoXKiaVJwFpmSl7UPXF+v3NqxA=; b=fQbU9ybFNa9WfpZg+AqOKcb8o1M/BZjGN/KhP1qNAC6UeKOBwXw2zIXdcw5fKBDNcc YFoLUfA9fsy8rk+vEoaFafwEfJDSMEomEZzf9+FGjNP6JqKlbH5Wyko+pc8+yJA6HCmw 93ptAH+B0C4nj7twv1znkvtg0ZuMTlxbYp7eNE7LBSZhxljTFIz1zjnbEUpcAdnZyS5h 8nvLe0Uzh7TPbYX+3Pm/OZFtRN1TviDjgfSdc+V5BVYgMvPcGmDgjveK254J1dJc50LU sGVVShACylN767INrCMsvopeqWsGVUkrWdBogxGpVYXULr/1k+QSUDZ4LRKkfytZEreC AHWA== X-Forwarded-Encrypted: i=1; AJvYcCWgPPG5r4nKk/jLNtV0GKIZlEOOtdVES3OLN2JPCVt7PcY+34pV6Vh2LpIM1fJOCi2Mv/WTvQcLtztQTwAlv/3m79E= X-Gm-Message-State: AOJu0YzeZ9tmcU31JkZd1AAYg+lMxTnO8VFhbU4Jec0PNltpkNUcyIp/ ZcYzCxKrFu2IREPUQUpp3/UFhM9i0Kdn9F7tR+75XrKrZpU/3N0L X-Google-Smtp-Source: AGHT+IEOEr0sFekIupSP3xekgic9S7PT2e9fYoRzjDiwd7jQcu7Ky0Mjk2cBkuub50BcjRZKEkBxKQ== X-Received: by 2002:a2e:9b0b:0:b0:2ec:5364:c792 with SMTP id 38308e7fff4ca-2ec56c86e7cmr16601251fa.13.1719231645324; Mon, 24 Jun 2024 05:20:45 -0700 (PDT) Received: from pc636 (host-90-233-219-252.mobileonline.telia.com. [90.233.219.252]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ec63baecafsm1388471fa.122.2024.06.24.05.20.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 05:20:44 -0700 (PDT) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Mon, 24 Jun 2024 14:20:42 +0200 To: Nick Bowler Cc: 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <00d74f24-c49c-460e-871c-d5af64701306@draconx.ca> X-Stat-Signature: 9he6piqb4psk3c8zybxiq8wx8ts9rgbd X-Rspamd-Queue-Id: 3150A140011 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1719231646-924556 X-HE-Meta: U2FsdGVkX1/l5SOG5svndKDGEg3Cb7UoWBK/pal3E3cBfrB/RBj4ofnXH3Cir01dxU2dqu98Ey+zQt/3fvWutOx4sVBWIyAOgKZSDAb98LjiwYzWWKoxf8S7/aZ90Th3x+rmkktmbczoeFvVwQvUFpclEyTfXWqTxEDGDR0GlySRhskG/qmzfg2baCKCeGnDQRJvyNb94MIZgSamTzx+JVo5L0Fm6IdFAztwNF8g60ISfzVLINn47TMKHplHGril81ChgDftY7pM/KshEs3AggB/SFNYblHll2BpmUNoQeynHL+UUEotmfURVuMYA75C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, 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 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). > > 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). > > 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; > > xfsdump is working again. > Could you please test below? diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 5d3aa2dc88a8..1733946f7a12 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -5087,7 +5087,13 @@ void __init vmalloc_init(void) */ vmap_area_cachep = KMEM_CACHE(vmap_area, SLAB_PANIC); - for_each_possible_cpu(i) { + /* + * We use "nr_cpu_ids" here because some architectures + * may have "gaps" in cpu-possible-mask. It is OK for + * per-cpu approaches but is not OK for cases where it + * can be used as hashes also. + */ + for (i = 0; i < nr_cpu_ids; i++) { struct vmap_block_queue *vbq; struct vfree_deferred *p; Thank you in advance and i really appreciate for finding this issue! -- Uladzislau Rezki