From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from DM1PR04CU001.outbound.protection.outlook.com (mail-centralusazon11010049.outbound.protection.outlook.com [52.101.61.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95E0F3FFD for ; Mon, 8 Jun 2026 21:16:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.61.49 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780953408; cv=fail; b=X22G3ixo0JNhZFs8SOKdAryaF0BqPRW/kOj7fQuMJ8//YdluZL2QcqT/TPZoPN2V+nzfVm0e6kjSRLg36KLSO4uGZe2/oLtnNfyPuUShmT4PY9IfQbD8Enz9q7wL2n7kDLZP/oPkXEujWp0VklM6KXxvIzYV9KhMnsNp7a+pgZs= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780953408; c=relaxed/simple; bh=UoAHBFHXAsqWP4O/a5PBU9TyVnerRGEHWYN6pqURh0I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=JjA858SV1M9UVT7FWe5vxCF+jvgp3aS2vq4yPRqV2q9VuK+b3FE9EfdfjCdsOO8z+1Vfj9rg0LgQhN+x2i5DFLXjpksf/SvrYId+fD+K0k5l5DcAl3RmCutOwVDT0pRvEyfi7LK5F1NWMUYYzXMdrWYJxXhQLt9fXafkHg2q8l8= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=Kv8Np7Z3; arc=fail smtp.client-ip=52.101.61.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="Kv8Np7Z3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M7UIBKdgti+gu162q2xC0CtWqZxGoieUpmtyKALJ81wc4pwNPDMnjpmlgmnAzbOOXxs2vKjRnC7xy8GArVJNGaxuLr+PiFGvR6TOvlrvmDYBlgdJH88J2sJdL+1w1DCOw4uRIBye2YRSLw0AquIOFkMcP9N7EIXEliqaYTgcssMUqCiZI6OVclcIyYRGiAvIzzZlrBHWdlMI+VOksJQTptdWZ+Jx3QgMrj76FuoX6uUDDHRIGXar7WgLjbce73J/hQNKVLe20/mCbV64jurmVYe44d4fXwfViNIlWxd0/K772sHa99ZRvytTRIxbUUbugjym+ABYlunawrN7zQGYag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=UdVIvNJTRLgGKZIz2PpQ7CDioW1m7oTMB3irCc8ztso=; b=BUW0waeXQ21m2aniicVtDfhF0yT17iaXbp8r1zcp+h7CYzs4H1TL8L4xbBxPQBws7Ro+cQb9ZBDpq+YFmszeejEPMGNWj/cHpjgNulaDdRWd+0J62ixosfxW6iXjyuh+F4KRsEdLb2uYJ6WcSkI6Gms2aODsu0fMrAgNNSA/u/D31KuQECRUpgNEbb1tSksljX7Vls2j6Ou0oVi5RVlx1Sb3zHThOoDX4TNaBxDP9V8vAzSfl2m8tuGlqpuV1cq7vT4hV8NkmD3SW3Z8gCBy4FHGMRHoL6wr9xIncwhf93frVgsGh9mksGB8rcWqcoLh+sF4aeDKbGbueK+7Wg9WDw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UdVIvNJTRLgGKZIz2PpQ7CDioW1m7oTMB3irCc8ztso=; b=Kv8Np7Z3B6KE1cySivfitTRjG6ZOyul68EPtVWCHTg7TEC5cvjex8TMefIHALGDD6t5yfWQDuu2MfPZNnC8Ive+Th3WF430JOrHrpuRvyap+az1FafbliNmIZXoc4eN2sdychGgOfqkaHveNG2ZXiDXgDAm8VjDcUk3Akn80JY7Nj/BdQjykEeLsoa06mqcYpWus1JbMKKY9w80Z0vlBcL0XPsvsVC1PSHODC3SZqDeR/H//I5Ek6Vh78vi6mBAPv411EfGlbmvx3lb6b7Rxgt/fe+ZDz2zgYeC2LItWSgYb6ETzzghA5AOfuk9z9ZWdueOLRs/lAwghyRXXoYeMuw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS7PR12MB9473.namprd12.prod.outlook.com (2603:10b6:8:252::5) by CH3PR12MB8233.namprd12.prod.outlook.com (2603:10b6:610:129::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.92.13; Mon, 8 Jun 2026 21:16:29 +0000 Received: from DS7PR12MB9473.namprd12.prod.outlook.com ([fe80::f01d:73d2:2dda:c7b2]) by DS7PR12MB9473.namprd12.prod.outlook.com ([fe80::f01d:73d2:2dda:c7b2%5]) with mapi id 15.21.0092.011; Mon, 8 Jun 2026 21:16:29 +0000 From: Zi Yan To: "Michael S. Tsirkin" Cc: Gregory Price , Matthew Wilcox , Lorenzo Stoakes , linux-kernel@vger.kernel.org, "David Hildenbrand (Arm)" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Muchun Song , Oscar Salvador , Andrew Morton , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Hugh Dickins , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Ying Huang , Alistair Popple , Christoph Lameter , David Rientjes , Roman Gushchin , Harry Yoo , Axel Rasmussen , Yuanchu Xie , Wei Xu , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , virtualization@lists.linux.dev, linux-mm@kvack.org, Andrea Arcangeli Subject: Re: [PATCH v10 07/37] mm: thread user_addr through page allocator for cache-friendly zeroing Date: Mon, 08 Jun 2026 17:16:25 -0400 X-Mailer: MailMate (2.0r6290) Message-ID: In-Reply-To: <20260608170348-mutt-send-email-mst@kernel.org> References: <50d410b47fe3f45327783e05bd306d5eaab75e65.1780906288.git.mst@redhat.com> <20260608163257-mutt-send-email-mst@kernel.org> <20260608170348-mutt-send-email-mst@kernel.org> Content-Type: text/plain X-ClientProxiedBy: MN2PR05CA0056.namprd05.prod.outlook.com (2603:10b6:208:236::25) To DS7PR12MB9473.namprd12.prod.outlook.com (2603:10b6:8:252::5) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR12MB9473:EE_|CH3PR12MB8233:EE_ X-MS-Office365-Filtering-Correlation-Id: 327640ec-9261-4792-9398-08dec5a33516 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016|4143699003|11063799006|56012099006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: C8qykidKy/Dpjp13DwP4tcl1We7wHPr7hUQ3GksFigWJ6igS1jcItrKqI6c2s5HfTYApPdYTc05OMp4TZGloNcXF0hvpvh02WhP4Z9wTs1nxcMRY9dtbh2K7ROX/Al4wNvuEs3caN7IgDVh/CyRhl4rmpIVqlqkyQgNRKcSgYlqQfyqzTsRlvyeoWeTNhOh04j1Gk7+998VgrIXgvxLqMfQtMT8Bf7WFu3C7TKynYMPQLqnhW1NFl1hFeGbGkj2joKhVuOp3BgD9VHHUIdDzMQqo0jJVOKRsRvwGDsgQBrjGo3QK8SNYtGB9XBKyVW/BexeNRQDYz1aXc2yMtXc99y30hWHJlDdsJj6/6cXib3r7w48jJCzhIOThiSOG6uAnAi/Q35Pq72+GqXtpi9KlpHEA2Vi/hXrx0Yl5tHTbtBc4+BzefDRhO63jvxf6NTP4ly5ywNCOJLbLweY9w9pMEmL9qGWCHAqtMwA4Wa4b8YiBiVjRvc7dUOne3MAaGS2myOpPic2WvejqxsOBKAG28eQOTLARTo+AaDWBID/8ynNEJ+VARjTHrkNisinGb3Fr0CdqXYAPo8R2BhG+lH4K3P+qnr1c6/atllzmvXXFStgXatC1XGjNvPH6ZNBVd9b9oDjavBCfcUO1RJ7yHPv4hJ8+nHQ1QyQBiqMWC4dWqnZixazaojJ6Texz5DJ2BEPg X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR12MB9473.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(366016)(4143699003)(11063799006)(56012099006)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Us3aLT/CNmk/ejJcKHzyGsQTyiJBtaLxVGybGAFNr1/WC/xOwmt2LX7Y37wW?= =?us-ascii?Q?pstF2JnEw6bHd+bWnM9tpCxiX11zxWES+t2NlpuVYM5rtu7/97Tj2Uuya3el?= =?us-ascii?Q?5AMZVUTHC36hB3GxUViYjsvTaEMJ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-ascii?Q?D6J2NHO0J/uA6+4yXx2hUeOmWq41ktvEJNpQlfhE2W87+S9Q7U/iVYsyh8ri?= =?us-ascii?Q?Utp0N7kulgUy3qwymnqhpPta71HZOUhHFo2xY5sonFY7BtdOZQGg+M/MW54H?= =?us-ascii?Q?ZvMwv7++77QMRtrFr+FkVnFqjzLFwXodAqM0JzSqPYwFs66ziv/n7SmHesD3?= =?us-ascii?Q?8JsKMINEhGt2z9Vy3F0NuFTGcvP14zp0qhWzjbK6jPztBbH0oFM+DyESRPTm?= =?us-ascii?Q?wMM24sfUn/LohqnLgQKHdgfn4p/PZWH3kL6jEJRzTMpHQuE9Nl17JxEFuT7/?= =?us-ascii?Q?TY6qWaO/zKXA8x2zKPeqFhnhG1tPy/vRSZ1ejcsZwxAzsMNfZ74NNV9xJtws?= =?us-ascii?Q?hMPHqCfvZa9refQxtut3C3psIdOSjpcV0I0iiPbK8+gLgAjIZwZovLCg1YRq?= =?us-ascii?Q?GLmbZjSalX4hpMHhBzyPMuMgUpU+xU+Ap2lxHtNKszYxaO+/WQaaxd1vgwSI?= =?us-ascii?Q?ECol+CM6udHXQKW99k53yCPOT0f93c+9qcAz2ZsMgl3A8D/96XyMrmti60Gr?= =?us-ascii?Q?k7Y7eSkiCxOo+7d49n0JUq/khDXrWHzPKVX7pOhZ7vqv4kyXUZAghWWFmrLo?= =?us-ascii?Q?gUar1z7aW7nKpuGVtOPBXHSfv3KPmgFub8Fn1Ua7VBPxd66wrdnaHDzt40Et?= =?us-ascii?Q?LUvk+VwEt/Mh3BZo+1AVjxxO59a0XnGhLJQ1LAXQEZLLEMuE?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 327640ec-9261-4792-9398-08dec5a33516 X-MS-Exchange-CrossTenant-AuthSource: DS7PR12MB9473.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2026 21:16:29.5383 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SWKroQM5PlJK3fA7vcAXwYSfPp1GIhTBgoMwX8v+VPLb2592vzXbSx5Bf1+x8QdD X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8233 On 8 Jun 2026, at 17:04, Michael S. Tsirkin wrote: > On Mon, Jun 08, 2026 at 04:40:15PM -0400, Zi Yan wrote: >> On 8 Jun 2026, at 16:33, Michael S. Tsirkin wrote: >> >>> On Mon, Jun 08, 2026 at 04:21:08PM -0400, Zi Yan wrote: >>>> On 8 Jun 2026, at 15:59, Gregory Price wrote: >>>> >>>>> On Mon, Jun 08, 2026 at 02:04:28PM +0100, Matthew Wilcox wrote: >>>>>> On Mon, Jun 08, 2026 at 12:06:35PM +0100, Lorenzo Stoakes wrote: >>>>>>> But instead of overloading user_addr to indicate all kinds of things, instead >>>>>>> make life easier by actually breaking things out. >>>>>>> >>>>>>> Like: >>>>>>> >>>>>>> enum alloc_context_type { >>>>>>> KERNEL_ALLOCATION, >>>>>>> USER_MAPPED_ALLOCATION, >>>>>>> USER_UNMAPPED_ALLOCATION, // Maybe? Do we ever? >>>>>>> /* Perhaps some other states we want to encode? */ >>>>>>> }; >>>>>>> >>>>>>> struct alloc_context { >>>>>>> ... >>>>>>> >>>>>>> enum alloc_context_type type; >>>>>>> unsigned long user_addr; // Only set if type == USER_ALLOCATION >>>>>>> >>>>>>> // Maybe something suggesting context or whether we init before in some >>>>>>> // cases? >>>>>>> }; >>>>>> >>>>>> Ugh, please, no. As I suggested last time I commented on this >>>>>> trainwreck of a series, lift the zeroing functionality from >>>>>> alloc_frozen_pages() into its callers. >>>>> >>>>> This sort of just implies writing the "alloc_frozen_zeroed_pages()" >>>>> wrapper that does the zeroing at the end before return, and then killing >>>>> the post hook nonsense associated with it in the first place. >>>> >>>> This means it is going to be a multi-step optimization. This is probably >>>> step 1. >>>> >>>>> >>>>> None of this resolves the user address annoyance which is needed on some >>>>> archs for cache flushing. Whether anyone agrees that the page allocator >>>>> should be responsible for this particular operation - open debate. >>>> >>>> This is probably step 2. But does the virtio use case apply to these >>>> archs? Does the performance matter for them? If not, maybe this part can >>>> be left as a TODO. >>>> >>>> >>>> Best Regards, >>>> Yan, Zi >>> >>> I doubt it. But I don't get what's proposed, the code that we >>> have to modify is arch independent? >> >> Change user_alloc_needs_zeroing() to only check address aliasing even >> if that can cause double zeroing for virtio. >> >> Best Regards, >> Yan, Zi > > Ah. I started with exactly that in v1/v2. It's a simple approach. > > But mm maintainers said no, user_alloc_needs_zeroing is a hack and > I must not add to it. Got it. It sounds that you now get conflicting ideas. Maybe you should start a [DISCUSSION] thread that presents the high level idea of what you want to achieve and all the ideas you got from the reviews, so that people in this thread can have the big picture and come up a consensus before you send another version. Thank you for patiently replying my comments, since those points apparently have been discussed in prior submissions. Best Regards, Yan, Zi