Re: [PATCH v3 2/9] mm: limit pagecache folio refcount when splicing into pipes

From: David Hildenbrand (Arm)

Date: Thu Nov 12 2026 - 10:07:07 EST


On 11/12/26 15:00, Pedro Falcato wrote:
> On Thu, Nov 12, 2026 at 02:24:09PM +0100, David Hildenbrand (Arm) wrote:
>> On 11/12/26 14:09, Pedro Falcato wrote:
>>
>> [...]
>>>
>>> -EFAULT is a weird error code to return from splice, et al.
>>
>> We might be able to use ETOOMANYREFS (have to check if that could confuse
>> callers), but IMHO EFAULT is good enough.
>>
>> What would be your suggestion?
>
> ETOOMANYREFS I think is good, also EBUSY, EMLINK (though this would be weird)
> or even a generic -EIO.

So I used EFAULT because that's also what we currently return when
generic_pipe_buf_get() fails through pipe_buf_get() in splice_pipe_to_pipe() and
link_pipe().

If we want to return ETOOMANYREFS we'd likely have to special-case "<= 0" ref
count and things get more complicated, as we'd have to return two different
error cases.

And then we'd still have the inconsistency with the above cases.

I'll mention that I do not expect that we can trigger overflows in any
reasonable setup once we changed the way page table mappings are refcounted.

So for consistency with the existing checks I'd leave it at -EFAULT for now.

>
>>
>>>
>>> return spliced ?: -EFAULT;
>>>
>>> I don't know if there's much kernel code out there doing this, but I like
>>> the trick :)
>>
>> There are a couple of thousands, but yes, one doesn't encounter it that often.
>>
>>>
>>>
>>> I'm confused. Why does this need to be done here?
>>>
>>
>> I have above:
>>
>> "stop filemap_splice_read() if we only spliced part of a folio, so we don't
>> skip ahead to the next folio"
>
> Yes, but is this a separate fix? A folio could be partially spliced previously
> as well, no?

I think that wasn't possible because splice_folio_to_pipe() never returned
early. So it's only possible now once we fail to splice halfway through.

>
>>
>> Thanks a lot for the review!
>
> You're welcome! :)
>
> FWIW, you can add my
>
> Reviewed-by: Pedro Falcato <pfalcato@xxxxxxx>
>
> to whatever comes out of these nits :)

Thanks! :)

--
Cheers,

David