All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] block: add a new flag BLK_MQ_POLL_CLASSIC for hybrid poll
@ 2019-03-15  4:24 Yufen Yu
  2019-03-15 16:11 ` Damien Le Moal
  0 siblings, 1 reply; 3+ messages in thread
From: Yufen Yu @ 2019-03-15  4:24 UTC (permalink / raw)
  To: axboe, Damien.LeMoal, marcos.souza.org; +Cc: linux-block

For q->poll_nsec == -1, means doing classic poll, not hybrid poll.
We introduce a new flag BLK_MQ_POLL_CLASSIC to replace -1, which
may make code much easier to read.

Signed-off-by: Yufen Yu <yuyufen@huawei.com>
---
 block/blk-mq.c         | 4 ++--
 block/blk-sysfs.c      | 8 ++++----
 include/linux/blkdev.h | 3 +++
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index a9c181603cbd..1c588e5c4a02 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2857,7 +2857,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
 	/*
 	 * Default to classic polling
 	 */
-	q->poll_nsec = -1;
+	q->poll_nsec = BLK_MQ_POLL_CLASSIC;
 
 	blk_mq_init_cpu_queues(q, set->nr_hw_queues);
 	blk_mq_add_queue_tag_set(set, q);
@@ -3392,7 +3392,7 @@ static bool blk_mq_poll_hybrid(struct request_queue *q,
 {
 	struct request *rq;
 
-	if (q->poll_nsec == -1)
+	if (q->poll_nsec == BLK_MQ_POLL_CLASSIC)
 		return false;
 
 	if (!blk_qc_t_is_internal(cookie))
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 59685918167e..cd127067998a 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -360,8 +360,8 @@ static ssize_t queue_poll_delay_show(struct request_queue *q, char *page)
 {
 	int val;
 
-	if (q->poll_nsec == -1)
-		val = -1;
+	if (q->poll_nsec == BLK_MQ_POLL_CLASSIC)
+		val = BLK_MQ_POLL_CLASSIC;
 	else
 		val = q->poll_nsec / 1000;
 
@@ -380,8 +380,8 @@ static ssize_t queue_poll_delay_store(struct request_queue *q, const char *page,
 	if (err < 0)
 		return err;
 
-	if (val == -1)
-		q->poll_nsec = -1;
+	if (val == BLK_MQ_POLL_CLASSIC)
+		q->poll_nsec = BLK_MQ_POLL_CLASSIC;
 	else
 		q->poll_nsec = val * 1000;
 
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 0de92b29f589..5c58a3b2bf00 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -50,6 +50,9 @@ struct blk_stat_callback;
 /* Must be consistent with blk_mq_poll_stats_bkt() */
 #define BLK_MQ_POLL_STATS_BKTS 16
 
+/* Doing classic polling */
+#define BLK_MQ_POLL_CLASSIC -1
+
 /*
  * Maximum number of blkcg policies allowed to be registered concurrently.
  * Defined here to simplify include dependency.
-- 
2.16.2.dirty


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] block: add a new flag BLK_MQ_POLL_CLASSIC for hybrid poll
  2019-03-15  4:24 [PATCH v3] block: add a new flag BLK_MQ_POLL_CLASSIC for hybrid poll Yufen Yu
@ 2019-03-15 16:11 ` Damien Le Moal
  2019-03-18 14:11   ` yuyufen
  0 siblings, 1 reply; 3+ messages in thread
From: Damien Le Moal @ 2019-03-15 16:11 UTC (permalink / raw)
  To: Yufen Yu, axboe, marcos.souza.org; +Cc: linux-block

On 2019/03/14 21:19, Yufen Yu wrote:
> For q->poll_nsec == -1, means doing classic poll, not hybrid poll.
> We introduce a new flag BLK_MQ_POLL_CLASSIC to replace -1, which
> may make code much easier to read.
> 
> Signed-off-by: Yufen Yu <yuyufen@huawei.com>
> ---
>  block/blk-mq.c         | 4 ++--
>  block/blk-sysfs.c      | 8 ++++----
>  include/linux/blkdev.h | 3 +++
>  3 files changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index a9c181603cbd..1c588e5c4a02 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -2857,7 +2857,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
>  	/*
>  	 * Default to classic polling
>  	 */
> -	q->poll_nsec = -1;
> +	q->poll_nsec = BLK_MQ_POLL_CLASSIC;
>  
>  	blk_mq_init_cpu_queues(q, set->nr_hw_queues);
>  	blk_mq_add_queue_tag_set(set, q);
> @@ -3392,7 +3392,7 @@ static bool blk_mq_poll_hybrid(struct request_queue *q,
>  {
>  	struct request *rq;
>  
> -	if (q->poll_nsec == -1)
> +	if (q->poll_nsec == BLK_MQ_POLL_CLASSIC)
>  		return false;
>  
>  	if (!blk_qc_t_is_internal(cookie))
> diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
> index 59685918167e..cd127067998a 100644
> --- a/block/blk-sysfs.c
> +++ b/block/blk-sysfs.c
> @@ -360,8 +360,8 @@ static ssize_t queue_poll_delay_show(struct request_queue *q, char *page)
>  {
>  	int val;
>  
> -	if (q->poll_nsec == -1)
> -		val = -1;
> +	if (q->poll_nsec == BLK_MQ_POLL_CLASSIC)
> +		val = BLK_MQ_POLL_CLASSIC;
>  	else
>  		val = q->poll_nsec / 1000;
>  
> @@ -380,8 +380,8 @@ static ssize_t queue_poll_delay_store(struct request_queue *q, const char *page,
>  	if (err < 0)
>  		return err;
>  
> -	if (val == -1)
> -		q->poll_nsec = -1;
> +	if (val == BLK_MQ_POLL_CLASSIC)
> +		q->poll_nsec = BLK_MQ_POLL_CLASSIC;
>  	else
>  		q->poll_nsec = val * 1000;

You are not handling negative values other than -1 here as we discussed. Any
reason for not adding the check ?

>  
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 0de92b29f589..5c58a3b2bf00 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -50,6 +50,9 @@ struct blk_stat_callback;
>  /* Must be consistent with blk_mq_poll_stats_bkt() */
>  #define BLK_MQ_POLL_STATS_BKTS 16
>  
> +/* Doing classic polling */
> +#define BLK_MQ_POLL_CLASSIC -1
> +
>  /*
>   * Maximum number of blkcg policies allowed to be registered concurrently.
>   * Defined here to simplify include dependency.
> 
-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] block: add a new flag BLK_MQ_POLL_CLASSIC for hybrid poll
  2019-03-15 16:11 ` Damien Le Moal
