Mailing List Archive

Preemptive Kernel Patch
Hi,

I just tried the Preemptive Kernel Patch. I went from practically no
stutter to very noticeable stutter. That was just during play back;
the machine wasn't running anything else. So, thinking that some
other process was occasionally stealing the system (I don't know,
mysql or something), I reniced by -5 all of the mythfrontend
processes. After that, the stutter went away.

Has anyone else had a similar experience with the Preemptive Kernel
Patch? Did you have to renice as well? By how much?

Cliff Draper Sun Microsystems, Forte Tools
My opinions may or may not reflect those of my employer.
---------------------------- food for thought ---------------------------
At Group L, Stoffel oversees six first-rate programmers, a managerial
challenge roughly comparable to herding cats.
Re: Preemptive Kernel Patch [ In reply to ]
On Sun, 16 Feb 2003 14:46:18 -0800 (PST)
Cliff Draper <Cliff.Draper@Sun.com> wrote:

> Hi,
>
> I just tried the Preemptive Kernel Patch. I went from practically no
> stutter to very noticeable stutter. That was just during play back;
> the machine wasn't running anything else. So, thinking that some
> other process was occasionally stealing the system (I don't know,
> mysql or something), I reniced by -5 all of the mythfrontend
> processes. After that, the stutter went away.
>
> Has anyone else had a similar experience with the Preemptive Kernel
> Patch? Did you have to renice as well? By how much?

I'm running the preemptive-kernel patch with the low-latency patches on
RH 7.3 (kernel 2.4.18-19.7). I saw the same kind of stuttering before I
niced myth to -20. As a suggestion don't request realtime priority with
mythfrontend (hangs the box...).

As far as the stuttering, it kind of makes sense in that the actual
capture activities can not be preempted in kernel, by other tasks.

I've also used vcr with some realtime patches on the same kernel
patches and had good luck (3 RT threads: audio, video, writer threads).

--
-Monty Walls (mwalls@castor.oktax.state.ok.us)
- MIS, Oklahoma Tax Commission
-
- My opinions are my own, my employer knows nothing about it.
Re: Preemptive Kernel Patch [ In reply to ]
Wouldn't this make a great addition to the HOWTO or FAQ section?

I'm new to Linux and thought "nice" was a good way to describe the people on
this forum ;-P

Which processes did you "nice" and do you just do it in a console window in
"real-time" and watch the results in Myth or what? Do you start with a
lower number and then increase?

A little step-by-step would be really, ummm, nice!

Thanks,
JC

----- Original Message -----
From: "Monty Walls" <mwalls@castor.oktax.state.ok.us>
To: "Discussion about mythtv" <mythtv-users@snowman.net>
Sent: Tuesday, February 18, 2003 11:48 AM
Subject: Re: [mythtv-users] Preemptive Kernel Patch


> On Sun, 16 Feb 2003 14:46:18 -0800 (PST)
> Cliff Draper <Cliff.Draper@Sun.com> wrote:
>
> > Hi,
> >
> > I just tried the Preemptive Kernel Patch. I went from practically no
> > stutter to very noticeable stutter. That was just during play back;
> > the machine wasn't running anything else. So, thinking that some
> > other process was occasionally stealing the system (I don't know,
> > mysql or something), I reniced by -5 all of the mythfrontend
> > processes. After that, the stutter went away.
> >
> > Has anyone else had a similar experience with the Preemptive Kernel
> > Patch? Did you have to renice as well? By how much?
>
> I'm running the preemptive-kernel patch with the low-latency patches on
> RH 7.3 (kernel 2.4.18-19.7). I saw the same kind of stuttering before I
> niced myth to -20. As a suggestion don't request realtime priority with
> mythfrontend (hangs the box...).
>
> As far as the stuttering, it kind of makes sense in that the actual
> capture activities can not be preempted in kernel, by other tasks.
>
> I've also used vcr with some realtime patches on the same kernel
> patches and had good luck (3 RT threads: audio, video, writer threads).
>
> --
> -Monty Walls (mwalls@castor.oktax.state.ok.us)
> - MIS, Oklahoma Tax Commission
> -
> - My opinions are my own, my employer knows nothing about it.
> _______________________________________________
> mythtv-users mailing list
> mythtv-users@snowman.net
> http://www.snowman.net/mailman/listinfo/mythtv-users
>
>
Re: Preemptive Kernel Patch [ In reply to ]
On Tue, 18 Feb 2003 12:10:06 -0500
"JC" <johnmythtv@crombe.com> wrote:

