[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#67490: [PATCH v2] tail: fix tailing sysfs files on large page kernel
From: |
dann frazier |
Subject: |
bug#67490: [PATCH v2] tail: fix tailing sysfs files on large page kernels |
Date: |
Thu, 30 Nov 2023 13:37:25 -0700 |
On Thu, Nov 30, 2023 at 08:11:52PM +0000, Pádraig Brady wrote:
> Much clearer thanks.
>
> On my system:
>
> $ stat /sys/kernel/profiling
> File: /sys/kernel/profiling
> Size: 4096 Blocks: 0 IO Block: 4096 regular file
>
> I can easily repro by setting the buffer size < PAGE_SIZE.
Oh, clever.
> So this patch handles the case where sysfs reports a file is a certain size,
> but it isn't really. In that case seeking to anywhere other than the start
> doesn't give an error, but reading returns nothing. So we use a buffer size
> large enough (>= PAGE_SIZE as inferred from st_blksize) so that we'll be
> reading from the start of the file in this case.
Exactly.
> Note st_blksize can have unusual values, so it might be better
> to use the io_blksize() wrapper to sanitize the values.
> Though that will generally give 128K, which is good when processing all of a
> file,
> but perhaps overkill when processing just the last part of a file.
>
> So perhaps it's better to use buffer_size = MAX (BUFSIZ, getpagesize ())
> and avoid all the st_blksize edge cases.
Is there any performance concern about switching to 64K reads for
"normal" files (on these systems)?
> I'll think about it a little, and make the adjustments.
Appreciated!
-dann
> thanks!
> Pádraig.