From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f73.google.com (mail-ej1-f73.google.com [209.85.218.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 A0C6D28C5AA for ; Fri, 7 Nov 2025 12:12:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762517568; cv=none; b=r5VhHcIBBrltBL9hR28fSvIXBOrCz3LgXh5Xc4vaz3bLtS9ZUVXBiXTMcC9ePPZnr2G/OjlKEn4jv26qF1N8Bzpm9Y2pzrmluJJ9qJ5TzTJ5ppa481saX3qKwB4VM/gFFII2hklVWFSY/uHRDhRfehfDWcH6OOvTvMaevfddlT4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762517568; c=relaxed/simple; bh=Tfpbm92o9W7BVvnGiM2caH4qh7ZyE+P+DguJ0PvN6mQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=G3xjhrhPDmHYj3QPJALc5Udio9iMxoUz0XriNrwEB23F5CCOSv3UzLYtVtZerIMsTEJ8iPHuRICkTFF7BoeFlqy/IL21xGirC/2L77CG6aDyZ1oR4Wx5+fuqgQckOxt45gGiT+WFUP4oHIa3oiNTqd5iyQNmyYEJTz+hoWNk2MQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=tpBHtU6H; arc=none smtp.client-ip=209.85.218.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--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="tpBHtU6H" Received: by mail-ej1-f73.google.com with SMTP id a640c23a62f3a-b5fcada9d24so76669666b.1 for ; Fri, 07 Nov 2025 04:12:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1762517565; x=1763122365; 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=jiMZz3p9r1cXUEtJOvXENsRsqsu1S4GTx2JzdMxXhCI=; b=tpBHtU6H+uXNawvpoCU6gmGnXVQWUKcfsKVxFE+D8QNj4HARSbp6TnAW6uvuj4qgb8 Ep6t/ejz9fVp7xs12kzya9XyD+fL48Jsc0TA3Uf7VJUEMUb9sf0ChK/1XFEsVfINkdYk zPsgwUwryAKVbT0ly27gQYkH/kmjXN0DXEazIYsEjFTFtkMizU20NR2yHMLilOQiO4G5 2QrFv625cl3ZQSIa1OIcFSPzk1+YbeXbrz2NQLQAFOn8sMMBITasCBJlzgTFHXMgD2c3 GseWHjVlUX+pH0Ph1H8STTfMMp5FrZrI6eUcHQ+SORgQkwjsiSyHnhSY9AgYmT57gAxN xm5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762517565; x=1763122365; 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=jiMZz3p9r1cXUEtJOvXENsRsqsu1S4GTx2JzdMxXhCI=; b=rvl1A5dE8kZx9ETzgB/zAh+XEZC/InP/F7aYX3iZyHuSpD2k/ul+WD7WtFZSwZYhJl ZH5gKYue95IaO7bUuOIN6aHiyLs9uQfxl/BclCnXyuTldAjkn4vV6AOGTwGW2PnVxcfu 9vw9gzgzuzkP2iKC6yljRcWIhFmiLZH7Hg1b3TdtPXFc50aRJDd/L9XeMyBhgNlBIO3z Vxc9uYU1bAd3PQKqAASfi/Cj6NA3AEh9I/vSBLwe/rJ/kQ1xgDv3CfHzugvJF2mDzfAz PsKWlg7UnxeIfS9kC4VXqNkYaWAiDx456wGlGB7kO1zyvyKnAprNkCEecpDz0CjBBzIb mQJw== X-Forwarded-Encrypted: i=1; AJvYcCWfW5ZEBpsplKA7L0q70tayeuduyTfDIfBH9h+qrctLgRgDEkzKOqAEwM/HW+uI04jJq1zj7zeMv40=@vger.kernel.org X-Gm-Message-State: AOJu0YyBPphb4QwTShiDp1E22GMefhe8Te8q0DhltKGKZwqo44p5+XOj Do5FFW2FmnpujQyixdFs+KGKU11PJiafBETtD01RfJuUPDJCalrsoBKVGjJxL5+QM28rvGhKZro CmQtQoY3nxXv3LNOClg== X-Google-Smtp-Source: AGHT+IFz1d7JwOnWSoe0fVf8qRe2tAmBflmhL4Mg+i45pACLer1ETGlr4r2lHbYGUH0n6LT169uz4zsABZFzda8= X-Received: from ejdaz21.prod.google.com ([2002:a17:906:8f15:b0:b72:5aa5:2d0b]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a17:907:6d16:b0:b6d:7e04:7a24 with SMTP id a640c23a62f3a-b72c0ac01aemr279299066b.36.1762517565061; Fri, 07 Nov 2025 04:12:45 -0800 (PST) Date: Fri, 7 Nov 2025 12:12:43 +0000 In-Reply-To: <0f7186b3-16bd-44b7-a3fe-637af9d25dd3@lucifer.local> Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <043dcbdb-e069-46e7-8f79-8fdaf354fb44@lucifer.local> <0f7186b3-16bd-44b7-a3fe-637af9d25dd3@lucifer.local> Message-ID: Subject: Re: [PATCH v2 1/5] mm: introduce VM_MAYBE_GUARD and make visible in /proc/$pid/smaps From: Alice Ryhl To: Lorenzo Stoakes Cc: Pedro Falcato , Andrew Morton , Jonathan Corbet , David Hildenbrand , "Liam R . Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jann Horn , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Andrei Vagin Content-Type: text/plain; charset="utf-8" On Fri, Nov 07, 2025 at 09:44:22AM +0000, Lorenzo Stoakes wrote: > On Fri, Nov 07, 2025 at 09:13:00AM +0000, Alice Ryhl wrote: > > On Thu, Nov 06, 2025 at 02:54:33PM +0000, Lorenzo Stoakes wrote: > > > +cc Alice for rust stuff > > > > > > On Thu, Nov 06, 2025 at 02:27:56PM +0000, Pedro Falcato wrote: > > > > On Thu, Nov 06, 2025 at 10:46:12AM +0000, Lorenzo Stoakes wrote: > > > > > /* > > > > > * vm_flags in vm_area_struct, see mm_types.h. > > > > > * When changing, update also include/trace/events/mmflags.h > > > > > @@ -296,6 +298,7 @@ extern unsigned int kobjsize(const void *objp); > > > > > #define VM_UFFD_MISSING 0 > > > > > #endif /* CONFIG_MMU */ > > > > > #define VM_PFNMAP 0x00000400 /* Page-ranges managed without "struct page", just pure PFN */ > > > > > +#define VM_MAYBE_GUARD BIT(VM_MAYBE_GUARD_BIT) /* The VMA maybe contains guard regions. */ > > > > > > > > Don't we also need an adjustment on the rust side for this BIT()? Like we > > > > for f04aad36a07c ("mm/ksm: fix flag-dropping behavior in ksm_madvise"). > > > > > > That's a bit unhelpful if rust can't cope with extremely basic assignments like > > > that and we just have to know to add helpers :/ > > > > > > We do BIT() stuff for e.g. VM_HIGH_ARCH_n, VM_UFFD_MINOR_BIT, > > > VM_ALLOW_ANY_UNCACHED_BIT, VM_DROPPABLE_BIT and VM_SEALED_BIT too and no such > > > helpers there, So not sure if this is required? > > > > > > Alice - why is it these 'non-trivial' defines were fine but VM_MERGEABLE was > > > problematic? That seems strange. > > > > > > I see [0], so let me build rust here and see if it moans, if it moans I'll add > > > it. > > > > > > [0]:https://lore.kernel.org/oe-kbuild-all/CANiq72kOhRdGtQe2UVYmDLdbw6VNkiMtdFzkQizsfQV0gLY1Hg@mail.gmail.com/ > > > > When you use #define to declare a constant whose right-hand-side > > contains a function-like macro such as BIT(), bindgen does not define a > > Rust version of that constant. However, VM_MAYBE_GUARD is not referenced > > in Rust anywhere, so that isn't a problem. > > > > It was a problem with VM_MERGEABLE because rust/kernel/mm/virt.rs > > references it. > > > > Note that it's only the combination of #define and function-like macro > > that triggers this condition. If the constant is defined using another > > mechanism such as enum {}, then bindgen will generate the constant no > > matter how complex the right-hand-side is. The problem is that bindgen > > can't tell whether a #define is just a constant or not. > > Thanks, I guess we can update as we go as rust needs. Or I can do a big update > as part of my VMA flag series respin? Whenever you think is a good time works for me. I think it would be nice to move those constants so they use enum {} instead of #define at some point. Alice