From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) (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 3F490332909 for ; Fri, 27 Feb 2026 11:04:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772190245; cv=none; b=Z9IpwSZy36ooodQ0SbyD5SXTNMR6wEMDpshXU478Brx+NLb4zNM+WpzkIDkuWfO5SjJSRYTmawXJ4OGpRi8HC6AmyIRzx6/j/5PjzFVQ9zmPSUklUon+YvZX8dMt7mDo+6jYQONe/gsgW7hTgAI4UuSkATsh8MgLA6i91AubJ74= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772190245; c=relaxed/simple; bh=9iZ/mcfPfXrpNXadDG4oIQ7cagkubRqppFA44CBWgiw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=jI/D/uoSCzH/RZIYPEI42pYnczxuoGzOqAvQQ93pyi0jvKTot5dPobs2Kkt5U4yf+LI4X/xH+xYqvmYYIIAd60kPPVr2GCS2jq8HR1/ZkJzfDNEnoO7qgw6bjHj7S2mq0MIcsSR3Yk/QuJ+76BUUul8DgTO8X9x87zrp0u3g9JU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=uLq3M3eq; arc=none smtp.client-ip=209.85.221.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="uLq3M3eq" Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-4376ec2b1cfso1618631f8f.0 for ; Fri, 27 Feb 2026 03:04:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772190242; x=1772795042; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=FUnn+HEzz7FxTPfMeOpy8wErtBbGc/VEuKzZnO44vHk=; b=uLq3M3eqq7Ep90NaxgJIho8UeaaDLUtPNrlIaDrBUGxxCphZjS3lVqc9yu/3Xy8J20 tnJh1FMTsHzfWqZdJZrYUAe/d1cT1tjpZ0f7pzlLgJ7YsdUR5w1XWNkJX15YhXh2jmbL oZL3vf1lHcbe+5IhMNDZxul6krcDIifG3khFzVVOu267SZFVrC2Y+X6u1x4Y0Nk3kONz jhDCEZSK5wB6RMqWsm9Che10Ys/JMyF4x6B4hFG3wQY68vRg0aOAjao/oCdKcnR/cN0Q 1QyfeeLJa+FKzQvYeOwtTynw6saYA5ygWPlyz4gO6WQx7AQYiFMSwx+aE5tyv/nu3Qrg B6aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772190242; x=1772795042; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FUnn+HEzz7FxTPfMeOpy8wErtBbGc/VEuKzZnO44vHk=; b=opoZT1sMi5n3b3cxthOIZ1RRKxWP/mvz4iq/x4I99zwf2T3283Jjr5dSSSJtsZvRwP 1ltS3+bNUfB5jo80wOE/InnYFgfH4d2sLyTkvzSLIHFl1JbC2RRLcjOYmzo5/+zsNRKn lYJFyvlZNOoX8860esir3r052/EZrc0PfGXALQHbYicwHvatCRxn4kW/pNUehmgIvM06 /9suvIzmPcYGyWIzSc5XYLwy0Wdo7IkFxr+qmyllvnsV3KLtrvmSv/GKreVSluKcIUEv 6yT57qyAfbRh4V/FiMd8E+51EFZjSt1SQuZ6q19pfxceR+eWx1cKFi5yKVrRIEEyBuUz bb0g== X-Forwarded-Encrypted: i=1; AJvYcCUak7/4sgf47L0jHU++pcFlEyT+l/BMy+GOwxdm9ZhkMOv7Vg3C1G6UAkI8AoxpTDLqrpPP/puG69OAdhw=@vger.kernel.org X-Gm-Message-State: AOJu0YyFvm0NmYT8zR0u3MgrkzMCoPiDp0wmpLxaOH9U+ApbqSg/C95w knEgqVn0HOgTEfhrSJ0VGqrbmE9UUPAWHiTyJo6meleGkPACy6PbOxH9fi9od8ua2JSY/myBZ28 3T2jhnNThd31Q2A== X-Received: from wrbeh4.prod.google.com ([2002:a05:6000:4104:b0:439:935b:4f51]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:4021:b0:437:8162:c0f2 with SMTP id ffacd0b85a97d-4399de2ebb0mr3691225f8f.39.1772190242107; Fri, 27 Feb 2026 03:04:02 -0800 (PST) Date: Fri, 27 Feb 2026 11:04:01 +0000 In-Reply-To: <20260225-page_alloc-unmapped-v1-18-e8808a03cd66@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260225-page_alloc-unmapped-v1-0-e8808a03cd66@google.com> <20260225-page_alloc-unmapped-v1-18-e8808a03cd66@google.com> X-Mailer: aerc 0.21.0 Message-ID: Subject: Re: [PATCH RFC 18/19] mm/page_alloc: implement __GFP_UNMAPPED|__GFP_ZERO allocations From: Brendan Jackman To: Brendan Jackman , Borislav Petkov , Dave Hansen , Peter Zijlstra , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , Vlastimil Babka , Wei Xu , Johannes Weiner , Zi Yan Cc: , , , , Sumit Garg , , , Will Deacon , , "Kalyazin, Nikita" , , "Itazuri, Takahiro" , Andy Lutomirski , David Kaplan , Thomas Gleixner , Yosry Ahmed Content-Type: text/plain; charset="UTF-8" On Wed Feb 25, 2026 at 4:34 PM UTC, Brendan Jackman wrote: > +static inline void clear_page_mermap(struct page *page, unsigned int numpages) > +{ > + void *mermap; > + > + BUILD_BUG_ON(IS_ENABLED(CONFIG_HIGHMEM)); > + > + /* Fast path: single mapping (may fail under preemption). */ > + mermap = mermap_get(page, numpages << PAGE_SHIFT, PAGE_KERNEL_NOGLOBAL); > + if (mermap) { > + void *buf = kasan_reset_tag(mermap_addr(mermap)); > + > + for (int i = 0; i < numpages; i++) > + clear_page(buf + (i << PAGE_SHIFT)); > + mermap_put(mermap); > + return; > + } > + > + /* Slow path, map each page individually (always succeeds). */ > + for (int i = 0; i < numpages; i++) { > + unsigned long flags; > + > + local_irq_save(flags); > + mermap = mermap_get_reserved(page + i, PAGE_KERNEL); Oh, that should be PAGE_KERNEL_NONGLOBAL. I think this means I never tested this path as this will crash - mermap_get_reserved() will WARN() and return NULL and then we'll dereference that below. Maybe that's a bad idea, maybe it should WARN() but serve the request anyway. Anyway maybe I need to support failure injection to test the fallback path. > + clear_page(kasan_reset_tag(mermap_addr(mermap))); > + mermap_put(mermap); > + local_irq_restore(flags); > + } > +} > +#else > +static inline bool pageblock_unmapped(struct page *page) > +{ > + return false; > +} > + > +static inline void clear_page_mermap(struct page *page, unsigned int numpages) > +{ > + BUG(); > +} > +#endif > + > +static void kernel_init_pages(struct page *page, unsigned int numpages) > +{ > + int num_blocks = DIV_ROUND_UP(numpages, pageblock_nr_pages); > + > + for (int block = 0; block < num_blocks; block++) { > + struct page *block_page = page + (block << pageblock_order); > + bool unmapped = pageblock_unmapped(block_page); > + > + /* s390's use of memset() could override KASAN redzones. */ > + kasan_disable_current(); > + if (unmapped) { > + clear_page_mermap(page, numpages); That should be clearing block_page. > + } else { > + for (int i = 0; i < min(numpages, pageblock_nr_pages); i++) > + clear_highpage_kasan_tagged(block_page + i); > + } > + kasan_enable_current(); > + > + numpages -= pageblock_nr_pages; > + } > }