Messages in this thread | | | Date | Thu, 31 Jul 2003 20:01:14 -0400 | From | Joe Korty <> | Subject | Re: [PATCH] protect migration/%d etc from sched_setaffinity |
| |
On Thu, Jul 31, 2003 at 04:17:03PM -0700, Andrew Morton wrote: > Joe Korty <joe.korty@ccur.com> wrote: > > > > I'd like to be able to write shell scrips that operate on the set of > > /proc/[0-9]* without having to know which of the ever-changing list > > of processes need to be avoided and which not. > > Like this? > > #!/bin/sh > > # > # can_set_affinity pid > # > can_set_affinity() > { > if [ "$(cat /proc/$1/maps)" != "" ] > then > return 0 > fi > if head -1 /proc/$1/status | egrep "events|migration" > then > return 1 > else > return 0 > fi > } > > if can_set_affinity $1 > then > echo can set affinity of pid $1 > else > echo cannot set affinity of pid $1 > fi
Good stuff. I reduced it to (having trouble easily reading the original output):
name=$(head -1 /proc/$1/status | awk '{print $2}') echo -n '[' $1 '] ' $name ' ' if [ "$(cat /proc/$1/maps)" == "" ] then echo SAFE else echo changeable fi
It catches all those that need catching, plus denies changes to some daemons that could survive sched_setaffinity: khubd, kirqd, pdflush*, kswapd0, scsi_eh_[01], ahc_dv_[01], kseriod, and kjournald*.
Joe - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |