Bug 5076
Summary: | truncated output from /proc/acpi/debug_level | ||
---|---|---|---|
Product: | ACPI | Reporter: | Sanjoy Mahajan (sanjoy) |
Component: | Other | Assignee: | Zhang Rui (rui.zhang) |
Status: | CLOSED PATCH_ALREADY_AVAILABLE | ||
Severity: | normal | CC: | acpi-bugzilla, nm127 |
Priority: | P2 | ||
Hardware: | i386 | ||
OS: | Linux | ||
Kernel Version: | 2.6.15 | Subsystem: | |
Regression: | --- | Bisected commit-id: | |
Attachments: |
patch to fix reading from debug_level and debug_layer
new model of ACPI debug interface remove ACPI debug proc interface |
Description
Sanjoy Mahajan
2005-08-16 11:53:53 UTC
Hmmm, I don't recall seeting this in earlier kernels -- did you notice at what kernel release /proc/acpi/debug_level broke? I've noticed it on and off with several kernels, but never pinned it down until now. I just tried 2.6.11.4, the earliest 2.6 kernel that I have lying around, and it shows the same problem. Are there earlier kernels worth trying? Created attachment 5653 [details]
patch to fix reading from debug_level and debug_layer
The attached patch fixes the problem for me.
The problem happens if the first read asks for fewer bytes than the size of the
answer, e.g. if you read 1 byte at a time. The second read will then arrive at
acpi_system_read_debug() with offset=1. The test at the top (off != 0) then
skips to the 'end:' label, which sets *eof=1 (and sets size=0). So the code
reading from /proc/acpi/debug_level (or debug_layer) will get 1 byte and then
an eof. The fix is to delete the (off != 0) test, and recompute the answer
from scratch each time, returning whatever piece of it the user wants.
Probably 'cat /proc/acpi/debug_level | cat' worked fine because cat increases
its buffer size to 4096 (big enough) when its stdout is not a tty, otherwise it
uses 1024:
$ strace -eread cat /proc/acpi/debug_level | cat
...
read(3, "Description \tHex "..., 4096) = 1313
...
but (showing the problem):
$ strace -eread cat /proc/acpi/debug_level
...
read(3, "Description \tHex "..., 1024) = 1024
...
Another problem could happen on a machine with small pages (1024 bytes or
less), because then the answer would overflow the allocated page passed in
'page' (on this kernel, the answer has 1313 bytes).
Updated kernel version to 2.6.15, which I just tested and it has the same problem. Created attachment 8846 [details]
new model of ACPI debug interface
This patach is to build a new model of ACPI debug interface by using seq_file
helper functions for making synthetic files from sequences of records.
This can successfully reduce the potential problems brought by the former model
which do all the fallible operations itself.
a change of plan: Rui created these files under /sys/module/acpi/parameters/ so we're going to delete the ones under /proc/ rather than fixing them. Created attachment 10659 [details]
remove ACPI debug proc interface
|