* [PATCH 0/5] Five BFQ patches for kernel v4.14
@ 2017-08-30 18:42 Bart Van Assche
2017-08-30 18:42 ` [PATCH 1/5] bfq: Annotate fall-through in a switch statement Bart Van Assche
` (4 more replies)
0 siblings, 5 replies; 14+ messages in thread
From: Bart Van Assche @ 2017-08-30 18:42 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Bart Van Assche
Hello Jens,
This series consists of five small patches. Three patches address compiler
warnings, one patch is a fix for the BFQ sysfs interface and a fifth patch
makes the BFQ code slightly more consistent. Please consider these patches
for kernel v4.14.
Thanks,
Bart.
Bart Van Assche (5):
bfq: Annotate fall-through in a switch statement
bfq: Declare local functions static
bfq: Check kstrtoul() return value
bfq: Suppress compiler warnings about comparisons
bfq: Use icq_to_bic() consistently
block/bfq-cgroup.c | 18 +++++++-------
block/bfq-iosched.c | 71 +++++++++++++++++++++++++++++++++++------------------
2 files changed, 56 insertions(+), 33 deletions(-)
--
2.14.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/5] bfq: Annotate fall-through in a switch statement
2017-08-30 18:42 [PATCH 0/5] Five BFQ patches for kernel v4.14 Bart Van Assche
@ 2017-08-30 18:42 ` Bart Van Assche
2017-09-01 17:14 ` Paolo Valente
2017-08-30 18:42 ` [PATCH 2/5] bfq: Declare local functions static Bart Van Assche
` (3 subsequent siblings)
4 siblings, 1 reply; 14+ messages in thread
From: Bart Van Assche @ 2017-08-30 18:42 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Bart Van Assche, Paolo Valente
This patch avoids that gcc 7 issues a warning about fall-through
when building with W=1.
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Paolo Valente <paolo.valente@linaro.org>
---
block/bfq-iosched.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index 6a7a26b6cec1..8c11c2e827a5 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -3780,6 +3780,7 @@ bfq_set_next_ioprio_data(struct bfq_queue *bfqq, struct bfq_io_cq *bic)
default:
dev_err(bfqq->bfqd->queue->backing_dev_info->dev,
"bfq: bad prio class %d\n", ioprio_class);
+ /* fall through */
case IOPRIO_CLASS_NONE:
/*
* No prio set, inherit CPU scheduling settings.
--
2.14.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/5] bfq: Declare local functions static
2017-08-30 18:42 [PATCH 0/5] Five BFQ patches for kernel v4.14 Bart Van Assche
2017-08-30 18:42 ` [PATCH 1/5] bfq: Annotate fall-through in a switch statement Bart Van Assche
@ 2017-08-30 18:42 ` Bart Van Assche
2017-09-01 17:14 ` Paolo Valente
2017-08-30 18:42 ` [PATCH 3/5] bfq: Check kstrtoul() return value Bart Van Assche
` (2 subsequent siblings)
4 siblings, 1 reply; 14+ messages in thread
From: Bart Van Assche @ 2017-08-30 18:42 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Bart Van Assche, Paolo Valente
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Paolo Valente <paolo.valente@linaro.org>
---
block/bfq-cgroup.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c
index 78b2e0db4fb2..ceefb9a706d6 100644
--- a/block/bfq-cgroup.c
+++ b/block/bfq-cgroup.c
@@ -206,7 +206,7 @@ static void bfqg_get(struct bfq_group *bfqg)
bfqg->ref++;
}
-void bfqg_put(struct bfq_group *bfqg)
+static void bfqg_put(struct bfq_group *bfqg)
{
bfqg->ref--;
@@ -385,7 +385,7 @@ static struct bfq_group_data *blkcg_to_bfqgd(struct blkcg *blkcg)
return cpd_to_bfqgd(blkcg_to_cpd(blkcg, &blkcg_policy_bfq));
}
-struct blkcg_policy_data *bfq_cpd_alloc(gfp_t gfp)
+static struct blkcg_policy_data *bfq_cpd_alloc(gfp_t gfp)
{
struct bfq_group_data *bgd;
@@ -395,7 +395,7 @@ struct blkcg_policy_data *bfq_cpd_alloc(gfp_t gfp)
return &bgd->pd;
}
-void bfq_cpd_init(struct blkcg_policy_data *cpd)
+static void bfq_cpd_init(struct blkcg_policy_data *cpd)
{
struct bfq_group_data *d = cpd_to_bfqgd(cpd);
@@ -403,12 +403,12 @@ void bfq_cpd_init(struct blkcg_policy_data *cpd)
CGROUP_WEIGHT_DFL : BFQ_WEIGHT_LEGACY_DFL;
}
-void bfq_cpd_free(struct blkcg_policy_data *cpd)
+static void bfq_cpd_free(struct blkcg_policy_data *cpd)
{
kfree(cpd_to_bfqgd(cpd));
}
-struct blkg_policy_data *bfq_pd_alloc(gfp_t gfp, int node)
+static struct blkg_policy_data *bfq_pd_alloc(gfp_t gfp, int node)
{
struct bfq_group *bfqg;
@@ -426,7 +426,7 @@ struct blkg_policy_data *bfq_pd_alloc(gfp_t gfp, int node)
return &bfqg->pd;
}
-void bfq_pd_init(struct blkg_policy_data *pd)
+static void bfq_pd_init(struct blkg_policy_data *pd)
{
struct blkcg_gq *blkg = pd_to_blkg(pd);
struct bfq_group *bfqg = blkg_to_bfqg(blkg);
@@ -445,7 +445,7 @@ void bfq_pd_init(struct blkg_policy_data *pd)
bfqg->rq_pos_tree = RB_ROOT;
}
-void bfq_pd_free(struct blkg_policy_data *pd)
+static void bfq_pd_free(struct blkg_policy_data *pd)
{
struct bfq_group *bfqg = pd_to_bfqg(pd);
@@ -453,7 +453,7 @@ void bfq_pd_free(struct blkg_policy_data *pd)
bfqg_put(bfqg);
}
-void bfq_pd_reset_stats(struct blkg_policy_data *pd)
+static void bfq_pd_reset_stats(struct blkg_policy_data *pd)
{
struct bfq_group *bfqg = pd_to_bfqg(pd);
@@ -740,7 +740,7 @@ static void bfq_reparent_active_entities(struct bfq_data *bfqd,
* blkio already grabs the queue_lock for us, so no need to use
* RCU-based magic
*/
-void bfq_pd_offline(struct blkg_policy_data *pd)
+static void bfq_pd_offline(struct blkg_policy_data *pd)
{
struct bfq_service_tree *st;
struct bfq_group *bfqg = pd_to_bfqg(pd);
--
2.14.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 3/5] bfq: Check kstrtoul() return value
2017-08-30 18:42 [PATCH 0/5] Five BFQ patches for kernel v4.14 Bart Van Assche
2017-08-30 18:42 ` [PATCH 1/5] bfq: Annotate fall-through in a switch statement Bart Van Assche
2017-08-30 18:42 ` [PATCH 2/5] bfq: Declare local functions static Bart Van Assche
@ 2017-08-30 18:42 ` Bart Van Assche
2017-09-01 17:14 ` Paolo Valente
2017-08-30 18:42 ` [PATCH 4/5] bfq: Suppress compiler warnings about comparisons Bart Van Assche
2017-08-30 18:42 ` [PATCH 5/5] bfq: Use icq_to_bic() consistently Bart Van Assche
4 siblings, 1 reply; 14+ messages in thread
From: Bart Van Assche @ 2017-08-30 18:42 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Bart Van Assche, Paolo Valente
Make sysfs writes fail for invalid numbers instead of storing
uninitialized data copied from the stack. This patch removes
all uninitialized_var() occurrences from the BFQ source code.
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Paolo Valente <paolo.valente@linaro.org>
---
block/bfq-iosched.c | 52 +++++++++++++++++++++++++++++++++++++---------------
1 file changed, 37 insertions(+), 15 deletions(-)
diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index 8c11c2e827a5..cf92f16eb5f2 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -4802,13 +4802,15 @@ static ssize_t bfq_var_show(unsigned int var, char *page)
return sprintf(page, "%u\n", var);
}
-static void bfq_var_store(unsigned long *var, const char *page)
+static int bfq_var_store(unsigned long *var, const char *page)
{
unsigned long new_val;
int ret = kstrtoul(page, 10, &new_val);
- if (ret == 0)
- *var = new_val;
+ if (ret)
+ return ret;
+ *var = new_val;
+ return 0;
}
#define SHOW_FUNCTION(__FUNC, __VAR, __CONV) \
@@ -4849,8 +4851,12 @@ static ssize_t \
__FUNC(struct elevator_queue *e, const char *page, size_t count) \
{ \
struct bfq_data *bfqd = e->elevator_data; \
- unsigned long uninitialized_var(__data); \
- bfq_var_store(&__data, (page)); \
+ unsigned long __data; \
+ int ret; \
+ \
+ ret = bfq_var_store(&__data, (page)); \
+ if (ret) \
+ return ret; \
if (__data < (MIN)) \
__data = (MIN); \
else if (__data > (MAX)) \
@@ -4877,8 +4883,12 @@ STORE_FUNCTION(bfq_slice_idle_store, &bfqd->bfq_slice_idle, 0, INT_MAX, 2);
static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count)\
{ \
struct bfq_data *bfqd = e->elevator_data; \
- unsigned long uninitialized_var(__data); \
- bfq_var_store(&__data, (page)); \
+ unsigned long __data; \
+ int ret; \
+ \
+ ret = bfq_var_store(&__data, (page)); \
+ if (ret) \
+ return ret; \
if (__data < (MIN)) \
__data = (MIN); \
else if (__data > (MAX)) \
@@ -4894,9 +4904,12 @@ static ssize_t bfq_max_budget_store(struct elevator_queue *e,
const char *page, size_t count)
{
struct bfq_data *bfqd = e->elevator_data;
- unsigned long uninitialized_var(__data);
+ unsigned long __data;
+ int ret;
- bfq_var_store(&__data, (page));
+ ret = bfq_var_store(&__data, (page));
+ if (ret)
+ return ret;
if (__data == 0)
bfqd->bfq_max_budget = bfq_calc_max_budget(bfqd);
@@ -4919,9 +4932,12 @@ static ssize_t bfq_timeout_sync_store(struct elevator_queue *e,
const char *page, size_t count)
{
struct bfq_data *bfqd = e->elevator_data;
- unsigned long uninitialized_var(__data);
+ unsigned long __data;
+ int ret;
- bfq_var_store(&__data, (page));
+ ret = bfq_var_store(&__data, (page));
+ if (ret)
+ return ret;
if (__data < 1)
__data = 1;
@@ -4939,9 +4955,12 @@ static ssize_t bfq_strict_guarantees_store(struct elevator_queue *e,
const char *page, size_t count)
{
struct bfq_data *bfqd = e->elevator_data;
- unsigned long uninitialized_var(__data);
+ unsigned long __data;
+ int ret;
- bfq_var_store(&__data, (page));
+ ret = bfq_var_store(&__data, (page));
+ if (ret)
+ return ret;
if (__data > 1)
__data = 1;
@@ -4958,9 +4977,12 @@ static ssize_t bfq_low_latency_store(struct elevator_queue *e,
const char *page, size_t count)
{
struct bfq_data *bfqd = e->elevator_data;
- unsigned long uninitialized_var(__data);
+ unsigned long __data;
+ int ret;
- bfq_var_store(&__data, (page));
+ ret = bfq_var_store(&__data, (page));
+ if (ret)
+ return ret;
if (__data > 1)
__data = 1;
--
2.14.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 4/5] bfq: Suppress compiler warnings about comparisons
2017-08-30 18:42 [PATCH 0/5] Five BFQ patches for kernel v4.14 Bart Van Assche
` (2 preceding siblings ...)
2017-08-30 18:42 ` [PATCH 3/5] bfq: Check kstrtoul() return value Bart Van Assche
@ 2017-08-30 18:42 ` Bart Van Assche
2017-09-01 17:15 ` Paolo Valente
2017-08-30 18:42 ` [PATCH 5/5] bfq: Use icq_to_bic() consistently Bart Van Assche
4 siblings, 1 reply; 14+ messages in thread
From: Bart Van Assche @ 2017-08-30 18:42 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Bart Van Assche, Paolo Valente
This patch avoids that the following warnings are reported when
building with W=1:
block/bfq-iosched.c: In function 'bfq_back_seek_max_store':
block/bfq-iosched.c:4860:13: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
if (__data < (MIN)) \
^
block/bfq-iosched.c:4876:1: note: in expansion of macro 'STORE_FUNCTION'
STORE_FUNCTION(bfq_back_seek_max_store, &bfqd->bfq_back_max, 0, INT_MAX, 0);
^~~~~~~~~~~~~~
block/bfq-iosched.c: In function 'bfq_slice_idle_store':
block/bfq-iosched.c:4860:13: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
if (__data < (MIN)) \
^
block/bfq-iosched.c:4879:1: note: in expansion of macro 'STORE_FUNCTION'
STORE_FUNCTION(bfq_slice_idle_store, &bfqd->bfq_slice_idle, 0, INT_MAX, 2);
^~~~~~~~~~~~~~
block/bfq-iosched.c: In function 'bfq_slice_idle_us_store':
block/bfq-iosched.c:4892:13: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
if (__data < (MIN)) \
^
block/bfq-iosched.c:4899:1: note: in expansion of macro 'USEC_STORE_FUNCTION'
USEC_STORE_FUNCTION(bfq_slice_idle_us_store, &bfqd->bfq_slice_idle, 0,
^~~~~~~~~~~~~~~~~~~
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Paolo Valente <paolo.valente@linaro.org>
---
block/bfq-iosched.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index cf92f16eb5f2..d375b29ad085 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -4851,16 +4851,16 @@ static ssize_t \
__FUNC(struct elevator_queue *e, const char *page, size_t count) \
{ \
struct bfq_data *bfqd = e->elevator_data; \
- unsigned long __data; \
+ unsigned long __data, __min = (MIN), __max = (MAX); \
int ret; \
\
ret = bfq_var_store(&__data, (page)); \
if (ret) \
return ret; \
- if (__data < (MIN)) \
- __data = (MIN); \
- else if (__data > (MAX)) \
- __data = (MAX); \
+ if (__data < __min) \
+ __data = __min; \
+ else if (__data > __max) \
+ __data = __max; \
if (__CONV == 1) \
*(__PTR) = msecs_to_jiffies(__data); \
else if (__CONV == 2) \
@@ -4883,16 +4883,16 @@ STORE_FUNCTION(bfq_slice_idle_store, &bfqd->bfq_slice_idle, 0, INT_MAX, 2);
static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count)\
{ \
struct bfq_data *bfqd = e->elevator_data; \
- unsigned long __data; \
+ unsigned long __data, __min = (MIN), __max = (MAX); \
int ret; \
\
ret = bfq_var_store(&__data, (page)); \
if (ret) \
return ret; \
- if (__data < (MIN)) \
- __data = (MIN); \
- else if (__data > (MAX)) \
- __data = (MAX); \
+ if (__data < __min) \
+ __data = __min; \
+ else if (__data > __max) \
+ __data = __max; \
*(__PTR) = (u64)__data * NSEC_PER_USEC; \
return count; \
}
--
2.14.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 5/5] bfq: Use icq_to_bic() consistently
2017-08-30 18:42 [PATCH 0/5] Five BFQ patches for kernel v4.14 Bart Van Assche
` (3 preceding siblings ...)
2017-08-30 18:42 ` [PATCH 4/5] bfq: Suppress compiler warnings about comparisons Bart Van Assche
@ 2017-08-30 18:42 ` Bart Van Assche
2017-09-01 17:15 ` Paolo Valente
4 siblings, 1 reply; 14+ messages in thread
From: Bart Van Assche @ 2017-08-30 18:42 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Bart Van Assche, Paolo Valente
Some code uses icq_to_bic() to convert an io_cq pointer to a
bfq_io_cq pointer while other code uses a direct cast. Convert
the code that uses a direct cast such that it uses icq_to_bic().
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Paolo Valente <paolo.valente@linaro.org>
---
block/bfq-iosched.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index d375b29ad085..7d1b85e393b2 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -239,7 +239,7 @@ static int T_slow[2];
static int T_fast[2];
static int device_speed_thresh[2];
-#define RQ_BIC(rq) ((struct bfq_io_cq *) (rq)->elv.priv[0])
+#define RQ_BIC(rq) icq_to_bic((rq)->elv.priv[0])
#define RQ_BFQQ(rq) ((rq)->elv.priv[1])
struct bfq_queue *bic_to_bfqq(struct bfq_io_cq *bic, bool is_sync)
--
2.14.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 1/5] bfq: Annotate fall-through in a switch statement
2017-08-30 18:42 ` [PATCH 1/5] bfq: Annotate fall-through in a switch statement Bart Van Assche
@ 2017-09-01 17:14 ` Paolo Valente
0 siblings, 0 replies; 14+ messages in thread
From: Paolo Valente @ 2017-09-01 17:14 UTC (permalink / raw)
To: Bart Van Assche; +Cc: Jens Axboe, linux-block
> Il giorno 30 ago 2017, alle ore 20:42, Bart Van Assche =
<bart.vanassche@wdc.com> ha scritto:
>=20
> This patch avoids that gcc 7 issues a warning about fall-through
> when building with W=3D1.
>=20
> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> Cc: Paolo Valente <paolo.valente@linaro.org>
Acked-by: Paolo Valente <paolo.valente@linaro.org>
> ---
> block/bfq-iosched.c | 1 +
> 1 file changed, 1 insertion(+)
>=20
> diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
> index 6a7a26b6cec1..8c11c2e827a5 100644
> --- a/block/bfq-iosched.c
> +++ b/block/bfq-iosched.c
> @@ -3780,6 +3780,7 @@ bfq_set_next_ioprio_data(struct bfq_queue *bfqq, =
struct bfq_io_cq *bic)
> default:
> dev_err(bfqq->bfqd->queue->backing_dev_info->dev,
> "bfq: bad prio class %d\n", ioprio_class);
> + /* fall through */
> case IOPRIO_CLASS_NONE:
> /*
> * No prio set, inherit CPU scheduling settings.
> --=20
> 2.14.1
>=20
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/5] bfq: Declare local functions static
2017-08-30 18:42 ` [PATCH 2/5] bfq: Declare local functions static Bart Van Assche
@ 2017-09-01 17:14 ` Paolo Valente
0 siblings, 0 replies; 14+ messages in thread
From: Paolo Valente @ 2017-09-01 17:14 UTC (permalink / raw)
To: Bart Van Assche; +Cc: Jens Axboe, linux-block
> Il giorno 30 ago 2017, alle ore 20:42, Bart Van Assche =
<bart.vanassche@wdc.com> ha scritto:
>=20
> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> Cc: Paolo Valente <paolo.valente@linaro.org>
Acked-by: Paolo Valente <paolo.valente@linaro.org>
> ---
> block/bfq-cgroup.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>=20
> diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c
> index 78b2e0db4fb2..ceefb9a706d6 100644
> --- a/block/bfq-cgroup.c
> +++ b/block/bfq-cgroup.c
> @@ -206,7 +206,7 @@ static void bfqg_get(struct bfq_group *bfqg)
> bfqg->ref++;
> }
>=20
> -void bfqg_put(struct bfq_group *bfqg)
> +static void bfqg_put(struct bfq_group *bfqg)
> {
> bfqg->ref--;
>=20
> @@ -385,7 +385,7 @@ static struct bfq_group_data =
*blkcg_to_bfqgd(struct blkcg *blkcg)
> return cpd_to_bfqgd(blkcg_to_cpd(blkcg, &blkcg_policy_bfq));
> }
>=20
> -struct blkcg_policy_data *bfq_cpd_alloc(gfp_t gfp)
> +static struct blkcg_policy_data *bfq_cpd_alloc(gfp_t gfp)
> {
> struct bfq_group_data *bgd;
>=20
> @@ -395,7 +395,7 @@ struct blkcg_policy_data *bfq_cpd_alloc(gfp_t gfp)
> return &bgd->pd;
> }
>=20
> -void bfq_cpd_init(struct blkcg_policy_data *cpd)
> +static void bfq_cpd_init(struct blkcg_policy_data *cpd)
> {
> struct bfq_group_data *d =3D cpd_to_bfqgd(cpd);
>=20
> @@ -403,12 +403,12 @@ void bfq_cpd_init(struct blkcg_policy_data *cpd)
> CGROUP_WEIGHT_DFL : BFQ_WEIGHT_LEGACY_DFL;
> }
>=20
> -void bfq_cpd_free(struct blkcg_policy_data *cpd)
> +static void bfq_cpd_free(struct blkcg_policy_data *cpd)
> {
> kfree(cpd_to_bfqgd(cpd));
> }
>=20
> -struct blkg_policy_data *bfq_pd_alloc(gfp_t gfp, int node)
> +static struct blkg_policy_data *bfq_pd_alloc(gfp_t gfp, int node)
> {
> struct bfq_group *bfqg;
>=20
> @@ -426,7 +426,7 @@ struct blkg_policy_data *bfq_pd_alloc(gfp_t gfp, =
int node)
> return &bfqg->pd;
> }
>=20
> -void bfq_pd_init(struct blkg_policy_data *pd)
> +static void bfq_pd_init(struct blkg_policy_data *pd)
> {
> struct blkcg_gq *blkg =3D pd_to_blkg(pd);
> struct bfq_group *bfqg =3D blkg_to_bfqg(blkg);
> @@ -445,7 +445,7 @@ void bfq_pd_init(struct blkg_policy_data *pd)
> bfqg->rq_pos_tree =3D RB_ROOT;
> }
>=20
> -void bfq_pd_free(struct blkg_policy_data *pd)
> +static void bfq_pd_free(struct blkg_policy_data *pd)
> {
> struct bfq_group *bfqg =3D pd_to_bfqg(pd);
>=20
> @@ -453,7 +453,7 @@ void bfq_pd_free(struct blkg_policy_data *pd)
> bfqg_put(bfqg);
> }
>=20
> -void bfq_pd_reset_stats(struct blkg_policy_data *pd)
> +static void bfq_pd_reset_stats(struct blkg_policy_data *pd)
> {
> struct bfq_group *bfqg =3D pd_to_bfqg(pd);
>=20
> @@ -740,7 +740,7 @@ static void bfq_reparent_active_entities(struct =
bfq_data *bfqd,
> * blkio already grabs the queue_lock for us, so no need to use
> * RCU-based magic
> */
> -void bfq_pd_offline(struct blkg_policy_data *pd)
> +static void bfq_pd_offline(struct blkg_policy_data *pd)
> {
> struct bfq_service_tree *st;
> struct bfq_group *bfqg =3D pd_to_bfqg(pd);
> --=20
> 2.14.1
>=20
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/5] bfq: Check kstrtoul() return value
2017-08-30 18:42 ` [PATCH 3/5] bfq: Check kstrtoul() return value Bart Van Assche
@ 2017-09-01 17:14 ` Paolo Valente
2017-09-01 17:37 ` weiping zhang
0 siblings, 1 reply; 14+ messages in thread
From: Paolo Valente @ 2017-09-01 17:14 UTC (permalink / raw)
To: Bart Van Assche; +Cc: Jens Axboe, linux-block
> Il giorno 30 ago 2017, alle ore 20:42, Bart Van Assche =
<bart.vanassche@wdc.com> ha scritto:
>=20
> Make sysfs writes fail for invalid numbers instead of storing
> uninitialized data copied from the stack. This patch removes
> all uninitialized_var() occurrences from the BFQ source code.
>=20
> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> Cc: Paolo Valente <paolo.valente@linaro.org>
Acked-by: Paolo Valente <paolo.valente@linaro.org>
> ---
> block/bfq-iosched.c | 52 =
+++++++++++++++++++++++++++++++++++++---------------
> 1 file changed, 37 insertions(+), 15 deletions(-)
>=20
> diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
> index 8c11c2e827a5..cf92f16eb5f2 100644
> --- a/block/bfq-iosched.c
> +++ b/block/bfq-iosched.c
> @@ -4802,13 +4802,15 @@ static ssize_t bfq_var_show(unsigned int var, =
char *page)
> return sprintf(page, "%u\n", var);
> }
>=20
> -static void bfq_var_store(unsigned long *var, const char *page)
> +static int bfq_var_store(unsigned long *var, const char *page)
> {
> unsigned long new_val;
> int ret =3D kstrtoul(page, 10, &new_val);
>=20
> - if (ret =3D=3D 0)
> - *var =3D new_val;
> + if (ret)
> + return ret;
> + *var =3D new_val;
> + return 0;
> }
>=20
> #define SHOW_FUNCTION(__FUNC, __VAR, __CONV) =
\
> @@ -4849,8 +4851,12 @@ static ssize_t =
\
> __FUNC(struct elevator_queue *e, const char *page, size_t count) =
\
> { =
\
> struct bfq_data *bfqd =3D e->elevator_data; =
\
> - unsigned long uninitialized_var(__data); =
\
> - bfq_var_store(&__data, (page)); =
\
> + unsigned long __data; =
\
> + int ret; =
\
> + =
\
> + ret =3D bfq_var_store(&__data, (page)); =
\
> + if (ret) =
\
> + return ret; =
\
> if (__data < (MIN)) =
\
> __data =3D (MIN); =
\
> else if (__data > (MAX)) =
\
> @@ -4877,8 +4883,12 @@ STORE_FUNCTION(bfq_slice_idle_store, =
&bfqd->bfq_slice_idle, 0, INT_MAX, 2);
> static ssize_t __FUNC(struct elevator_queue *e, const char *page, =
size_t count)\
> { =
\
> struct bfq_data *bfqd =3D e->elevator_data; =
\
> - unsigned long uninitialized_var(__data); =
\
> - bfq_var_store(&__data, (page)); =
\
> + unsigned long __data; =
\
> + int ret; =
\
> + =
\
> + ret =3D bfq_var_store(&__data, (page)); =
\
> + if (ret) =
\
> + return ret; =
\
> if (__data < (MIN)) =
\
> __data =3D (MIN); =
\
> else if (__data > (MAX)) =
\
> @@ -4894,9 +4904,12 @@ static ssize_t bfq_max_budget_store(struct =
elevator_queue *e,
> const char *page, size_t count)
> {
> struct bfq_data *bfqd =3D e->elevator_data;
> - unsigned long uninitialized_var(__data);
> + unsigned long __data;
> + int ret;
>=20
> - bfq_var_store(&__data, (page));
> + ret =3D bfq_var_store(&__data, (page));
> + if (ret)
> + return ret;
>=20
> if (__data =3D=3D 0)
> bfqd->bfq_max_budget =3D bfq_calc_max_budget(bfqd);
> @@ -4919,9 +4932,12 @@ static ssize_t bfq_timeout_sync_store(struct =
elevator_queue *e,
> const char *page, size_t count)
> {
> struct bfq_data *bfqd =3D e->elevator_data;
> - unsigned long uninitialized_var(__data);
> + unsigned long __data;
> + int ret;
>=20
> - bfq_var_store(&__data, (page));
> + ret =3D bfq_var_store(&__data, (page));
> + if (ret)
> + return ret;
>=20
> if (__data < 1)
> __data =3D 1;
> @@ -4939,9 +4955,12 @@ static ssize_t =
bfq_strict_guarantees_store(struct elevator_queue *e,
> const char *page, size_t count)
> {
> struct bfq_data *bfqd =3D e->elevator_data;
> - unsigned long uninitialized_var(__data);
> + unsigned long __data;
> + int ret;
>=20
> - bfq_var_store(&__data, (page));
> + ret =3D bfq_var_store(&__data, (page));
> + if (ret)
> + return ret;
>=20
> if (__data > 1)
> __data =3D 1;
> @@ -4958,9 +4977,12 @@ static ssize_t bfq_low_latency_store(struct =
elevator_queue *e,
> const char *page, size_t count)
> {
> struct bfq_data *bfqd =3D e->elevator_data;
> - unsigned long uninitialized_var(__data);
> + unsigned long __data;
> + int ret;
>=20
> - bfq_var_store(&__data, (page));
> + ret =3D bfq_var_store(&__data, (page));
> + if (ret)
> + return ret;
>=20
> if (__data > 1)
> __data =3D 1;
> --=20
> 2.14.1
>=20
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 5/5] bfq: Use icq_to_bic() consistently
2017-08-30 18:42 ` [PATCH 5/5] bfq: Use icq_to_bic() consistently Bart Van Assche
@ 2017-09-01 17:15 ` Paolo Valente
0 siblings, 0 replies; 14+ messages in thread
From: Paolo Valente @ 2017-09-01 17:15 UTC (permalink / raw)
To: Bart Van Assche; +Cc: Jens Axboe, linux-block
> Il giorno 30 ago 2017, alle ore 20:42, Bart Van Assche =
<bart.vanassche@wdc.com> ha scritto:
>=20
> Some code uses icq_to_bic() to convert an io_cq pointer to a
> bfq_io_cq pointer while other code uses a direct cast. Convert
> the code that uses a direct cast such that it uses icq_to_bic().
>=20
> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> Cc: Paolo Valente <paolo.valente@linaro.org>
Acked-by: Paolo Valente <paolo.valente@linaro.org>
> ---
> block/bfq-iosched.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>=20
> diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
> index d375b29ad085..7d1b85e393b2 100644
> --- a/block/bfq-iosched.c
> +++ b/block/bfq-iosched.c
> @@ -239,7 +239,7 @@ static int T_slow[2];
> static int T_fast[2];
> static int device_speed_thresh[2];
>=20
> -#define RQ_BIC(rq) ((struct bfq_io_cq *) (rq)->elv.priv[0])
> +#define RQ_BIC(rq) icq_to_bic((rq)->elv.priv[0])
> #define RQ_BFQQ(rq) ((rq)->elv.priv[1])
>=20
> struct bfq_queue *bic_to_bfqq(struct bfq_io_cq *bic, bool is_sync)
> --=20
> 2.14.1
>=20
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 4/5] bfq: Suppress compiler warnings about comparisons
2017-08-30 18:42 ` [PATCH 4/5] bfq: Suppress compiler warnings about comparisons Bart Van Assche
@ 2017-09-01 17:15 ` Paolo Valente
0 siblings, 0 replies; 14+ messages in thread
From: Paolo Valente @ 2017-09-01 17:15 UTC (permalink / raw)
To: Bart Van Assche; +Cc: Jens Axboe, linux-block
> Il giorno 30 ago 2017, alle ore 20:42, Bart Van Assche =
<bart.vanassche@wdc.com> ha scritto:
>=20
> This patch avoids that the following warnings are reported when
> building with W=3D1:
>=20
> block/bfq-iosched.c: In function 'bfq_back_seek_max_store':
> block/bfq-iosched.c:4860:13: warning: comparison of unsigned =
expression < 0 is always false [-Wtype-limits]
> if (__data < (MIN)) \
> ^
> block/bfq-iosched.c:4876:1: note: in expansion of macro =
'STORE_FUNCTION'
> STORE_FUNCTION(bfq_back_seek_max_store, &bfqd->bfq_back_max, 0, =
INT_MAX, 0);
> ^~~~~~~~~~~~~~
> block/bfq-iosched.c: In function 'bfq_slice_idle_store':
> block/bfq-iosched.c:4860:13: warning: comparison of unsigned =
expression < 0 is always false [-Wtype-limits]
> if (__data < (MIN)) \
> ^
> block/bfq-iosched.c:4879:1: note: in expansion of macro =
'STORE_FUNCTION'
> STORE_FUNCTION(bfq_slice_idle_store, &bfqd->bfq_slice_idle, 0, =
INT_MAX, 2);
> ^~~~~~~~~~~~~~
> block/bfq-iosched.c: In function 'bfq_slice_idle_us_store':
> block/bfq-iosched.c:4892:13: warning: comparison of unsigned =
expression < 0 is always false [-Wtype-limits]
> if (__data < (MIN)) \
> ^
> block/bfq-iosched.c:4899:1: note: in expansion of macro =
'USEC_STORE_FUNCTION'
> USEC_STORE_FUNCTION(bfq_slice_idle_us_store, &bfqd->bfq_slice_idle, 0,
> ^~~~~~~~~~~~~~~~~~~
>=20
> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> Cc: Paolo Valente <paolo.valente@linaro.org>
Acked-by: Paolo Valente <paolo.valente@linaro.org>
> ---
> block/bfq-iosched.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>=20
> diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
> index cf92f16eb5f2..d375b29ad085 100644
> --- a/block/bfq-iosched.c
> +++ b/block/bfq-iosched.c
> @@ -4851,16 +4851,16 @@ static ssize_t =
\
> __FUNC(struct elevator_queue *e, const char *page, size_t count) =
\
> { =
\
> struct bfq_data *bfqd =3D e->elevator_data; =
\
> - unsigned long __data; =
\
> + unsigned long __data, __min =3D (MIN), __max =3D (MAX); =
\
> int ret; =
\
> =
\
> ret =3D bfq_var_store(&__data, (page)); =
\
> if (ret) =
\
> return ret; =
\
> - if (__data < (MIN)) =
\
> - __data =3D (MIN); =
\
> - else if (__data > (MAX)) =
\
> - __data =3D (MAX); =
\
> + if (__data < __min) =
\
> + __data =3D __min; =
\
> + else if (__data > __max) =
\
> + __data =3D __max; =
\
> if (__CONV =3D=3D 1) =
\
> *(__PTR) =3D msecs_to_jiffies(__data); =
\
> else if (__CONV =3D=3D 2) =
\
> @@ -4883,16 +4883,16 @@ STORE_FUNCTION(bfq_slice_idle_store, =
&bfqd->bfq_slice_idle, 0, INT_MAX, 2);
> static ssize_t __FUNC(struct elevator_queue *e, const char *page, =
size_t count)\
> { =
\
> struct bfq_data *bfqd =3D e->elevator_data; =
\
> - unsigned long __data; =
\
> + unsigned long __data, __min =3D (MIN), __max =3D (MAX); =
\
> int ret; =
\
> =
\
> ret =3D bfq_var_store(&__data, (page)); =
\
> if (ret) =
\
> return ret; =
\
> - if (__data < (MIN)) =
\
> - __data =3D (MIN); =
\
> - else if (__data > (MAX)) =
\
> - __data =3D (MAX); =
\
> + if (__data < __min) =
\
> + __data =3D __min; =
\
> + else if (__data > __max) =
\
> + __data =3D __max; =
\
> *(__PTR) =3D (u64)__data * NSEC_PER_USEC; =
\
> return count; =
\
> }
> --=20
> 2.14.1
>=20
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/5] bfq: Check kstrtoul() return value
2017-09-01 17:14 ` Paolo Valente
@ 2017-09-01 17:37 ` weiping zhang
2017-09-01 17:41 ` Bart Van Assche
0 siblings, 1 reply; 14+ messages in thread
From: weiping zhang @ 2017-09-01 17:37 UTC (permalink / raw)
To: Paolo Valente; +Cc: Bart Van Assche, Jens Axboe, linux-block
2017-09-02 1:14 GMT+08:00 Paolo Valente <paolo.valente@linaro.org>:
>
>> Il giorno 30 ago 2017, alle ore 20:42, Bart Van Assche <bart.vanassche@wdc.com> ha scritto:
>>
>> Make sysfs writes fail for invalid numbers instead of storing
>> uninitialized data copied from the stack. This patch removes
>> all uninitialized_var() occurrences from the BFQ source code.
>>
>> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
>> Cc: Paolo Valente <paolo.valente@linaro.org>
>
> Acked-by: Paolo Valente <paolo.valente@linaro.org>
>
Hi Bart,
how about using simple_strtoul which was used in cfq/mq-iosched.c
*var = simple_strtoul(p, &p, 10);
if invalid string came from sysfs, this function just return 0,
and there are validations after every calling bfq_var_store.
Thanks
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/5] bfq: Check kstrtoul() return value
2017-09-01 17:37 ` weiping zhang
@ 2017-09-01 17:41 ` Bart Van Assche
2017-09-01 18:06 ` weiping zhang
0 siblings, 1 reply; 14+ messages in thread
From: Bart Van Assche @ 2017-09-01 17:41 UTC (permalink / raw)
To: zwp10758, paolo.valente; +Cc: linux-block, axboe
T24gU2F0LCAyMDE3LTA5LTAyIGF0IDAxOjM3ICswODAwLCB3ZWlwaW5nIHpoYW5nIHdyb3RlOg0K
PiAyMDE3LTA5LTAyIDE6MTQgR01UKzA4OjAwIFBhb2xvIFZhbGVudGUgPHBhb2xvLnZhbGVudGVA
bGluYXJvLm9yZz46DQo+ID4gSWwgZ2lvcm5vIDMwIGFnbyAyMDE3LCBhbGxlIG9yZSAyMDo0Miwg
QmFydCBWYW4gQXNzY2hlIDxiYXJ0LnZhbmFzc2NoZUB3ZGMuY29tPiBoYSBzY3JpdHRvOg0KPiA+
ID4gDQo+ID4gPiBNYWtlIHN5c2ZzIHdyaXRlcyBmYWlsIGZvciBpbnZhbGlkIG51bWJlcnMgaW5z
dGVhZCBvZiBzdG9yaW5nDQo+ID4gPiB1bmluaXRpYWxpemVkIGRhdGEgY29waWVkIGZyb20gdGhl
IHN0YWNrLiBUaGlzIHBhdGNoIHJlbW92ZXMNCj4gPiA+IGFsbCB1bmluaXRpYWxpemVkX3Zhcigp
IG9jY3VycmVuY2VzIGZyb20gdGhlIEJGUSBzb3VyY2UgY29kZS4NCj4gPiA+IA0KPiA+ID4gU2ln
bmVkLW9mZi1ieTogQmFydCBWYW4gQXNzY2hlIDxiYXJ0LnZhbmFzc2NoZUB3ZGMuY29tPg0KPiA+
ID4gQ2M6IFBhb2xvIFZhbGVudGUgPHBhb2xvLnZhbGVudGVAbGluYXJvLm9yZz4NCj4gPiANCj4g
PiBBY2tlZC1ieTogUGFvbG8gVmFsZW50ZSA8cGFvbG8udmFsZW50ZUBsaW5hcm8ub3JnPg0KPiAN
Cj4gaG93IGFib3V0IHVzaW5nIHNpbXBsZV9zdHJ0b3VsICB3aGljaCB3YXMgdXNlZCBpbiBjZnEv
bXEtaW9zY2hlZC5jDQo+ICp2YXIgPSBzaW1wbGVfc3RydG91bChwLCAmcCwgMTApOw0KPiANCj4g
aWYgaW52YWxpZCBzdHJpbmcgY2FtZSBmcm9tIHN5c2ZzLCB0aGlzIGZ1bmN0aW9uIGp1c3QgcmV0
dXJuIDAsDQo+IGFuZCB0aGVyZSBhcmUgdmFsaWRhdGlvbnMgYWZ0ZXIgZXZlcnkgY2FsbGluZyBi
ZnFfdmFyX3N0b3JlLg0KDQpIZWxsbyBXZWlwaW5nLA0KDQpTb3JyeSBidXQgSSBkbyBub3QgbGlr
ZSB0aGlzIHByb3Bvc2FsIGJlY2F1c2U6DQoqIElmIGludmFsaWQgaW5wdXQgaXMgcHJvdmlkZWQg
d3JpdGluZyBpbnRvIGEgc3lzZnMgYXR0cmlidXRlIHNob3VsZCBmYWlsDQogIGluc3RlYWQgb2Yg
aWdub3JpbmcgdGhlIGludmFsaWQgaW5wdXQgc2lsZW50bHkuDQoqIHNpbXBsZV9zdHJ0b3VsKCkg
aXMgY29uc2lkZXJlZCBvYnNvbGV0ZSBhbmQgbXVzdCBub3QgYmUgdXNlZCBpbiBuZXcgY29kZS4N
CiAgRnJvbSBpbmNsdWRlL2xpbnV4L2tlcm5lbC5oOg0KDQovKiBPYnNvbGV0ZSwgZG8gbm90IHVz
ZS4gIFVzZSBrc3RydG88Zm9vPiBpbnN0ZWFkICovDQoNCmV4dGVybiB1bnNpZ25lZCBsb25nIHNp
bXBsZV9zdHJ0b3VsKGNvbnN0IGNoYXIgKixjaGFyICoqLHVuc2lnbmVkIGludCk7DQpleHRlcm4g
bG9uZyBzaW1wbGVfc3RydG9sKGNvbnN0IGNoYXIgKixjaGFyICoqLHVuc2lnbmVkIGludCk7DQpl
eHRlcm4gdW5zaWduZWQgbG9uZyBsb25nIHNpbXBsZV9zdHJ0b3VsbChjb25zdCBjaGFyICosY2hh
ciAqKix1bnNpZ25lZCBpbnQpOw0KZXh0ZXJuIGxvbmcgbG9uZyBzaW1wbGVfc3RydG9sbChjb25z
dCBjaGFyICosY2hhciAqKix1bnNpZ25lZCBpbnQpOw0KDQpCYXJ0Lg==
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/5] bfq: Check kstrtoul() return value
2017-09-01 17:41 ` Bart Van Assche
@ 2017-09-01 18:06 ` weiping zhang
0 siblings, 0 replies; 14+ messages in thread
From: weiping zhang @ 2017-09-01 18:06 UTC (permalink / raw)
To: Bart Van Assche; +Cc: paolo.valente, linux-block, axboe
> Sorry but I do not like this proposal because:
> * If invalid input is provided writing into a sysfs attribute should fail
> instead of ignoring the invalid input silently.
> * simple_strtoul() is considered obsolete and must not be used in new code.
> From include/linux/kernel.h:
>
> /* Obsolete, do not use. Use kstrto<foo> instead */
>
> extern unsigned long simple_strtoul(const char *,char **,unsigned int);
> extern long simple_strtol(const char *,char **,unsigned int);
> extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
> extern long long simple_strtoll(const char *,char **,unsigned int);
>
Hello Bart,
Agree with you, it seems more reasonable to give error message to user.
Thanks
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2017-09-01 18:06 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-30 18:42 [PATCH 0/5] Five BFQ patches for kernel v4.14 Bart Van Assche
2017-08-30 18:42 ` [PATCH 1/5] bfq: Annotate fall-through in a switch statement Bart Van Assche
2017-09-01 17:14 ` Paolo Valente
2017-08-30 18:42 ` [PATCH 2/5] bfq: Declare local functions static Bart Van Assche
2017-09-01 17:14 ` Paolo Valente
2017-08-30 18:42 ` [PATCH 3/5] bfq: Check kstrtoul() return value Bart Van Assche
2017-09-01 17:14 ` Paolo Valente
2017-09-01 17:37 ` weiping zhang
2017-09-01 17:41 ` Bart Van Assche
2017-09-01 18:06 ` weiping zhang
2017-08-30 18:42 ` [PATCH 4/5] bfq: Suppress compiler warnings about comparisons Bart Van Assche
2017-09-01 17:15 ` Paolo Valente
2017-08-30 18:42 ` [PATCH 5/5] bfq: Use icq_to_bic() consistently Bart Van Assche
2017-09-01 17:15 ` Paolo Valente
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.