> Wouldn't this make a great addition to the HOWTO or FAQ section?
>
> I'm new to Linux and thought "nice" was a good way to describe the people on
> this forum ;-P
>
> Which processes did you "nice" and do you just do it in a console window in
> "real-time" and watch the results in Myth or what? Do you start with a
> lower number and then increase?
>
> A little step-by-step would be really, ummm, nice!#!/bin/bash

No. I use a wrapper script to fire up myth. Adding
preemptive-kernel to the hacked redhat kernel is hard, basically.

----
export PATH=/sbin:/usr/sbin:$PATH
export DISPLAY=:0.0
alsactl -f /tmp/asound.save store
alsactl -f /root/mythtv.asound.state restore
#
v4lctl -c /dev/video0 setnorm ntsc
if [ -f ~/.tv.myth ]; then
. ~/.tv.myth
v4lctl -c /dev/video0 bright ${BRIGHT}
v4lctl -c /dev/video0 color ${COLOR}
v4lctl -c /dev/video0 contrast ${CONTRAST}
v4lctl -c /dev/video0 hue ${HUE}
fi
#
#mythtv
nice -20 mythfrontend
alsactl -f /tmp/asound.save restore
------


--
-Monty Walls (mwalls@castor.oktax.state.ok.us)
- MIS, Oklahoma Tax Commission
-
- My opinions are my own, my employer knows nothing about it.
Re: Preemptive Kernel Patch [ In reply to ]
In this mail you said don't -20 frontend or it'll hang the box, but in
your shell snippet that's exactly what you do.

Make up your mind :)


----- Original Message -----
From: "Monty Walls" <mwalls@castor.oktax.state.ok.us>
To: "Discussion about mythtv" <mythtv-users@snowman.net>
Sent: Tuesday, February 18, 2003 10:48 AM
Subject: Re: [mythtv-users] Preemptive Kernel Patch


> On Sun, 16 Feb 2003 14:46:18 -0800 (PST)
> Cliff Draper <Cliff.Draper@Sun.com> wrote:
>
> > Hi,
> >
> > I just tried the Preemptive Kernel Patch. I went from practically no
> > stutter to very noticeable stutter. That was just during play back;
> > the machine wasn't running anything else. So, thinking that some
> > other process was occasionally stealing the system (I don't know,
> > mysql or something), I reniced by -5 all of the mythfrontend
> > processes. After that, the stutter went away.
> >
> > Has anyone else had a similar experience with the Preemptive Kernel
> > Patch? Did you have to renice as well? By how much?
>
> I'm running the preemptive-kernel patch with the low-latency patches on
> RH 7.3 (kernel 2.4.18-19.7). I saw the same kind of stuttering before I
> niced myth to -20. As a suggestion don't request realtime priority with
> mythfrontend (hangs the box...).
>
> As far as the stuttering, it kind of makes sense in that the actual
> capture activities can not be preempted in kernel, by other tasks.
>
> I've also used vcr with some realtime patches on the same kernel
> patches and had good luck (3 RT threads: audio, video, writer threads).
>
> --
> -Monty Walls (mwalls@castor.oktax.state.ok.us)
> - MIS, Oklahoma Tax Commission
> -
> - My opinions are my own, my employer knows nothing about it.
> _______________________________________________
> mythtv-users mailing list
> mythtv-users@snowman.net
> http://www.snowman.net/mailman/listinfo/mythtv-users
Re: Preemptive Kernel Patch [ In reply to ]
On Tue, 18 Feb 2003 11:59:40 -0600
"William Preston" <bpreston@networkusa.net> wrote:

> In this mail you said don't -20 frontend or it'll hang the box, but in
> your shell snippet that's exactly what you do.
>
> Make up your mind :)
>

nice -20 doesn't get realtime. You can't get realtime from the command-line without
writing a wrapper program that:


schp.sched_priority = sched_get_priority_max(SCHED_RR);

if (sched_setscheduler(0, sc, &schp) != 0) {
perror("sched_setscheduler");
return (-1);
}


