Re: [PATCH 1/2] add tunable_notifier function ,take2

2007-10-25 Thread Takenori Nagano
Randy Dunlap wrote:
> On Thu, 18 Oct 2007 17:53:00 +0900 Takenori Nagano wrote:
> 
>> This patch adds new notifier function tunable_notifier_chain. Its base is
>> atomic_notifier_chain.
>>
>> Thanks,
>>
>> ---
>>
>> Signed-off-by: Takenori Nagano <[EMAIL PROTECTED]>
>>
>> ---
>> diff -uprN linux-2.6.23.orig/kernel/sys.c linux-2.6.23/kernel/sys.c
>> --- linux-2.6.23.orig/kernel/sys.c   2007-10-10 05:31:38.0 +0900
>> +++ linux-2.6.23/kernel/sys.c2007-10-18 10:08:52.72800 +0900
>> @@ -38,6 +38,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  
>>  #include 
>>  #include 
>> @@ -393,6 +394,243 @@ int blocking_notifier_call_chain(struct 
>>  EXPORT_SYMBOL_GPL(blocking_notifier_call_chain);
> 
>> +/**
>> + *  tunable_atomic_notifier_chain_register
>> + *  - Add notifier to an tunable notifier chain
> 
> Function name & short description must be on one (long?) line.  :(

OK. I'll fix next version.

>> +
>> +int __kprobes __tunable_atomic_notifier_call_chain(
>> +struct tunable_atomic_notifier_head *nh,
>> +unsigned long val, void *v,
>> +int nr_to_call, int *nr_calls)
>> +{
>> +int ret;
>> +
>> +rcu_read_lock();
>> +ret = notifier_call_chain(>head, val, v, nr_to_call, nr_calls);
>> +rcu_read_unlock();
>> +return ret;
>> +}
>> +
>> +EXPORT_SYMBOL_GPL(__tunable_atomic_notifier_call_chain);
> 
> Blank line is usually omitted before EXPORT_SYMBOL

OK. I'll fix, too.

Thanks,
  Takenori

> ---
> ~Randy
> 
> 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] add tunable_notifier function ,take2

2007-10-25 Thread Takenori Nagano
Randy Dunlap wrote:
 On Thu, 18 Oct 2007 17:53:00 +0900 Takenori Nagano wrote:
 
 This patch adds new notifier function tunable_notifier_chain. Its base is
 atomic_notifier_chain.

 Thanks,

 ---

 Signed-off-by: Takenori Nagano [EMAIL PROTECTED]

 ---
 diff -uprN linux-2.6.23.orig/kernel/sys.c linux-2.6.23/kernel/sys.c
 --- linux-2.6.23.orig/kernel/sys.c   2007-10-10 05:31:38.0 +0900
 +++ linux-2.6.23/kernel/sys.c2007-10-18 10:08:52.72800 +0900
 @@ -38,6 +38,7 @@
  #include linux/syscalls.h
  #include linux/kprobes.h
  #include linux/user_namespace.h
 +#include linux/debugfs.h
  
  #include asm/uaccess.h
  #include asm/io.h
 @@ -393,6 +394,243 @@ int blocking_notifier_call_chain(struct 
  EXPORT_SYMBOL_GPL(blocking_notifier_call_chain);
 
 +/**
 + *  tunable_atomic_notifier_chain_register
 + *  - Add notifier to an tunable notifier chain
 
 Function name  short description must be on one (long?) line.  :(

OK. I'll fix next version.

 +
 +int __kprobes __tunable_atomic_notifier_call_chain(
 +struct tunable_atomic_notifier_head *nh,
 +unsigned long val, void *v,
 +int nr_to_call, int *nr_calls)
 +{
 +int ret;
 +
 +rcu_read_lock();
 +ret = notifier_call_chain(nh-head, val, v, nr_to_call, nr_calls);
 +rcu_read_unlock();
 +return ret;
 +}
 +
 +EXPORT_SYMBOL_GPL(__tunable_atomic_notifier_call_chain);
 
 Blank line is usually omitted before EXPORT_SYMBOL

OK. I'll fix, too.

Thanks,
  Takenori

 ---
 ~Randy
 
 
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] add tunable_notifier function ,take2

2007-10-24 Thread Randy Dunlap
On Thu, 18 Oct 2007 17:53:00 +0900 Takenori Nagano wrote:

> This patch adds new notifier function tunable_notifier_chain. Its base is
> atomic_notifier_chain.
> 
> Thanks,
> 
> ---
> 
> Signed-off-by: Takenori Nagano <[EMAIL PROTECTED]>
> 
> ---
> diff -uprN linux-2.6.23.orig/kernel/sys.c linux-2.6.23/kernel/sys.c
> --- linux-2.6.23.orig/kernel/sys.c2007-10-10 05:31:38.0 +0900
> +++ linux-2.6.23/kernel/sys.c 2007-10-18 10:08:52.72800 +0900
> @@ -38,6 +38,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  #include 
> @@ -393,6 +394,243 @@ int blocking_notifier_call_chain(struct 
>  EXPORT_SYMBOL_GPL(blocking_notifier_call_chain);

> +/**
> + *   tunable_atomic_notifier_chain_register
> + *   - Add notifier to an tunable notifier chain

Function name & short description must be on one (long?) line.  :(

> + *   @nh: Pointer to head of the tunable notifier chain
> + *   @n: New entry in notifier chain
> + *   @name: Pointer to the name of the new notifier entry
> + *   @desc: Pointer to the description of new entry
> + *
> + *   Adds a notifier to an tunable notifier chain and makes control dir.
> + *
> + *   Returns zero on success or %-ENODEV on failure.
> + */
> +
> +int tunable_atomic_notifier_chain_register(
> + struct tunable_atomic_notifier_head *nh,
> + struct tunable_atomic_notifier_block *n, char *name, char *desc)
> +{

> +}
> +
> +EXPORT_SYMBOL_GPL(tunable_atomic_notifier_chain_register);
> +
> +/**
> + *   tunable_atomic_notifier_chain_unregister
> + *   - Remove notifier from a tunable notifier chain

Ditto.

> + *   @nh: Pointer to head of the tunable notifier chain
> + *   @n: Entry to remove from notifier chain
> + *
> + *   Removes a notifier from a tunable notifier chain.
> + *
> + *   Retunrns zero on success or %-ENOENT on failure.
> + */
> +
> +int tunable_atomic_notifier_chain_unregister(
> + struct tunable_atomic_notifier_head *nh,
> + struct tunable_atomic_notifier_block *n)
> +{

> +}
> +
> +EXPORT_SYMBOL_GPL(tunable_atomic_notifier_chain_unregister);
> +
> +/**
> + *   __tunable_atomic_notifier_call_chain
> + *   - Call functions in a tunable notifier chain

Same.

> + *   @nh: Pointer to head of the tunable notifier chain
> + *   @val: Value passed unmodified to notifier function
> + *   @v: Pointer passed unmodified to notifier function
> + *   @nt_to_call: See the comment for notifier_call_chain

@nr_to_call: ...

> + *   @nr_calls: See the comment for notifier_call_chain
> + *
> + *   Calls each function in a notifier chain in turn. The functions
> + *   run in an atomic context, so they must not block.
> + *   This routine uses RCU to synchronize with changes to the chain.
> + *
> + *   If the return value of the notifier can be and'ed
> + *   with %NOTIFY_STOP_MASK then tunable_atomic_notifier_call_chain()
> + *   will return immediately, with the return value of
> + *   the notifier function which halted execution.
> + *   Otherwise the return value is the return value
> + *   of the last notifier function called.
> + */
> +
> +int __kprobes __tunable_atomic_notifier_call_chain(
> + struct tunable_atomic_notifier_head *nh,
> + unsigned long val, void *v,
> + int nr_to_call, int *nr_calls)
> +{
> + int ret;
> +
> + rcu_read_lock();
> + ret = notifier_call_chain(>head, val, v, nr_to_call, nr_calls);
> + rcu_read_unlock();
> + return ret;
> +}
> +
> +EXPORT_SYMBOL_GPL(__tunable_atomic_notifier_call_chain);

Blank line is usually omitted before EXPORT_SYMBOL

---
~Randy
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] add tunable_notifier function ,take2

