Re: [PATCH v4 3/4] block: implement runtime pm strategy

From: Alan Stern
Date: Thu Jul 05 2012 - 09:54:07 EST


On Thu, 5 Jul 2012, Lin Ming wrote:

> When a request is added:
> If device is suspended or is suspending and the request is not a
> PM request, resume the device.
>
> When a request finishes:
> Call pm_runtime_mark_last_busy().
>
> When pick a request:
> If device is resuming/suspending, then only PM request is allowed to go.
> Return NULL for other cases.
>
> Signed-off-by: Lin Ming <ming.m.lin@xxxxxxxxx>

These changes would look better if you didn't have "#ifdef
CONFIG_PM_RUNTIME" sprinkled throughout the block-layer routines.

Instead, define static helper functions to do your work, and put the
definitions inside a #ifdef block. If CONFIG_PM_RUNTIME isn't enabled,
the helper functions can be empty static inlines.

> --- a/block/elevator.c +++ b/block/elevator.c @@ -536,6 +537,11 @@

> void elv_requeue_request(struct request_queue *q, struct request *rq)
>
> rq->cmd_flags &= ~REQ_STARTED;
>
> +#ifdef CONFIG_PM_RUNTIME
> + /* __elv_add_request will increment the count */
> + if (!(rq->cmd_flags & REQ_PM))
> + q->nr_pending--;
> +#endif

__elv_add_request increments nr_pending even when REQ_PM is set. You
need to be consistent with that behavior.

Alan Stern

--
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/