I have hacked vcr to do that and wrote a wrapper program and
tried it with myth (wasn't good idea).

--
-Monty Walls (mwalls@castor.oktax.state.ok.us)
- MIS, Oklahoma Tax Commission
-
- My opinions are my own, my employer knows nothing about it.
RE: Preemptive Kernel Patch [ In reply to ]
perhaps this is a stupid question, but have you figured out a graceful way to nice the processes without having to run the script as root?

-----Original Message-----
From: Monty Walls [mailto:mwalls@castor.oktax.state.ok.us]
Sent: Tuesday, February 18, 2003 9:32 AM
To: Discussion about mythtv
Subject: Re: [mythtv-users] Preemptive Kernel Patch


On Tue, 18 Feb 2003 12:10:06 -0500
"JC" <johnmythtv@crombe.com> wrote:

> Wouldn't this make a great addition to the HOWTO or FAQ section?
>
> I'm new to Linux and thought "nice" was a good way to describe the people on
> this forum ;-P
>
> Which processes did you "nice" and do you just do it in a console window in
> "real-time" and watch the results in Myth or what? Do you start with a
> lower number and then increase?
>
> A little step-by-step would be really, ummm, nice!#!/bin/bash

No. I use a wrapper script to fire up myth. Adding
preemptive-kernel to the hacked redhat kernel is hard, basically.

----
export PATH=/sbin:/usr/sbin:$PATH
export DISPLAY=:0.0
alsactl -f /tmp/asound.save store
alsactl -f /root/mythtv.asound.state restore
#
v4lctl -c /dev/video0 setnorm ntsc
if [ -f ~/.tv.myth ]; then
. ~/.tv.myth
v4lctl -c /dev/video0 bright ${BRIGHT}
v4lctl -c /dev/video0 color ${COLOR}
v4lctl -c /dev/video0 contrast ${CONTRAST}
v4lctl -c /dev/video0 hue ${HUE}
fi
#
#mythtv
nice -20 mythfrontend
alsactl -f /tmp/asound.save restore
------


--
-Monty Walls (mwalls@castor.oktax.state.ok.us)
- MIS, Oklahoma Tax Commission
-
- My opinions are my own, my employer knows nothing about it.
_______________________________________________
mythtv-users mailing list
mythtv-users@snowman.net
http://www.snowman.net/mailman/listinfo/mythtv-users
Re: Preemptive Kernel Patch [ In reply to ]
Thus spake Kevin Bowen:
> perhaps this is a stupid question, but have you figured out a graceful
> way to nice the processes without having to run the script as root?

You could always set up sudo to allow the (I assume) mythtv user to do
the nice.

--
Nathan Poznick <poznick@conwaycorp.net>

"You want to unpack that one for me, son?" -Tom Servo (as Tom Grant).
#522
Re: Preemptive Kernel Patch [ In reply to ]
On Tue, 18 Feb 2003 11:14:00 -0800
"Kevin Bowen" <kevin@ucsd.edu> wrote:

> perhaps this is a stupid question, but have you figured out a graceful way to nice the processes without having to run the script as root?

Since the script takes no arguments, you could always just setuid the stupid script.
This not exactly a high security box :)


--
-Monty Walls (mwalls@castor.oktax.state.ok.us)
- MIS, Oklahoma Tax Commission
-
- My opinions are my own, my employer knows nothing about it.
Re: Preemptive Kernel Patch [ In reply to ]
Thus spake Monty Walls:
> Since the script takes no arguments, you could always just setuid the
> stupid script. This not exactly a high security box :)

Can't just setuid a shell script...

--
Nathan Poznick <poznick@conwaycorp.net>

Some men can live up to their loftiest ideals without ever going higher
than a basement. - Theodore Roosevelt
Re: Preemptive Kernel Patch [ In reply to ]
On Tue, 18 Feb 2003 13:27:50 -0600
Nathan Poznick <poznick@conwaycorp.net> wrote:

> Thus spake Monty Walls:
> > Since the script takes no arguments, you could always just setuid the
> > stupid script. This not exactly a high security box :)
>
> Can't just setuid a shell script...
>

Sure you can, just might not be smart, plus may require some fiddling
with the actual code. Since the only user is me, and it's
not an externally exposed box (inside a firewalled, NATed network), it might be
an acceptable risk...



> --
> Nathan Poznick <poznick@conwaycorp.net>
>
> Some men can live up to their loftiest ideals without ever going higher
> than a basement. - Theodore Roosevelt
>
> _______________________________________________
> mythtv-users mailing list
> mythtv-users@snowman.net
> http://www.snowman.net/mailman/listinfo/mythtv-users


--
-Monty Walls (mwalls@castor.oktax.state.ok.us)
- MIS, Oklahoma Tax Commission
-
- My opinions are my own, my employer knows nothing about it.
Re: Preemptive Kernel Patch [ In reply to ]
Thus spake Monty Walls:
> Sure you can, just might not be smart, plus may require some fiddling
> with the actual code. Since the only user is me, and it's
> not an externally exposed box (inside a firewalled, NATed network), it
> might be an acceptable risk...