2007-10-24 Thread Randy Dunlap
On Thu, 18 Oct 2007 17:53:00 +0900 Takenori Nagano wrote:

 This patch adds new notifier function tunable_notifier_chain. Its base is
 atomic_notifier_chain.
 
 Thanks,
 
 ---
 
 Signed-off-by: Takenori Nagano [EMAIL PROTECTED]
 
 ---
 diff -uprN linux-2.6.23.orig/kernel/sys.c linux-2.6.23/kernel/sys.c
 --- linux-2.6.23.orig/kernel/sys.c2007-10-10 05:31:38.0 +0900
 +++ linux-2.6.23/kernel/sys.c 2007-10-18 10:08:52.72800 +0900
 @@ -38,6 +38,7 @@
  #include linux/syscalls.h
  #include linux/kprobes.h
  #include linux/user_namespace.h
 +#include linux/debugfs.h
  
  #include asm/uaccess.h
  #include asm/io.h
 @@ -393,6 +394,243 @@ int blocking_notifier_call_chain(struct 
  EXPORT_SYMBOL_GPL(blocking_notifier_call_chain);

 +/**
 + *   tunable_atomic_notifier_chain_register
 + *   - Add notifier to an tunable notifier chain

Function name  short description must be on one (long?) line.  :(

 + *   @nh: Pointer to head of the tunable notifier chain
 + *   @n: New entry in notifier chain
 + *   @name: Pointer to the name of the new notifier entry
 + *   @desc: Pointer to the description of new entry
 + *
 + *   Adds a notifier to an tunable notifier chain and makes control dir.
 + *
 + *   Returns zero on success or %-ENODEV on failure.
 + */
 +
 +int tunable_atomic_notifier_chain_register(
 + struct tunable_atomic_notifier_head *nh,
 + struct tunable_atomic_notifier_block *n, char *name, char *desc)
 +{

 +}
 +
 +EXPORT_SYMBOL_GPL(tunable_atomic_notifier_chain_register);
 +
 +/**
 + *   tunable_atomic_notifier_chain_unregister
 + *   - Remove notifier from a tunable notifier chain

Ditto.

 + *   @nh: Pointer to head of the tunable notifier chain
 + *   @n: Entry to remove from notifier chain
 + *
 + *   Removes a notifier from a tunable notifier chain.
 + *
 + *   Retunrns zero on success or %-ENOENT on failure.
 + */
 +
 +int tunable_atomic_notifier_chain_unregister(
 + struct tunable_atomic_notifier_head *nh,
 + struct tunable_atomic_notifier_block *n)
 +{

 +}
 +
 +EXPORT_SYMBOL_GPL(tunable_atomic_notifier_chain_unregister);
 +
 +/**
 + *   __tunable_atomic_notifier_call_chain
 + *   - Call functions in a tunable notifier chain

Same.

 + *   @nh: Pointer to head of the tunable notifier chain
 + *   @val: Value passed unmodified to notifier function
 + *   @v: Pointer passed unmodified to notifier function
 + *   @nt_to_call: See the comment for notifier_call_chain

@nr_to_call: ...

 + *   @nr_calls: See the comment for notifier_call_chain
 + *
 + *   Calls each function in a notifier chain in turn. The functions
 + *   run in an atomic context, so they must not block.
 + *   This routine uses RCU to synchronize with changes to the chain.
 + *
 + *   If the return value of the notifier can be and'ed
 + *   with %NOTIFY_STOP_MASK then tunable_atomic_notifier_call_chain()
 + *   will return immediately, with the return value of
 + *   the notifier function which halted execution.
 + *   Otherwise the return value is the return value
 + *   of the last notifier function called.
 + */
 +
 +int __kprobes __tunable_atomic_notifier_call_chain(
 + struct tunable_atomic_notifier_head *nh,
 + unsigned long val, void *v,
 + int nr_to_call, int *nr_calls)
 +{
 + int ret;
 +
 + rcu_read_lock();
 + ret = notifier_call_chain(nh-head, val, v, nr_to_call, nr_calls);
 + rcu_read_unlock();
 + return ret;
 +}
 +
 +EXPORT_SYMBOL_GPL(__tunable_atomic_notifier_call_chain);

Blank line is usually omitted before EXPORT_SYMBOL

---
~Randy
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] add tunable_notifier function

