Re: [RFC][PATCH 4/6] min and max kobjects

From: Randy Dunlap
Date: Wed Jan 24 2007 - 17:47:43 EST


On Tue, 16 Jan 2007 07:15:20 +0100 Nadia.Derbey@xxxxxxxx wrote:

> [PATCH 04/06]
>
> Introduces the kobjects associated to each tunable min and max value
>
> Signed-off-by: Nadia Derbey <Nadia.Derbey@xxxxxxxx>
> ---
> include/linux/akt.h | 30 ++++
> include/linux/akt_ops.h | 311 ++++++++++++++++++++++++++++++++++++++++++++
> kernel/autotune/akt.c | 120 ++++++++++++++++
> kernel/autotune/akt_sysfs.c | 8 +
> 4 files changed, 469 insertions(+)
>
> Index: linux-2.6.20-rc4/include/linux/akt.h
> ===================================================================
> --- linux-2.6.20-rc4.orig/include/linux/akt.h 2007-01-15 15:08:41.000000000 +0100
> +++ linux-2.6.20-rc4/include/linux/akt.h 2007-01-15 15:21:47.000000000 +0100
> @@ -62,6 +62,13 @@ struct tunable_kobject {
> * auto_tune structure.
> * These values are type dependent and are used as high / low boundaries when
> * tuning up or down.
> + * The show and store routines (thare are type dependent too) are here for

they (or these ?)

> + * sysfs support (since the min and max can be updated through sysfs).
> + * The abs_value field is used to check that we are not:
> + * . falling under the very 1st min value when updating the min value
> + * through sysfs
> + * . going over the very 1st max value when updating the max value
> + * through sysfs
> * The type is known when the tunable is defined (see DEFINE_TUNABLE macro).
> */
> struct typed_value {

> Index: linux-2.6.20-rc4/kernel/autotune/akt.c
> ===================================================================
> --- linux-2.6.20-rc4.orig/kernel/autotune/akt.c 2007-01-15 15:13:31.000000000 +0100
> +++ linux-2.6.20-rc4/kernel/autotune/akt.c 2007-01-15 15:25:35.000000000 +0100
> @@ -203,5 +207,121 @@ ssize_t store_tuning_mode(struct auto_tu
> }
>
>
> +/*
> + * FUNCTION: Get operation called by tunable_attr_show (i.e. when the file
> + * /sys/tunables/<tunable>/min is displayed).
> + * Outputs the current tunable minimum value
> + *
> + * RETURN VALUE: >0 : output string length (including the '\0')
> + * <0 : failure
> + */

Since you are providing function comment header blocks, please use
the accepted kernel-doc format for (all of) these.

> +ssize_t show_tunable_min(struct auto_tune *tun_addr, char *buf)
> +{
> + ssize_t rc;
> +
> + if (tun_addr == NULL) {
> + printk(KERN_ERR
> + " show_tunable_min(): tunable address is invalid\n");
> + return -EINVAL;
> + }
> +
> + spin_lock(&tun_addr->tunable_lck);
> +
> + rc = tun_addr->min.show(tun_addr, buf);
> +
> + spin_unlock(&tun_addr->tunable_lck);
> +
> + return rc;
> +}
> +
> +
> +/*
> + * FUNCTION: Set operation called by tunable_attr_store (i.e. when a
> + * string is stored into /sys/tunables/<tunable>/min).
> + *
> + * PARAMETERS: count: input buffer size (including the '\0')
> + *
> + * RETURN VALUE: >0: number of characters used from the input buffer
> + * <= 0: failure

I would expect a return value of 0 not to indicate failure;
only <0 should do that. So is this a typo or a real case where
a return of 0 indicates failure?

> + */
> +ssize_t store_tunable_min(struct auto_tune *tun_addr, const char *buf,
> + size_t count)
> +{
> + ssize_t rc;
> +
> + if (tun_addr == NULL) {
> + printk(KERN_ERR
> + " store_tunable_min(): tunable address is invalid\n");
> + return -EINVAL;
> + }
> +
> + spin_lock(&tun_addr->tunable_lck);
> +
> + rc = tun_addr->min.store(tun_addr, buf, count);
> +
> + spin_unlock(&tun_addr->tunable_lck);
> +
> + return rc;
> +}
> +
> +
> +
> +
> +/*
> + * FUNCTION: Set operation called by tunable_attr_store (i.e. when a
> + * string is stored into /sys/tunables/<tunable>/max).
> + *
> + * PARAMETERS: count: input buffer size (including the '\0')
> + *
> + * RETURN VALUE: >0: number of characters used from the input buffer
> + * <= 0: failure

same question.

> + */
> +ssize_t store_tunable_max(struct auto_tune *tun_addr, const char *buf,
> + size_t count)
> +{
> + ssize_t rc;
> +
> + if (tun_addr == NULL) {
> + printk(KERN_ERR
> + " store_tunable_max(): tunable address is invalid\n");
> + return -EINVAL;
> + }
> +
> + spin_lock(&tun_addr->tunable_lck);
> +
> + rc = tun_addr->max.store(tun_addr, buf, count);
> +
> + spin_unlock(&tun_addr->tunable_lck);
> +
> + return rc;
> +}
> +
> +
> EXPORT_SYMBOL_GPL(register_tunable);
> EXPORT_SYMBOL_GPL(unregister_tunable);

Thanks.

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