Re: [PATCH bpf v2] lib/buildid: use __kernel_read() for sleepable context
From: Matthew Wilcox
Date: Thu Dec 18 2025 - 23:07:59 EST
On Thu, Dec 18, 2025 at 04:16:40PM -0800, Shakeel Butt wrote:
> On Thu, Dec 18, 2025 at 11:55:39PM +0000, Matthew Wilcox wrote:
> > On Thu, Dec 18, 2025 at 12:55:05PM -0800, Shakeel Butt wrote:
> > > + do {
> > > + ret = __kernel_read(r->file, buf, sz, &pos);
> > > + if (ret <= 0) {
> > > + r->err = ret ?: -EIO;
> > > + return NULL;
> > > + }
> > > + buf += ret;
> > > + sz -= ret;
> > > + } while (sz > 0);
> >
> > Why are you doing a loop around __kernel_read()? eg kernel_read() does
> > not do a read around __kernel_read(). The callers of kernel_read()
> > don't do a loop either. So what makes you think it needs to have a loop
> > around it?
>
> I am assuming that __kernel_read() can return less data than the
> requested. Is that assumption incorrect?
I think it can, but I don't think a second call will get any more data.
For example, it could hit EOF. What led you to think that calling it in
a loop was the right approach?