2007-10-05 Thread Eric W. Biederman
Takenori Nagano <[EMAIL PROTECTED]> writes:

> This patch adds new notifier function tunable_notifier_chain. Its base is
> atomic_notifier_chain.



> +/**
> + * tunable_notifier_chain_register - Add notifier to an tunable notifier 
> chain
> + *   @nh: Pointer to head of the tunable notifier chain
> + *   @n: New entry in notifier chain
> + *   @name: Pointer to the name of this notifier chain
> + *   @desc: Pointer to the description of new entry
> + *
> + *   Adds a notifier to an tunable notifier chain and makes control dir.
> + *
> + *   Returns zero on success or %-ENODEV on failure.
> + */
> +
> +int tunable_notifier_chain_register(struct tunable_notifier_head *nh,
> + struct tunable_notifier_block *n, char *name, char *desc)
> +{
> + unsigned long flags;
> + int ret = -EINVAL;
> + struct dentry *nh_dir, *nb_dir, *pri_dentry, *desc_dentry = NULL;
> +
> + if (!name)
> + goto nb_fail;
> +
> + ret = -ENOMEM;
> + if (!nh->dir) {
> + nh_dir = debugfs_create_dir(nh->name, NULL);

Hmm. debugfs does not appear to be an appropriate place to create
files that are supposed to be part of a serious user space interface.

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] add tunable_notifier function

2007-10-05 Thread Eric W. Biederman
Takenori Nagano [EMAIL PROTECTED] writes:

 This patch adds new notifier function tunable_notifier_chain. Its base is
 atomic_notifier_chain.



 +/**
 + * tunable_notifier_chain_register - Add notifier to an tunable notifier 
 chain
 + *   @nh: Pointer to head of the tunable notifier chain
 + *   @n: New entry in notifier chain
 + *   @name: Pointer to the name of this notifier chain
 + *   @desc: Pointer to the description of new entry
 + *
 + *   Adds a notifier to an tunable notifier chain and makes control dir.
 + *
 + *   Returns zero on success or %-ENODEV on failure.
 + */
 +
 +int tunable_notifier_chain_register(struct tunable_notifier_head *nh,
 + struct tunable_notifier_block *n, char *name, char *desc)
 +{
 + unsigned long flags;
 + int ret = -EINVAL;
 + struct dentry *nh_dir, *nb_dir, *pri_dentry, *desc_dentry = NULL;
 +
 + if (!name)
 + goto nb_fail;
 +
 + ret = -ENOMEM;
 + if (!nh-dir) {
 + nh_dir = debugfs_create_dir(nh-name, NULL);

Hmm. debugfs does not appear to be an appropriate place to create
files that are supposed to be part of a serious user space interface.

Eric
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] add tunable_notifier function

2007-10-04 Thread Takenori Nagano
Vivek Goyal wrote:
> On Thu, Oct 04, 2007 at 08:38:34PM +0900, Takenori Nagano wrote:
>> This patch adds new notifier function tunable_notifier_chain. Its base is
>> atomic_notifier_chain.
>>
>> Thanks,
>>
>> ---
>>
>> Signed-off-by: Takenori Nagano <[EMAIL PROTECTED]>
>>
>> ---
>> diff -uprN linux-2.6.23-rc9.orig/include/linux/notifier.h
>> linux-2.6.23-rc9/include/linux/notifier.h
>> --- linux-2.6.23-rc9.orig/include/linux/notifier.h   2007-10-02 
>> 12:24:52.0
>> +0900
>> +++ linux-2.6.23-rc9/include/linux/notifier.h2007-10-03 
>> 14:48:04.28800 +0900
>> @@ -13,6 +13,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>
>>  /*
>>   * Notifier chains are of four types:
>> @@ -53,6 +54,14 @@ struct notifier_block {
>>  int priority;
>>  };
>>
>> +struct tunable_notifier_block {
>> +struct notifier_block *nb;
>> +struct tunable_notifier_head *head;
>> +struct dentry *dir;
>> +struct dentry *pri_dentry;
>> +struct dentry *desc_dentry;
>> +};
>> +
> 
> Should this be tunable_atomic_notifier_block? I think there are two kind
> of lists. One where handlers have to be atomic and other one where handlers
> can be blocking one. I think you are making atomic one tunable. If that's
> the case it should be reflected in the naming everywhere.

Hi Vivek,

Yes, it based on atomic_notifier_list. I think your opinion is reasonable.
I'll change the name tunable_notifier to tunable_atomic_notifier.

Thanks,

Takenori Nagano <[EMAIL PROTECTED]>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] add tunable_notifier function

2007-10-04 Thread Vivek Goyal
On Thu, Oct 04, 2007 at 08:38:34PM +0900, Takenori Nagano wrote:
> This patch adds new notifier function tunable_notifier_chain. Its base is
> atomic_notifier_chain.
> 
> Thanks,
> 
> ---
> 
> Signed-off-by: Takenori Nagano <[EMAIL PROTECTED]>
> 
> ---
> diff -uprN linux-2.6.23-rc9.orig/include/linux/notifier.h
> linux-2.6.23-rc9/include/linux/notifier.h
> --- linux-2.6.23-rc9.orig/include/linux/notifier.h2007-10-02 
> 12:24:52.0
> +0900
> +++ linux-2.6.23-rc9/include/linux/notifier.h 2007-10-03 14:48:04.28800 
> +0900
> @@ -13,6 +13,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
> 
>  /*
>   * Notifier chains are of four types:
> @@ -53,6 +54,14 @@ struct notifier_block {
>   int priority;
>  };
> 
> +struct tunable_notifier_block {
> + struct notifier_block *nb;
> + struct tunable_notifier_head *head;
> + struct dentry *dir;
> + struct dentry *pri_dentry;
> + struct dentry *desc_dentry;
> +};
> +

Should this be tunable_atomic_notifier_block? I think there are two kind
of lists. One where handlers have to be atomic and other one where handlers
can be blocking one. I think you are making atomic one tunable. If that's
the case it should be reflected in the naming everywhere.

Thanks
Vivek
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] add tunable_notifier function

2007-10-04 Thread Takenori Nagano
Randy Dunlap wrote:
> On Thu, 04 Oct 2007 20:38:34 +0900 Takenori Nagano wrote:
>> diff -uprN linux-2.6.23-rc9.orig/kernel/sys.c linux-2.6.23-rc9/kernel/sys.c
>> --- linux-2.6.23-rc9.orig/kernel/sys.c   2007-10-02 12:24:52.0 
>> +0900
>> +++ linux-2.6.23-rc9/kernel/sys.c2007-10-03 14:48:15.16000 +0900
>> @@ -38,6 +38,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>
>>  #include 
>>  #include 
>> @@ -393,6 +394,234 @@ int blocking_notifier_call_chain(struct
> 
>> +/**
>> + *  tunable_notifier_chain_register - Add notifier to an tunable notifier 
>> chain
>> + *  @nh: Pointer to head of the tunable notifier chain
>> + *  @n: New entry in notifier chain
>> + *  @name: Pointer to the name of this notifier chain
> 
> Is @name the name of a notifier chain or of the new notifier entry?

Hi Randy,

@name: Pointer to the name of the new notifier entry.

I'll change the explanation.

Thanks,
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] add tunable_notifier function

2007-10-04 Thread Randy Dunlap
On Thu, 04 Oct 2007 20:38:34 +0900 Takenori Nagano wrote:

> This patch adds new notifier function tunable_notifier_chain. Its base is
> atomic_notifier_chain.
> 
> Thanks,
> 
> ---
> 
> Signed-off-by: Takenori Nagano <[EMAIL PROTECTED]>
> 
> ---

> diff -uprN linux-2.6.23-rc9.orig/kernel/sys.c linux-2.6.23-rc9/kernel/sys.c
> --- linux-2.6.23-rc9.orig/kernel/sys.c2007-10-02 12:24:52.0 
> +0900
> +++ linux-2.6.23-rc9/kernel/sys.c 2007-10-03 14:48:15.16000 +0900
> @@ -38,6 +38,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
> 
>  #include 
>  #include 
> @@ -393,6 +394,234 @@ int blocking_notifier_call_chain(struct

> +/**
> + *   tunable_notifier_chain_register - Add notifier to an tunable notifier 
> chain
> + *   @nh: Pointer to head of the tunable notifier chain
> + *   @n: New entry in notifier chain
> + *   @name: Pointer to the name of this notifier chain

Is @name the name of a notifier chain or of the new notifier entry?


> + *   @desc: Pointer to the description of new entry
> + *
> + *   Adds a notifier to an tunable notifier chain and makes control dir.
> + *
> + *   Returns zero on success or %-ENODEV on failure.
> + */
> +
> +int tunable_notifier_chain_register(struct tunable_notifier_head *nh,
> + struct tunable_notifier_block *n, char *name, char *desc)
> +{
> + unsigned long flags;
> + int ret = -EINVAL;
> + struct dentry *nh_dir, *nb_dir, *pri_dentry, *desc_dentry = NULL;
> +
> + if (!name)
> + goto nb_fail;
> +
> + ret = -ENOMEM;
> + if (!nh->dir) {
> + nh_dir = debugfs_create_dir(nh->name, NULL);
> + if (!nh_dir)
> + return ret;
> + nh->dir = nh_dir;
> + } else
> + nh_dir = nh->dir;
> +
> + nb_dir = debugfs_create_dir(name, nh_dir);
> + if (!nb_dir)
> + goto nb_fail;
> + n->dir = nb_dir;
> +
> + pri_dentry = debugfs_create_file("priority",0600, nb_dir, n, _fops);
> + if (!pri_dentry)
> + goto pri_fail;
> + n->pri_dentry = pri_dentry;
> +
> + if (desc) {
> + desc_dentry = debugfs_create_file("description", 0400, nb_dir,
> + desc, _fops);
> + if (!desc_dentry)
> + goto desc_fail;
> + n->desc_dentry = desc_dentry;
> + }
> +
> + spin_lock_irqsave(>lock, flags);
> + ret = notifier_chain_register(>head, n->nb);
> + spin_unlock_irqrestore(>lock, flags);
> +
> + if (ret)
> + goto reg_fail;
> + 
> + n->head = nh;
> +
> + return ret;
> +
> +reg_fail:
> + debugfs_remove(desc_dentry);
> +desc_fail:
> + debugfs_remove(pri_dentry);
> +pri_fail:
> + debugfs_remove(nb_dir);
> +nb_fail:
> + return ret;
> +}
> +
> +EXPORT_SYMBOL_GPL(tunable_notifier_chain_register);

---
~Randy
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] add tunable_notifier function

2007-10-04 Thread Randy Dunlap
On Thu, 04 Oct 2007 20:38:34 +0900 Takenori Nagano wrote:

 This patch adds new notifier function tunable_notifier_chain. Its base is
 atomic_notifier_chain.
 
 Thanks,
 
 ---
 
 Signed-off-by: Takenori Nagano [EMAIL PROTECTED]
 
 ---

 diff -uprN linux-2.6.23-rc9.orig/kernel/sys.c linux-2.6.23-rc9/kernel/sys.c
 --- linux-2.6.23-rc9.orig/kernel/sys.c2007-10-02 12:24:52.0 
 +0900
 +++ linux-2.6.23-rc9/kernel/sys.c 2007-10-03 14:48:15.16000 +0900
 @@ -38,6 +38,7 @@
  #include linux/syscalls.h
  #include linux/kprobes.h
  #include linux/user_namespace.h
 +#include linux/debugfs.h
 
  #include asm/uaccess.h
  #include asm/io.h
 @@ -393,6 +394,234 @@ int blocking_notifier_call_chain(struct

 +/**
 + *   tunable_notifier_chain_register - Add notifier to an tunable notifier 
 chain
 + *   @nh: Pointer to head of the tunable notifier chain
 + *   @n: New entry in notifier chain
 + *   @name: Pointer to the name of this notifier chain

Is @name the name of a notifier chain or of the new notifier entry?


 + *   @desc: Pointer to the description of new entry
 + *
 + *   Adds a notifier to an tunable notifier chain and makes control dir.
 + *
 + *   Returns zero on success or %-ENODEV on failure.
 + */
 +
 +int tunable_notifier_chain_register(struct tunable_notifier_head *nh,
 + struct tunable_notifier_block *n, char *name, char *desc)
 +{
 + unsigned long flags;
 + int ret = -EINVAL;
 + struct dentry *nh_dir, *nb_dir, *pri_dentry, *desc_dentry = NULL;
 +
 + if (!name)
 + goto nb_fail;
 +
 + ret = -ENOMEM;
 + if (!nh-dir) {
 + nh_dir = debugfs_create_dir(nh-name, NULL);
 + if (!nh_dir)
 + return ret;
 + nh-dir = nh_dir;
 + } else
 + nh_dir = nh-dir;
 +
 + nb_dir = debugfs_create_dir(name, nh_dir);
 + if (!nb_dir)
 + goto nb_fail;
 + n-dir = nb_dir;
 +
 + pri_dentry = debugfs_create_file(priority,0600, nb_dir, n, pri_fops);
 + if (!pri_dentry)
 + goto pri_fail;
 + n-pri_dentry = pri_dentry;
 +
 + if (desc) {
 + desc_dentry = debugfs_create_file(description, 0400, nb_dir,
 + desc, desc_fops);
 + if (!desc_dentry)
 + goto desc_fail;
 + n-desc_dentry = desc_dentry;
 + }
 +
 + spin_lock_irqsave(nh-lock, flags);
 + ret = notifier_chain_register(nh-head, n-nb);
 + spin_unlock_irqrestore(nh-lock, flags);
 +
 + if (ret)
 + goto reg_fail;
 + 
 + n-head = nh;
 +
 + return ret;
 +
 +reg_fail:
 + debugfs_remove(desc_dentry);
 +desc_fail:
 + debugfs_remove(pri_dentry);
 +pri_fail:
 + debugfs_remove(nb_dir);
 +nb_fail:
 + return ret;
 +}
 +
 +EXPORT_SYMBOL_GPL(tunable_notifier_chain_register);

---
~Randy
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] add tunable_notifier function

2007-10-04 Thread Takenori Nagano
Randy Dunlap wrote:
 On Thu, 04 Oct 2007 20:38:34 +0900 Takenori Nagano wrote:
 diff -uprN linux-2.6.23-rc9.orig/kernel/sys.c linux-2.6.23-rc9/kernel/sys.c
 --- linux-2.6.23-rc9.orig/kernel/sys.c   2007-10-02 12:24:52.0 
 +0900
 +++ linux-2.6.23-rc9/kernel/sys.c2007-10-03 14:48:15.16000 +0900
 @@ -38,6 +38,7 @@
  #include linux/syscalls.h
  #include linux/kprobes.h
  #include linux/user_namespace.h
 +#include linux/debugfs.h

  #include asm/uaccess.h
  #include asm/io.h
 @@ -393,6 +394,234 @@ int blocking_notifier_call_chain(struct
 
 +/**
 + *  tunable_notifier_chain_register - Add notifier to an tunable notifier 
 chain
 + *  @nh: Pointer to head of the tunable notifier chain
 + *  @n: New entry in notifier chain
 + *  @name: Pointer to the name of this notifier chain
 
 Is @name the name of a notifier chain or of the new notifier entry?

Hi Randy,

@name: Pointer to the name of the new notifier entry.

I'll change the explanation.

Thanks,
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] add tunable_notifier function

2007-10-04 Thread Vivek Goyal
On Thu, Oct 04, 2007 at 08:38:34PM +0900, Takenori Nagano wrote:
 This patch adds new notifier function tunable_notifier_chain. Its base is
 atomic_notifier_chain.
 
 Thanks,
 
 ---
 
 Signed-off-by: Takenori Nagano [EMAIL PROTECTED]
 
 ---
 diff -uprN linux-2.6.23-rc9.orig/include/linux/notifier.h
 linux-2.6.23-rc9/include/linux/notifier.h
 --- linux-2.6.23-rc9.orig/include/linux/notifier.h2007-10-02 
 12:24:52.0
 +0900
 +++ linux-2.6.23-rc9/include/linux/notifier.h 2007-10-03 14:48:04.28800 
 +0900
 @@ -13,6 +13,7 @@
  #include linux/mutex.h
  #include linux/rwsem.h
  #include linux/srcu.h
 +#include linux/kobject.h
 
  /*
   * Notifier chains are of four types:
 @@ -53,6 +54,14 @@ struct notifier_block {
   int priority;
  };
 
 +struct tunable_notifier_block {
 + struct notifier_block *nb;
 + struct tunable_notifier_head *head;
 + struct dentry *dir;
 + struct dentry *pri_dentry;
 + struct dentry *desc_dentry;
 +};
 +

Should this be tunable_atomic_notifier_block? I think there are two kind
of lists. One where handlers have to be atomic and other one where handlers
can be blocking one. I think you are making atomic one tunable. If that's
the case it should be reflected in the naming everywhere.

Thanks
Vivek
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] add tunable_notifier function

2007-10-04 Thread Takenori Nagano
Vivek Goyal wrote:
 On Thu, Oct 04, 2007 at 08:38:34PM +0900, Takenori Nagano wrote:
 This patch adds new notifier function tunable_notifier_chain. Its base is
 atomic_notifier_chain.

 Thanks,

 ---

 Signed-off-by: Takenori Nagano [EMAIL PROTECTED]

 ---
 diff -uprN linux-2.6.23-rc9.orig/include/linux/notifier.h
 linux-2.6.23-rc9/include/linux/notifier.h
 --- linux-2.6.23-rc9.orig/include/linux/notifier.h   2007-10-02 
 12:24:52.0
 +0900
 +++ linux-2.6.23-rc9/include/linux/notifier.h2007-10-03 
 14:48:04.28800 +0900
 @@ -13,6 +13,7 @@
  #include linux/mutex.h
  #include linux/rwsem.h
  #include linux/srcu.h
 +#include linux/kobject.h

  /*
   * Notifier chains are of four types:
 @@ -53,6 +54,14 @@ struct notifier_block {
  int priority;
  };

 +struct tunable_notifier_block {
 +struct notifier_block *nb;
 +struct tunable_notifier_head *head;
 +struct dentry *dir;
 +struct dentry *pri_dentry;
 +struct dentry *desc_dentry;
 +};
 +
 
 Should this be tunable_atomic_notifier_block? I think there are two kind
 of lists. One where handlers have to be atomic and other one where handlers
 can be blocking one. I think you are making atomic one tunable. If that's
 the case it should be reflected in the naming everywhere.

Hi Vivek,

Yes, it based on atomic_notifier_list. I think your opinion is reasonable.
I'll change the name tunable_notifier to tunable_atomic_notifier.

Thanks,

Takenori Nagano [EMAIL PROTECTED]
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/