From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) (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 5E20C37B409 for ; Fri, 10 Jul 2026 19:20:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783711252; cv=none; b=UG3JXloSFzMHy7Mq5CM19aIPo0J1aaKiMQi4k1SIEExi5JtNjP7t3dcKm4RssYRw4JzaYFuQLf45D4vcZfCcyHAhlxCAxXH7kYC4xUtg+R22ceKzNtUXZRQ1Ih0nNSp/g0HJtCdBVl9eFXBgBzJ48t9Ivo03iR1V3UMg6QUJ4GA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783711252; c=relaxed/simple; bh=bX34iOgCjAyoyd0wtccoyCGEJ+0E8xtv6sAci2MgTt8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NEqom7yhwacM6lJnYeDMsGltiChB+DS3WI8OLVMVx0yfiyE4Dp/Bd7VlPZYprM9p7CxBgXApkNQ2aB86q1sNpT5oiP4qeOv9usO638gYHALVXx0MH+dR5MOm1rpHUugEcME4pnigNL+iG+DhWc7x0UhiQYtSoFkvKasNctnnldA= 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=QRHXydDJ; arc=none smtp.client-ip=209.85.222.170 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="QRHXydDJ" Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-92e5c92c389so65820385a.3 for ; Fri, 10 Jul 2026 12:20:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1783711249; x=1784316049; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=xFW+QIJ4JFkYmnZudtxzUHG1gsom4gRJfGrSXFnz7n8=; b=QRHXydDJ5/nQOc8HvU3q4OunBP6vz4zthUIJ0dkwyXxVO/A5OI0D3B5US7tjGhkA0o 2Y4iy8tprf9PaAxfkB8E4J4KUFOeR0hOdpRHpcm/3cq9mk2PpgAhLGikVu9EtYdys80y 7CThLFBj6rKv8qfTgGy54aok4Gk/KcW5DYg5XZSEaB9mevnpFZmmPoMZoGQD8l3/rPMw ZWbB6ttvdjuCrPiV0APso8CbgZXYVm2zeKU1oT4g8xXhqPRqb/WazBgSs8BZvH8o4Nfm Yu9bvipGLMh3EB8pwlFHBEsrUFfGTNGooltP0RM3rBS+KU3LKl86QIqefaM9ZlDcZqJD Iv6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783711249; x=1784316049; h=in-reply-to:content-disposition:content-type: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 :content-type; bh=xFW+QIJ4JFkYmnZudtxzUHG1gsom4gRJfGrSXFnz7n8=; b=eiSE4NWKPBFsDFbSNn6o3LPQ0XC/sv5ZEc5t+W1wO8uyPZD1M3PnvZ4ub3u1QhjX6Q dBl1w3Q5avxFg2ITcb331Xu+KBbRA3xOZXYa3DZhPIQ23sSrLHDQLBpS/ercAxJWxzeD rOt7ajdP89PxKUXgkgIcWHcBEM+6hValj1/nGizcOj/BKgY4POQOKWLlmWjOIZD/ipnk C++f/6tTsx8cL8Heg989RY46mSF9TriSng8OsRh7Zvu9GfOUu6Eiza5iN231Ed1KLjxn AcHMsqweyZvZkpHirpPTl/sck5++c/rMB+AWkQbeJDLUPLtuDrwhvV0TAf7Q7DSPbpAU mtsg== X-Forwarded-Encrypted: i=1; AHgh+RrMnp0xcF9U2NBtCYEosueRYeYP7+gSAGirpFG88cDELPktyy6OmNw/8rPN7zKbVWxEAY3jdXmCZgKTe94=@vger.kernel.org X-Gm-Message-State: AOJu0YyItWqEcIdo5LOgQkS9I8Ifn7HPTOn/lDE/ApxyloihK1xNit64 kU2rBbX4/0ke3aPlhSv1CeKaJwcWjZ/G2NnjlW1JKqA1A201sCq0/oFNYxVkywJ2gWs= X-Gm-Gg: AfdE7clN7Z2vCyb/XaX+ewqvj5d92BAAiOk1N2BuZCHBJGLXZxHa4QubRNqVP+GrRdv up5jWZU4u/c+gNgABP+hlvLgYaMwSMGIUYb7NCUCWWC9cpGSHDxeSB8I7r6XfLU1MhTws2Fl67g wUfDwTg6iC5RKFqukJZ02E53EsfnnKZfD6bn2ROOTJQ+//Xap4/WDh8A/SwMPQZ9/Mc0m8eaE9X s7TPZ+TX7ptpGUicgCsd4scAc3mg/uDNUCRUsfV/yMac0r7ihuPH3y9gBiafgZ6tF3gGh9Sy+ng qn6NVZ2Mtz73YNcmnIAs7Bn/01qXkUEwAdvtO+4sRm3u+S4f6gC9SF+rKhbDWmZlQwbaVVe2lLd ZahN77flXr39eUB6LIY3m1DRdLRzpQEFZidGGlKbf4vEWUf3t0XHNXcLxlTs9qOqAkcvekj8l3k D4D4FqdIwXl6PLH2O1fc0L0goGEkb2P2L4GkUu/QIWLXsdEoOB/85dsnej89ykp71Rq49n X-Received: by 2002:a05:620a:44c3:b0:92e:c117:5ecd with SMTP id af79cd13be357-92ef2d107efmr56266185a.77.1783711249227; Fri, 10 Jul 2026 12:20:49 -0700 (PDT) Received: from gourry-fedora-PF4VCD3F (pool-173-79-60-52.washdc.fios.verizon.net. [173.79.60.52]) by smtp.gmail.com with ESMTPSA id af79cd13be357-92ee5b8b3f2sm268883885a.13.2026.07.10.12.20.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2026 12:20:48 -0700 (PDT) Date: Fri, 10 Jul 2026 15:20:43 -0400 From: Gregory Price To: Lorenzo Stoakes Cc: Andrew Morton , Russell King , Dinh Nguyen , Simon Schuster , "James E . J . Bottomley" , Helge Deller , Jarkko Sakkinen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Ian Abbott , H Hartley Sweeten , Lucas Stach , David Airlie , Simona Vetter , Patrik Jakobsson , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Clark , Dmitry Baryshkov , Tomi Valkeinen , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Christian Koenig , Huang Rui , Ankit Agrawal , Alex Williamson , Alexander Viro , Christian Brauner , Dan Williams , Muchun Song , Oscar Salvador , David Hildenbrand , Suren Baghdasaryan , "Liam R . Howlett" , Matthew Wilcox , Marek Szyprowski , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Masami Hiramatsu , Oleg Nesterov , Steven Rostedt , SeongJae Park , Miaohe Lin , Hugh Dickins , Mike Rapoport , Kees Cook , Paolo Bonzini , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-parisc@vger.kernel.org, linux-sgx@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-tegra@vger.kernel.org, kvm@vger.kernel.org, linux-fsdevel@vger.kernel.org, nvdimm@lists.linux.dev, linux-mm@kvack.org, iommu@lists.linux.dev, linux-perf-users@vger.kernel.org, linux-trace-kernel@vger.kernel.org, kasan-dev@googlegroups.com, damon@lists.linux.dev, Pedro Falcato , Rik van Riel , Harry Yoo , Jann Horn Subject: Re: [PATCH 26/30] mm/vma: introduce and use vma_set_pgoff() Message-ID: References: <37f4d951897641f304dba26f6f91ade03a50eb01.1782735110.git.ljs@kernel.org> Precedence: bulk X-Mailing-List: linux-parisc@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: <37f4d951897641f304dba26f6f91ade03a50eb01.1782735110.git.ljs@kernel.org> On Mon, Jun 29, 2026 at 01:23:37PM +0100, Lorenzo Stoakes wrote: > In order to lay the foundation for work that permits us to track the > virtual page offset of MAP_PRIVATE file-backed mappings, we abstract the > assignment of vma->vm_pgoff to vma_set_pgoff(). > > We additionally add a lock check here using the newly introduced > vma_assert_can_modify(). This asserts the VMA write lock if the VMA is > attached. > > We also assert that, if this is an anonymous VMA and unfaulted, that its > (virtual) page offset is equal to the page offset of the VMA's address. > > In order to maintain correctness given this assert, we also update > __install_special_mapping() to invoke vma_set_range() after it's set > vma->vm_ops (which determine whether the VMA is anonymous or not). > > We do not use vma_set_pgoff() in vm_area_init_from(), as at the point of > forking, we don't necessarily have correct locking state. > > Updating vma_set_range() covers most cases, but in addition to this we also > update insert_vm_struct(), compat_set_vma_from_desc() and nommu callers. > > We also update vma_add_pgoff() and vma_sub_pgoff() to use vma_set_pgoff(). > > While we're here, we drop a BUG_ON() and update insert_vm_struct()'s > comment to reflect the fact anonymous mappings can be added here. > > No functional change intended. > > Signed-off-by: Lorenzo Stoakes Reviewed-by: Gregory Price