linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "John B. Wyatt IV" <jwyatt@redhat.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Shuah Khan <skhan@linuxfoundation.org>,
	linux-pm@vger.kernel.org, Thomas Renninger <trenn@suse.com>,
	Shuah Khan <shuah@kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	linux-kernel@vger.kernel.org, John Kacur <jkacur@redhat.com>,
	Tomas Glozar <tglozar@redhat.com>, Arnaldo Melo <acme@redhat.com>,
	"John B. Wyatt IV" <sageofredondo@gmail.com>
Subject: Re: [PATCH 0/2][RFC] Add SWIG Bindings to libcpupower
Date: Tue, 6 Aug 2024 16:56:40 -0400	[thread overview]
Message-ID: <ZrKOCLYvYklsPg1K@fedora.redhat.com> (raw)
In-Reply-To: <2024080405-roundish-casket-2474@gregkh>

Adding Arnaldo to the CC list.

On Sun, Aug 04, 2024 at 10:54:10AM +0200, Greg Kroah-Hartman wrote:
> On Thu, Aug 01, 2024 at 05:24:20PM -0400, John B. Wyatt IV wrote:
> > > On 7/24/24 16:11, John B. Wyatt IV wrote:
> > > > SWIG is a tool packaged in Fedora and other distros that can generate
> > > > bindings from C and C++ code for several languages including Python,
> > > > Perl, and Go. We at Red Hat are interested in adding binding support to
> > > > libcpupower so Python tools like rteval or tuned can make easy use of it.
> > > > 
> > > 
> > > Can you elaborate on the use-case and what rteval currently does and
> > > how it could benefit from using libcpupower with the bindings?
> > 
> > rteval is a Python program used to measure realtime performance. We wanted to
> > test the effect of enabling some levels of idle-stat to see how it affects
> > latency, and didn't want to reinvent the wheel. We thought that the Python
> > bindings could be useful to other people as well who might want to call
> > cpupower too from Python. I did some testing and was able to achieve this with
> > SWIG. We sent the patchset to see what folks thought about this.
> 
> Is this going to require a built-time dependency on SWIG?  If not, when
> would it be run

It is optional, and based on my conversation with Shuah; the bindings will be
in a seperate makefile. It would be ran after running cpupower's
makefile, seperately. (But one can call the other.)

> and who will be in charge of running it and updating the bindings?

That would be myself. If I no longer wish to continue I would reassign it to
another person here on the real-time team at Red Hat. John Kacur (whom I am
working with on rteval) is fine with being listed as a backup contact.

The bindings would need to be updated every time one of the functions or data
structures listed in the .i file changes. But it can be as simple as copying the
changed declaration from the header file to the .i file to resolve.

> And finally, why do we need these at all?

To provide bindings for Python programs like rteval to easily interface with
libcpupower. It is very common for userspace programs to include bindings to
scripting languages.

> You are saying these are new
> tests that external tools will be using, but why, if external tools are
> required to run them, are they needed in the kernel tree at all?  Why
> isn't this just another external test-suite that people who care about
> measuring this type of thing going to just run on their own if desired?

SWIG the tool requires the .o files compiled from libcpupower to generate
bindings. Since we need these artifacts from a packaging and usability perspective
it makes sense to include the bindings source code along in a seperate directory
with the cpupower source code to generate the builds for them at the same time.
The source code is: the .i definitions file, any future Python wrapper helpers
around the bindings needed by SWIG, and the documentation.

Why SWIG? It was chosen for this project because of:

1) Many Python bindings generators are strickly Apache2 or GPL v3 licensed; and
they may inject code into the bindings binary that will create a license conflict
with the GPL v2. Swig was far more clear about the license status of the
generated bindings. As described above:
https://lore.kernel.org/linux-pm/1f5c24b6-f3ee-4863-8b7a-49344a550206@linuxfoundation.org/T/#mb7170232fb429fc242bb45c8d3d4d5ed47f0c59f

2) It's extensive documentation. This is the Python section:
https://www.swig.org/Doc4.2/Python.html#Python

3) Support: SWIG has been around since 1996 and had a release 5 months ago. It's
length of time and the acitvity in it's community makes it unlikely SWIG will
lose support by it's developers anytime soon.

4) This RFC demonstrates how quickly and with little work you can generate
bindings for an existing C project with no code changes to that project. :-)
There were issues getting other Python bindings generators to work as
described in their documentation.

-- 
Sincerely,
John Wyatt
Software Engineer, Core Kernel
Red Hat


  reply	other threads:[~2024-08-06 20:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-24 22:11 [PATCH 0/2][RFC] Add SWIG Bindings to libcpupower John B. Wyatt IV
2024-07-24 22:11 ` [PATCH 1/2] Add SWIG bindings files for libcpupower John B. Wyatt IV
2024-07-24 22:11 ` [PATCH 2/2] Include test_raw_pylibcpupower.py John B. Wyatt IV
2024-07-26 17:34 ` [PATCH 0/2][RFC] Add SWIG Bindings to libcpupower Shuah Khan
2024-07-30 20:48 ` Shuah Khan
2024-08-01 21:24   ` John B. Wyatt IV
2024-08-04  8:54     ` Greg Kroah-Hartman
2024-08-06 20:56       ` John B. Wyatt IV [this message]
2024-08-20  6:40         ` John B. Wyatt IV
2024-08-21  7:08           ` Shuah Khan
2024-08-22  3:25             ` Shuah Khan
2024-08-27 17:58               ` John B. Wyatt IV
2024-08-09 20:25       ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZrKOCLYvYklsPg1K@fedora.redhat.com \
    --to=jwyatt@redhat.com \
    --cc=acme@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jkacur@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=sageofredondo@gmail.com \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=tglozar@redhat.com \
    --cc=torvalds@linux-foundation.org \
    --cc=trenn@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).