mbox series

[v2,0/4] tools/thermal: thermal library and tools

Message ID 20220330100444.3846661-1-daniel.lezcano@linaro.org
Headers show
Series tools/thermal: thermal library and tools | expand

Message

Daniel Lezcano March 30, 2022, 10:04 a.m. UTC
These changes are providing the following tools and library:

 - A thermal library doing the netlink abstraction from the kernel in
   order to make the userspace thermal implementation easier. Having
   the library integrated with the kernel tree is also a guarantee to
   keep the message format and their encoding/decoding aligned
                                                                                                                                                                                                                                                                               
 - A thermal tools library providing a set of functions to deal with
   usual features like the log, the mainloop and the time. This
   library is used by the provided tools below

 - An data acquisition program to capture the temperature of the
   different thermal zone during an amount of time or during the
   execution of an application. The output is formated to be easily
   parsed by gnuplot, a spreadsheet program or a statistical command
   line utility. The timestamp is based on the system uptime, thus
   giving an indication of when a thermal event happened, that can
   help to spot or reproduce thermal issue in the long run

 - A thermal monitoring program based on the thermal library. It gives
   a skeleton to build any logic on top of it and shows how to use the
   thermal library. It does nothing except discovering the thermal
   zones, their trip points and listening for events like cooling
   devices state changes or trip point crossed

 Changelog:

 v1: Initial post after a RFC

 v2:

  - Fixed all trailing whitespaces and some other checkpatch
    warnings. Some warnings remain but they can be considered as false
    positive

  - Added in the thermometer tool:
    - Usage/help option as well as a man page
    - The ability to execute a program
    - The capture duration
    - Create the output directory if it does not exist

  - Add in the thermal-engine tool:
    - A usage/help option
    - A message telling the userspace it is waiting for events
    - A daemonize option

  - Minor bug fixes here and there, as well as typos

Daniel Lezcano (4):
  tools/lib/thermal: Add a thermal library
  tools/thermal: Add util library
  tools/thermal: A temperature capture tool
  tools/thermal: Add thermal daemon skeleton

 MAINTAINERS                                   |   1 +
 tools/Makefile                                |  36 +-
 tools/lib/thermal/.gitignore                  |   2 +
 tools/lib/thermal/Build                       |   5 +
 tools/lib/thermal/Makefile                    | 165 ++++++
 tools/lib/thermal/commands.c                  | 349 +++++++++++
 tools/lib/thermal/events.c                    | 164 +++++
 tools/lib/thermal/include/thermal.h           | 142 +++++
 tools/lib/thermal/libthermal.map              |  25 +
 tools/lib/thermal/libthermal.pc.template      |  12 +
 tools/lib/thermal/sampling.c                  |  75 +++
 tools/lib/thermal/thermal.c                   | 126 ++++
 tools/lib/thermal/thermal_nl.c                | 215 +++++++
 tools/lib/thermal/thermal_nl.h                |  46 ++
 tools/thermal/lib/Build                       |   3 +
 tools/thermal/lib/Makefile                    | 158 +++++
 .../thermal/lib/libthermal_tools.pc.template  |  12 +
 tools/thermal/lib/log.c                       |  77 +++
 tools/thermal/lib/log.h                       |  31 +
 tools/thermal/lib/mainloop.c                  | 120 ++++
 tools/thermal/lib/mainloop.h                  |  15 +
 tools/thermal/lib/thermal-tools.h             |  10 +
 tools/thermal/lib/uptimeofday.c               |  40 ++
 tools/thermal/lib/uptimeofday.h               |  12 +
 tools/thermal/thermal-engine/Build            |   2 +
 tools/thermal/thermal-engine/Makefile         |  28 +
 tools/thermal/thermal-engine/thermal-engine.c | 326 ++++++++++
 tools/thermal/thermometer/Build               |   2 +
 tools/thermal/thermometer/Makefile            |  26 +
 tools/thermal/thermometer/thermometer.8       |  93 +++
 tools/thermal/thermometer/thermometer.c       | 558 ++++++++++++++++++
 tools/thermal/thermometer/thermometer.conf    |   5 +
 32 files changed, 2878 insertions(+), 3 deletions(-)
 create mode 100644 tools/lib/thermal/.gitignore
 create mode 100644 tools/lib/thermal/Build
 create mode 100644 tools/lib/thermal/Makefile
 create mode 100644 tools/lib/thermal/commands.c
 create mode 100644 tools/lib/thermal/events.c
 create mode 100644 tools/lib/thermal/include/thermal.h
 create mode 100644 tools/lib/thermal/libthermal.map
 create mode 100644 tools/lib/thermal/libthermal.pc.template
 create mode 100644 tools/lib/thermal/sampling.c
 create mode 100644 tools/lib/thermal/thermal.c
 create mode 100644 tools/lib/thermal/thermal_nl.c
 create mode 100644 tools/lib/thermal/thermal_nl.h
 create mode 100644 tools/thermal/lib/Build
 create mode 100644 tools/thermal/lib/Makefile
 create mode 100644 tools/thermal/lib/libthermal_tools.pc.template
 create mode 100644 tools/thermal/lib/log.c
 create mode 100644 tools/thermal/lib/log.h
 create mode 100644 tools/thermal/lib/mainloop.c
 create mode 100644 tools/thermal/lib/mainloop.h
 create mode 100644 tools/thermal/lib/thermal-tools.h
 create mode 100644 tools/thermal/lib/uptimeofday.c
 create mode 100644 tools/thermal/lib/uptimeofday.h
 create mode 100644 tools/thermal/thermal-engine/Build
 create mode 100644 tools/thermal/thermal-engine/Makefile
 create mode 100644 tools/thermal/thermal-engine/thermal-engine.c
 create mode 100644 tools/thermal/thermometer/Build
 create mode 100644 tools/thermal/thermometer/Makefile
 create mode 100644 tools/thermal/thermometer/thermometer.8
 create mode 100644 tools/thermal/thermometer/thermometer.c
 create mode 100644 tools/thermal/thermometer/thermometer.conf

Comments

Daniel Lezcano April 6, 2022, 8 a.m. UTC | #1
Hi,

if there is no comment for the series, shall I pick it so we can go 
forward ?



On 30/03/2022 12:04, Daniel Lezcano wrote:
> These changes are providing the following tools and library:
> 
>   - A thermal library doing the netlink abstraction from the kernel in
>     order to make the userspace thermal implementation easier. Having
>     the library integrated with the kernel tree is also a guarantee to
>     keep the message format and their encoding/decoding aligned
>                                                                                                                                                                                                                                                                                 
>   - A thermal tools library providing a set of functions to deal with
>     usual features like the log, the mainloop and the time. This
>     library is used by the provided tools below
> 
>   - An data acquisition program to capture the temperature of the
>     different thermal zone during an amount of time or during the
>     execution of an application. The output is formated to be easily
>     parsed by gnuplot, a spreadsheet program or a statistical command
>     line utility. The timestamp is based on the system uptime, thus
>     giving an indication of when a thermal event happened, that can
>     help to spot or reproduce thermal issue in the long run
> 
>   - A thermal monitoring program based on the thermal library. It gives
>     a skeleton to build any logic on top of it and shows how to use the
>     thermal library. It does nothing except discovering the thermal
>     zones, their trip points and listening for events like cooling
>     devices state changes or trip point crossed
> 
>   Changelog:
> 
>   v1: Initial post after a RFC
> 
>   v2:
> 
>    - Fixed all trailing whitespaces and some other checkpatch
>      warnings. Some warnings remain but they can be considered as false
>      positive
> 
>    - Added in the thermometer tool:
>      - Usage/help option as well as a man page
>      - The ability to execute a program
>      - The capture duration
>      - Create the output directory if it does not exist
> 
>    - Add in the thermal-engine tool:
>      - A usage/help option
>      - A message telling the userspace it is waiting for events
>      - A daemonize option
> 
>    - Minor bug fixes here and there, as well as typos
> 
> Daniel Lezcano (4):
>    tools/lib/thermal: Add a thermal library
>    tools/thermal: Add util library
>    tools/thermal: A temperature capture tool
>    tools/thermal: Add thermal daemon skeleton
> 
>   MAINTAINERS                                   |   1 +
>   tools/Makefile                                |  36 +-
>   tools/lib/thermal/.gitignore                  |   2 +
>   tools/lib/thermal/Build                       |   5 +
>   tools/lib/thermal/Makefile                    | 165 ++++++
>   tools/lib/thermal/commands.c                  | 349 +++++++++++
>   tools/lib/thermal/events.c                    | 164 +++++
>   tools/lib/thermal/include/thermal.h           | 142 +++++
>   tools/lib/thermal/libthermal.map              |  25 +
>   tools/lib/thermal/libthermal.pc.template      |  12 +
>   tools/lib/thermal/sampling.c                  |  75 +++
>   tools/lib/thermal/thermal.c                   | 126 ++++
>   tools/lib/thermal/thermal_nl.c                | 215 +++++++
>   tools/lib/thermal/thermal_nl.h                |  46 ++
>   tools/thermal/lib/Build                       |   3 +
>   tools/thermal/lib/Makefile                    | 158 +++++
>   .../thermal/lib/libthermal_tools.pc.template  |  12 +
>   tools/thermal/lib/log.c                       |  77 +++
>   tools/thermal/lib/log.h                       |  31 +
>   tools/thermal/lib/mainloop.c                  | 120 ++++
>   tools/thermal/lib/mainloop.h                  |  15 +
>   tools/thermal/lib/thermal-tools.h             |  10 +
>   tools/thermal/lib/uptimeofday.c               |  40 ++
>   tools/thermal/lib/uptimeofday.h               |  12 +
>   tools/thermal/thermal-engine/Build            |   2 +
>   tools/thermal/thermal-engine/Makefile         |  28 +
>   tools/thermal/thermal-engine/thermal-engine.c | 326 ++++++++++
>   tools/thermal/thermometer/Build               |   2 +
>   tools/thermal/thermometer/Makefile            |  26 +
>   tools/thermal/thermometer/thermometer.8       |  93 +++
>   tools/thermal/thermometer/thermometer.c       | 558 ++++++++++++++++++
>   tools/thermal/thermometer/thermometer.conf    |   5 +
>   32 files changed, 2878 insertions(+), 3 deletions(-)
>   create mode 100644 tools/lib/thermal/.gitignore
>   create mode 100644 tools/lib/thermal/Build
>   create mode 100644 tools/lib/thermal/Makefile
>   create mode 100644 tools/lib/thermal/commands.c
>   create mode 100644 tools/lib/thermal/events.c
>   create mode 100644 tools/lib/thermal/include/thermal.h
>   create mode 100644 tools/lib/thermal/libthermal.map
>   create mode 100644 tools/lib/thermal/libthermal.pc.template
>   create mode 100644 tools/lib/thermal/sampling.c
>   create mode 100644 tools/lib/thermal/thermal.c
>   create mode 100644 tools/lib/thermal/thermal_nl.c
>   create mode 100644 tools/lib/thermal/thermal_nl.h
>   create mode 100644 tools/thermal/lib/Build
>   create mode 100644 tools/thermal/lib/Makefile
>   create mode 100644 tools/thermal/lib/libthermal_tools.pc.template
>   create mode 100644 tools/thermal/lib/log.c
>   create mode 100644 tools/thermal/lib/log.h
>   create mode 100644 tools/thermal/lib/mainloop.c
>   create mode 100644 tools/thermal/lib/mainloop.h
>   create mode 100644 tools/thermal/lib/thermal-tools.h
>   create mode 100644 tools/thermal/lib/uptimeofday.c
>   create mode 100644 tools/thermal/lib/uptimeofday.h
>   create mode 100644 tools/thermal/thermal-engine/Build
>   create mode 100644 tools/thermal/thermal-engine/Makefile
>   create mode 100644 tools/thermal/thermal-engine/thermal-engine.c
>   create mode 100644 tools/thermal/thermometer/Build
>   create mode 100644 tools/thermal/thermometer/Makefile
>   create mode 100644 tools/thermal/thermometer/thermometer.8
>   create mode 100644 tools/thermal/thermometer/thermometer.c
>   create mode 100644 tools/thermal/thermometer/thermometer.conf
>
Srinivas Pandruvada April 6, 2022, 2:28 p.m. UTC | #2
Hi Daniel,