Actually, many systems disable the ability to use a setuid shell script.

npozni@ripcord:~$ cat script
#!/bin/bash
ls -l /
sleep 30

npozni@ripcord:~$ ls -l script
-rwsr-xr-x 1 root root 30 Feb 18 14:09 script*

(user npozni runs ./script)

If the script was running setuid, it would show up as running as root in
the process listing...

npozni 18405 0.2 0.2 2060 960 pts/4 S 14:09 0:00 /bin/bash ./script
npozni 18407 0.0 0.1 1708 452 pts/4 S 14:09 0:00 sleep 30


One way to get around this is to write a very simple C wrapper program
which is setuid, and serves no purpose other than to exec the intended
shell script.


--
Nathan Poznick <poznick@conwaycorp.net>

To swallow and follow, whether old doctrine or new propaganda, is a
weakness still dominating the human mind. - Charlotte P. Gillman
RE: Preemptive Kernel Patch [ In reply to ]
Why not use sudo to handle this? It would be the appropriate way to do
it, and mimizes security risk:

# useradd mythvuser
((no password))

Change /etc/sudoers and add the following line:

mythtvuser ALL = NOPASSWD: /usr/local/bin/mythstart

(where /usr/local/bin/mythstart is your startup script, owned by root,
and chmod u+rx).

I use a similar tactic to allow VMWare to access /dev/dsp through the
artsdsp wrapper.

Cheers,
Aaron
-----Original Message-----
From: mythtv-users-bounces@snowman.net
[mailto:mythtv-users-bounces@snowman.net] On Behalf Of Nathan Poznick
Sent: Tuesday, February 18, 2003 12:26 PM
To: Discussion about mythtv
Subject: Re: [mythtv-users] Preemptive Kernel Patch


Thus spake Monty Walls:
> Sure you can, just might not be smart, plus may require some fiddling
> with the actual code. Since the only user is me, and it's
> not an externally exposed box (inside a firewalled, NATed network), it
> might be an acceptable risk...

Actually, many systems disable the ability to use a setuid shell script.

npozni@ripcord:~$ cat script
#!/bin/bash
ls -l /
sleep 30

npozni@ripcord:~$ ls -l script
-rwsr-xr-x 1 root root 30 Feb 18 14:09 script*

(user npozni runs ./script)

If the script was running setuid, it would show up as running as root in
the process listing...

npozni 18405 0.2 0.2 2060 960 pts/4 S 14:09 0:00 /bin/bash
./script
npozni 18407 0.0 0.1 1708 452 pts/4 S 14:09 0:00 sleep 30


One way to get around this is to write a very simple C wrapper program
which is setuid, and serves no purpose other than to exec the intended
shell script.


--
Nathan Poznick <poznick@conwaycorp.net>

To swallow and follow, whether old doctrine or new propaganda, is a
weakness still dominating the human mind. - Charlotte P. Gillman

_______________________________________________
mythtv-users mailing list
mythtv-users@snowman.net
http://www.snowman.net/mailman/listinfo/mythtv-users
Re: Preemptive Kernel Patch [ In reply to ]
On Tue, 18 Feb 2003 14:26:06 -0600
Nathan Poznick <poznick@conwaycorp.net> wrote:

> Thus spake Monty Walls:
> > Sure you can, just might not be smart, plus may require some fiddling
> > with the actual code. Since the only user is me, and it's
> > not an externally exposed box (inside a firewalled, NATed network), it
> > might be an acceptable risk...
>
> Actually, many systems disable the ability to use a setuid shell script.
>

Now for a picture of me eating humble pie, having just verified that my
box does disable setuid shell scripts.

Looks like sudo is the solution for those who don't run myth as root.

--
-Monty Walls (mwalls@castor.oktax.state.ok.us)
- MIS, Oklahoma Tax Commission
-
- My opinions are my own, my employer knows nothing about it.
Re: Preemptive Kernel Patch [ In reply to ]
>
>
>Now for a picture of me eating humble pie, having just verified that my
>box does disable setuid shell scripts.
>
>Looks like sudo is the solution for those who don't run myth as root.
>
>
>
You can't setuid bash scripts, but you can zsh scripts. perl will also
work if you have perl-suidperl installed, but it will require you to
follow special rules of how to write the script to protect you from
common security problems like the person running it being able to
manipulate the PATH.