From: Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>
To: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>,
Dhaval Giani <dhaval@linux.vnet.ibm.com>,
Mike Galbraith <efault@gmx.de>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Dmitry Adamushko <dmitry.adamushko@gmail.com>,
lkml <linux-kernel@vger.kernel.org>,
maneesh@linux.vnet.ibm.com,
Andrew Morton <akpm@linux-foundation.org>,
Sudhir Kumar <skumar@linux.vnet.ibm.com>
Subject: [PATCH sched-devel] Generate uevents for user creation/destruction
Date: Tue, 9 Oct 2007 20:42:01 +0530 [thread overview]
Message-ID: <20071009151201.GK3707@linux.vnet.ibm.com> (raw)
In-Reply-To: <20071004085451.GA8108@osiris.boeblingen.de.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 2418 bytes --]
On Thu, Oct 04, 2007 at 10:54:51AM +0200, Heiko Carstens wrote:
> > i'm wondering about the following: could not (yet) existing UIDs be made
> > configurable too? I.e. if i do this in a bootup script:
> >
> > echo 2048 > /sys/kernel/uids/500/cpu_share
> >
> > this should just work too, regardless of there not being any UID 500
> > tasks yet. Likewise, once configured, the /sys/kernel/uids/* directories
> > (with the settings in them) should probably not go away either.
>
> Shouldn't that be done via uevents? E.g. UID x gets added to the sysfs tree,
> generates a uevent and a script then figures out the cpu_share and sets it.
> That way you also don't need to keep the directories. No?
Heiko,
Thanks for the hint. Here's a patch to enable generation of
uevents for user creation/deletion. These uevents can be handled in
userspace to configure a new user's cpu share.
Note : After bootup I could test that new user's cpu share is configured
as per a configuration file (/etc/user_cpu_share.conf). However this
mechanism didnt work for root user. Perhaps uevent for root user is
generated way too early?
A HOWTO text file is also attached explaining how to make use of these
uevents in userspace.
Ingo,
This patch applies on top of latest sched-devel tree. Pls review
and apply ..
---
Generate uevents when a user is being created/destroyed. These events
could be used to configure cpu share of a new user.
Signed-off-by : Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>
Signed-off-by : Dhaval Giani <dhaval@linux.vnet.ibm.com>
---
kernel/user.c | 4 ++++
1 files changed, 4 insertions(+)
Index: current/kernel/user.c
===================================================================
--- current.orig/kernel/user.c
+++ current/kernel/user.c
@@ -174,6 +174,8 @@ static int user_kobject_create(struct us
if (error)
kobject_del(kobj);
+ kobject_uevent(kobj, KOBJ_ADD);
+
done:
return error;
}
@@ -189,6 +191,7 @@ int __init uids_kobject_init(void)
/* create under /sys/kernel dir */
uids_kobject.parent = &kernel_subsys.kobj;
+ uids_kobject.kset = &kernel_subsys;
kobject_set_name(&uids_kobject, "uids");
kobject_init(&uids_kobject);
@@ -228,6 +231,7 @@ static void remove_user_sysfs_dir(struct
goto done;
sysfs_remove_file(kobj, &up->user_attr.attr);
+ kobject_uevent(kobj, KOBJ_REMOVE);
kobject_del(kobj);
sched_destroy_user(up);
--
Regards,
vatsa
[-- Attachment #2: HOWTO --]
[-- Type: text/plain, Size: 920 bytes --]
This HOWTO explains the steps required to configure a user's cpu share
automatically when he/she logs in. This has been verified to work on
a Redhat distribution.
Note : This HOWTO is a *hack* to get things working quickly. In particular it
doesn't follow standards like LSB.
1. Create a file /etc/user_cpu_share.conf with this format:
[uid] [cpu_share]
Ex:
512 1024 #user vatsa
514 512 #user guest
2. Create a script, named "kernel.agent" in /etc/hotplug directory
as follows. Make that script executable and owned by root.
#!/bin/sh
#
# kernel hotplug agent for 2.6 kernels
#
# ACTION=add
# DEVPATH=/kernel/uids/[uid]
#
cd /etc/hotplug
. ./hotplug.functions
case $ACTION in
add)
uid=${DEVPATH##*/}
line=`grep -w $uid /etc/user_cpu_share.conf`
if [ $? -eq 0 ]
then
cpu_share=`echo $line | awk '{print $2}'`
echo $cpu_share > /sys/$DEVPATH/cpu_share
fi
;;
*)
;;
esac
next prev parent reply other threads:[~2007-10-09 15:00 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-24 21:45 [git] CFS-devel, latest code Ingo Molnar
2007-09-24 21:55 ` Andrew Morton
2007-09-24 21:59 ` Ingo Molnar
2007-09-25 0:08 ` Daniel Walker
2007-09-25 6:45 ` Ingo Molnar
2007-09-25 15:17 ` Daniel Walker
2007-09-25 6:10 ` Mike Galbraith
2007-09-25 7:35 ` Mike Galbraith
2007-09-25 8:33 ` Mike Galbraith
2007-09-25 8:53 ` Srivatsa Vaddagiri
2007-09-25 9:11 ` Srivatsa Vaddagiri
2007-09-25 9:15 ` Mike Galbraith
2007-09-25 9:12 ` Mike Galbraith
2007-09-25 9:13 ` Ingo Molnar
2007-09-25 9:17 ` Mike Galbraith
2007-09-25 9:47 ` Ingo Molnar
2007-09-25 10:02 ` Mike Galbraith
2007-09-26 8:04 ` Mike Galbraith
2007-09-28 21:46 ` Bill Davidsen
2007-09-25 9:44 ` Srivatsa Vaddagiri
2007-09-25 9:40 ` Ingo Molnar
2007-09-25 10:10 ` Ingo Molnar
2007-09-25 10:28 ` Srivatsa Vaddagiri
2007-09-25 10:36 ` Ingo Molnar
2007-09-25 11:33 ` Ingo Molnar
2007-09-25 14:48 ` Srivatsa Vaddagiri
2007-09-25 12:51 ` Srivatsa Vaddagiri
2007-09-25 13:35 ` Mike Galbraith
2007-09-25 14:07 ` Srivatsa Vaddagiri
2007-09-25 12:28 ` Mike Galbraith
2007-09-25 12:54 ` Mike Galbraith
[not found] ` <20070925131717.GM26289@linux.vnet.ibm.com>
[not found] ` <1190725693.13716.10.camel@Homer.simpson.net>
[not found] ` <20070925132528.GN26289@linux.vnet.ibm.com>
[not found] ` <1190726682.11260.1.camel@Homer.simpson.net>
[not found] ` <20070925140559.GB26310@linux.vnet.ibm.com>
[not found] ` <20070925143755.GA15594@elte.hu>
[not found] ` <20070926210737.GA8663@elte.hu>
2007-10-01 14:04 ` [RFC/PATCH] Add sysfs control to modify a user's cpu share Dhaval Giani
2007-10-01 14:44 ` Ingo Molnar
2007-10-01 15:32 ` Srivatsa Vaddagiri
2007-10-02 22:12 ` Eric St-Laurent
2007-10-03 4:09 ` Srivatsa Vaddagiri
2007-10-03 17:10 ` [RFC/PATCH -v2] " Dhaval Giani
2007-10-04 7:57 ` Ingo Molnar
2007-10-04 8:54 ` Heiko Carstens
2007-10-04 16:02 ` Bill Davidsen
2007-10-04 17:20 ` Srivatsa Vaddagiri
2007-10-04 21:32 ` Valdis.Kletnieks
2007-10-05 7:01 ` Srivatsa Vaddagiri
2007-10-09 15:12 ` Srivatsa Vaddagiri [this message]
2007-10-10 7:42 ` [PATCH sched-devel] Generate uevents for user creation/destruction Ingo Molnar
2007-10-01 16:12 ` [RFC/PATCH] Add sysfs control to modify a user's cpu share Dave Jones
2007-10-01 16:37 ` Srivatsa Vaddagiri
2007-09-25 6:50 ` [git] CFS-devel, latest code S.Çağlar Onur
2007-09-25 9:17 ` Ingo Molnar
2007-09-25 7:41 ` Andrew Morton
2007-09-25 8:43 ` Srivatsa Vaddagiri
2007-09-25 8:48 ` Andrew Morton
2007-09-25 11:00 ` Ingo Molnar
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=20071009151201.GK3707@linux.vnet.ibm.com \
--to=vatsa@linux.vnet.ibm.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=dhaval@linux.vnet.ibm.com \
--cc=dmitry.adamushko@gmail.com \
--cc=efault@gmx.de \
--cc=heiko.carstens@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maneesh@linux.vnet.ibm.com \
--cc=mingo@elte.hu \
--cc=skumar@linux.vnet.ibm.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