On Wed, 2022-04-06 at 10:00 +0200, Daniel Lezcano wrote:
> 
> Hi,
> 
> if there is no comment for the series, shall I pick it so we can go 
> forward ?
Didn't get time to check yet. It will still be for the next merge
window, correct?

Thanks,
Srinivas

> 
> 
> 
> On 30/03/2022 12:04, Daniel Lezcano wrote:
> > These changes are providing the following tools and library:
> > 
> >   - A thermal library doing the netlink abstraction from the kernel
> > in
> >     order to make the userspace thermal implementation easier.
> > Having
> >     the library integrated with the kernel tree is also a guarantee
> > to
> >     keep the message format and their encoding/decoding aligned
> >                                                                    
> >                                                                    
> >                                                                    
> >                                                                    
> >    
> >   - A thermal tools library providing a set of functions to deal
> > with
> >     usual features like the log, the mainloop and the time. This
> >     library is used by the provided tools below
> > 
> >   - An data acquisition program to capture the temperature of the
> >     different thermal zone during an amount of time or during the
> >     execution of an application. The output is formated to be
> > easily
> >     parsed by gnuplot, a spreadsheet program or a statistical
> > command
> >     line utility. The timestamp is based on the system uptime, thus
> >     giving an indication of when a thermal event happened, that can
> >     help to spot or reproduce thermal issue in the long run
> > 
> >   - A thermal monitoring program based on the thermal library. It
> > gives
> >     a skeleton to build any logic on top of it and shows how to use
> > the
> >     thermal library. It does nothing except discovering the thermal
> >     zones, their trip points and listening for events like cooling
> >     devices state changes or trip point crossed
> > 
> >   Changelog:
> > 
> >   v1: Initial post after a RFC
> > 
> >   v2:
> > 
> >    - Fixed all trailing whitespaces and some other checkpatch
> >      warnings. Some warnings remain but they can be considered as
> > false
> >      positive
> > 
> >    - Added in the thermometer tool:
> >      - Usage/help option as well as a man page
> >      - The ability to execute a program
> >      - The capture duration
> >      - Create the output directory if it does not exist
> > 
> >    - Add in the thermal-engine tool:
> >      - A usage/help option
> >      - A message telling the userspace it is waiting for events
> >      - A daemonize option
> > 
> >    - Minor bug fixes here and there, as well as typos
> > 
> > Daniel Lezcano (4):
> >    tools/lib/thermal: Add a thermal library
> >    tools/thermal: Add util library
> >    tools/thermal: A temperature capture tool
> >    tools/thermal: Add thermal daemon skeleton
> > 
> >   MAINTAINERS                                   |   1 +
> >   tools/Makefile                                |  36 +-
> >   tools/lib/thermal/.gitignore                  |   2 +
> >   tools/lib/thermal/Build                       |   5 +
> >   tools/lib/thermal/Makefile                    | 165 ++++++
> >   tools/lib/thermal/commands.c                  | 349 +++++++++++
> >   tools/lib/thermal/events.c                    | 164 +++++
> >   tools/lib/thermal/include/thermal.h           | 142 +++++
> >   tools/lib/thermal/libthermal.map              |  25 +
> >   tools/lib/thermal/libthermal.pc.template      |  12 +
> >   tools/lib/thermal/sampling.c                  |  75 +++
> >   tools/lib/thermal/thermal.c                   | 126 ++++
> >   tools/lib/thermal/thermal_nl.c                | 215 +++++++
> >   tools/lib/thermal/thermal_nl.h                |  46 ++
> >   tools/thermal/lib/Build                       |   3 +
> >   tools/thermal/lib/Makefile                    | 158 +++++
> >   .../thermal/lib/libthermal_tools.pc.template  |  12 +
> >   tools/thermal/lib/log.c                       |  77 +++
> >   tools/thermal/lib/log.h                       |  31 +
> >   tools/thermal/lib/mainloop.c                  | 120 ++++
> >   tools/thermal/lib/mainloop.h                  |  15 +
> >   tools/thermal/lib/thermal-tools.h             |  10 +
> >   tools/thermal/lib/uptimeofday.c               |  40 ++
> >   tools/thermal/lib/uptimeofday.h               |  12 +
> >   tools/thermal/thermal-engine/Build            |   2 +
> >   tools/thermal/thermal-engine/Makefile         |  28 +
> >   tools/thermal/thermal-engine/thermal-engine.c | 326 ++++++++++
> >   tools/thermal/thermometer/Build               |   2 +
> >   tools/thermal/thermometer/Makefile            |  26 +
> >   tools/thermal/thermometer/thermometer.8       |  93 +++
> >   tools/thermal/thermometer/thermometer.c       | 558
> > ++++++++++++++++++
> >   tools/thermal/thermometer/thermometer.conf    |   5 +
> >   32 files changed, 2878 insertions(+), 3 deletions(-)
> >   create mode 100644 tools/lib/thermal/.gitignore
> >   create mode 100644 tools/lib/thermal/Build
> >   create mode 100644 tools/lib/thermal/Makefile
> >   create mode 100644 tools/lib/thermal/commands.c
> >   create mode 100644 tools/lib/thermal/events.c
> >   create mode 100644 tools/lib/thermal/include/thermal.h
> >   create mode 100644 tools/lib/thermal/libthermal.map
> >   create mode 100644 tools/lib/thermal/libthermal.pc.template
> >   create mode 100644 tools/lib/thermal/sampling.c
> >   create mode 100644 tools/lib/thermal/thermal.c
> >   create mode 100644 tools/lib/thermal/thermal_nl.c
> >   create mode 100644 tools/lib/thermal/thermal_nl.h
> >   create mode 100644 tools/thermal/lib/Build
> >   create mode 100644 tools/thermal/lib/Makefile
> >   create mode 100644 tools/thermal/lib/libthermal_tools.pc.template
> >   create mode 100644 tools/thermal/lib/log.c
> >   create mode 100644 tools/thermal/lib/log.h
> >   create mode 100644 tools/thermal/lib/mainloop.c
> >   create mode 100644 tools/thermal/lib/mainloop.h
> >   create mode 100644 tools/thermal/lib/thermal-tools.h
> >   create mode 100644 tools/thermal/lib/uptimeofday.c
> >   create mode 100644 tools/thermal/lib/uptimeofday.h
> >   create mode 100644 tools/thermal/thermal-engine/Build
> >   create mode 100644 tools/thermal/thermal-engine/Makefile
> >   create mode 100644 tools/thermal/thermal-engine/thermal-engine.c
> >   create mode 100644 tools/thermal/thermometer/Build
> >   create mode 100644 tools/thermal/thermometer/Makefile
> >   create mode 100644 tools/thermal/thermometer/thermometer.8
> >   create mode 100644 tools/thermal/thermometer/thermometer.c
> >   create mode 100644 tools/thermal/thermometer/thermometer.conf
> > 
> 
>
Daniel Lezcano April 6, 2022, 2:44 p.m. UTC | #3
On 06/04/2022 16:28, srinivas pandruvada wrote:
> Hi Daniel,
> 
> On Wed, 2022-04-06 at 10:00 +0200, Daniel Lezcano wrote:
>>
>> Hi,
>>
>> if there is no comment for the series, shall I pick it so we can go
>> forward ?
> Didn't get time to check yet. It will still be for the next merge
> window, correct?

Right, but I would like to continue adding more features, scripts and 
tests. Iteratively.

