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 14F46C27C4F for ; Wed, 26 Jun 2024 05:12:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D4D56B0089; Wed, 26 Jun 2024 01:12:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 984196B008C; Wed, 26 Jun 2024 01:12:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D6C36B00A3; Wed, 26 Jun 2024 01:12:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 59D226B0089 for ; Wed, 26 Jun 2024 01:12:21 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 179421609CB for ; Wed, 26 Jun 2024 05:12:21 +0000 (UTC) X-FDA: 82271868882.25.692AD53 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2056.outbound.protection.outlook.com [40.107.117.56]) by imf25.hostedemail.com (Postfix) with ESMTP id B8490A000E for ; Wed, 26 Jun 2024 05:12:17 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=oppo.com header.s=selector1 header.b=YOezDb7u; spf=pass (imf25.hostedemail.com: domain of hailong.liu@oppo.com designates 40.107.117.56 as permitted sender) smtp.mailfrom=hailong.liu@oppo.com; dmarc=pass (policy=quarantine) header.from=oppo.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719378730; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=S1lhyCs390xmQSsgJIh0jCXS6Syd1z3RP8K4gAmHxSg=; b=MwqJNNkjKMSChfBrDR+CsLqRBXbzFkjGQiidUgX7IF+AR+y36XqQTPUAgxUsyiyeuTsu7g XGAaBsKC6YRh3ykANXWJVCVDY/TR+VkjE3aIT/UnPt4jh2ywmlmZ7UdYPPxWqMbtJljA1Q LoeizowJZGxyy5gKWwyZqlCII3S++/Y= ARC-Authentication-Results: i=2; imf25.hostedemail.com; dkim=pass header.d=oppo.com header.s=selector1 header.b=YOezDb7u; spf=pass (imf25.hostedemail.com: domain of hailong.liu@oppo.com designates 40.107.117.56 as permitted sender) smtp.mailfrom=hailong.liu@oppo.com; dmarc=pass (policy=quarantine) header.from=oppo.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1719378730; a=rsa-sha256; cv=pass; b=wA7c15balhYmsMG0hPcI2IId+2xwY6sTsoTvDpO9HMDXc0vh5Q206BsTMGKO4P9/wLejri 5VqoasN0C0jtAT6ssl83r7n94s/ERJAVoHAv4EAWdkGe8kunj82nS1PFeOpt4Y0G7wNinD kTj7dDFkjHjBDMhT1Bca4zoBWtDILIE= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LyNwwElvf2e7pfncKgMEwoKCJ1d/mQcepsl52pyySQCZXVWbM96CcRnpipAfn3O3k7kKF1sGql4gmLtTVN/03bq7OT4DUOB/XVKRZsY0+H9cydqUuTkY2eVSSr1+rZZXvftomq9ZzzUNNU/bC5tGjMmLPEtjbpF3lmN1CV5AiYndG+u+coQcsJW8kfzbHM5qfMHaOXVRN2z3BIMmli/gR4OBIgvdpmHb42IGQM9W90xuO+0sK1BkMcb3F0xixS7k2UUXOh+HBvZPyuhklKRR/LOC9qUUhCA7x1avJ9lEGqSS3cXHq5ZGUxFBWkuv/7tylT92V7PQqpygNHHATCo3lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=S1lhyCs390xmQSsgJIh0jCXS6Syd1z3RP8K4gAmHxSg=; b=RW2kuH7YwcBVszfaLab1IyGNkFeN5Rn+7IutyoOujwMdXybuuARqYwsNwYb/wp+DGk5VdbzgqVG+TyhxMyfDh6zPw1hG0Xyo8c2mf0uyhv5BVQFPknpw8vEaO5iisj6X1GwuSTViMsD/WZQQBAQZCju91Wxdvwt8RUlHaKHlQWiIynW0KRZ/5PdyCSfxW6FGvF6xZozuiBYS/KV1vfVUOI0lzpEk1QEuZA7LLil82lrIsN/pGVW1ksf7wBZjMhawmOELl4zQK4uYQLdVVxlgbsrBRyQzThWYy+8tlGKutWppliRusjygmTFOzbfjUNzMtg2eD0reCkCfV/v0t1RbRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 58.252.5.68) smtp.rcpttodomain=gmail.com smtp.mailfrom=oppo.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=oppo.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oppo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=S1lhyCs390xmQSsgJIh0jCXS6Syd1z3RP8K4gAmHxSg=; b=YOezDb7usqSKz+HDZyWlfmLX7Iei3m0BDKFMN+31yziSnhkbIOR+2U8/0fm+QbGejWvzBjmnhTrbVN/dV8TgWrVPEvsexMeEzSYdlBuCSxOkv2oAGSj3cAje4wajxmB0U6s3/mzjlKoVLO7nVJMCrzbivEFLLT1De5Th7eWQZ5k= Received: from SGXP274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::17) by SI2PR02MB5803.apcprd02.prod.outlook.com (2603:1096:4:1b2::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.30; Wed, 26 Jun 2024 05:12:13 +0000 Received: from SG2PEPF000B66CB.apcprd03.prod.outlook.com (2603:1096:4:b8:cafe::d0) by SGXP274CA0005.outlook.office365.com (2603:1096:4:b8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.22 via Frontend Transport; Wed, 26 Jun 2024 05:12:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 58.252.5.68) smtp.mailfrom=oppo.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=oppo.com; Received-SPF: Pass (protection.outlook.com: domain of oppo.com designates 58.252.5.68 as permitted sender) receiver=protection.outlook.com; client-ip=58.252.5.68; helo=mail.oppo.com; pr=C Received: from mail.oppo.com (58.252.5.68) by SG2PEPF000B66CB.mail.protection.outlook.com (10.167.240.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Wed, 26 Jun 2024 05:12:12 +0000 Received: from oppo.com (172.16.40.118) by mailappw31.adc.com (172.16.56.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 26 Jun 2024 13:12:11 +0800 Date: Wed, 26 Jun 2024 13:12:06 +0800 From: Hailong Liu To: Uladzislau Rezki CC: Baoquan He , Nick Bowler , , Linux regressions mailing list , , , Andrew Morton Subject: Re: PROBLEM: kernel crashes when running xfsdump since ~6.4 Message-ID: <20240626051206.mx2r4iy3wpexykay@oppo.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Originating-IP: [172.16.40.118] X-ClientProxiedBy: mailappw31.adc.com (172.16.56.198) To mailappw31.adc.com (172.16.56.198) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SG2PEPF000B66CB:EE_|SI2PR02MB5803:EE_ X-MS-Office365-Filtering-Correlation-Id: d11873f4-9758-4d1d-f012-08dc959e8983 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230038|1800799022|82310400024|36860700011|376012; X-Microsoft-Antispam-Message-Info: =?utf-8?B?NEN6Yk42ZElwSDNLMVdXdUpqS1ZDd0ZDdU5Ualh4UlJzM0kzaG5Ob3liY0Iw?= =?utf-8?B?WWZ6TDlKUDNQamZpcENJRmtZM3huRXIyRGRLb0lreEtxYzE2ZnRpb2t5WDd6?= =?utf-8?B?aHduc29uVWtPN1Y2SERlejlBQUxJbXM1NklBZ1p3dlZlblhRV2RWdVBXaCtD?= =?utf-8?B?OGUvN3FhMjE1aGZEVmQrOWRxeUtXaWhtc0JvQmJ1N1VYdW5OVDAvZjhTUEVv?= =?utf-8?B?WFJCOW45M0k4TWFQMm5EUWNEdDRTTklOWXhrUk01VHdveVRod0xuMDVYT1BP?= =?utf-8?B?YlpaU01mSmJVbmY0RU1PRnM1bW9CWmFBdEQvZGxYZm9WRVJBQyt6YVlZbGFB?= =?utf-8?B?YlBYa2JrUHJpc2VVZGwzYkljTVhqcFN5QmJtck90UVpTbFA3Q3RxMnJnemg5?= =?utf-8?B?YWN0NzFtVUJZbUZpblpKOGc2c1U5U1cwdEh2dFZBTUxyQ1JVKzMrS05GRE8w?= =?utf-8?B?ek5yeHljMjdqa0t4bWttMHpRUVY4R1ZCYkFYeW9qVDdPdU50UHBYd1hORTBa?= =?utf-8?B?bU16N1luNC9pdzB1Y3dlbC9TVTdXTExmTE1RRVh4RnhYTWsrRE0wQmFZVGR4?= =?utf-8?B?Q3ZNZWVHb1ZkTURGN2E2dlJzYzA1S1RnS2w2WVZpT1pPMjQ1NTdRMjI1TnA2?= =?utf-8?B?em1zRHZYNElveXd2TmZ3ZnlYNWV1QzZ5ckx2QnFRNnNXc1JPNWVOY3FEWmp3?= =?utf-8?B?N0lsT2FaWE9Id2ZCMGMyVW9hZGpoQnp3V2hCYndTS1g3QmNOTUdBN0VvUE1w?= =?utf-8?B?Q0RXNGJZSEdUWnNjS1NsM003MGlZbXREVHZTQlpQWEM0M3pQWkZ4NkNvK2dT?= =?utf-8?B?QndaSmU4Wm9WME9mbGZrYy83Y2hOS0daVWxHVlZJQk9jT21XNlYyWHl2T0hJ?= =?utf-8?B?ZnJtdnI3VTFzRU90TGVJVW5tY0NOQ0dIc3pJNTdzNnQ0WHo5dm5WWmtTTW5E?= =?utf-8?B?dS8ydlluUkR1bE1RM1lHbVJWbzlOeXhLa1Z5ZGZJWXZxaWdpajhTeWlwc1lm?= =?utf-8?B?T1oyMll0UVNDdTVEUVpEMWVxMzNVS3JrbEtFdlJSdW1uQUsxUW44dXB1dDB1?= =?utf-8?B?NmtUTXVzdU1JdGw0S1lWUzZrbG9pSHEwdnRPbVRVNU5IWUlwOWlwUTlEQ3Ev?= =?utf-8?B?aWJRc2tLNzUxRUxOWWR4OWpSRHpvam5nMUVHNXZ2TDRKVHVJUDY3NlRBMlRk?= =?utf-8?B?ZldFamE3UkdOQThNck1XVkNXMXB1R1NHQzQ5bG96MlFibHE5aFQ5TXN2RDFB?= =?utf-8?B?OVhJaUhVWWZxR2ExK1lVa3RoMlY1MnMxeGx6WVZ5Qk5OOHhLTGRFNkVPVGJq?= =?utf-8?B?NGI0SFkvMUlXcU02WnZvRGs3UndpUkRkVzJDaDhkSWUxTDF6bllqa05JVDMw?= =?utf-8?B?dDI1K25KY0Rla3lUYUhBb3IyR096TzJwUlVIOWp6MWE1Z0JqOHhuQ0lzem9k?= =?utf-8?B?eHZKWmpYcGRVYjErVEhrcHhhem9uNUxXNVNDMHRjcUpzVGZoc29jVk1yWENL?= =?utf-8?B?dkgxaG5ld2VuQjlMT250dHRJTlZaam83Mk1taUxMak94ZVlUVU1JUjhOTWNr?= =?utf-8?B?cU9hMnRNV3VsZ2hZUTVyM2ovdDk5VUxJejI4Rk9uQitJV1JCS0tHSEZtWkJH?= =?utf-8?B?SkN3T0xUWFVBbnJGa05LSndpbGJLczBZN281cEJqQ0hqTlQvM2pzazVPNEUv?= =?utf-8?B?SE5IRWNWMlNzaHlOb3Zmd00vNFVFMXRyNXVOVDd4NmcwRncrMXhhQWVkZmZj?= =?utf-8?B?Mzc2UThHaFNxTWRiM2dvSnc5VFYvN0dxQUZHdTJrTjJmTy84ZjNXMk1FMHR6?= =?utf-8?B?Z1pobTIxSnJ3ZE1mbGNyYkVJY2R6eTRkdWJaK2prTmRVSTJPYi96bVdEdjI2?= =?utf-8?B?UVZ5YjFRSjFPVjk1TzhOSUF2TXpLY01GQlZKelpDeXR6SUR4eWVRckJVcW9T?= =?utf-8?Q?x9lxP6g3I4TUTx0NTnsXqGR8qm0vpBJV?= X-Forefront-Antispam-Report: CIP:58.252.5.68;CTRY:CN;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.oppo.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230038)(1800799022)(82310400024)(36860700011)(376012);DIR:OUT;SFP:1101; X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2024 05:12:12.3170 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d11873f4-9758-4d1d-f012-08dc959e8983 X-MS-Exchange-CrossTenant-Id: f1905eb1-c353-41c5-9516-62b4a54b5ee6 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f1905eb1-c353-41c5-9516-62b4a54b5ee6;Ip=[58.252.5.68];Helo=[mail.oppo.com] X-MS-Exchange-CrossTenant-AuthSource: SG2PEPF000B66CB.apcprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR02MB5803 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: B8490A000E X-Stat-Signature: umt8p9ku3pjxh1cb7q8gghi6sot5393h X-HE-Tag: 1719378737-536310 X-HE-Meta: U2FsdGVkX188CktLWKDrp6xeUtNMYqUzFeae0pyudJ3GWCSfeU5GOw8o7ypuPz/sw67czVNmne+qgqidLLeCVjZ6Vda5r37cwJoJ16l6Cp4gk50aSNfweMYKF+bFiX/DllexjyzqUjRbNOaw0Bp61rT/rnTOB+Zk0jXrxRSGkn9MSMCgmDwqUSYpPEtnhGpfQ/RVKIjGp7ozZm7bv9auBUal4FMEL5hhPx8Rav0cCzSzKdVdL6v6hO8DcQ2Yk9gPoKGXwYFnTNlQwSxTzHUQvOZ+o6xgqD6yqfeOl7gO4T1GrpDrnWi05IZyrFg+oPSPZHVJagNy7V6/Rcxl86YXbPb1KjWwpp9sLXfaGgzqdKUqgKsNpyupBYgBmZtiNVxfPuu6vZ0mBTpbSMHv6yxBbWYnbV+h5DEQ82NiDY8v1G6nKsGu56+XOBaxYm7M67XXEfv3OKKByTY+qo2xq5PSSD7U0LLMqhuHZDRMU8pPFCq3fXwA868OnbnqU31bA/9tx+yM/VufcbGcLfbXBHHsOtotL+gQsRc2JE0NFidmC/uNCltwssIa9SWU3LI0jtp9KipNVkXWdZwClLs9i/IRr3FeCNip6NpVD2YXs0es6OmABzoPe86aoELa5qbW18pVvQpH4PrKX9bxsWuY5PoaCOlye2BP7iWhigh3absLxPWteojt/YFPKN9GY9n5VIphke+BZTLwiPri4gyrGkKdph0CS6qrJ+gMe77n6JNKBACYInOigXIQK3ZqgD68Ibob/OYPYCqah2t5FZIA4uzqEB0nBs7KcfTK+VlkRJwcCVceZQ/VWe5REconOLADaJJWO19S6P+2EXdg4L0eVVCJ4YDJrI0sbhsWYff8aSsRQ02zOlm+bQRQrmondPtVGF/orXyCQDrGFvS3F2NVDz62yF3s11kvdjQTRml5KxTA6K9ca6fA86YRORR11CpVltbL9z7KwzEGA+cI1f8pXCG FjzDiMjW S1gH9zsjGQhC0YoAf2FgyCCc2yQlkB9wPZ6S/FecYCbwTKeYXhELMbivSFK7lQJPLkBnIOjiAohRvKQeKfQND7nR7/R0rEdaPI61mof+xnEo9eKK7N/TRrVd761fSG8jpronxytaJYB1HX3cTG7yUppiqYcO2IjlfiPp1OUJOIjx3NTJMr8UHfjqHvK/88+PLszzWiDhCTU4hBhfTVaX4ibXPAA//HChEJw+5CXyewgOv+RzQzbXU4T6c6F3GEmdNWXePJ4y+EEvSX7pgTlJmixPNRu9WGFVpG4mdo2pYMGwdSuK34w1JNNIwZrMzciWiPPRlBPuvwiXAhrVRvHGuxxTB9+/VPKG4nqMV9/XgbPL+kh1ZAxCaoVCOrBXK1xU9pcSlv9NwPoMEhdaGpheiDLyIV3WCmwa7ip5wh9L4f9ii4Dw= 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 Tue, 25. Jun 22:05, Uladzislau Rezki wrote: > > > > > > /** > > > > > > * cpumask_next - get the next cpu in a cpumask > > > > > > * @n: the cpu prior to the place to search (i.e. return will be > @n) > > > > > > * @srcp: the cpumask pointer > > > > > > * > > > > > > * Return: >= nr_cpu_ids if no further cpus set. > > > > > > > > > > Ah, I got what you mean. In the vbq case, it may not have chance to get > > > > > a return number as nr_cpu_ids. Becuase the hashed index limits the > > > > > range to [0, nr_cpu_ids-1], and cpu_possible(index) will guarantee it > > > > > won't be the highest cpu number [nr_cpu_ids-1] since CPU[nr_cpu_ids-1] must > > > > > be possible CPU. > > > > > > > > > > Do I miss some corner cases? > > > > > > > > > Right. We guarantee that a highest CPU is available by doing: % nr_cpu_ids. > > > > So we do not need to use *next_wrap() variant. You do not miss anything :) > > > > > > > > Hailong Liu has proposed more simpler version: > > > > > > > > > > > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > > > > index 11fe5ea208aa..e1e63ffb9c57 100644 > > > > --- a/mm/vmalloc.c > > > > +++ b/mm/vmalloc.c > > > > @@ -1994,8 +1994,9 @@ static struct xarray * > > > > addr_to_vb_xa(unsigned long addr) > > > > { > > > > int index = (addr / VMAP_BLOCK_SIZE) % num_possible_cpus(); > > > > + int cpu = cpumask_nth(index, cpu_possible_mask); > > > > > > > > - return &per_cpu(vmap_block_queue, index).vmap_blocks; > > > > + return &per_cpu(vmap_block_queue, cpu).vmap_blocks; > > > > > > > > > > > > which just takes a next CPU if an index is not set in the cpu_possible_mask. > > > > > > > > The only thing that can be updated in the patch is to replace num_possible_cpu() > > > > by the nr_cpu_ids. > > > > > > > > Any thoughts? I think we need to fix it by a minor change so it is > > > > easier to back-port on stable kernels. > > > > > > Yeah, sounds good since the regresson commit is merged in v6.3. > > > Please feel free to post this and the hash array patch separately for > > > formal reviewing. > > > > > Agreed! The patch about hash array i will post later. > > > > > By the way, when I am replying this mail, I check the cpumask_nth() > > > again. I doubt it may take more checking then cpu_possible(), given most > > > of systems don't have gaps in cpu_possible_mask. I could be dizzy at > > > this moment. > > > > > > static inline unsigned int cpumask_nth(unsigned int cpu, const struct cpumask *srcp) > > > { > > > return find_nth_bit(cpumask_bits(srcp), small_cpumask_bits, cpumask_check(cpu)); > > > } > > > > > Yep, i do not think it is a big problem based on your noted fact. > > > Checked. There is a difference: > > 1. Default > > > ... > + 15.95% 6.05% [kernel] [k] __vmap_pages_range_noflush > + 15.91% 1.74% [kernel] [k] addr_to_vb_xa <--------------- > + 15.13% 12.05% [kernel] [k] vunmap_p4d_range > + 14.17% 13.38% [kernel] [k] __find_nth_bit <-------------- > + 10.62% 0.00% [kernel] [k] ret_from_fork_asm > + 10.62% 0.00% [kernel] [k] ret_from_fork > + 10.62% 0.00% [kernel] [k] kthread > ... > > > 2. Check if cpu_possible() and then fallback to cpumask_nth() if not > > > ... > + 6.84% 0.29% [kernel] [k] alloc_vmap_area > + 6.80% 6.70% [kernel] [k] native_queued_spin_lock_slowpath > + 4.24% 0.09% [kernel] [k] free_vmap_block > + 2.41% 2.38% [kernel] [k] addr_to_vb_xa <----------- > + 1.94% 1.91% [kernel] [k] xas_start > ... > > > It is _worth_ to check if an index is in possible mask: > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index 45e1506d58c3..af20f78c2cbf 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -2542,7 +2542,10 @@ 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; IIUC, use nr_cpu_ids here maybe incorrect. take b101 as example, nr_cpu_ids is 3. if index is 2 cpumask_nth(2, cpu_possible_mask); might return 64. /** * cpumask_nth_and - get the first cpu in 2 cpumasks * @srcp1: the cpumask pointer * @srcp2: the cpumask pointer * @cpu: the N'th cpu to find, starting from 0 <--- N'th cpu * * Returns >= nr_cpu_ids if such cpu doesn't exist. <----- */ static inline unsigned int cpumask_nth_and(unsigned int cpu, const struct cpumask *srcp1, const struct cpumask *srcp2) { return find_nth_and_bit(cpumask_bits(srcp1), cpumask_bits(srcp2), nr_cpumask_bits, cpumask_check(cpu)); } I use num_possible_cpus() and cpumask_nth() here to distribute the addresses evenly across different CPUs. if we use cpumask_next(index) or use cpumask_nth(index, cpu_possible_mask) becomes as follows: CPU_0 CPU_2 CPU_2 | | | V V V 0 10 20 30 40 50 60 |------|------|------|------|------|------|.. > + > + if (!cpu_possible(index)) > + index = cpumask_nth(index, cpu_possible_mask); > > return &per_cpu(vmap_block_queue, index).vmap_blocks; > } > > cpumask_nth() is not cheap. My measurements are based on a synthetic > tight test and it detects a difference. In a real workloads it should > not be visible. Having gaps is not a common case plus a "slow path" > will be mitigated by the hit against possible mask. If cpumask_nth() is not cheap or have performance regression. Perhaps we can use the solution suggested by Haoquan. I’ve drafted as follows: diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 11fe5ea208aa..355dbfdf51f1 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -92,6 +92,7 @@ struct vfree_deferred { struct work_struct wq; }; static DEFINE_PER_CPU(struct vfree_deferred, vfree_deferred); +static unsigned int *table_non_seq_cpu; /*** Page table manipulation functions ***/ static int vmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, @@ -1995,6 +1996,10 @@ addr_to_vb_xa(unsigned long addr) { int index = (addr / VMAP_BLOCK_SIZE) % num_possible_cpus(); + /* recalculate the cpuid if cpumask is not full. */ + if (table_non_seq_cpu) + index = table_non_seq_cpu[index]; + return &per_cpu(vmap_block_queue, index).vmap_blocks; } @@ -4473,17 +4478,25 @@ void __init vmalloc_init(void) { struct vmap_area *va; struct vm_struct *tmp; - int i; + int i, inx = 0; /* * Create the cache for vmap_area objects. */ vmap_area_cachep = KMEM_CACHE(vmap_area, SLAB_PANIC); + if (!cpumask_full(cpu_possible_mask)) { + table_non_seq_cpu = kzalloc(num_possible_cpus() * sizeof(unsigned int), + GFP_NOWAIT); + BUG_ON(!table_non_seq_cpu); + } + for_each_possible_cpu(i) { struct vmap_block_queue *vbq; struct vfree_deferred *p; + if (table_non_seq_cpu) + table_non_seq_cpu[inx++] = i; vbq = &per_cpu(vmap_block_queue, i); spin_lock_init(&vbq->lock); INIT_LIST_HEAD(&vbq->free); > > -- > Uladzislau Rezki -- help you, help me, Hailong.