@ 2019-03-18 14:11   ` yuyufen
  0 siblings, 0 replies; 3+ messages in thread
From: yuyufen @ 2019-03-18 14:11 UTC (permalink / raw)
  To: Damien Le Moal, axboe, marcos.souza.org; +Cc: linux-block



On 2019/3/16 0:11, Damien Le Moal wrote:
> On 2019/03/14 21:19, Yufen Yu wrote:
>> For q->poll_nsec == -1, means doing classic poll, not hybrid poll.
>> We introduce a new flag BLK_MQ_POLL_CLASSIC to replace -1, which
>> may make code much easier to read.
>>
>> Signed-off-by: Yufen Yu <yuyufen@huawei.com>
>> ---
>>   block/blk-mq.c         | 4 ++--
>>   block/blk-sysfs.c      | 8 ++++----
>>   include/linux/blkdev.h | 3 +++
>>   3 files changed, 9 insertions(+), 6 deletions(-)
>>
>> diff --git a/block/blk-mq.c b/block/blk-mq.c
>> index a9c181603cbd..1c588e5c4a02 100644
>> --- a/block/blk-mq.c
>> +++ b/block/blk-mq.c
>> @@ -2857,7 +2857,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
>>   	/*
>>   	 * Default to classic polling
>>   	 */
>> -	q->poll_nsec = -1;
>> +	q->poll_nsec = BLK_MQ_POLL_CLASSIC;
>>   
>>   	blk_mq_init_cpu_queues(q, set->nr_hw_queues);
>>   	blk_mq_add_queue_tag_set(set, q);
>> @@ -3392,7 +3392,7 @@ static bool blk_mq_poll_hybrid(struct request_queue *q,
>>   {
>>   	struct request *rq;
>>   
>> -	if (q->poll_nsec == -1)
>> +	if (q->poll_nsec == BLK_MQ_POLL_CLASSIC)
>>   		return false;
>>   
>>   	if (!blk_qc_t_is_internal(cookie))
>> diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
>> index 59685918167e..cd127067998a 100644
>> --- a/block/blk-sysfs.c
>> +++ b/block/blk-sysfs.c
>> @@ -360,8 +360,8 @@ static ssize_t queue_poll_delay_show(struct request_queue *q, char *page)
>>   {
>>   	int val;
>>   
>> -	if (q->poll_nsec == -1)
>> -		val = -1;
>> +	if (q->poll_nsec == BLK_MQ_POLL_CLASSIC)
>> +		val = BLK_MQ_POLL_CLASSIC;
>>   	else
>>   		val = q->poll_nsec / 1000;
>>   
>> @@ -380,8 +380,8 @@ static ssize_t queue_poll_delay_store(struct request_queue *q, const char *page,
>>   	if (err < 0)
>>   		return err;
>>   
>> -	if (val == -1)
>> -		q->poll_nsec = -1;
>> +	if (val == BLK_MQ_POLL_CLASSIC)
>> +		q->poll_nsec = BLK_MQ_POLL_CLASSIC;
>>   	else
>>   		q->poll_nsec = val * 1000;
> You are not handling negative values other than -1 here as we discussed. Any
> reason for not adding the check ?

Oops, I send the wrong version.
Thanks again for your review and suggestion.

Yufen.
thanks

>>   
>> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
>> index 0de92b29f589..5c58a3b2bf00 100644
>> --- a/include/linux/blkdev.h
>> +++ b/include/linux/blkdev.h
>> @@ -50,6 +50,9 @@ struct blk_stat_callback;
>>   /* Must be consistent with blk_mq_poll_stats_bkt() */
>>   #define BLK_MQ_POLL_STATS_BKTS 16
>>   
>> +/* Doing classic polling */
>> +#define BLK_MQ_POLL_CLASSIC -1
>> +
>>   /*
>>    * Maximum number of blkcg policies allowed to be registered concurrently.
>>    * Defined here to simplify include dependency.
>>



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-18 14:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-15  4:24 [PATCH v3] block: add a new flag BLK_MQ_POLL_CLASSIC for hybrid poll Yufen Yu
2019-03-15 16:11 ` Damien Le Moal
2019-03-18 14:11   ` yuyufen

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.