>>
>> On 30/03/2022 12:04, Daniel Lezcano wrote:
>>> These changes are providing the following tools and library:
>>>
>>>    - A thermal library doing the netlink abstraction from the kernel
>>> in
>>>      order to make the userspace thermal implementation easier.
>>> Having
>>>      the library integrated with the kernel tree is also a guarantee
>>> to
>>>      keep the message format and their encoding/decoding aligned
>>>                                                                     
>>>                                                                     
>>>                                                                     
>>>                                                                     
>>>     
>>>    - A thermal tools library providing a set of functions to deal
>>> with
>>>      usual features like the log, the mainloop and the time. This
>>>      library is used by the provided tools below
>>>
>>>    - An data acquisition program to capture the temperature of the
>>>      different thermal zone during an amount of time or during the
>>>      execution of an application. The output is formated to be
>>> easily
>>>      parsed by gnuplot, a spreadsheet program or a statistical
>>> command
>>>      line utility. The timestamp is based on the system uptime, thus
>>>      giving an indication of when a thermal event happened, that can
>>>      help to spot or reproduce thermal issue in the long run
>>>
>>>    - A thermal monitoring program based on the thermal library. It
>>> gives
>>>      a skeleton to build any logic on top of it and shows how to use
>>> the
>>>      thermal library. It does nothing except discovering the thermal
>>>      zones, their trip points and listening for events like cooling
>>>      devices state changes or trip point crossed
>>>
>>>    Changelog:
>>>
>>>    v1: Initial post after a RFC
>>>
>>>    v2:
>>>
>>>     - Fixed all trailing whitespaces and some other checkpatch
>>>       warnings. Some warnings remain but they can be considered as
>>> false
>>>       positive
>>>
>>>     - Added in the thermometer tool:
>>>       - Usage/help option as well as a man page
>>>       - The ability to execute a program
>>>       - The capture duration
>>>       - Create the output directory if it does not exist
>>>
>>>     - Add in the thermal-engine tool:
>>>       - A usage/help option
>>>       - A message telling the userspace it is waiting for events
>>>       - A daemonize option
>>>
>>>     - Minor bug fixes here and there, as well as typos
>>>
>>> Daniel Lezcano (4):
>>>     tools/lib/thermal: Add a thermal library
>>>     tools/thermal: Add util library
>>>     tools/thermal: A temperature capture tool
>>>     tools/thermal: Add thermal daemon skeleton
>>>
>>>    MAINTAINERS                                   |   1 +
>>>    tools/Makefile                                |  36 +-
>>>    tools/lib/thermal/.gitignore                  |   2 +
>>>    tools/lib/thermal/Build                       |   5 +
>>>    tools/lib/thermal/Makefile                    | 165 ++++++
>>>    tools/lib/thermal/commands.c                  | 349 +++++++++++
>>>    tools/lib/thermal/events.c                    | 164 +++++
>>>    tools/lib/thermal/include/thermal.h           | 142 +++++
>>>    tools/lib/thermal/libthermal.map              |  25 +
>>>    tools/lib/thermal/libthermal.pc.template      |  12 +
>>>    tools/lib/thermal/sampling.c                  |  75 +++
>>>    tools/lib/thermal/thermal.c                   | 126 ++++
>>>    tools/lib/thermal/thermal_nl.c                | 215 +++++++
>>>    tools/lib/thermal/thermal_nl.h                |  46 ++
>>>    tools/thermal/lib/Build                       |   3 +
>>>    tools/thermal/lib/Makefile                    | 158 +++++
>>>    .../thermal/lib/libthermal_tools.pc.template  |  12 +
>>>    tools/thermal/lib/log.c                       |  77 +++
>>>    tools/thermal/lib/log.h                       |  31 +
>>>    tools/thermal/lib/mainloop.c                  | 120 ++++
>>>    tools/thermal/lib/mainloop.h                  |  15 +
>>>    tools/thermal/lib/thermal-tools.h             |  10 +
>>>    tools/thermal/lib/uptimeofday.c               |  40 ++
>>>    tools/thermal/lib/uptimeofday.h               |  12 +
>>>    tools/thermal/thermal-engine/Build            |   2 +
>>>    tools/thermal/thermal-engine/Makefile         |  28 +
>>>    tools/thermal/thermal-engine/thermal-engine.c | 326 ++++++++++
>>>    tools/thermal/thermometer/Build               |   2 +
>>>    tools/thermal/thermometer/Makefile            |  26 +
>>>    tools/thermal/thermometer/thermometer.8       |  93 +++
>>>    tools/thermal/thermometer/thermometer.c       | 558
>>> ++++++++++++++++++
>>>    tools/thermal/thermometer/thermometer.conf    |   5 +
>>>    32 files changed, 2878 insertions(+), 3 deletions(-)
>>>    create mode 100644 tools/lib/thermal/.gitignore
>>>    create mode 100644 tools/lib/thermal/Build
>>>    create mode 100644 tools/lib/thermal/Makefile
>>>    create mode 100644 tools/lib/thermal/commands.c
>>>    create mode 100644 tools/lib/thermal/events.c
>>>    create mode 100644 tools/lib/thermal/include/thermal.h
>>>    create mode 100644 tools/lib/thermal/libthermal.map
>>>    create mode 100644 tools/lib/thermal/libthermal.pc.template
>>>    create mode 100644 tools/lib/thermal/sampling.c
>>>    create mode 100644 tools/lib/thermal/thermal.c
>>>    create mode 100644 tools/lib/thermal/thermal_nl.c
>>>    create mode 100644 tools/lib/thermal/thermal_nl.h
>>>    create mode 100644 tools/thermal/lib/Build
>>>    create mode 100644 tools/thermal/lib/Makefile
>>>    create mode 100644 tools/thermal/lib/libthermal_tools.pc.template
>>>    create mode 100644 tools/thermal/lib/log.c
>>>    create mode 100644 tools/thermal/lib/log.h
>>>    create mode 100644 tools/thermal/lib/mainloop.c
>>>    create mode 100644 tools/thermal/lib/mainloop.h
>>>    create mode 100644 tools/thermal/lib/thermal-tools.h
>>>    create mode 100644 tools/thermal/lib/uptimeofday.c
>>>    create mode 100644 tools/thermal/lib/uptimeofday.h
>>>    create mode 100644 tools/thermal/thermal-engine/Build
>>>    create mode 100644 tools/thermal/thermal-engine/Makefile
>>>    create mode 100644 tools/thermal/thermal-engine/thermal-engine.c
>>>    create mode 100644 tools/thermal/thermometer/Build
>>>    create mode 100644 tools/thermal/thermometer/Makefile
>>>    create mode 100644 tools/thermal/thermometer/thermometer.8
>>>    create mode 100644 tools/thermal/thermometer/thermometer.c
>>>    create mode 100644 tools/thermal/thermometer/thermometer.conf
>>>
>>
>>
> 
>
Rafael J. Wysocki April 13, 2022, 3:06 p.m. UTC | #4
On Wed, Apr 6, 2022 at 4:44 PM Daniel Lezcano <daniel.lezcano@linaro.org> wrote:
>
> On 06/04/2022 16:28, srinivas pandruvada wrote:
> > Hi Daniel,
> >
> > On Wed, 2022-04-06 at 10:00 +0200, Daniel Lezcano wrote:
> >>
> >> Hi,
> >>
> >> if there is no comment for the series, shall I pick it so we can go
> >> forward ?
> > Didn't get time to check yet. It will still be for the next merge
> > window, correct?
>
> Right, but I would like to continue adding more features, scripts and
> tests. Iteratively.

Srinivas, if you can give this a go, please, it will help.

Otherwise, I think that all of your comments so far have been
addressed, or have I missed anything?

>
> >>
> >> On 30/03/2022 12:04, Daniel Lezcano wrote:
> >>> These changes are providing the following tools and library:
> >>>
> >>>    - A thermal library doing the netlink abstraction from the kernel
> >>> in
> >>>      order to make the userspace thermal implementation easier.
> >>> Having
> >>>      the library integrated with the kernel tree is also a guarantee
> >>> to
> >>>      keep the message format and their encoding/decoding aligned
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>    - A thermal tools library providing a set of functions to deal
> >>> with
> >>>      usual features like the log, the mainloop and the time. This
> >>>      library is used by the provided tools below
> >>>
> >>>    - An data acquisition program to capture the temperature of the
> >>>      different thermal zone during an amount of time or during the
> >>>      execution of an application. The output is formated to be
> >>> easily
> >>>      parsed by gnuplot, a spreadsheet program or a statistical
> >>> command
> >>>      line utility. The timestamp is based on the system uptime, thus
> >>>      giving an indication of when a thermal event happened, that can
> >>>      help to spot or reproduce thermal issue in the long run
> >>>
> >>>    - A thermal monitoring program based on the thermal library. It
> >>> gives
> >>>      a skeleton to build any logic on top of it and shows how to use
> >>> the
> >>>      thermal library. It does nothing except discovering the thermal
> >>>      zones, their trip points and listening for events like cooling
> >>>      devices state changes or trip point crossed
> >>>
> >>>    Changelog:
> >>>
> >>>    v1: Initial post after a RFC
> >>>
> >>>    v2:
> >>>
> >>>     - Fixed all trailing whitespaces and some other checkpatch
> >>>       warnings. Some warnings remain but they can be considered as
> >>> false
> >>>       positive
> >>>
> >>>     - Added in the thermometer tool:
> >>>       - Usage/help option as well as a man page
> >>>       - The ability to execute a program
> >>>       - The capture duration
> >>>       - Create the output directory if it does not exist
> >>>
> >>>     - Add in the thermal-engine tool:
> >>>       - A usage/help option
> >>>       - A message telling the userspace it is waiting for events
> >>>       - A daemonize option
> >>>
> >>>     - Minor bug fixes here and there, as well as typos
> >>>
> >>> Daniel Lezcano (4):
> >>>     tools/lib/thermal: Add a thermal library
> >>>     tools/thermal: Add util library
> >>>     tools/thermal: A temperature capture tool
> >>>     tools/thermal: Add thermal daemon skeleton
> >>>
> >>>    MAINTAINERS                                   |   1 +
> >>>    tools/Makefile                                |  36 +-
> >>>    tools/lib/thermal/.gitignore                  |   2 +
> >>>    tools/lib/thermal/Build                       |   5 +
> >>>    tools/lib/thermal/Makefile                    | 165 ++++++
> >>>    tools/lib/thermal/commands.c                  | 349 +++++++++++
> >>>    tools/lib/thermal/events.c                    | 164 +++++
> >>>    tools/lib/thermal/include/thermal.h           | 142 +++++
> >>>    tools/lib/thermal/libthermal.map              |  25 +
> >>>    tools/lib/thermal/libthermal.pc.template      |  12 +
> >>>    tools/lib/thermal/sampling.c                  |  75 +++
> >>>    tools/lib/thermal/thermal.c                   | 126 ++++
> >>>    tools/lib/thermal/thermal_nl.c                | 215 +++++++
> >>>    tools/lib/thermal/thermal_nl.h                |  46 ++
> >>>    tools/thermal/lib/Build                       |   3 +
> >>>    tools/thermal/lib/Makefile                    | 158 +++++
> >>>    .../thermal/lib/libthermal_tools.pc.template  |  12 +
> >>>    tools/thermal/lib/log.c                       |  77 +++
> >>>    tools/thermal/lib/log.h                       |  31 +
> >>>    tools/thermal/lib/mainloop.c                  | 120 ++++
> >>>    tools/thermal/lib/mainloop.h                  |  15 +
> >>>    tools/thermal/lib/thermal-tools.h             |  10 +
> >>>    tools/thermal/lib/uptimeofday.c               |  40 ++
> >>>    tools/thermal/lib/uptimeofday.h               |  12 +
> >>>    tools/thermal/thermal-engine/Build            |   2 +
> >>>    tools/thermal/thermal-engine/Makefile         |  28 +
> >>>    tools/thermal/thermal-engine/thermal-engine.c | 326 ++++++++++
> >>>    tools/thermal/thermometer/Build               |   2 +
> >>>    tools/thermal/thermometer/Makefile            |  26 +
> >>>    tools/thermal/thermometer/thermometer.8       |  93 +++
> >>>    tools/thermal/thermometer/thermometer.c       | 558
> >>> ++++++++++++++++++
> >>>    tools/thermal/thermometer/thermometer.conf    |   5 +
> >>>    32 files changed, 2878 insertions(+), 3 deletions(-)
> >>>    create mode 100644 tools/lib/thermal/.gitignore
> >>>    create mode 100644 tools/lib/thermal/Build
> >>>    create mode 100644 tools/lib/thermal/Makefile
> >>>    create mode 100644 tools/lib/thermal/commands.c
> >>>    create mode 100644 tools/lib/thermal/events.c
> >>>    create mode 100644 tools/lib/thermal/include/thermal.h
> >>>    create mode 100644 tools/lib/thermal/libthermal.map
> >>>    create mode 100644 tools/lib/thermal/libthermal.pc.template
> >>>    create mode 100644 tools/lib/thermal/sampling.c
> >>>    create mode 100644 tools/lib/thermal/thermal.c
> >>>    create mode 100644 tools/lib/thermal/thermal_nl.c
> >>>    create mode 100644 tools/lib/thermal/thermal_nl.h
> >>>    create mode 100644 tools/thermal/lib/Build
> >>>    create mode 100644 tools/thermal/lib/Makefile
> >>>    create mode 100644 tools/thermal/lib/libthermal_tools.pc.template
> >>>    create mode 100644 tools/thermal/lib/log.c
> >>>    create mode 100644 tools/thermal/lib/log.h
> >>>    create mode 100644 tools/thermal/lib/mainloop.c
> >>>    create mode 100644 tools/thermal/lib/mainloop.h
> >>>    create mode 100644 tools/thermal/lib/thermal-tools.h
> >>>    create mode 100644 tools/thermal/lib/uptimeofday.c
> >>>    create mode 100644 tools/thermal/lib/uptimeofday.h
> >>>    create mode 100644 tools/thermal/thermal-engine/Build
> >>>    create mode 100644 tools/thermal/thermal-engine/Makefile
> >>>    create mode 100644 tools/thermal/thermal-engine/thermal-engine.c
> >>>    create mode 100644 tools/thermal/thermometer/Build
> >>>    create mode 100644 tools/thermal/thermometer/Makefile
> >>>    create mode 100644 tools/thermal/thermometer/thermometer.8
> >>>    create mode 100644 tools/thermal/thermometer/thermometer.c
> >>>    create mode 100644 tools/thermal/thermometer/thermometer.conf
> >>>
> >>
> >>
> >
> >
>
>
> --
> <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
>
> Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
> <http://twitter.com/#!/linaroorg> Twitter |
> <http://www.linaro.org/linaro-blog/> Blog
Srinivas Pandruvada April 13, 2022, 5:21 p.m. UTC | #5
On Wed, 2022-04-13 at 17:06 +0200, Rafael J. Wysocki wrote:
> On Wed, Apr 6, 2022 at 4:44 PM Daniel Lezcano <
> daniel.lezcano@linaro.org> wrote:
> > 
> > On 06/04/2022 16:28, srinivas pandruvada wrote:
> > > Hi Daniel,
> > > 
> > > On Wed, 2022-04-06 at 10:00 +0200, Daniel Lezcano wrote:
> > > > 
> > > > Hi,
> > > > 
> > > > if there is no comment for the series, shall I pick it so we
> > > > can go
> > > > forward ?
> > > Didn't get time to check yet. It will still be for the next merge
> > > window, correct?
> > 
> > Right, but I would like to continue adding more features, scripts
> > and
> > tests. Iteratively.
> 
> Srinivas, if you can give this a go, please, it will help.
> 
> Otherwise, I think that all of your comments so far have been
> addressed, or have I missed anything?
> 
I will provide by the end of this week.

