GNU bug report logs - #67490
[PATCH v2] tail: fix tailing sysfs files on large page kernels

Previous Next

Package: coreutils;

Reported by: dann frazier <dann.frazier <at> canonical.com>

Date: Mon, 27 Nov 2023 17:31:02 UTC

Severity: normal

Tags: patch

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: dann frazier <dann.frazier <at> canonical.com>
To: Pádraig Brady <P <at> draigbrady.com>
Cc: 67490 <at> debbugs.gnu.org
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.




This bug report was last modified 1 year and 175 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.