From nobody Fri Oct 3 14:44:01 2025 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (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 8235521B9C1 for ; Sun, 31 Aug 2025 09:39:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756633181; cv=none; b=elThkWPWUbH1xYLrBSFr8HkwJ4m5gyX52l+pJWTU+EZ2xOIsTtvYALNDIjVe1tRRbVmeJZc0nHX4EkSuexwZjIFK2kOoKv7VZojvgHjRKUmxXRs2EGHxQFeDIxDMpN76ddxCgTLDF+060f1Q/Z/P+bice91QrejCj/JqbCUZwL8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756633181; c=relaxed/simple; bh=e8jN8iSCUrThrccW1BHJJcYct0sngJONN8P17gEsOTE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qJuEq/pIOymZwx1DSZ+NAPbtLaq2G3LauRxrcMOJHciphnVi2DGPjY0+r3mEVDPu3dYlqFbn4daH8sqgMGFuf2n0s1rP4qC26teR3ZPRpC2ZkEJ7rV1W//6CMMAtTjAChf0xITEJRDOStpxR4x1PMK5iqoEbWF4PiHG4aeAF2Gw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=aZjMj7uY; arc=none smtp.client-ip=209.85.218.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="aZjMj7uY" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-afee6037847so520752266b.1 for ; Sun, 31 Aug 2025 02:39:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1756633178; x=1757237978; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fS4wJfZ2pDhZvPbiW+R+SY5FbZtgMq1SfXnP2mUytfo=; b=aZjMj7uYK4i5eIeDVOc6wxLYcaZiSGRUgcdsZPFIx6BZyAkyzBpBsnCgWH2rf+cL44 IWhpsHBDOWofCnqNaF07B9fyrEOjI3gXHoULl1PWfw9UvA6HALIZnC9fBJljiaWU7PGZ sKR1Laat5grkqv3Fv7R41EZL42NjPnUFN3eI1S5tw2zI04Tf2igifBhZnXBXCtdBYq8c +G8jqjHbb55ePJgkIvoQPjnzzmV6yCacAY3AG97r5YiSBigJdttqcpjV/olbXZ+dbWk0 CMGEQteTmO4+8RcjvGOFPy+oRKYSFcEJlmxVIUt2fW8tqUbfOim26OIxrfGHBit4b2rJ JFFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756633178; x=1757237978; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fS4wJfZ2pDhZvPbiW+R+SY5FbZtgMq1SfXnP2mUytfo=; b=c0eM9LZAbcfX6q/AMXcsG/Q9IkpchzPdmcYcpvr0T1c9M1ttKbZFPfItsMjnCbVF10 8zAityAmrcf+2SC5GROXLu66DfQ9Rq7PBZ9ctGm2v8xkypstCDpEd7dkxpvEvJddCtxk RhpnTO1VMuhGv1Qg9BDoUdpPIVPqX+phsXHsK6ttOdn3al4YJshvGe1Pd+oUFFX8wh8N 1OQ8DQM8gXNFS/+TFOmEdfEf6+Ym+Yzfa277vWk+ExCaP3o/3K8FBNY8/HJ2b3MdxW7h kdQDesvVxdQmfI7xIsZuo3iRcEcEeh3Iw67PvcYK6hFzV6jb6N+TGP9Y5K2Y0CST8/hc ZYIA== X-Forwarded-Encrypted: i=1; AJvYcCVtp3I9VB9fHLe3yrGPi1V+T+b3SdFf7qN40vl2FASr3YIMQpf6f6fI2E/uSE6lF0Mai8WyMQSv3/GU+k8=@vger.kernel.org X-Gm-Message-State: AOJu0YyArZbWJkzVCIUglLl0vTszfMtjoqXkbiM3kYzGNiHDCA/plbl7 kjrbSAyJb1107xQ1MlrJWf93G3v27oglvYUU+oURSWykz/gxgYthgE05PCA4zFyXbWI= X-Gm-Gg: ASbGncvOPZtFUUtC6Igt3h2oAAZwR/e5X8yn/bwiDBh8ws6NwdwO7YmLDMpWrskvdyz svzM2Sb4FQeGMmeccprLb3+6AT5bpKdhxmyNVc6cFEH/DuUzvgYqQ6/0SccLCL6NtlCZPqUFlsB hNoDHJBpL3AWljBNNN27Emx5fAXYJ0dCISi4yYrlKvblrjU4k6wZqZCiKIIam7GGT51273JEpaj ymYvOoxuQGvWbTMpPN2z9CaHAhUiB0n0GX0LshYi3VW/Ye7SvLSPS6LeaSVQTa7XoE7laXoU40/ RCt23xmLa3006hVvq+sNf7UNlJy8smJk0ZwsdEFtks9yz81NMq2/U6+VpiGaz6kysMkR3om60qp rNuB9csa6poHykVwSw6/man8UhM+mKVwTepPiBgyBACf+UTtQNssCMQ7q/IhWuCVbjkqpiJkANJ vKIBnsllIjxPatOgPSwISLQA== X-Google-Smtp-Source: AGHT+IFl6wqzfG0vHDTUkL/FnbDFFEhWrqTy9LAAxJMUtnBrhQMoPbd3VxGPn58hYgmzlZMy0V4cTg== X-Received: by 2002:a17:907:3f9e:b0:b04:299d:53ab with SMTP id a640c23a62f3a-b04299d590cmr3529566b.37.1756633177663; Sun, 31 Aug 2025 02:39:37 -0700 (PDT) Received: from raven.intern.cm-ag (p200300dc6f1d0f00023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f1d:f00:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-afefcbd8656sm597512566b.56.2025.08.31.02.39.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Aug 2025 02:39:37 -0700 (PDT) From: Max Kellermann To: akpm@linux-foundation.org, david@redhat.com, axelrasmussen@google.com, yuanchu@google.com, willy@infradead.org, hughd@google.com, mhocko@suse.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com, vbabka@suse.cz, rppt@kernel.org, surenb@google.com, vishal.moola@gmail.com Cc: Max Kellermann Subject: [PATCH v2 02/12] include/pagemap.h: add `const` to lots of pointer parameters Date: Sun, 31 Aug 2025 11:39:08 +0200 Message-ID: <20250831093918.2815332-3-max.kellermann@ionos.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250831093918.2815332-1-max.kellermann@ionos.com> References: <20250831093918.2815332-1-max.kellermann@ionos.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For improved const-correctness. Signed-off-by: Max Kellermann Reviewed-by: Vishal Moola (Oracle) --- include/linux/pagemap.h | 57 +++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index c9ba69e02e3e..d1244e7dcf0e 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -140,7 +140,7 @@ static inline int inode_drain_writes(struct inode *inod= e) return filemap_write_and_wait(inode->i_mapping); } =20 -static inline bool mapping_empty(struct address_space *mapping) +static inline bool mapping_empty(const struct address_space *const mapping) { return xa_empty(&mapping->i_pages); } @@ -166,7 +166,7 @@ static inline bool mapping_empty(struct address_space *= mapping) * refcount and the referenced bit, which will be elevated or set in * the process of adding new cache pages to an inode. */ -static inline bool mapping_shrinkable(struct address_space *mapping) +static inline bool mapping_shrinkable(const struct address_space *const ma= pping) { void *head; =20 @@ -265,7 +265,7 @@ static inline void mapping_clear_unevictable(struct add= ress_space *mapping) clear_bit(AS_UNEVICTABLE, &mapping->flags); } =20 -static inline bool mapping_unevictable(struct address_space *mapping) +static inline bool mapping_unevictable(const struct address_space *const m= apping) { return mapping && test_bit(AS_UNEVICTABLE, &mapping->flags); } @@ -275,7 +275,7 @@ static inline void mapping_set_exiting(struct address_s= pace *mapping) set_bit(AS_EXITING, &mapping->flags); } =20 -static inline int mapping_exiting(struct address_space *mapping) +static inline int mapping_exiting(const struct address_space *const mappin= g) { return test_bit(AS_EXITING, &mapping->flags); } @@ -285,7 +285,7 @@ static inline void mapping_set_no_writeback_tags(struct= address_space *mapping) set_bit(AS_NO_WRITEBACK_TAGS, &mapping->flags); } =20 -static inline int mapping_use_writeback_tags(struct address_space *mapping) +static inline int mapping_use_writeback_tags(const struct address_space *c= onst mapping) { return !test_bit(AS_NO_WRITEBACK_TAGS, &mapping->flags); } @@ -331,7 +331,7 @@ static inline void mapping_set_inaccessible(struct addr= ess_space *mapping) set_bit(AS_INACCESSIBLE, &mapping->flags); } =20 -static inline bool mapping_inaccessible(struct address_space *mapping) +static inline bool mapping_inaccessible(const struct address_space *const = mapping) { return test_bit(AS_INACCESSIBLE, &mapping->flags); } @@ -341,18 +341,18 @@ static inline void mapping_set_writeback_may_deadlock= _on_reclaim(struct address_ set_bit(AS_WRITEBACK_MAY_DEADLOCK_ON_RECLAIM, &mapping->flags); } =20 -static inline bool mapping_writeback_may_deadlock_on_reclaim(struct addres= s_space *mapping) +static inline bool mapping_writeback_may_deadlock_on_reclaim(const struct = address_space *const mapping) { return test_bit(AS_WRITEBACK_MAY_DEADLOCK_ON_RECLAIM, &mapping->flags); } =20 -static inline gfp_t mapping_gfp_mask(struct address_space * mapping) +static inline gfp_t mapping_gfp_mask(const struct address_space *const map= ping) { return mapping->gfp_mask; } =20 /* Restricts the given gfp_mask to what the mapping allows. */ -static inline gfp_t mapping_gfp_constraint(struct address_space *mapping, +static inline gfp_t mapping_gfp_constraint(const struct address_space *map= ping, gfp_t gfp_mask) { return mapping_gfp_mask(mapping) & gfp_mask; @@ -475,13 +475,13 @@ mapping_min_folio_order(const struct address_space *m= apping) } =20 static inline unsigned long -mapping_min_folio_nrpages(struct address_space *mapping) +mapping_min_folio_nrpages(const struct address_space *const mapping) { return 1UL << mapping_min_folio_order(mapping); } =20 static inline unsigned long -mapping_min_folio_nrbytes(struct address_space *mapping) +mapping_min_folio_nrbytes(const struct address_space *const mapping) { return mapping_min_folio_nrpages(mapping) << PAGE_SHIFT; } @@ -495,7 +495,7 @@ mapping_min_folio_nrbytes(struct address_space *mapping) * new folio to the page cache and need to know what index to give it, * call this function. */ -static inline pgoff_t mapping_align_index(struct address_space *mapping, +static inline pgoff_t mapping_align_index(const struct address_space *cons= t mapping, pgoff_t index) { return round_down(index, mapping_min_folio_nrpages(mapping)); @@ -505,7 +505,7 @@ static inline pgoff_t mapping_align_index(struct addres= s_space *mapping, * Large folio support currently depends on THP. These dependencies are * being worked on but are not yet fixed. */ -static inline bool mapping_large_folio_support(struct address_space *mappi= ng) +static inline bool mapping_large_folio_support(const struct address_space = *mapping) { /* AS_FOLIO_ORDER is only reasonable for pagecache folios */ VM_WARN_ONCE((unsigned long)mapping & FOLIO_MAPPING_ANON, @@ -520,7 +520,7 @@ static inline size_t mapping_max_folio_size(const struc= t address_space *mapping) return PAGE_SIZE << mapping_max_folio_order(mapping); } =20 -static inline int filemap_nr_thps(struct address_space *mapping) +static inline int filemap_nr_thps(const struct address_space *const mappin= g) { #ifdef CONFIG_READ_ONLY_THP_FOR_FS return atomic_read(&mapping->nr_thps); @@ -934,7 +934,7 @@ static inline struct page *grab_cache_page_nowait(struc= t address_space *mapping, * * Return: The index of the folio which follows this folio in the file. */ -static inline pgoff_t folio_next_index(struct folio *folio) +static inline pgoff_t folio_next_index(const struct folio *const folio) { return folio->index + folio_nr_pages(folio); } @@ -963,7 +963,7 @@ static inline struct page *folio_file_page(struct folio= *folio, pgoff_t index) * e.g., shmem did not move this folio to the swap cache. * Return: true or false. */ -static inline bool folio_contains(struct folio *folio, pgoff_t index) +static inline bool folio_contains(const struct folio *const folio, pgoff_t= index) { VM_WARN_ON_ONCE_FOLIO(folio_test_swapcache(folio), folio); return index - folio->index < folio_nr_pages(folio); @@ -1040,13 +1040,13 @@ static inline loff_t page_offset(struct page *page) /* * Get the offset in PAGE_SIZE (even for hugetlb folios). */ -static inline pgoff_t folio_pgoff(struct folio *folio) +static inline pgoff_t folio_pgoff(const struct folio *const folio) { return folio->index; } =20 -static inline pgoff_t linear_page_index(struct vm_area_struct *vma, - unsigned long address) +static inline pgoff_t linear_page_index(const struct vm_area_struct *const= vma, + const unsigned long address) { pgoff_t pgoff; pgoff =3D (address - vma->vm_start) >> PAGE_SHIFT; @@ -1466,7 +1466,7 @@ static inline unsigned int __readahead_batch(struct r= eadahead_control *rac, * readahead_pos - The byte offset into the file of this readahead request. * @rac: The readahead request. */ -static inline loff_t readahead_pos(struct readahead_control *rac) +static inline loff_t readahead_pos(const struct readahead_control *const r= ac) { return (loff_t)rac->_index * PAGE_SIZE; } @@ -1475,7 +1475,7 @@ static inline loff_t readahead_pos(struct readahead_c= ontrol *rac) * readahead_length - The number of bytes in this readahead request. * @rac: The readahead request. */ -static inline size_t readahead_length(struct readahead_control *rac) +static inline size_t readahead_length(const struct readahead_control *cons= t rac) { return rac->_nr_pages * PAGE_SIZE; } @@ -1484,7 +1484,7 @@ static inline size_t readahead_length(struct readahea= d_control *rac) * readahead_index - The index of the first page in this readahead request. * @rac: The readahead request. */ -static inline pgoff_t readahead_index(struct readahead_control *rac) +static inline pgoff_t readahead_index(const struct readahead_control *cons= t rac) { return rac->_index; } @@ -1493,7 +1493,7 @@ static inline pgoff_t readahead_index(struct readahea= d_control *rac) * readahead_count - The number of pages in this readahead request. * @rac: The readahead request. */ -static inline unsigned int readahead_count(struct readahead_control *rac) +static inline unsigned int readahead_count(const struct readahead_control = *const rac) { return rac->_nr_pages; } @@ -1502,12 +1502,12 @@ static inline unsigned int readahead_count(struct r= eadahead_control *rac) * readahead_batch_length - The number of bytes in the current batch. * @rac: The readahead request. */ -static inline size_t readahead_batch_length(struct readahead_control *rac) +static inline size_t readahead_batch_length(const struct readahead_control= *const rac) { return rac->_batch_count * PAGE_SIZE; } =20 -static inline unsigned long dir_pages(struct inode *inode) +static inline unsigned long dir_pages(const struct inode *const inode) { return (unsigned long)(inode->i_size + PAGE_SIZE - 1) >> PAGE_SHIFT; @@ -1521,8 +1521,8 @@ static inline unsigned long dir_pages(struct inode *i= node) * Return: the number of bytes in the folio up to EOF, * or -EFAULT if the folio was truncated. */ -static inline ssize_t folio_mkwrite_check_truncate(struct folio *folio, - struct inode *inode) +static inline ssize_t folio_mkwrite_check_truncate(const struct folio *con= st folio, + const struct inode *const inode) { loff_t size =3D i_size_read(inode); pgoff_t index =3D size >> PAGE_SHIFT; @@ -1553,7 +1553,8 @@ static inline ssize_t folio_mkwrite_check_truncate(st= ruct folio *folio, * Return: The number of filesystem blocks covered by this folio. */ static inline -unsigned int i_blocks_per_folio(struct inode *inode, struct folio *folio) +unsigned int i_blocks_per_folio(const struct inode *const inode, + const struct folio *const folio) { return folio_size(folio) >> inode->i_blkbits; } --=20 2.47.2