Thanks,
Srinivas


> > 
> > > > 
> > > > On 30/03/2022 12:04, Daniel Lezcano wrote:
> > > > > These changes are providing the following tools and library:
> > > > > 
> > > > >    - A thermal library doing the netlink abstraction from the
> > > > > kernel
> > > > > in
> > > > >      order to make the userspace thermal implementation
> > > > > easier.
> > > > > Having
> > > > >      the library integrated with the kernel tree is also a
> > > > > guarantee
> > > > > to
> > > > >      keep the message format and their encoding/decoding
> > > > > aligned
> > > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > >    - A thermal tools library providing a set of functions to
> > > > > deal
> > > > > with
> > > > >      usual features like the log, the mainloop and the time.
> > > > > This
> > > > >      library is used by the provided tools below
> > > > > 
> > > > >    - An data acquisition program to capture the temperature
> > > > > of the
> > > > >      different thermal zone during an amount of time or
> > > > > during the
> > > > >      execution of an application. The output is formated to
> > > > > be
> > > > > easily
> > > > >      parsed by gnuplot, a spreadsheet program or a
> > > > > statistical
> > > > > command
> > > > >      line utility. The timestamp is based on the system
> > > > > uptime, thus
> > > > >      giving an indication of when a thermal event happened,
> > > > > that can
> > > > >      help to spot or reproduce thermal issue in the long run
> > > > > 
> > > > >    - A thermal monitoring program based on the thermal
> > > > > library. It
> > > > > gives
> > > > >      a skeleton to build any logic on top of it and shows how
> > > > > to use
> > > > > the
> > > > >      thermal library. It does nothing except discovering the
> > > > > thermal
> > > > >      zones, their trip points and listening for events like
> > > > > cooling
> > > > >      devices state changes or trip point crossed
> > > > > 
> > > > >    Changelog:
> > > > > 
> > > > >    v1: Initial post after a RFC
> > > > > 
> > > > >    v2:
> > > > > 
> > > > >     - Fixed all trailing whitespaces and some other
> > > > > checkpatch
> > > > >       warnings. Some warnings remain but they can be
> > > > > considered as
> > > > > false
> > > > >       positive
> > > > > 
> > > > >     - Added in the thermometer tool:
> > > > >       - Usage/help option as well as a man page
> > > > >       - The ability to execute a program
> > > > >       - The capture duration
> > > > >       - Create the output directory if it does not exist
> > > > > 
> > > > >     - Add in the thermal-engine tool:
> > > > >       - A usage/help option
> > > > >       - A message telling the userspace it is waiting for
> > > > > events
> > > > >       - A daemonize option
> > > > > 
> > > > >     - Minor bug fixes here and there, as well as typos
> > > > > 
> > > > > Daniel Lezcano (4):
> > > > >     tools/lib/thermal: Add a thermal library
> > > > >     tools/thermal: Add util library
> > > > >     tools/thermal: A temperature capture tool
> > > > >     tools/thermal: Add thermal daemon skeleton
> > > > > 
> > > > >    MAINTAINERS                                   |   1 +
> > > > >    tools/Makefile                                |  36 +-
> > > > >    tools/lib/thermal/.gitignore                  |   2 +
> > > > >    tools/lib/thermal/Build                       |   5 +
> > > > >    tools/lib/thermal/Makefile                    | 165 ++++++
> > > > >    tools/lib/thermal/commands.c                  | 349
> > > > > +++++++++++
> > > > >    tools/lib/thermal/events.c                    | 164 +++++
> > > > >    tools/lib/thermal/include/thermal.h           | 142 +++++
> > > > >    tools/lib/thermal/libthermal.map              |  25 +
> > > > >    tools/lib/thermal/libthermal.pc.template      |  12 +
> > > > >    tools/lib/thermal/sampling.c                  |  75 +++
> > > > >    tools/lib/thermal/thermal.c                   | 126 ++++
> > > > >    tools/lib/thermal/thermal_nl.c                | 215
> > > > > +++++++
> > > > >    tools/lib/thermal/thermal_nl.h                |  46 ++
> > > > >    tools/thermal/lib/Build                       |   3 +
> > > > >    tools/thermal/lib/Makefile                    | 158 +++++
> > > > >    .../thermal/lib/libthermal_tools.pc.template  |  12 +
> > > > >    tools/thermal/lib/log.c                       |  77 +++
> > > > >    tools/thermal/lib/log.h                       |  31 +
> > > > >    tools/thermal/lib/mainloop.c                  | 120 ++++
> > > > >    tools/thermal/lib/mainloop.h                  |  15 +
> > > > >    tools/thermal/lib/thermal-tools.h             |  10 +
> > > > >    tools/thermal/lib/uptimeofday.c               |  40 ++
> > > > >    tools/thermal/lib/uptimeofday.h               |  12 +
> > > > >    tools/thermal/thermal-engine/Build            |   2 +
> > > > >    tools/thermal/thermal-engine/Makefile         |  28 +
> > > > >    tools/thermal/thermal-engine/thermal-engine.c | 326
> > > > > ++++++++++
> > > > >    tools/thermal/thermometer/Build               |   2 +
> > > > >    tools/thermal/thermometer/Makefile            |  26 +
> > > > >    tools/thermal/thermometer/thermometer.8       |  93 +++
> > > > >    tools/thermal/thermometer/thermometer.c       | 558
> > > > > ++++++++++++++++++
> > > > >    tools/thermal/thermometer/thermometer.conf    |   5 +
> > > > >    32 files changed, 2878 insertions(+), 3 deletions(-)
> > > > >    create mode 100644 tools/lib/thermal/.gitignore
> > > > >    create mode 100644 tools/lib/thermal/Build
> > > > >    create mode 100644 tools/lib/thermal/Makefile
> > > > >    create mode 100644 tools/lib/thermal/commands.c
> > > > >    create mode 100644 tools/lib/thermal/events.c
> > > > >    create mode 100644 tools/lib/thermal/include/thermal.h
> > > > >    create mode 100644 tools/lib/thermal/libthermal.map
> > > > >    create mode 100644
> > > > > tools/lib/thermal/libthermal.pc.template
> > > > >    create mode 100644 tools/lib/thermal/sampling.c
> > > > >    create mode 100644 tools/lib/thermal/thermal.c
> > > > >    create mode 100644 tools/lib/thermal/thermal_nl.c
> > > > >    create mode 100644 tools/lib/thermal/thermal_nl.h
> > > > >    create mode 100644 tools/thermal/lib/Build
> > > > >    create mode 100644 tools/thermal/lib/Makefile
> > > > >    create mode 100644
> > > > > tools/thermal/lib/libthermal_tools.pc.template
> > > > >    create mode 100644 tools/thermal/lib/log.c
> > > > >    create mode 100644 tools/thermal/lib/log.h
> > > > >    create mode 100644 tools/thermal/lib/mainloop.c
> > > > >    create mode 100644 tools/thermal/lib/mainloop.h
> > > > >    create mode 100644 tools/thermal/lib/thermal-tools.h
> > > > >    create mode 100644 tools/thermal/lib/uptimeofday.c
> > > > >    create mode 100644 tools/thermal/lib/uptimeofday.h
> > > > >    create mode 100644 tools/thermal/thermal-engine/Build
> > > > >    create mode 100644 tools/thermal/thermal-engine/Makefile
> > > > >    create mode 100644 tools/thermal/thermal-engine/thermal-
> > > > > engine.c
> > > > >    create mode 100644 tools/thermal/thermometer/Build
> > > > >    create mode 100644 tools/thermal/thermometer/Makefile
> > > > >    create mode 100644 tools/thermal/thermometer/thermometer.8
> > > > >    create mode 100644 tools/thermal/thermometer/thermometer.c
> > > > >    create mode 100644
> > > > > tools/thermal/thermometer/thermometer.conf
> > > > > 
> > > > 
> > > > 
> > > 
> > > 
> > 
> > 
> > --
> > <http://www.linaro.org/> Linaro.org │ Open source software for ARM
> > SoCs
> > 
> > Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
> > <http://twitter.com/#!/linaroorg> Twitter |
> > <http://www.linaro.org/linaro-blog/> Blog
Srinivas Pandruvada April 16, 2022, 3:50 a.m. UTC | #6
On Wed, 2022-04-13 at 10:21 -0700, srinivas pandruvada wrote:
> On Wed, 2022-04-13 at 17:06 +0200, Rafael J. Wysocki wrote:
> > On Wed, Apr 6, 2022 at 4:44 PM Daniel Lezcano <
> > daniel.lezcano@linaro.org> wrote:
> > > 
> > > On 06/04/2022 16:28, srinivas pandruvada wrote:
> > > > Hi Daniel,
> > > > 
> > > > On Wed, 2022-04-06 at 10:00 +0200, Daniel Lezcano wrote:
> > > > > 
> > > > > Hi,
> > > > > 
> > > > > if there is no comment for the series, shall I pick it so we
> > > > > can go
> > > > > forward ?
> > > > Didn't get time to check yet. It will still be for the next merge
> > > > window, correct?
> > > 
> > > Right, but I would like to continue adding more features, scripts
> > > and
> > > tests. Iteratively.
> > 
> > Srinivas, if you can give this a go, please, it will help.
> > 
> > Otherwise, I think that all of your comments so far have been
> > addressed, or have I missed anything?
> > 
> I will provide by the end of this week.

1. Some warnings in applying patch

Applying: tools/lib/thermal: Add a thermal library
Applying: tools/thermal: Add util library
Applying: tools/thermal: A temperature capture tool
.git/rebase-apply/patch:795: space before tab in indent.
	      	polling = 100; }
