From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A541E356771 for ; Tue, 12 May 2026 02:50:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778554254; cv=none; b=M6KRUqgjaIx7PNqOfjKPqcfvwalj7q0VfgOGLhOGYhUbCZPVzoU3MScDcBs/TBF+Old/A163jcRvz9MfvXpXSk8cl6wkKY4d3+rwcHWLBb8MsEjkiHsK1NqO85zvAqIuG3m+u9yXvE3K8i77qwtfQYG55Hw9/I0k9yTdjg/57wE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778554254; c=relaxed/simple; bh=ySpwvVwjaoz00brCrpac1ZXRE/yYfz3CspW4d8/R0Gk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iQCkwgjmKah0LGAw+lD8KeAJr5aRmL5Ts5DnTJA4upMoOebxVCA6bnbydtbCZA3isJM4pKPf4GxyEAEP4SaZjS8DGOacQq9O9WMlnDsQKBYG3ZI06EPy7SGkGLGf0OJgU3waKaYWLiOIb/4hUlEnBAs8MX/dhL852Y8R7XhBZ6g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b=Cwng+h+i; arc=none smtp.client-ip=209.85.222.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b="Cwng+h+i" Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-8d736211595so359107485a.0 for ; Mon, 11 May 2026 19:50:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1778554251; x=1779159051; 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=SkMrOM/wJbu6CYfcf0w3cGY5A4GXI3y3nMw7LLmua6c=; b=Cwng+h+iRoGWrcBJgqPF17il5YEtn1ZTOpOYV+ob1ZSeGWVfr2Hq4NtN0gqca8EAnp YB0xJo6+ddA+A+ELCxDG+AJ43VPABGwRkwL9dqTCBnJ9XbZPwdA7sRsQF95CVmE+2K9v VIaTxOQlI2nJCxo0umtAoTLKQEZFVcb8RwT1410BY6XdShAz9iOqkwT8WynRrwJqBBTr KusQU12mWX+XBQKlZTKMq777Xl+47jCiX01xU36Eklh1Z1GsRxPd8lUGaVZVmPqWiMRn sbPRVGZS3zR+l9999mbBBDFa9+F0c4IO868mpcxaw4fBOIk2lvcWJ+7f7I0TeydnQafo oafg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778554252; x=1779159052; 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=SkMrOM/wJbu6CYfcf0w3cGY5A4GXI3y3nMw7LLmua6c=; b=dB+sGijQvVo3cUMsh6jUmKdlDEBNdUiF+0W6t5X0BGk+9w1jAsxxYwMcX2lxk6ZfI8 Seeg61QvWpADooeCqweNpSmkvXQ/A7HKYgwAzpJmowBFxveftHrpH5kX9dupKemrjKZA HNQX9QEPeiZbEYwa0/XTOP4zHMv2J/hU5ffcQ4+Jj780ezqZo7hatyTZZ/S26dFXfDt4 9BN4soD+ILC+daZ9f0+y0B6Zxolvg8o0mrOtSE5QRR1L1uSVdO+6GIHUTMva1YQ6wqaH mzjPeTY9zBta71nZ6XAZg5Cg6iq+Q5VnWwEX36mdzXAjBT0mY/YUfRy5RuZGeEw0nOg1 JQ8g== X-Gm-Message-State: AOJu0Yy45fiwlxqqtsNXzrGPkaAe9dCBiz2zR2jORuHRD6GserXl8ZI/ JT7+IBSu/5AB0jE0/aULNWQYnxNae8tBB0u3Q94+bc3or+0uymfiaNmUE81s6BkJYvRvLYtL3TS 1tohD X-Gm-Gg: Acq92OF52tMwX6GN7mHWZlfcbNlmeArtD1WJR+Adr3jR+XAihMCsYNuP44u9vuqsgy2 FPaBa+RnvBjA4KCl1BfFCn2dFpTxeqf0mvP9va6LOz9NVEC0lhCLCQ953t8PNT7RQbUETNrtZ+A rOafwkxtSKq2rjWDOJD/731RN8eJrna4ML4JQgFcVCO4HWiPLsUyPOxL6+vWtXNJEtnLWgUsdvG qIOO2MLNi8Z2XAp+n8lNkVE65UBzQ2AMFPINm+nCo0L2jlK055ZDU74a+nJWIxY8QL6/jbcfG5y XKFjSnQz7TpJ4lrrD19hcDdo3bkq+K6KUm4nfSrrsG2hwymTpW7Jdu4GVMpDG5s2GMuFe856qZj 3hmg2kcoMMvNN+0ndGbuaniNTV2wWT8ROFDnRGxaQGhaS1UG7NHRUQEX1uU7bH47p7pkIKYYU8i XCtdu6mrpFVuU6yAvbmqNcXbwPQN+UrgWM0YIAKf3EeX5ONWmVQjmi5JEMT4ZHzUnP14bKqYBmM adFBbvVu7Vr X-Received: by 2002:a05:620a:44c7:b0:8cd:b61f:2f48 with SMTP id af79cd13be357-904d64ea04amr4159360985a.42.1778554251519; Mon, 11 May 2026 19:50:51 -0700 (PDT) Received: from gourry-fedora-PF4VCD3F (pool-100-36-248-188.washdc.fios.verizon.net. [100.36.248.188]) by smtp.gmail.com with ESMTPSA id af79cd13be357-907b9772b87sm1195078585a.5.2026.05.11.19.50.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 19:50:51 -0700 (PDT) Date: Mon, 11 May 2026 22:50:48 -0400 From: Gregory Price To: "Michael S. Tsirkin" 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: References: <9b53972f4854c1064b92cefc464f51949afeb83f.1778489843.git.mst@redhat.com> <20260511114853-mutt-send-email-mst@kernel.org> <20260511175032-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: <20260511175032-mutt-send-email-mst@kernel.org> On Mon, May 11, 2026 at 05:59:23PM -0400, Michael S. Tsirkin wrote: > 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. > That is worth documenting at least in the changelog if not the comment with the define there's a clue if anything ever changes. ~Gregory