On 3/12/26 1:27 PM, Lorenzo Stoakes (Oracle) wrote:
> Finally, we update the VMA tests accordingly to reflect the changes.
IMO we could omit the word "we" 5 times above.
(but no change is required)
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 88f42faeb377..88ad5649c02d 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> +/**
> + * range_is_subset - Is the specified inner range a subset of the outer
> range?
> + * @outer_start: The start of the outer range.
> + * @outer_end: The exclusive end of the outer range.
> + * @inner_start: The start of the inner range.
> + * @inner_end: The exclusive end of the inner range.
> + *
> + * Returns %true if [inner_start, inner_end) is a subset of [outer_start,
* Returns:
(for kernel-doc)
> + * outer_end), otherwise %false.
> + */
> +static inline bool range_is_subset(unsigned long outer_start,
> + unsigned long outer_end,
> + unsigned long inner_start,
> + unsigned long inner_end)
> +{
> + return outer_start <= inner_start && inner_end <= outer_end;
> +}
> +
> +/**
> + * range_in_vma - is the specified [@start, @end) range a subset of the VMA?
> + * @vma: The VMA against which we want to check [@start, @end).
> + * @start: The start of the range we wish to check.
> + * @end: The exclusive end of the range we wish to check.
> + *
> + * Returns %true if [@start, @end) is a subset of [@vma->vm_start,
* Returns:
> + * @vma->vm_end), %false otherwise.
> + */
> static inline bool range_in_vma(const struct vm_area_struct *vma,
> unsigned long start, unsigned long end)
> {
> - return (vma && vma->vm_start <= start && end <= vma->vm_end);
> + if (!vma)
> + return false;
> +
> + return range_is_subset(vma->vm_start, vma->vm_end, start, end);
> +}
> +
> +/**
> + * range_in_vma_desc - is the specified [@start, @end) range a subset of the
> VMA
> + * described by @desc, a VMA descriptor?
> + * @desc: The VMA descriptor against which we want to check [@start, @end).
> + * @start: The start of the range we wish to check.
> + * @end: The exclusive end of the range we wish to check.
> + *
> + * Returns %true if [@start, @end) is a subset of [@desc->start, @desc->end),
* Returns:
> + * %false otherwise.
> + */
> +static inline bool range_in_vma_desc(const struct vm_area_desc *desc,
> + unsigned long start, unsigned long end)
> +{
> + if (!desc)
> + return false;
> +
> + return range_is_subset(desc->start, desc->end, start, end);
> }
--
~Randy