.git/rebase-apply/patch:90: new blank line at EOF.
+
.git/rebase-apply/patch:221: new blank line at EOF.
+
warning: 3 lines add whitespace errors.
Applying: tools/thermal: Add thermal daemon skeleton
.git/rebase-apply/patch:86: new blank line at EOF.
+
warning: 1 line adds whitespace errors.

2. Thermometer is fine

3. segfault for thermal-engine

LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal-
engine
Segmentation fault (core dumped)
root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal-
engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
./thermal-engine --help
thermal-engine : A thermal monitoring engine based on notifications
Usage: thermal-engine [options]
	-h, --help		this help
	-d, --daemonize	capture duration
	-l <level>, --loglevel <level>	log level: DEBUG, INFO,
NOTICE, WARN, ERROR
	-s, --syslog		output to syslog

root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal-
engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
./thermal-engine -l DEBUG
Segmentation fault (core dumped)
root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal-
engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
./thermal-engine --loglevel DEBUG
Segmentation fault (core dumped)
root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal-
engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
./thermal-engine -s
Segmentation fault (core dumped)

Thanks,
Srinivas

> 
> Thanks,
> Srinivas
> 
> 
> > > 
> > > > > 
> > > > > On 30/03/2022 12:04, Daniel Lezcano wrote:
> > > > > > These changes are providing the following tools and library:
> > > > > > 
> > > > > >    - A thermal library doing the netlink abstraction from the
> > > > > > kernel
> > > > > > in
> > > > > >      order to make the userspace thermal implementation
> > > > > > easier.
> > > > > > Having
> > > > > >      the library integrated with the kernel tree is also a
> > > > > > guarantee
> > > > > > to
> > > > > >      keep the message format and their encoding/decoding
> > > > > > aligned
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > >    - A thermal tools library providing a set of functions to
> > > > > > deal
> > > > > > with
> > > > > >      usual features like the log, the mainloop and the time.
> > > > > > This
> > > > > >      library is used by the provided tools below
> > > > > > 
> > > > > >    - An data acquisition program to capture the temperature
> > > > > > of the
> > > > > >      different thermal zone during an amount of time or
> > > > > > during the
> > > > > >      execution of an application. The output is formated to
> > > > > > be
> > > > > > easily
> > > > > >      parsed by gnuplot, a spreadsheet program or a
> > > > > > statistical
> > > > > > command
> > > > > >      line utility. The timestamp is based on the system
> > > > > > uptime, thus
> > > > > >      giving an indication of when a thermal event happened,
> > > > > > that can
> > > > > >      help to spot or reproduce thermal issue in the long run
> > > > > > 
> > > > > >    - A thermal monitoring program based on the thermal
> > > > > > library. It
> > > > > > gives
> > > > > >      a skeleton to build any logic on top of it and shows how
> > > > > > to use
> > > > > > the
> > > > > >      thermal library. It does nothing except discovering the
> > > > > > thermal
> > > > > >      zones, their trip points and listening for events like
> > > > > > cooling
> > > > > >      devices state changes or trip point crossed
> > > > > > 
> > > > > >    Changelog:
> > > > > > 
> > > > > >    v1: Initial post after a RFC
> > > > > > 
> > > > > >    v2:
> > > > > > 
> > > > > >     - Fixed all trailing whitespaces and some other
> > > > > > checkpatch
> > > > > >       warnings. Some warnings remain but they can be
> > > > > > considered as
> > > > > > false
> > > > > >       positive
> > > > > > 
> > > > > >     - Added in the thermometer tool:
> > > > > >       - Usage/help option as well as a man page
> > > > > >       - The ability to execute a program
> > > > > >       - The capture duration
> > > > > >       - Create the output directory if it does not exist
> > > > > > 
> > > > > >     - Add in the thermal-engine tool:
> > > > > >       - A usage/help option
> > > > > >       - A message telling the userspace it is waiting for
> > > > > > events
> > > > > >       - A daemonize option
> > > > > > 
> > > > > >     - Minor bug fixes here and there, as well as typos
> > > > > > 
> > > > > > Daniel Lezcano (4):
> > > > > >     tools/lib/thermal: Add a thermal library
> > > > > >     tools/thermal: Add util library
> > > > > >     tools/thermal: A temperature capture tool
> > > > > >     tools/thermal: Add thermal daemon skeleton
> > > > > > 
> > > > > >    MAINTAINERS                                   |   1 +
> > > > > >    tools/Makefile                                |  36 +-
> > > > > >    tools/lib/thermal/.gitignore                  |   2 +
> > > > > >    tools/lib/thermal/Build                       |   5 +
> > > > > >    tools/lib/thermal/Makefile                    | 165 ++++++
> > > > > >    tools/lib/thermal/commands.c                  | 349
> > > > > > +++++++++++
> > > > > >    tools/lib/thermal/events.c                    | 164 +++++
> > > > > >    tools/lib/thermal/include/thermal.h           | 142 +++++
> > > > > >    tools/lib/thermal/libthermal.map              |  25 +
> > > > > >    tools/lib/thermal/libthermal.pc.template      |  12 +
> > > > > >    tools/lib/thermal/sampling.c                  |  75 +++
> > > > > >    tools/lib/thermal/thermal.c                   | 126 ++++
> > > > > >    tools/lib/thermal/thermal_nl.c                | 215
> > > > > > +++++++
> > > > > >    tools/lib/thermal/thermal_nl.h                |  46 ++
> > > > > >    tools/thermal/lib/Build                       |   3 +
> > > > > >    tools/thermal/lib/Makefile                    | 158 +++++
> > > > > >    .../thermal/lib/libthermal_tools.pc.template  |  12 +
> > > > > >    tools/thermal/lib/log.c                       |  77 +++
> > > > > >    tools/thermal/lib/log.h                       |  31 +
> > > > > >    tools/thermal/lib/mainloop.c                  | 120 ++++
> > > > > >    tools/thermal/lib/mainloop.h                  |  15 +
> > > > > >    tools/thermal/lib/thermal-tools.h             |  10 +
> > > > > >    tools/thermal/lib/uptimeofday.c               |  40 ++
> > > > > >    tools/thermal/lib/uptimeofday.h               |  12 +
> > > > > >    tools/thermal/thermal-engine/Build            |   2 +
> > > > > >    tools/thermal/thermal-engine/Makefile         |  28 +
> > > > > >    tools/thermal/thermal-engine/thermal-engine.c | 326
> > > > > > ++++++++++
> > > > > >    tools/thermal/thermometer/Build               |   2 +
> > > > > >    tools/thermal/thermometer/Makefile            |  26 +
> > > > > >    tools/thermal/thermometer/thermometer.8       |  93 +++
> > > > > >    tools/thermal/thermometer/thermometer.c       | 558
> > > > > > ++++++++++++++++++
> > > > > >    tools/thermal/thermometer/thermometer.conf    |   5 +
> > > > > >    32 files changed, 2878 insertions(+), 3 deletions(-)
> > > > > >    create mode 100644 tools/lib/thermal/.gitignore
> > > > > >    create mode 100644 tools/lib/thermal/Build
> > > > > >    create mode 100644 tools/lib/thermal/Makefile
> > > > > >    create mode 100644 tools/lib/thermal/commands.c
> > > > > >    create mode 100644 tools/lib/thermal/events.c
> > > > > >    create mode 100644 tools/lib/thermal/include/thermal.h
> > > > > >    create mode 100644 tools/lib/thermal/libthermal.map
> > > > > >    create mode 100644
> > > > > > tools/lib/thermal/libthermal.pc.template
> > > > > >    create mode 100644 tools/lib/thermal/sampling.c
> > > > > >    create mode 100644 tools/lib/thermal/thermal.c
> > > > > >    create mode 100644 tools/lib/thermal/thermal_nl.c
> > > > > >    create mode 100644 tools/lib/thermal/thermal_nl.h
> > > > > >    create mode 100644 tools/thermal/lib/Build
> > > > > >    create mode 100644 tools/thermal/lib/Makefile
> > > > > >    create mode 100644
> > > > > > tools/thermal/lib/libthermal_tools.pc.template
> > > > > >    create mode 100644 tools/thermal/lib/log.c
> > > > > >    create mode 100644 tools/thermal/lib/log.h
> > > > > >    create mode 100644 tools/thermal/lib/mainloop.c
> > > > > >    create mode 100644 tools/thermal/lib/mainloop.h
> > > > > >    create mode 100644 tools/thermal/lib/thermal-tools.h
> > > > > >    create mode 100644 tools/thermal/lib/uptimeofday.c
> > > > > >    create mode 100644 tools/thermal/lib/uptimeofday.h
> > > > > >    create mode 100644 tools/thermal/thermal-engine/Build
> > > > > >    create mode 100644 tools/thermal/thermal-engine/Makefile
> > > > > >    create mode 100644 tools/thermal/thermal-engine/thermal-
> > > > > > engine.c
> > > > > >    create mode 100644 tools/thermal/thermometer/Build
> > > > > >    create mode 100644 tools/thermal/thermometer/Makefile
> > > > > >    create mode 100644 tools/thermal/thermometer/thermometer.8
> > > > > >    create mode 100644 tools/thermal/thermometer/thermometer.c
> > > > > >    create mode 100644
> > > > > > tools/thermal/thermometer/thermometer.conf
> > > > > > 
> > > > > 
> > > > > 
> > > > 
> > > > 
> > > 
> > > 
> > > --
> > > <http://www.linaro.org/> Linaro.org │ Open source software for ARM
> > > SoCs
> > > 
> > > Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
> > > <http://twitter.com/#!/linaroorg> Twitter |
> > > <http://www.linaro.org/linaro-blog/> Blog
> 
>
Daniel Lezcano April 16, 2022, 7:55 a.m. UTC | #7
Hi Srinivas,


On 16/04/2022 05:50, srinivas pandruvada wrote:
> On Wed, 2022-04-13 at 10:21 -0700, srinivas pandruvada wrote:
>> On Wed, 2022-04-13 at 17:06 +0200, Rafael J. Wysocki wrote:
>>> On Wed, Apr 6, 2022 at 4:44 PM Daniel Lezcano <
>>> daniel.lezcano@linaro.org> wrote:
>>>>
>>>> On 06/04/2022 16:28, srinivas pandruvada wrote:
>>>>> Hi Daniel,
>>>>>
>>>>> On Wed, 2022-04-06 at 10:00 +0200, Daniel Lezcano wrote:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> if there is no comment for the series, shall I pick it so we
>>>>>> can go
>>>>>> forward ?
>>>>> Didn't get time to check yet. It will still be for the next merge
>>>>> window, correct?
>>>>
>>>> Right, but I would like to continue adding more features, scripts
>>>> and
>>>> tests. Iteratively.
>>>
>>> Srinivas, if you can give this a go, please, it will help.
>>>
>>> Otherwise, I think that all of your comments so far have been
>>> addressed, or have I missed anything?
>>>
>> I will provide by the end of this week.
> 
> 1. Some warnings in applying patch
> 
> Applying: tools/lib/thermal: Add a thermal library
> Applying: tools/thermal: Add util library
> Applying: tools/thermal: A temperature capture tool
> .git/rebase-apply/patch:795: space before tab in indent.
> 	      	polling = 100; }
> .git/rebase-apply/patch:90: new blank line at EOF.
> +
> .git/rebase-apply/patch:221: new blank line at EOF.
> +
> warning: 3 lines add whitespace errors.
> Applying: tools/thermal: Add thermal daemon skeleton
> .git/rebase-apply/patch:86: new blank line at EOF.
> +
> warning: 1 line adds whitespace errors.

