From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 EDDAD4DA52B for ; Mon, 11 May 2026 21:59:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778536775; cv=none; b=lT6B4Q6ir7zo34o782IqDW1jAZgRkllKpWJxRFKX8CENuBpDAzAXdIJRNSr5tCLqeUE3v8V3J0WdraL9NTiIoapRfzbKV9ugDOjN1ulq+hRBNqDAoGuXAKRixoZQw68P8x/+o6IjVhUN1d58nmy4M76FgKLcjnlTXC2TXrHASQE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778536775; c=relaxed/simple; bh=/RAKwLs7xITQyzEZAe+L+bwxAZbSC3kmGnvLvR0cXFU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bO0VIjtqUc2YwnTSQLuI94NxMkSHmthSkAxdNEJQWc7HsP808AgU3r5VPS0km5r+L3negvSFLqFSQyTAisPKvbQ38sLgti+IoiynSkZ2tylD1KQg8uMmP6HWMUdNSBSYjVwtJRM6IROMAV8BY6mpMGXD4WMpmSdtcMth/eSQ6nU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=PtM/7CFg; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=bh4PZvDN; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PtM/7CFg"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="bh4PZvDN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778536773; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PjGUst/RnjF+SV00Nscm4z96ojlmIg7JTTzXC6ZQiZA=; b=PtM/7CFgbWnQmf9ArgeQ51jfRU9WYoNLD7N0LVFgKLuFxm+EISUxChXpNLYuD2nb86cqiu yQiKBfgEidZiLnYrE0NCoQsWnH9cZvBeBeGy2jAZ+ZMCRoJrnAmfxW/dklYALLvOHfJsO0 /OnZGKrnKMISfEw1TgSNdMzCxafw7o4= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-677-lKf66CdQM7aGecNThi3X_w-1; Mon, 11 May 2026 17:59:31 -0400 X-MC-Unique: lKf66CdQM7aGecNThi3X_w-1 X-Mimecast-MFC-AGG-ID: lKf66CdQM7aGecNThi3X_w_1778536771 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-447f2ce5556so2985967f8f.2 for ; Mon, 11 May 2026 14:59:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778536770; x=1779141570; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=PjGUst/RnjF+SV00Nscm4z96ojlmIg7JTTzXC6ZQiZA=; b=bh4PZvDNX3lDiGJ3hkbPwGrVxqtvWInQdt/5C0720jTnIy8coxT73UStNrCa7t+iTK qEtzMHwcy36tEyAZ1sQqXQnI+r2t5RypQlSIw7DFrpi38phVQv7P10HoXre7fhcPCeOy 5A2GOB0n6aH0Aj78s0dvaWzj/ZXbDs8pHFXMsTBAS5JUjlBCZnfvKF1bOm3VP9ymhMIt Fh9uROzvY36TroEs13mNlSsGGCgf8CuT86eZrvxrK/Ly5woll77sRjkJhHQ000c81PP2 BtqlXSO0+JLQs+fs1PW1Qt7+p4pkQKPtHkoErp/smUOGrTtHXe/JpefdaC0ely685K7l 2GXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778536770; x=1779141570; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PjGUst/RnjF+SV00Nscm4z96ojlmIg7JTTzXC6ZQiZA=; b=rac3BoaNkHKfKf2G2DvpwR4F9G6QF3vGEPSk/qhwNrZDHREdhMxG21lx8TipWaO5Iv qoTZIB6M5vXEo2WdRwOYOSGtt0QgYUl+nPOB2Fw4x7D6ab7ai2KGUidKq4fdGv560VQR m/CTCQdKcqcg/F3uZihTaFc6m7le+X+6yYKmiDdaP6HtVijTtTNhy1HUF6nFlxXdMI22 BQOEBFb3VU6J4LOY8VHO91kiAjjGJAIbEGmdzH0paSmY5HxCYxZDdHYu4I0yb+3Y09HG rqUAvzxIKAc073qAZWUB+pj3k2JSPcKNIfTouCuK6Ar4RS0mUTDuDSTgcppRCvkyGy6H iGJg== X-Gm-Message-State: AOJu0YzVa3ezUigcm450EbWkVGqJf9mnmyJiuklTikGeaqzhXCm+c0Wb U+4moaETTRgTDm+qBwX5gI7YJiZ66ZPboO+gsdQCpuMrPexGAwVjiLfnQiyVwlZjhUPjDpxSXEV 8jCyOYL3vdPq24VkaE4Cveq+IEe1FI2RuVPBHQwgyIVNMQFTgDEfqE3II33wqyHyg9A== X-Gm-Gg: Acq92OHNOXQw4nEUKBML3yU2TWxY0+ISMY9k5WvctyK/LwB67UQyPGkZZEA/csOIb5l OeQRL1antOo7TY7Exbj5eWWdr9hgm7KuCp8OvwhP6uqnHme0tw44WS+w9twaSsgyonZT0bWrP9m tuqSLEjoat+EPNQGN9eWr85ff6uhL+mVy8v0pygHkL9fVZ0VgPfdgp3ouFxIIlFxLM3EPRumlll oqdlXWBr96XlgNNr0f+OMK2HzDovEG/ksjRKLQRnIWa7cK6wsK1kn9ZTKqxSI4KZc+vpHBE+otX unMm6xff2GoyQl04auFYJOuzJFC8GXPng1oLoqLqZmTPECe9uFpJYIXTjAYeXOlQ7ciZQ716Jfu DXD+reSUvM3NXeBKRL/06oYMMuVpNZO492SHOo8LW X-Received: by 2002:a05:6000:310a:b0:43b:4f86:e985 with SMTP id ffacd0b85a97d-4515d3dcac9mr40872462f8f.33.1778536770501; Mon, 11 May 2026 14:59:30 -0700 (PDT) X-Received: by 2002:a05:6000:310a:b0:43b:4f86:e985 with SMTP id ffacd0b85a97d-4515d3dcac9mr40872434f8f.33.1778536770030; Mon, 11 May 2026 14:59:30 -0700 (PDT) Received: from redhat.com (IGLD-80-230-48-7.inter.net.il. [80.230.48.7]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4548ec6cd75sm26961587f8f.16.2026.05.11.14.59.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 14:59:29 -0700 (PDT) Date: Mon, 11 May 2026 17:59:23 -0400 From: "Michael S. Tsirkin" To: Gregory Price Cc: linux-kernel@vger.kernel.org, "David Hildenbrand (Arm)" , Jason Wang , Xuan Zhuo , Eugenio =?iso-8859-1?Q?P=E9rez?= , Muchun Song , Oscar Salvador , Andrew Morton , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , 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 , "Liam R. Howlett" , Harry Yoo , Hao Li Subject: Re: [PATCH resend v6 03/30] mm: thread user_addr through page allocator for cache-friendly zeroing Message-ID: <20260511175032-mutt-send-email-mst@kernel.org> References: <9b53972f4854c1064b92cefc464f51949afeb83f.1778489843.git.mst@redhat.com> <20260511114853-mutt-send-email-mst@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, May 11, 2026 at 12:52:10PM -0400, Gregory Price wrote: > On Mon, May 11, 2026 at 11:55:40AM -0400, Michael S. Tsirkin wrote: > > On Mon, May 11, 2026 at 11:37:37AM -0400, Gregory Price wrote: > > > On Mon, May 11, 2026 at 05:01:55AM -0400, Michael S. Tsirkin wrote: > > > > > > > +/* > > > > + * Sentinel for user_addr: indicates a non-user allocation. > > > > + * Cannot use 0 because address 0 is a valid userspace mapping. > > > > + */ > > > > +#define USER_ADDR_NONE ((unsigned long)-1) > > > > > > Ehm, hm. Does -1 hold as a non-user address across all architectures? > > > > > > What about in linear addressing / no VM mode? > > > > this is used on a fault. I don't think there are any faults then? > > But maybe FAULT_ADDR_NONE would be clearer. > > > > Meh, naming here is less relevant than the sentinel correctness. > > My only concern is really whether -1 could end up being a valid address > in some horrid future timeline and this all going belly up. > > Is why I asked about whether this is correct on all architectures. I think the answer is yes: on all architectures Linux supports, the last page of the address space is never a valid user mapping. The kernel enforces this -- mmap will not create a mapping whose end wraps past -1. if (addr > TASK_SIZE - len) return -ENOMEM; So the maximum vm_end = addr + len <= TASK_SIZE. On every architecture TASK_SIZE <= (unsigned long)-1, so vm_end can never wrap around to 0 and address -1 can never be within any VMA. > > > So the trade off is: > > > a) churn the current interface for everyone > > > b) add a user_ variant and know people will just get it wrong > > > > I was also explicitly asked not to proliferate too many new APIs. > > > > Yeah simply spelling it out, not asking for a change. Probably no > better way to go about it. > > ~Gregory