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.133.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 010233EDE55 for ; Tue, 12 May 2026 18:06:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778609202; cv=none; b=irgps3eoq2LPjFuFEJlSJBNwX6MaHhixeJbJVsWn/ajVaVh9+Yn0nbR6A16IE34CXf7h6SZuM+xKC44BCCj/LHLqf/gAOE5f8rH/HiFOIUWVKhiB6mTv+KtMYizc+vPUvYKKxvfZ0YhXozHFUdUwqM4vKVrtZEcprVOVH8xCD5E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778609202; c=relaxed/simple; bh=RpSu/XW/aDuFc8HVqqoQGgZcY95TC8aEBDOi0Yk9GRA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZsZ90E4NcVdXNfk6If4II6yZ+5eLnhuUabfa9r0YnKDhL/FK4opvEmYpMk1/iBD+owRSH036KCRddxndMI83phtwngklJVDr8i149Trl4afPwRC9vuB8GBuUmlMJQorbvnymj/p93TIWWYkEhDDGTS65vjcRWaNteUhe/5khkTw= 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=DVHe5xrw; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=bDYzdsOl; arc=none smtp.client-ip=170.10.133.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="DVHe5xrw"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="bDYzdsOl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778609199; 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=xc/NhkzuaZoAdTp3ChNwKwwR0U6LJ0GRCb8Tqmiuz2M=; b=DVHe5xrwi6hwUrWG1b9SpO9J4K4T7/uH0UNyyQTeAy6zL+uHbBVfdJ4NySkTe88xUYF7j9 83rMKOqRdWX5M4zyf872sWr4PLVYVr5MudQcJGc62BbvV+wUT2IJ15aRpIF2oy5EYhbtJy zBCxC+Kj7APyS109s8w63Xj7Hh5/tsA= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-14-mdbGDmSoOGuUFuW6w0d2rA-1; Tue, 12 May 2026 14:06:38 -0400 X-MC-Unique: mdbGDmSoOGuUFuW6w0d2rA-1 X-Mimecast-MFC-AGG-ID: mdbGDmSoOGuUFuW6w0d2rA_1778609197 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-45b7ff2140eso705293f8f.3 for ; Tue, 12 May 2026 11:06:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778609197; x=1779213997; 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=xc/NhkzuaZoAdTp3ChNwKwwR0U6LJ0GRCb8Tqmiuz2M=; b=bDYzdsOlypcgN5+ppMdIFnVJGe1F7dskRuI1ytsmeu27lT8tPamaEKTJ+bIw1VE1ow g8S/gXgv1sa0mRUd+nxE8sp4EjJezQl/6NbR+2yeMRwgWzLLjPnMq2ZRqHDkSH2OmWO5 BHpx7lqIVSGKbRT+9v44sNuPMOgHbz1BcpTmA9U+EmTLSqyQh/or8VT9/HBl5nZSz12+ dWErAmNZK6UjeRxZQ8r2XAOwcZGePUeW8OueR+KrynU5mNC3Y+R/JKDdXNm9IMNXun4Y L2i2mDsnqzc8xP3trXkJCKF0Z2Tr7UpMobV45aueFhbexAhZCeWdLGkm31LBjaLgeGd9 nLmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778609197; x=1779213997; 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=xc/NhkzuaZoAdTp3ChNwKwwR0U6LJ0GRCb8Tqmiuz2M=; b=lJuJH0H3WTefInE1ZI82R2lasKaJ0JazqZzY8QAI9/rHBMeNrP2Va4IFrZtj+BEDBW kgZB73qzyIjMWUHwUlh9wkHCL4XWcTCSysLlpi5XV8BdoNuPG7VjIXYfrND5AD10uuIb o4cRoV5WYi48jsAVrB9NLLEBWgNtXdnQDRfuyWsTAlymCkbxOKoujgTLX9jLgvAsnpNz +3Iy4c/CuGG0VdgcAtGEd17+p8rsq2/jMGeaOCRln2Q7SwcTqMV4tatYEkdK5g0lzssa Gkvj8S7nQ38zRmSTPH8U4N/rJdfiDNXBrhJHCnHo1gyeZjg7G64j5Di+KdG/Q/Frz8uO Nn7g== X-Gm-Message-State: AOJu0YwGraetPx5yLx3jBTXHbb5JHR/MlCGuZkDefafqzDBFPhE6LnE/ PdB0hSgjTtE8S4FOXgRB3VPHYAoRV4TcwDxU+t+sUTI2tYDGsIASMyViKJYGkqD2hsZPjn9wlA2 JEDV1k70pc9q8uFdqmpahGFs9X/W961qGdFs+MIKZLIJ1wui6FFKQVxBXLCyF401ufA== X-Gm-Gg: Acq92OFCQSgNiLl6U3CyMOoA60yeoXVcgJnuQwTcupZ8Deo9D9RplRoDw/uL3BqtY2n 7BN8BYvF6IPLbpK2NeWPmejshaNEdm5yRF2P8xbLJp7lId88kRiurHMauuV9sMNCZYJchCYRcdI DyX7uTMTfqIWLptZx4nUU6hZ3ewq18pa1amzfKQxOZAziTUZYRfj/xk/jw2eJSfp9KlIX6Q7we1 ewh58tLIJppIOi0HAVU4Y5OSHRAV+vfJUW6QYdD9TMhtY416Z7odKYTvAhJOPPN3wpkVzuEqfzD INaLHsOn4L1i7puXStBqKiDKTlphm9G0XBPd0HtgaAsRaWKTt8SIcfP4D9B5h4R3SUZhnBwnajL z88FEnrNKs+JsgfjkdnF482sizk1ld01OmsCkSD6h X-Received: by 2002:a05:6000:2311:b0:43d:6244:f8b with SMTP id ffacd0b85a97d-4546140ac8bmr30487469f8f.13.1778609197022; Tue, 12 May 2026 11:06:37 -0700 (PDT) X-Received: by 2002:a05:6000:2311:b0:43d:6244:f8b with SMTP id ffacd0b85a97d-4546140ac8bmr30487412f8f.13.1778609196463; Tue, 12 May 2026 11:06:36 -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-45491ca383asm33507368f8f.28.2026.05.12.11.06.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2026 11:06:35 -0700 (PDT) Date: Tue, 12 May 2026 14:06:30 -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: <20260512140254-mutt-send-email-mst@kernel.org> 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: On Mon, May 11, 2026 at 10:50:48PM -0400, Gregory Price wrote: > 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 Actually that's one reason. And there is *another* reason. Almost all callers pass vmf->addr in there (with hugetlb being a single exception using vmf->real_addr). So I changed hugetlb and now everyone always passes a page aligned address. It can never be USER_ADDR_NONE