Strange, I did not have those but I'll try to reproduce

> 2. Thermometer is fine
> 
> 3. segfault for thermal-engine
> 
> LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH ./thermal-
> engine
> Segmentation fault (core dumped)
> root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal-
> engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
> ./thermal-engine --help
> thermal-engine : A thermal monitoring engine based on notifications
> Usage: thermal-engine [options]
> 	-h, --help		this help
> 	-d, --daemonize	capture duration
> 	-l <level>, --loglevel <level>	log level: DEBUG, INFO,
> NOTICE, WARN, ERROR
> 	-s, --syslog		output to syslog
> 
> root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal-
> engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
> ./thermal-engine -l DEBUG
> Segmentation fault (core dumped)
> root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal-
> engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
> ./thermal-engine --loglevel DEBUG
> Segmentation fault (core dumped)
> root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal-
> engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
> ./thermal-engine -s
> Segmentation fault (core dumped)

Is CONFIG_THERMAL_NETLINK set ?
Srinivas Pandruvada April 17, 2022, 4:23 a.m. UTC | #8
Hi Daniel,

On Sat, 2022-04-16 at 09:55 +0200, Daniel Lezcano wrote:
> 
> Hi Srinivas,
> 
> 
> On 16/04/2022 05:50, srinivas pandruvada wrote:
> > On Wed, 2022-04-13 at 10:21 -0700, srinivas pandruvada wrote:
> > > On Wed, 2022-04-13 at 17:06 +0200, Rafael J. Wysocki wrote:
> > > > On Wed, Apr 6, 2022 at 4:44 PM Daniel Lezcano <
> > > > daniel.lezcano@linaro.org> wrote:
> > > > > 
> > 

[...]

> > root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal-
> > engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
> > ./thermal-engine -l DEBUG
> > Segmentation fault (core dumped)
> > root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal-
> > engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
> > ./thermal-engine --loglevel DEBUG
> > Segmentation fault (core dumped)
> > root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal-
> > engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
> > ./thermal-engine -s
> > Segmentation fault (core dumped)
> 
> Is CONFIG_THERMAL_NETLINK set ?

Yes, Thermometer program works fine. Just thermal-engine fails.
CONFIG_THERMAL=y
CONFIG_THERMAL_NETLINK=y
CONFIG_THERMAL_STATISTICS=y
CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0
CONFIG_THERMAL_HWMON=y
CONFIG_THERMAL_WRITABLE_TRIPS=y
CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y
# CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE is not set
# CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE is not set
CONFIG_THERMAL_GOV_FAIR_SHARE=y
CONFIG_THERMAL_GOV_STEP_WISE=y
CONFIG_THERMAL_GOV_BANG_BANG=y
CONFIG_THERMAL_GOV_USER_SPACE=y
CONFIG_DEVFREQ_THERMAL=y
CONFIG_THERMAL_EMULATION=y

This may help

#gdb ./thermal-engine 
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show
copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./thermal-engine...(no debugging symbols
found)...done.
(gdb) run
Starting program:
/home/labuser/development/linux/tools/thermal/thermal-engine/thermal-
engine 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-
gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7402036 in parse_tz_get_trip (info=0x7fffffffdf60,
tz=0x555555607898) at commands.c:143
143		__tt[size].id = -1;
(gdb) backtrace 
#0  0x00007ffff7402036 in parse_tz_get_trip (info=0x7fffffffdf60,
tz=0x555555607898) at commands.c:143
#1  0x00007ffff7402233 in handle_netlink (unused=0x0,
cmd=0x7ffff76052f8 <thermal_cmds+120>, info=0x7fffffffdf60,
arg=0x555555607898) at commands.c:206
#2  0x00007ffff7003435 in ?? () from /lib/x86_64-linux-gnu/libnl-genl-
3.so.200
#3  0x00007ffff6810c1c in nl_recvmsgs_report () from /lib/x86_64-linux-
gnu/libnl-3.so.200
#4  0x00007ffff6811049 in nl_recvmsgs () from /lib/x86_64-linux-
gnu/libnl-3.so.200
#5  0x00007ffff7402eaf in nl_send_msg (sock=0x555555606040,
cb=0x5555556065d0, msg=0x555555606110, rx_handler=0x7ffff70036f0
<genl_handle_msg>, data=0x555555607898) at thermal_nl.c:70
#6  0x00007ffff7402327 in thermal_genl_auto (th=0x5555556048a0, id=1,
cmd=2, flags=0, arg=0x555555607898) at commands.c:282
#7  0x00007ffff74023e0 in thermal_cmd_get_trip (th=0x5555556048a0,
tz=0x555555607898) at commands.c:304
#8  0x00007ffff74039db in __thermal_zone_discover (tz=0x555555607898,
th=0x5555556048a0) at thermal.c:71
#9  0x00007ffff7403842 in for_each_thermal_zone (tz=0x555555607860,
cb=0x7ffff74039b8 <__thermal_zone_discover>, arg=0x5555556048a0) at
thermal.c:33
#10 0x00007ffff7403a5b in thermal_zone_discover (th=0x5555556048a0) at
thermal.c:87
#11 0x00005555554019bd in main ()

Thanks,
Srinivas

>
Daniel Lezcano April 17, 2022, 8:20 a.m. UTC | #9
Hi Srinivas,

thanks for the information. I've indeed not tested on x86_64 but on ARM64.

I'll give a try to reproduce and fix the issue.

Thanks again for taking the time to run it

   -- Daniel

On 17/04/2022 06:23, srinivas pandruvada wrote:
> Hi Daniel,
> 
> On Sat, 2022-04-16 at 09:55 +0200, Daniel Lezcano wrote:
>>
>> Hi Srinivas,
>>
>>
>> On 16/04/2022 05:50, srinivas pandruvada wrote:
>>> On Wed, 2022-04-13 at 10:21 -0700, srinivas pandruvada wrote:
>>>> On Wed, 2022-04-13 at 17:06 +0200, Rafael J. Wysocki wrote:
>>>>> On Wed, Apr 6, 2022 at 4:44 PM Daniel Lezcano <
>>>>> daniel.lezcano@linaro.org> wrote:
>>>>>>
>>>
> 
> [...]
> 
>>> root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal-
>>> engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
>>> ./thermal-engine -l DEBUG
>>> Segmentation fault (core dumped)
>>> root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal-
>>> engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
>>> ./thermal-engine --loglevel DEBUG
>>> Segmentation fault (core dumped)
>>> root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/thermal-
>>> engine# LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
>>> ./thermal-engine -s
>>> Segmentation fault (core dumped)
>>
>> Is CONFIG_THERMAL_NETLINK set ?
> 
> Yes, Thermometer program works fine. Just thermal-engine fails.
> CONFIG_THERMAL=y
> CONFIG_THERMAL_NETLINK=y
> CONFIG_THERMAL_STATISTICS=y
> CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0
> CONFIG_THERMAL_HWMON=y
> CONFIG_THERMAL_WRITABLE_TRIPS=y
> CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y
> # CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE is not set
> # CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE is not set
> CONFIG_THERMAL_GOV_FAIR_SHARE=y
> CONFIG_THERMAL_GOV_STEP_WISE=y
> CONFIG_THERMAL_GOV_BANG_BANG=y
> CONFIG_THERMAL_GOV_USER_SPACE=y
> CONFIG_DEVFREQ_THERMAL=y
> CONFIG_THERMAL_EMULATION=y
> 
> This may help
> 
> #gdb ./thermal-engine
> GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
> Copyright (C) 2018 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later
> <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.  Type "show
> copying"
> and "show warranty" for details.
> This GDB was configured as "x86_64-linux-gnu".
> Type "show configuration" for configuration details.
> For bug reporting instructions, please see:
> <http://www.gnu.org/software/gdb/bugs/>.
> Find the GDB manual and other documentation resources online at:
> <http://www.gnu.org/software/gdb/documentation/>.
> For help, type "help".
> Type "apropos word" to search for commands related to "word"...
> Reading symbols from ./thermal-engine...(no debugging symbols
> found)...done.
> (gdb) run
> Starting program:
> /home/labuser/development/linux/tools/thermal/thermal-engine/thermal-
> engine
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib/x86_64-linux-
> gnu/libthread_db.so.1".
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007ffff7402036 in parse_tz_get_trip (info=0x7fffffffdf60,
> tz=0x555555607898) at commands.c:143
> 143		__tt[size].id = -1;
> (gdb) backtrace
> #0  0x00007ffff7402036 in parse_tz_get_trip (info=0x7fffffffdf60,
> tz=0x555555607898) at commands.c:143
> #1  0x00007ffff7402233 in handle_netlink (unused=0x0,
> cmd=0x7ffff76052f8 <thermal_cmds+120>, info=0x7fffffffdf60,
> arg=0x555555607898) at commands.c:206
> #2  0x00007ffff7003435 in ?? () from /lib/x86_64-linux-gnu/libnl-genl-
> 3.so.200
> #3  0x00007ffff6810c1c in nl_recvmsgs_report () from /lib/x86_64-linux-
> gnu/libnl-3.so.200
> #4  0x00007ffff6811049 in nl_recvmsgs () from /lib/x86_64-linux-
> gnu/libnl-3.so.200
> #5  0x00007ffff7402eaf in nl_send_msg (sock=0x555555606040,
> cb=0x5555556065d0, msg=0x555555606110, rx_handler=0x7ffff70036f0
> <genl_handle_msg>, data=0x555555607898) at thermal_nl.c:70
> #6  0x00007ffff7402327 in thermal_genl_auto (th=0x5555556048a0, id=1,
> cmd=2, flags=0, arg=0x555555607898) at commands.c:282
> #7  0x00007ffff74023e0 in thermal_cmd_get_trip (th=0x5555556048a0,
> tz=0x555555607898) at commands.c:304
> #8  0x00007ffff74039db in __thermal_zone_discover (tz=0x555555607898,
> th=0x5555556048a0) at thermal.c:71
> #9  0x00007ffff7403842 in for_each_thermal_zone (tz=0x555555607860,
> cb=0x7ffff74039b8 <__thermal_zone_discover>, arg=0x5555556048a0) at
> thermal.c:33
> #10 0x00007ffff7403a5b in thermal_zone_discover (th=0x5555556048a0) at
> thermal.c:87
> #11 0x00005555554019bd in main ()
> 
> Thanks,
> Srinivas
> 
>>
> 
>
Srinivas Pandruvada April 18, 2022, 3:36 a.m. UTC | #10
Hi Daniel,

The attached diff fixes the crash,

Also when you run in daemon mode, you need to use some pid lock file.
Otherwise it launches multiple daemons.

Thanks,
Srinivas



