[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1AE640813FDE7649BE1B193DEA596E883BC0EB20@SHSMSX101.ccr.corp.intel.com>
Date: Wed, 17 Aug 2016 02:39:35 +0000
From: "Zheng, Lv" <lv.zheng@...el.com>
To: "Rafael J. Wysocki" <rjw@...ysocki.net>
CC: "Wysocki, Rafael J" <rafael.j.wysocki@...el.com>,
"Brown, Len" <len.brown@...el.com>, Lv Zheng <zetalog@...il.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-acpi@...r.kernel.org" <linux-acpi@...r.kernel.org>,
"linux-api@...r.kernel.org" <linux-api@...r.kernel.org>
Subject: RE: [PATCH v4 1/3] ACPI / debugger: Add kernel flushing support
Hi, Rafael
> From: Rafael J. Wysocki [mailto:rjw@...ysocki.net]
> Subject: Re: [PATCH v4 1/3] ACPI / debugger: Add kernel flushing support
>
> On Tuesday, July 26, 2016 07:01:33 PM Lv Zheng wrote:
> > This patch adds debugger output flushing support in kernel via .ioctl()
> > callback. The in-kernel flushing is more efficient, because it reduces
> > useless log IOs by bypassing log user_read/kern_write during the flush
> > period.
> >
> > This mechanism is useful for the batch mode.
>
> Is it only useful or is it required?
Should be required.
>
> Also the batch mode is introduced by the remaining patches in the series,
> isn't it?
No, the batch mode is already in the upstream.
It's acpidbg -b "debugger commands".
For example:
acpidbg "-b namespace"
It's currently working.
>
> > Scripts can integrate a batch mode acpidbg instance to perform AML debugger
> > functionalities.
>
> This sentence is not parsable for me. What does it mean, really?
By default, just like acpiexec, acpidbg is a shell like interactive utility.
Running acpidbg enters an interactive acpidbg shell.
So it cannot be used by the shell scripts.
With acpidbg -b option, acpidbg executes 1 command and exits.
So it can be used in a script like:
#!/bin/sh
acpidbg -b "find _LID"
acpidbg -b "namespace"
So that validators can use "acpidbg -b" to create recursive test cases.
>
> > As the batch mode always starts from a new command write, it thus requires
> > the kernel debugger driver to drop the old input/output first.
>
> What does "the old" mean here?
There are 2 cases, requiring the "flush" operation to be performed before an "acpidbg -b" execution.
A. The first case requiring flush is "prompt string":
After the kernel is booted, for the first acpidbg execution, user may choose to use it in either batch mode or in interactive mode.
A.1. First use is batch mode, for example, "acpidbg -b namespace"
1. acpi_dbg kernel driver outputs prompt strings into the output buffer.
2. acpidbg user program writes "namespace" command to the acpi_dbg kernel driver's input buffer.
3. acpi_dbg kernel driver reads the input buffer.
It then obtains the "namespace" command and starts to execute it.
4. acpi_dbg kernel driver put the command result into the output buffer.
And wait the userspace acpidbg to read the output.
5. acpidbg user program reads the acpi_dbg kernel driver's output buffer.
It then obtains both the unexpected "prompt string" and the expected command result.
If there is a "flush" between 1 and 2, acpidbg user program won't obtain the unexpected "prompt string".
A.2. First use is interactive mode
However, it is not ensured that the "prompt string" can always appear before the command result.
For example:
1. User runs acpidbg with the interactive mode
2. acpi_dbg kernel driver outputs prompt strings into the output buffer.
3. acpidbg user program reads the output buffer and get the "prompt string".
4. User exits acpidbg.
5. User runs acpidbg with the batch mode.
In this case, "prompt string" has already been read by the 1st "acpidbg interactive execution"
Thus the 2nd "acpidbg batch execution" won't read unexpected "prompt string".
There is no harm to have a "flush" between 4 and 5.
Conclusion:
Whether there is "prompt string" in the output buffer depends on whether the "acpidbg -b" is the first use.
While running “flush" operation before batch mode execution can always drain the output buffer.
B. The second case requiring "flush" is the old output:
The old output can be remained in the output buffer because we allow "asynchronous termination" of acpi_dbg IO.
The use case is:
1. User runs acpidbg by executing a command in either interactive mode or in batch mode.
2. acpi_dbg kernel driver put the command result into the output buffer.
3. When the output buffer is full, acpi_dbg kernel driver blocks, to wait for the userspace to read the result.
4. Instead of reading the result, userspace can close the acpi_dbg IO.
User can achieve this by typing "ctrl+C" in acpidbg user program.
5. User runs acpidbg with the batch mode.
It then obtains both the unexpected "old output", "prompt string" and the expected command result.
If there is a "flush" between 4 and 5, acpidbg user program won't obtain the unexpected "old output" and "prompt string".
>
> > The old input is automatically dropped by acpi_os_get_line() via an error
> > returning value,
>
> I can't parse this too, sorry.
OK, so we don't need this statement.
The flush is mainly used to drain the output buffer.
Because it can wrong output for the batch mode.
>
> > but the output are remained in acpi_dbg output buffers and should be
> > dropped prior than reading the new command, otherwise, the old output can
> > be read out by the batch mode instance and the result of the batch mode
> > command will be messed up.
>
> Can you give an example here for clarity, please?
Please find the 2 cases in A.1. and B.
Thanks and best regards
Lv
Powered by blists - more mailing lists