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 BB19AC2D0D1 for ; Mon, 24 Jun 2024 12:17:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 310B96B03E0; Mon, 24 Jun 2024 08:17:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C0D06B03E1; Mon, 24 Jun 2024 08:17:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 161266B03E2; Mon, 24 Jun 2024 08:17:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E86E36B03E0 for ; Mon, 24 Jun 2024 08:17:43 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9AD10140E70 for ; Mon, 24 Jun 2024 12:17:43 +0000 (UTC) X-FDA: 82265683206.02.CC40C55 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by imf20.hostedemail.com (Postfix) with ESMTP id 890181C0024 for ; Mon, 24 Jun 2024 12:17:41 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=XGpWWLYL; spf=pass (imf20.hostedemail.com: domain of urezki@gmail.com designates 209.85.167.44 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=1719231443; 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=od+jH6L9t73h5zcRVnTnTfDsZO/0F05mRIypT0waugI=; b=d4rEl7CUisFjx6ndr+qFtXyKpOZCvuigA6RbDVK+PGgXuJLlgxzdjYn9plbxtzfhArmay2 wOs6/u7CsXqb5k3xrTz67sIZdBc5bamzCt3mARY024ZWQgvjEVlPapQMAP1Oano82AUaHC PpIoU1Yng4TnPnyfRBcgprT/C3v9Was= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=XGpWWLYL; spf=pass (imf20.hostedemail.com: domain of urezki@gmail.com designates 209.85.167.44 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=1719231443; a=rsa-sha256; cv=none; b=1y4ItphQbhQNXpHEyyCUQynu94bAVu00BHU40jrHsWzT5XjgKbYkjyIlwXsfe5qRgwLSAd L+Uti9kDV9A2a3U2aHtJgZ7vtcinuQoXCvKCtfCMhBH1qZsdsL28PqMkNOENMK+tiluZ5f gRjkSXpwfc78FA1Cz0jXzwiUUIsw6Po= Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-5295e488248so4815475e87.2 for ; Mon, 24 Jun 2024 05:17:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719231460; x=1719836260; 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=od+jH6L9t73h5zcRVnTnTfDsZO/0F05mRIypT0waugI=; b=XGpWWLYLsR7JT8gAa4j928fUrYunFqQIOgaHMDZZe9VAPzzz1+0dhhOvzB8kdy+/ty kFqZHhSIKTfX8A9bDf5fM8kgPUluprQh7C98IBrrYjVa8Xe+1LdGlAsr8UsAwYPQ2KwA FeYnkCu4T5PiZA0EXHJTH9fDgOvNToCItkkwmggsizh5xVejPFUqCrZHBY6jOiQhGbSZ qo1m/APsGPGhsUqEIN7zqwD1FRRL6KUa/OnhvoFV29s4B2dYEPwHOgsGkfAQsRDw1xQs ThnR0pOjOvSUi9ZdZMSa5yDa4Hwve1JykFzYFccDPNlGK6el1VyqR0IDQ67bJUtrW7g7 F7YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719231460; x=1719836260; 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=od+jH6L9t73h5zcRVnTnTfDsZO/0F05mRIypT0waugI=; b=QPl1r00UkWlHlMIfLr5kIb2nNF1vnPCdgd31gsiLVzKbU6O1TpmaSNDdfFqsFCDUYi oMee3RlfePfeIaBvdG6YPJ3uGM8okMV6P7ZRN4/UFE76kA1/ZTU7W/G0FMvLYkmmGhwc gMb+6TzQZM9VPhB/PqfHn6LXVP+qQ8UCelBI67Jri6uoxJZWg8LVdyLbSOOPfj+/7b8z 7rX1V1EJ4idTrp+zm7d5jXTR0COVNPZ4xsJewn/q52+jahAPwQoJTi73oNtRAeQxjt/b 9rJB5zfLyPccWMxq/NkS208BdT/PzkkPj1gF+qGT7HkDc5DTlWgjwch9yIMl1TNkGdCa GCWg== X-Forwarded-Encrypted: i=1; AJvYcCUtXEI8p1nzwF28emtu6FQswwIMOB6T5pEnOI9BgAnfK0cW19u9DWEhTbVmAdpUpRPlnj56LaLHcJdcqXtGdac++2k= X-Gm-Message-State: AOJu0YxwpUegByypfnORvB/QL/Mi27IN3dOLmKvHZoo6B2ZlKPvZcCHn S2Jgg7uPPhT2DNljevK9L+ODQK94POJryMtE0x2sPYCnDT7q6HwC X-Google-Smtp-Source: AGHT+IHcVpH3CudI+W5MvprM1/PmweuKVDd3GbvgLYGCPocT+n9ET+XbztV/qerkXuZ6NHsNPBrR+g== X-Received: by 2002:a05:6512:55c:b0:52c:d9c6:f934 with SMTP id 2adb3069b0e04-52ce18356e5mr2532189e87.18.1719231459616; Mon, 24 Jun 2024 05:17:39 -0700 (PDT) Received: from pc636 (host-90-233-219-252.mobileonline.telia.com. [90.233.219.252]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52ce17c3821sm470190e87.241.2024.06.24.05.17.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 05:17:39 -0700 (PDT) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Mon, 24 Jun 2024 14:17:37 +0200 To: Michael Kelley Cc: Uladzislau Rezki , Baoquan He , Nick Bowler , Hailong Liu , "linux-kernel@vger.kernel.org" , Linux regressions mailing list , "linux-mm@kvack.org" , "sparclinux@vger.kernel.org" , 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: rspam06 X-Rspamd-Queue-Id: 890181C0024 X-Stat-Signature: 3eij1amotf3j6mtb9153k5jyahcwoo3r X-Rspam-User: X-HE-Tag: 1719231461-864164 X-HE-Meta: U2FsdGVkX1+LI06A6s1WSj4/7PtcvmwnjEJwTOcERjLg0bsm3rmt/KWWYHl0vT/nfucDXu5Zt0/kYb0mbbpFddyeQmeH7DeVmdVlNIumm9+OQZRfVrYnxyIxoAv3XzylC/qDyB46rBILR0Nvq6XQVOxZwAj08s4QnwFU+VsGYBUw3yw7xjy5TM7Cf81t5LccKhjp6Qvq8c6u+DzJyTSxgUWKR9sIZKoxe5E/d4LCSNzpvx105pv5x0BccXRwVRtzJj/alV8RWv9hgWA29OIyjrul/22/KKKk2uME1Mb08VPgoXq8PZhtfBSWCW3nqudXi2MhB9/6I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W7xFBSb4TubRqnlxl/LRldoUIeQIK5pw== 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 Fri, Jun 21, 2024 at 01:42:28PM +0000, Michael Kelley wrote: > From: Uladzislau Rezki Sent: Friday, June 21, 2024 2:44 AM > > > > 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: > > [snip] > > > > > > 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 :) > > > > +1 > > More broadly, throughout kernel code there are a number of places > that incorrectly assume the cpu_possible_mask has no gaps in it. The > typical case does kcalloc() or kmalloc_array() with num_possible_cpus() > as the first argument, then indexes into the allocated array with a CPU > number from smp_processor_id() or a variant. These places should be > using nr_cpu_ids instead of num_possible_cpus(). > > I'm usually working on the code for Linux guests on Hyper-V, and > there are six occurrences in that code. While they probably don't > have immediate practical impact because I don't think the ACPI MADT > in a such a VM would have a gap in the processor enumeration, > I'm planning to do fixes in the interest of general correctness. > Thank you for valuable information! -- Uladzislau Rezki