On Sun, 2022-04-17 at 10:20 +0200, Daniel Lezcano wrote:
> 
> Hi Srinivas,
> 
> thanks for the information. I've indeed not tested on x86_64 but on
> ARM64.
> 
> I'll give a try to reproduce and fix the issue.
> 
> Thanks again for taking the time to run it
> 
>    -- Daniel
> 
> On 17/04/2022 06:23, srinivas pandruvada wrote:
> > Hi Daniel,
> > 
> > On Sat, 2022-04-16 at 09:55 +0200, Daniel Lezcano wrote:
> > > 
> > > Hi Srinivas,
> > > 
> > > 
> > > On 16/04/2022 05:50, srinivas pandruvada wrote:
> > > > On Wed, 2022-04-13 at 10:21 -0700, srinivas pandruvada wrote:
> > > > > On Wed, 2022-04-13 at 17:06 +0200, Rafael J. Wysocki wrote:
> > > > > > On Wed, Apr 6, 2022 at 4:44 PM Daniel Lezcano <
> > > > > > daniel.lezcano@linaro.org> wrote:
> > > > > > > 
> > > > 
> > 
> > [...]
> > 
> > > > root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/the
> > > > rmal-
> > > > engine#
> > > > LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
> > > > ./thermal-engine -l DEBUG
> > > > Segmentation fault (core dumped)
> > > > root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/the
> > > > rmal-
> > > > engine#
> > > > LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
> > > > ./thermal-engine --loglevel DEBUG
> > > > Segmentation fault (core dumped)
> > > > root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/the
> > > > rmal-
> > > > engine#
> > > > LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
> > > > ./thermal-engine -s
> > > > Segmentation fault (core dumped)
> > > 
> > > Is CONFIG_THERMAL_NETLINK set ?
> > 
> > Yes, Thermometer program works fine. Just thermal-engine fails.
> > CONFIG_THERMAL=y
> > CONFIG_THERMAL_NETLINK=y
> > CONFIG_THERMAL_STATISTICS=y
> > CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0
> > CONFIG_THERMAL_HWMON=y
> > CONFIG_THERMAL_WRITABLE_TRIPS=y
> > CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y
> > # CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE is not set
> > # CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE is not set
> > CONFIG_THERMAL_GOV_FAIR_SHARE=y
> > CONFIG_THERMAL_GOV_STEP_WISE=y
> > CONFIG_THERMAL_GOV_BANG_BANG=y
> > CONFIG_THERMAL_GOV_USER_SPACE=y
> > CONFIG_DEVFREQ_THERMAL=y
> > CONFIG_THERMAL_EMULATION=y
> > 
> > This may help
> > 
> > #gdb ./thermal-engine
> > GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
> > Copyright (C) 2018 Free Software Foundation, Inc.
> > License GPLv3+: GNU GPL version 3 or later
> > <http://gnu.org/licenses/gpl.html>
> > This is free software: you are free to change and redistribute it.
> > There is NO WARRANTY, to the extent permitted by law.  Type "show
> > copying"
> > and "show warranty" for details.
> > This GDB was configured as "x86_64-linux-gnu".
> > Type "show configuration" for configuration details.
> > For bug reporting instructions, please see:
> > <http://www.gnu.org/software/gdb/bugs/>.
> > Find the GDB manual and other documentation resources online at:
> > <http://www.gnu.org/software/gdb/documentation/>.
> > For help, type "help".
> > Type "apropos word" to search for commands related to "word"...
> > Reading symbols from ./thermal-engine...(no debugging symbols
> > found)...done.
> > (gdb) run
> > Starting program:
> > /home/labuser/development/linux/tools/thermal/thermal-
> > engine/thermal-
> > engine
> > [Thread debugging using libthread_db enabled]
> > Using host libthread_db library "/lib/x86_64-linux-
> > gnu/libthread_db.so.1".
> > 
> > Program received signal SIGSEGV, Segmentation fault.
> > 0x00007ffff7402036 in parse_tz_get_trip (info=0x7fffffffdf60,
> > tz=0x555555607898) at commands.c:143
> > 143             __tt[size].id = -1;
> > (gdb) backtrace
> > #0  0x00007ffff7402036 in parse_tz_get_trip (info=0x7fffffffdf60,
> > tz=0x555555607898) at commands.c:143
> > #1  0x00007ffff7402233 in handle_netlink (unused=0x0,
> > cmd=0x7ffff76052f8 <thermal_cmds+120>, info=0x7fffffffdf60,
> > arg=0x555555607898) at commands.c:206
> > #2  0x00007ffff7003435 in ?? () from /lib/x86_64-linux-gnu/libnl-
> > genl-
> > 3.so.200
> > #3  0x00007ffff6810c1c in nl_recvmsgs_report () from /lib/x86_64-
> > linux-
> > gnu/libnl-3.so.200
> > #4  0x00007ffff6811049 in nl_recvmsgs () from /lib/x86_64-linux-
> > gnu/libnl-3.so.200
> > #5  0x00007ffff7402eaf in nl_send_msg (sock=0x555555606040,
> > cb=0x5555556065d0, msg=0x555555606110, rx_handler=0x7ffff70036f0
> > <genl_handle_msg>, data=0x555555607898) at thermal_nl.c:70
> > #6  0x00007ffff7402327 in thermal_genl_auto (th=0x5555556048a0,
> > id=1,
> > cmd=2, flags=0, arg=0x555555607898) at commands.c:282
> > #7  0x00007ffff74023e0 in thermal_cmd_get_trip (th=0x5555556048a0,
> > tz=0x555555607898) at commands.c:304
> > #8  0x00007ffff74039db in __thermal_zone_discover
> > (tz=0x555555607898,
> > th=0x5555556048a0) at thermal.c:71
> > #9  0x00007ffff7403842 in for_each_thermal_zone (tz=0x555555607860,
> > cb=0x7ffff74039b8 <__thermal_zone_discover>, arg=0x5555556048a0) at
> > thermal.c:33
> > #10 0x00007ffff7403a5b in thermal_zone_discover (th=0x5555556048a0)
> > at
> > thermal.c:87
> > #11 0x00005555554019bd in main ()
> > 
> > Thanks,
> > Srinivas
> > 
> > > 
> > 
> > 
> 
>
Srinivas Pandruvada April 18, 2022, 3:38 a.m. UTC | #11
On Sun, 2022-04-17 at 20:36 -0700, srinivas pandruvada wrote:
> Hi Daniel,
> 
> The attached diff fixes the crash,
> 
> Also when you run in daemon mode, you need to use some pid lock file.
> Otherwise it launches multiple daemons.
> 
With the diff
./thermal-engine 
thermal zone 'acpitz', id=0
trip id=0, type=3, temp=119000, hyst=0
trip id=1, type=0, temp=71000, hyst=0
trip id=2, type=0, temp=55000, hyst=0
trip id=3, type=0, temp=50000, hyst=0
trip id=4, type=0, temp=45000, hyst=0
trip id=5, type=0, temp=40000, hyst=0
temperature: 25000
governor: 'step_wise'
thermal zone 'INT3400 Thermal', id=1
temperature: 20000
governor: 'user_space'
thermal zone 'B0D4', id=2
trip id=0, type=3, temp=110050, hyst=0
trip id=1, type=2, temp=110050, hyst=0
trip id=2, type=1, temp=110050, hyst=0
trip id=3, type=0, temp=90050, hyst=0
trip id=4, type=0, temp=85050, hyst=0
trip id=5, type=0, temp=80050, hyst=0
trip id=6, type=0, temp=75050, hyst=0
trip id=7, type=0, temp=70050, hyst=0
temperature: 26050
governor: 'user_space'
thermal zone 'x86_pkg_temp', id=3
trip id=0, type=1, temp=-274000, hyst=0
trip id=1, type=1, temp=-274000, hyst=0
temperature: 26000
governor: 'step_wise'
Waiting for thermal events ...

> Thanks,
> Srinivas
> 
> 
> 
> On Sun, 2022-04-17 at 10:20 +0200, Daniel Lezcano wrote:
> > 
> > Hi Srinivas,
> > 
> > thanks for the information. I've indeed not tested on x86_64 but on
> > ARM64.
> > 
> > I'll give a try to reproduce and fix the issue.
> > 
> > Thanks again for taking the time to run it
> > 
> >    -- Daniel
> > 
> > On 17/04/2022 06:23, srinivas pandruvada wrote:
> > > Hi Daniel,
> > > 
> > > On Sat, 2022-04-16 at 09:55 +0200, Daniel Lezcano wrote:
> > > > 
> > > > Hi Srinivas,
> > > > 
> > > > 
> > > > On 16/04/2022 05:50, srinivas pandruvada wrote:
> > > > > On Wed, 2022-04-13 at 10:21 -0700, srinivas pandruvada wrote:
> > > > > > On Wed, 2022-04-13 at 17:06 +0200, Rafael J. Wysocki wrote:
> > > > > > > On Wed, Apr 6, 2022 at 4:44 PM Daniel Lezcano <
> > > > > > > daniel.lezcano@linaro.org> wrote:
> > > > > > > > 
> > > > > 
> > > 
> > > [...]
> > > 
> > > > > root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/the
> > > > > rmal-
> > > > > engine#
> > > > > LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
> > > > > ./thermal-engine -l DEBUG
> > > > > Segmentation fault (core dumped)
> > > > > root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/the
> > > > > rmal-
> > > > > engine#
> > > > > LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
> > > > > ./thermal-engine --loglevel DEBUG
> > > > > Segmentation fault (core dumped)
> > > > > root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/the
> > > > > rmal-
> > > > > engine#
> > > > > LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
> > > > > ./thermal-engine -s
> > > > > Segmentation fault (core dumped)
> > > > 
> > > > Is CONFIG_THERMAL_NETLINK set ?
> > > 
> > > Yes, Thermometer program works fine. Just thermal-engine fails.
> > > CONFIG_THERMAL=y
> > > CONFIG_THERMAL_NETLINK=y
> > > CONFIG_THERMAL_STATISTICS=y
> > > CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0
> > > CONFIG_THERMAL_HWMON=y
> > > CONFIG_THERMAL_WRITABLE_TRIPS=y
> > > CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y
> > > # CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE is not set
> > > # CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE is not set
> > > CONFIG_THERMAL_GOV_FAIR_SHARE=y
> > > CONFIG_THERMAL_GOV_STEP_WISE=y
> > > CONFIG_THERMAL_GOV_BANG_BANG=y
> > > CONFIG_THERMAL_GOV_USER_SPACE=y
> > > CONFIG_DEVFREQ_THERMAL=y
> > > CONFIG_THERMAL_EMULATION=y
> > > 
> > > This may help
> > > 
> > > #gdb ./thermal-engine
> > > GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
> > > Copyright (C) 2018 Free Software Foundation, Inc.
> > > License GPLv3+: GNU GPL version 3 or later
> > > <http://gnu.org/licenses/gpl.html>
> > > This is free software: you are free to change and redistribute it.
> > > There is NO WARRANTY, to the extent permitted by law.  Type "show
> > > copying"
> > > and "show warranty" for details.
> > > This GDB was configured as "x86_64-linux-gnu".
> > > Type "show configuration" for configuration details.
> > > For bug reporting instructions, please see:
> > > <http://www.gnu.org/software/gdb/bugs/>.
> > > Find the GDB manual and other documentation resources online at:
> > > <http://www.gnu.org/software/gdb/documentation/>.
> > > For help, type "help".
> > > Type "apropos word" to search for commands related to "word"...
> > > Reading symbols from ./thermal-engine...(no debugging symbols
> > > found)...done.
> > > (gdb) run
> > > Starting program:
> > > /home/labuser/development/linux/tools/thermal/thermal-
> > > engine/thermal-
> > > engine
> > > [Thread debugging using libthread_db enabled]
> > > Using host libthread_db library "/lib/x86_64-linux-
> > > gnu/libthread_db.so.1".
> > > 
> > > Program received signal SIGSEGV, Segmentation fault.
> > > 0x00007ffff7402036 in parse_tz_get_trip (info=0x7fffffffdf60,
> > > tz=0x555555607898) at commands.c:143
> > > 143             __tt[size].id = -1;
> > > (gdb) backtrace
> > > #0  0x00007ffff7402036 in parse_tz_get_trip (info=0x7fffffffdf60,
> > > tz=0x555555607898) at commands.c:143
> > > #1  0x00007ffff7402233 in handle_netlink (unused=0x0,
> > > cmd=0x7ffff76052f8 <thermal_cmds+120>, info=0x7fffffffdf60,
> > > arg=0x555555607898) at commands.c:206
> > > #2  0x00007ffff7003435 in ?? () from /lib/x86_64-linux-gnu/libnl-
> > > genl-
> > > 3.so.200
> > > #3  0x00007ffff6810c1c in nl_recvmsgs_report () from /lib/x86_64-
> > > linux-
> > > gnu/libnl-3.so.200
> > > #4  0x00007ffff6811049 in nl_recvmsgs () from /lib/x86_64-linux-
> > > gnu/libnl-3.so.200
> > > #5  0x00007ffff7402eaf in nl_send_msg (sock=0x555555606040,
> > > cb=0x5555556065d0, msg=0x555555606110, rx_handler=0x7ffff70036f0
> > > <genl_handle_msg>, data=0x555555607898) at thermal_nl.c:70
> > > #6  0x00007ffff7402327 in thermal_genl_auto (th=0x5555556048a0,
> > > id=1,
> > > cmd=2, flags=0, arg=0x555555607898) at commands.c:282
> > > #7  0x00007ffff74023e0 in thermal_cmd_get_trip (th=0x5555556048a0,
> > > tz=0x555555607898) at commands.c:304
> > > #8  0x00007ffff74039db in __thermal_zone_discover
> > > (tz=0x555555607898,
> > > th=0x5555556048a0) at thermal.c:71
> > > #9  0x00007ffff7403842 in for_each_thermal_zone (tz=0x555555607860,
> > > cb=0x7ffff74039b8 <__thermal_zone_discover>, arg=0x5555556048a0) at
> > > thermal.c:33
> > > #10 0x00007ffff7403a5b in thermal_zone_discover (th=0x5555556048a0)
> > > at
> > > thermal.c:87
> > > #11 0x00005555554019bd in main ()
> > > 
> > > Thanks,
> > > Srinivas
> > > 
> > > > 
> > > 
> > > 
> > 
> > 
>
Daniel Lezcano April 18, 2022, 7:46 a.m. UTC | #12
Hi Srinivas,

thanks for the fix !

On 18/04/2022 05:36, srinivas pandruvada wrote:
> Hi Daniel,
> 
> The attached diff fixes the crash,
> 
> Also when you run in daemon mode, you need to use some pid lock file.
> Otherwise it launches multiple daemons.

Thanks for the feedback, I'll add it

   -- Daniel

> 
> On Sun, 2022-04-17 at 10:20 +0200, Daniel Lezcano wrote:
>>
>> Hi Srinivas,
>>
>> thanks for the information. I've indeed not tested on x86_64 but on
>> ARM64.
>>
>> I'll give a try to reproduce and fix the issue.
>>
>> Thanks again for taking the time to run it
>>
>>     -- Daniel
>>
>> On 17/04/2022 06:23, srinivas pandruvada wrote:
>>> Hi Daniel,
>>>
>>> On Sat, 2022-04-16 at 09:55 +0200, Daniel Lezcano wrote:
>>>>
>>>> Hi Srinivas,
>>>>
>>>>
>>>> On 16/04/2022 05:50, srinivas pandruvada wrote:
>>>>> On Wed, 2022-04-13 at 10:21 -0700, srinivas pandruvada wrote:
>>>>>> On Wed, 2022-04-13 at 17:06 +0200, Rafael J. Wysocki wrote:
>>>>>>> On Wed, Apr 6, 2022 at 4:44 PM Daniel Lezcano <
>>>>>>> daniel.lezcano@linaro.org> wrote:
>>>>>>>>
>>>>>
>>>
>>> [...]
>>>
>>>>> root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/the
>>>>> rmal-
>>>>> engine#
>>>>> LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
>>>>> ./thermal-engine -l DEBUG
>>>>> Segmentation fault (core dumped)
>>>>> root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/the
>>>>> rmal-
>>>>> engine#
>>>>> LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
>>>>> ./thermal-engine --loglevel DEBUG
>>>>> Segmentation fault (core dumped)
>>>>> root@srinivas-otcpl-icl-u:~/development/linux/tools/thermal/the
>>>>> rmal-
>>>>> engine#
>>>>> LD_LIBRARY_PATH=../lib:../../lib/thermal:$LD_LIBRARY_pATH
>>>>> ./thermal-engine -s
>>>>> Segmentation fault (core dumped)
>>>>
>>>> Is CONFIG_THERMAL_NETLINK set ?
>>>
>>> Yes, Thermometer program works fine. Just thermal-engine fails.
>>> CONFIG_THERMAL=y
>>> CONFIG_THERMAL_NETLINK=y
>>> CONFIG_THERMAL_STATISTICS=y
>>> CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0
>>> CONFIG_THERMAL_HWMON=y
>>> CONFIG_THERMAL_WRITABLE_TRIPS=y
>>> CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y
>>> # CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE is not set
>>> # CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE is not set
>>> CONFIG_THERMAL_GOV_FAIR_SHARE=y
>>> CONFIG_THERMAL_GOV_STEP_WISE=y
>>> CONFIG_THERMAL_GOV_BANG_BANG=y
>>> CONFIG_THERMAL_GOV_USER_SPACE=y
>>> CONFIG_DEVFREQ_THERMAL=y
>>> CONFIG_THERMAL_EMULATION=y
>>>
>>> This may help
>>>
>>> #gdb ./thermal-engine
>>> GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
>>> Copyright (C) 2018 Free Software Foundation, Inc.
>>> License GPLv3+: GNU GPL version 3 or later
>>> <http://gnu.org/licenses/gpl.html>
>>> This is free software: you are free to change and redistribute it.
>>> There is NO WARRANTY, to the extent permitted by law.  Type "show
>>> copying"
>>> and "show warranty" for details.
>>> This GDB was configured as "x86_64-linux-gnu".
>>> Type "show configuration" for configuration details.
>>> For bug reporting instructions, please see:
>>> <http://www.gnu.org/software/gdb/bugs/>.
>>> Find the GDB manual and other documentation resources online at:
>>> <http://www.gnu.org/software/gdb/documentation/>.
>>> For help, type "help".
>>> Type "apropos word" to search for commands related to "word"...
>>> Reading symbols from ./thermal-engine...(no debugging symbols
>>> found)...done.
>>> (gdb) run
>>> Starting program:
>>> /home/labuser/development/linux/tools/thermal/thermal-
>>> engine/thermal-
>>> engine
>>> [Thread debugging using libthread_db enabled]
>>> Using host libthread_db library "/lib/x86_64-linux-
>>> gnu/libthread_db.so.1".
>>>
>>> Program received signal SIGSEGV, Segmentation fault.
>>> 0x00007ffff7402036 in parse_tz_get_trip (info=0x7fffffffdf60,
>>> tz=0x555555607898) at commands.c:143
>>> 143             __tt[size].id = -1;
>>> (gdb) backtrace
>>> #0  0x00007ffff7402036 in parse_tz_get_trip (info=0x7fffffffdf60,
>>> tz=0x555555607898) at commands.c:143
>>> #1  0x00007ffff7402233 in handle_netlink (unused=0x0,
>>> cmd=0x7ffff76052f8 <thermal_cmds+120>, info=0x7fffffffdf60,
>>> arg=0x555555607898) at commands.c:206
>>> #2  0x00007ffff7003435 in ?? () from /lib/x86_64-linux-gnu/libnl-
>>> genl-
>>> 3.so.200
>>> #3  0x00007ffff6810c1c in nl_recvmsgs_report () from /lib/x86_64-
>>> linux-
>>> gnu/libnl-3.so.200
>>> #4  0x00007ffff6811049 in nl_recvmsgs () from /lib/x86_64-linux-
>>> gnu/libnl-3.so.200
>>> #5  0x00007ffff7402eaf in nl_send_msg (sock=0x555555606040,
>>> cb=0x5555556065d0, msg=0x555555606110, rx_handler=0x7ffff70036f0
>>> <genl_handle_msg>, data=0x555555607898) at thermal_nl.c:70
>>> #6  0x00007ffff7402327 in thermal_genl_auto (th=0x5555556048a0,
>>> id=1,
>>> cmd=2, flags=0, arg=0x555555607898) at commands.c:282
>>> #7  0x00007ffff74023e0 in thermal_cmd_get_trip (th=0x5555556048a0,
>>> tz=0x555555607898) at commands.c:304
>>> #8  0x00007ffff74039db in __thermal_zone_discover
>>> (tz=0x555555607898,
>>> th=0x5555556048a0) at thermal.c:71
>>> #9  0x00007ffff7403842 in for_each_thermal_zone (tz=0x555555607860,
>>> cb=0x7ffff74039b8 <__thermal_zone_discover>, arg=0x5555556048a0) at
>>> thermal.c:33
>>> #10 0x00007ffff7403a5b in thermal_zone_discover (th=0x5555556048a0)
>>> at
>>> thermal.c:87
>>> #11 0x00005555554019bd in main ()
>>>
>>> Thanks,
>>> Srinivas
>>>
>>>>
>>>
>>>
>>
>>
>
Daniel Lezcano April 19, 2022, 8:26 p.m. UTC | #13
Hi Srinivas,


On 18/04/2022 05:36, srinivas pandruvada wrote:
> Hi Daniel,
> 
> The attached diff fixes the crash,
> 
> Also when you run in daemon mode, you need to use some pid lock file.
> Otherwise it launches multiple daemons.

I've been thinking about it and I don't think it is a problem to have 
multiple instances of the daemon. The netlink allows multicast and can 
be run as non-root user.

If the finality of the thermal engine is to manage the system and has 
some code making actions on the system with the root privilege, the init 
scripts can take care of the pid lock
Srinivas Pandruvada April 20, 2022, 3:16 a.m. UTC | #14
Hi Daniel,

On Tue, 2022-04-19 at 22:26 +0200, Daniel Lezcano wrote:
> 
> Hi Srinivas,
> 
> 
> On 18/04/2022 05:36, srinivas pandruvada wrote:
> > Hi Daniel,
> > 
> > The attached diff fixes the crash,
> > 
> > Also when you run in daemon mode, you need to use some pid lock
> > file.
> > Otherwise it launches multiple daemons.
> 
> I've been thinking about it and I don't think it is a problem to have
> multiple instances of the daemon. The netlink allows multicast and
> can 
> be run as non-root user.
> 
> If the finality of the thermal engine is to manage the system and has
> some code making actions on the system with the root privilege, the
> init 
> scripts can take care of the pid lock
> 
If there is use case, then this is fine otherwise wasting system
resources.

Thanks,
Srinivas





> 
>